更改了现场发现的问题

This commit is contained in:
2025-01-03 09:11:02 +08:00
parent 6ff9103fa2
commit 3a5674054d
10 changed files with 408 additions and 244 deletions

View File

@@ -1,5 +1,6 @@
using AutoMapper.Internal;
using CapMachine.Core;
using CapMachine.Wpf.Dtos;
using CapMachine.Wpf.Models;
using CapMachine.Wpf.Models.Tag;
using CapMachine.Wpf.PrismEvent;
@@ -13,6 +14,7 @@ using Prism.Mvvm;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
@@ -794,6 +796,29 @@ namespace CapMachine.Wpf.Services
#endregion
ListHandSwitchData = new List<HandSwitchData>()
{
new HandSwitchData(){Name="自动",ActionAddress="M0.0",StateAddress="M0.0" },
new HandSwitchData(){Name="抽真空",ActionAddress="M0.1",StateAddress="M0.1" },
new HandSwitchData(){Name="复位",ActionAddress="M0.2",StateAddress="M0.2" },
new HandSwitchData(){Name="消音",ActionAddress="M0.3",StateAddress="M0.3" },
new HandSwitchData(){Name="HV电源",ActionAddress="M1.1",StateAddress="Q0.1" },
new HandSwitchData(){Name="HV启动",ActionAddress="M1.2",StateAddress="Q0.6" },
new HandSwitchData(){Name="LV电源",ActionAddress="M1.3",StateAddress="Q0.2" },
new HandSwitchData(){Name="水泵",ActionAddress="M1.4",StateAddress="Q0.3" },
new HandSwitchData(){Name="冷凝器电加热",ActionAddress="M1.5",StateAddress="Q0.4" },
new HandSwitchData(){Name="吸气混合器电加热",ActionAddress="M1.6",StateAddress="Q0.5" },
new HandSwitchData(){Name="吸排气球阀",ActionAddress="M1.7",StateAddress="Q0.7" },
new HandSwitchData(){Name="试验箱",ActionAddress="M2.0",StateAddress="V15.0" },
new HandSwitchData(){Name="水SEV1",ActionAddress="M2.1",StateAddress="Q1.0" },
new HandSwitchData(){Name="水SEV2",ActionAddress="M2.2",StateAddress="Q1.1" },
new HandSwitchData(){Name="HCV1",ActionAddress="M2.3",StateAddress="Q1.2" },
new HandSwitchData(){Name="HCV2",ActionAddress="M2.4",StateAddress="Q1.3" },
new HandSwitchData(){Name="ECV1",ActionAddress="M2.5",StateAddress="Q1.4" },
new HandSwitchData(){Name="ECV2",ActionAddress="M2.6",StateAddress="Q1.5" },
new HandSwitchData(){Name="使能",ActionAddress="M2.7",StateAddress="V15.1" },
};
//TagManger.ListTag[0].Name = "new TestType() { byteValue=12}";
//TagManger.ListTag[0].Name = "new TestType() { byteValue=12}";
@@ -821,6 +846,113 @@ namespace CapMachine.Wpf.Services
PubRtDataStart();
}
#region
//// <summary>
///// 手自动切换集合数据
///// </summary>
public List<HandSwitchData> ListHandSwitchData { get; set; }
/// <summary>
/// 程序复位
/// </summary>
/// <returns></returns>
public bool SysReset()
{
var FindData = ListHandSwitchData.Where(a => a.Name == "复位");
if (FindData.Count() > 0)
{
var Result = SiemensDrive.Write(FindData.First().ActionAddress, true);
if (Result.IsSuccess)
{
return true;
}
else
{
return false;
}
}
return false;
}
/// <summary>
/// 程序消音
/// </summary>
/// <returns></returns>
public bool SysMute()
{
var FindData = ListHandSwitchData.Where(a => a.Name == "消音");
if (FindData.Count() > 0)
{
var Result = SiemensDrive.Write(FindData.First().ActionAddress, true);
if (Result.IsSuccess)
{
return true;
}
else
{
return false;
}
}
return false;
}
/// <summary>
/// 程序Start
/// </summary>
/// <returns></returns>
public bool SysStart()
{
var Result = SiemensDrive.Write("M0.4", true);
if (Result.IsSuccess)
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// 程序结束
/// </summary>
/// <returns></returns>
public bool SysEnd()
{
var Result = SiemensDrive.Write("M0.7", true);
if (Result.IsSuccess)
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// 程序暂停
/// </summary>
/// <returns></returns>
public bool SysPause()
{
var Result = SiemensDrive.Write("M0.6", true);
if (Result.IsSuccess)
{
return true;
}
else
{
return false;
}
}
#endregion
/// <summary>
/// UI更新
/// </summary>
@@ -900,6 +1032,11 @@ namespace CapMachine.Wpf.Services
/// </summary>
private OperateResult<short> OperateResultSVShort { get; set; }
/// <summary>
/// MV数据
/// </summary>
private OperateResult<short> OperateResultMVShort { get; set; }
private Random Random { get; set; } = new Random();
/// <summary>
@@ -925,7 +1062,7 @@ namespace CapMachine.Wpf.Services
try
{
//TagInfo.RtValue.Value++;
//var data = TagManger.DicTags["转速"].ValueType.Name;
////第一次计时
@@ -960,34 +1097,34 @@ namespace CapMachine.Wpf.Services
TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.IsShow = IsValueShow;
////仿真数据
//TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value = (short)Random.Next(1, 100);
//TagManger.GetTagByName<short>(itemTag.Value.Name).EngPvValue = (short)Random.Next(1, 100) * 1.0 / TagManger.GetTagByName<short>(itemTag.Value.Name)!.Precision;
//LinkState = false;
//仿真数据
TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value = (short)Random.Next(1, 100);
TagManger.GetTagByName<short>(itemTag.Value.Name).EngPvValue = (short)Random.Next(1, 100) * 1.0 / TagManger.GetTagByName<short>(itemTag.Value.Name)!.Precision;
LinkState = false;
//PLC 数据
if (!string.IsNullOrEmpty(itemTag.Value.PVAddress))
{
OperateResultShort = SiemensDrive.ReadInt16(itemTag.Value.PVAddress);
if (OperateResultShort.IsSuccess)
{
TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value = SiemensDrive.ReadInt16(itemTag.Value.PVAddress).Content;
TagManger.GetTagByName<short>(itemTag.Value.Name).EngPvValue = TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value * 1.0 / TagManger.GetTagByName<short>(itemTag.Value.Name)!.Precision;
LinkState = true;
}
else
{
LinkState = false;
}
}
////PLC 数据
//if (!string.IsNullOrEmpty(itemTag.Value.PVAddress))
//{
// OperateResultShort = SiemensDrive.ReadInt16(itemTag.Value.PVAddress);
// if (OperateResultShort.IsSuccess)
// {
// TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value = SiemensDrive.ReadInt16(itemTag.Value.PVAddress).Content;
// TagManger.GetTagByName<short>(itemTag.Value.Name).EngPvValue = TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value * 1.0 / TagManger.GetTagByName<short>(itemTag.Value.Name)!.Precision;
// LinkState = true;
// }
// else
// {
// LinkState = false;
// }
//}
if (!string.IsNullOrEmpty(itemTag.Value.SVAddress))
{
OperateResultSVShort = SiemensDrive.ReadInt16(itemTag.Value.SVAddress);
if (OperateResultSVShort.IsSuccess)
{
TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value = OperateResultSVShort.Content;
TagManger.GetTagByName<short>(itemTag.Value.Name).EngSvValue = TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value * 1.0 / TagManger.GetTagByName<short>(itemTag.Value.Name)!.Precision;
//TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value = OperateResultSVShort.Content;
TagManger.GetTagByName<short>(itemTag.Value.Name).EngSvValue = OperateResultSVShort.Content * 1.0 / TagManger.GetTagByName<short>(itemTag.Value.Name)!.Precision;
LinkState = true;
}
else
@@ -995,6 +1132,22 @@ namespace CapMachine.Wpf.Services
LinkState = false;
}
}
if (!string.IsNullOrEmpty(itemTag.Value.MVAddress))
{
OperateResultMVShort = SiemensDrive.ReadInt16(itemTag.Value.MVAddress);
if (OperateResultMVShort.IsSuccess)
{
//TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value = OperateResultMVShort.Content;
TagManger.GetTagByName<short>(itemTag.Value.Name).EngMvValue = OperateResultMVShort.Content;
LinkState = true;
}
else
{
LinkState = false;
}
}
break;
default:
break;
@@ -1014,6 +1167,17 @@ namespace CapMachine.Wpf.Services
}
}
//循环读取手自动切换
foreach (var item in ListHandSwitchData)
{
item.StateOperateResult = SiemensDrive.ReadBool(item.StateAddress);
if (item.StateOperateResult.IsSuccess)
{
item.State = item.StateOperateResult.Content;
}
}
}
catch (Exception ex)
{