更新CAN的配置和CAN和实时数据的连接

This commit is contained in:
2025-01-06 22:47:27 +08:00
parent d2bad96b96
commit e367d9a8eb
7 changed files with 149 additions and 18 deletions

View File

@@ -35,6 +35,8 @@ namespace CapMachine.Wpf.Services
/// </summary>
private IEventAggregator _EventAggregator { get; set; }
public AlarmService AlarmService { get; }
public CanDriveService CanDriveService { get; }
public SysRunService SysRunService { get; }
/// <summary>
/// PLCScanTask扫描Task
@@ -105,7 +107,7 @@ namespace CapMachine.Wpf.Services
/// 实例化函数
/// </summary>
/// <param name="eventAggregator"></param>
public MachineRtDataService(IEventAggregator eventAggregator, AlarmService alarmService)//, AlarmService alarmService
public MachineRtDataService(IEventAggregator eventAggregator, AlarmService alarmService, CanDriveService canDriveService, SysRunService sysRunService)//, AlarmService alarmService
{
//ConcurrentDictionary<DateTime, RecordInfo> keyValuePairs = new ConcurrentDictionary<DateTime, RecordInfo>();
@@ -119,6 +121,8 @@ namespace CapMachine.Wpf.Services
//事件服务
_EventAggregator = eventAggregator;
AlarmService = alarmService;
CanDriveService = canDriveService;
SysRunService = sysRunService;
//秒触发一次
CycleTimer = new System.Timers.Timer(500);
@@ -1115,8 +1119,9 @@ namespace CapMachine.Wpf.Services
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;
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
{
@@ -1130,8 +1135,15 @@ namespace CapMachine.Wpf.Services
if (OperateResultSVShort.IsSuccess)
{
//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;
TagManger.GetTagByName<short>(itemTag.Value.Name)!.EngSvValue = OperateResultSVShort.Content * 1.0 / TagManger.GetTagByName<short>(itemTag.Value.Name)!.Precision;
LinkState = true;
//在运行时更新速度的SV的值
if (itemTag.Value.Name == "转速[rpm]" && SysRunService.MachineRunState1.RunStateMsg == "运行")
{
//更新SV的速度值
CanDriveService.UpdateSpeedCmdData(TagManger.GetTagByName<short>(itemTag.Value.Name)!.EngSvValue);
}
}
else
{
@@ -1145,7 +1157,7 @@ namespace CapMachine.Wpf.Services
if (OperateResultMVShort.IsSuccess)
{
//TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value = OperateResultMVShort.Content;
TagManger.GetTagByName<short>(itemTag.Value.Name).EngMvValue = OperateResultMVShort.Content*1.0/10;
TagManger.GetTagByName<short>(itemTag.Value.Name)!.EngMvValue = OperateResultMVShort.Content * 1.0 / 10;
LinkState = true;
}
else
@@ -1155,8 +1167,8 @@ namespace CapMachine.Wpf.Services
}
//手自动切换按钮条件
AutoHandSwtichConditionState.AlarmStateResult= SiemensDrive.ReadBool(AutoHandSwtichConditionState.AlarmAddress);
AutoHandSwtichConditionState.HandStateResult= SiemensDrive.ReadBool(AutoHandSwtichConditionState.HandStateAddress);
AutoHandSwtichConditionState.AlarmStateResult = SiemensDrive.ReadBool(AutoHandSwtichConditionState.AlarmAddress);
AutoHandSwtichConditionState.HandStateResult = SiemensDrive.ReadBool(AutoHandSwtichConditionState.HandStateAddress);
AutoHandSwtichConditionState.SumResult();
break;