LIN 调度表功能同步 25002

This commit is contained in:
2026-01-05 22:07:54 +08:00
parent cae76745e5
commit 427cdc5305
17 changed files with 2225 additions and 73 deletions

View File

@@ -1,15 +1,10 @@
using CapMachine.Model.CANLIN;
using CapMachine.Wpf.CanDrive;
using CapMachine.Wpf.Dtos;
using CapMachine.Wpf.LinDrive;
using ImTools;
using Prism.Ioc;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CapMachine.Wpf.Services
{
@@ -20,15 +15,19 @@ namespace CapMachine.Wpf.Services
{
public HighSpeedDataService HighSpeedDataService { get; }
public LogicRuleService LogicRuleService { get; }
/// <summary>
/// 实例化函数
/// </summary>
public LinDriveService(HighSpeedDataService highSpeedDataService, IContainerProvider containerProvider)
public LinDriveService(HighSpeedDataService highSpeedDataService, IContainerProvider containerProvider, LogicRuleService logicRuleService)
{
ToomossLinDrive = new ToomossLin(containerProvider);
//高速数据服务
HighSpeedDataService = highSpeedDataService;
LogicRuleService = logicRuleService;
//ToomossLinDrive.StartLinDrive();
}
@@ -123,6 +122,11 @@ namespace CapMachine.Wpf.Services
/// </summary>
public List<LinCmdData> CmdData { get; set; } = new List<LinCmdData>();
/// <summary>
/// 调度表LIN配置信息
/// </summary>
public List<LINScheduleConfigDto> ListLINScheduleConfig { get; set; } = new List<LINScheduleConfigDto>();
/// <summary>
/// 增加发送的指令数据
/// </summary>
@@ -171,16 +175,32 @@ namespace CapMachine.Wpf.Services
/// <param name="canCmdData"></param>
public void UpdateSpeedCmdData(double SpeedData)
{
//if (SpeedLinCmdData != null)
//{
// SpeedLinCmdData.SignalCmdValue = SpeedData;
//}
if (SpeedLinCmdData != null)
{
SpeedLinCmdData.SignalCmdValue = SpeedData;
}
//if (EnableLinCmdData != null)
//{
// EnableLinCmdData.SignalCmdValue = 1;
//}
}
//首先是否判断是有斜率
if (SpeedLinCmdData.LogicRuleDto == null)
{
//没有启动逻辑规则处理
SpeedLinCmdData.SignalCmdValue = SpeedData;
}
else
{
//LogicRuleService.ApplyExpressionFast(SpeedData, SpeedCanCmdData.LogicRuleDto);
SpeedLinCmdData.SignalCmdValue = LogicRuleService.ApplyExpressionFast(SpeedData, SpeedLinCmdData.LogicRuleDto);
//Console.WriteLine($"实时转换后转速值:{SpeedCanCmdData.SignalCmdValue}-SV值:{SpeedData}");
}
//if (EnableLinCmdData != null)
//{
// EnableLinCmdData.SignalCmdValue = 1;
//}
}
}
/// <summary>
/// 更新压缩机使能数据
@@ -225,9 +245,25 @@ namespace CapMachine.Wpf.Services
/// <param name="IsEnable"></param>
public void UpdateCapPTCPwCmdData(double PTCPw)
{
//if (PTCPwCanCmdData != null)
//{
// PTCPwCanCmdData.SignalCmdValue = PTCPw;
//}
if (PTCPwCanCmdData != null)
{
PTCPwCanCmdData.SignalCmdValue = PTCPw;
//首先是否判断是有斜率
if (PTCPwCanCmdData.LogicRuleDto == null)
{
//没有启动逻辑规则处理
PTCPwCanCmdData.SignalCmdValue = PTCPw;
}
else
{
//LogicRuleService.ApplyExpressionFast(SpeedData, SpeedCanCmdData.LogicRuleDto);
PTCPwCanCmdData.SignalCmdValue = LogicRuleService.ApplyExpressionFast(PTCPw, PTCPwCanCmdData.LogicRuleDto);
//Console.WriteLine($"实时转换后转速值:{SpeedCanCmdData.SignalCmdValue}-SV值:{SpeedData}");
}
}
}
@@ -237,10 +273,27 @@ namespace CapMachine.Wpf.Services
/// <param name="IsEnable"></param>
public void UpdateCapPTCFlowCmdData(double Flow)
{
//if (PTCFlowCanCmdData != null)
//{
// PTCFlowCanCmdData.SignalCmdValue = Flow;
//}
if (PTCFlowCanCmdData != null)
{
PTCFlowCanCmdData.SignalCmdValue = Flow;
//首先是否判断是有斜率
if (PTCFlowCanCmdData.LogicRuleDto == null)
{
//没有启动逻辑规则处理
PTCFlowCanCmdData.SignalCmdValue = Flow;
}
else
{
//LogicRuleService.ApplyExpressionFast(SpeedData, SpeedCanCmdData.LogicRuleDto);
PTCFlowCanCmdData.SignalCmdValue = LogicRuleService.ApplyExpressionFast(Flow, PTCFlowCanCmdData.LogicRuleDto);
//Console.WriteLine($"实时转换后转速值:{SpeedCanCmdData.SignalCmdValue}-SV值:{SpeedData}");
}
}
}
/// <summary>
@@ -249,10 +302,27 @@ namespace CapMachine.Wpf.Services
/// <param name="IsEnable"></param>
public void UpdateCapPTCWaterTempCmdData(double WaterTemp)
{
//if (PTCWaterTempCanCmdData != null)
//{
// PTCWaterTempCanCmdData.SignalCmdValue = WaterTemp;
//}
if (PTCWaterTempCanCmdData != null)
{
PTCWaterTempCanCmdData.SignalCmdValue = WaterTemp;
//首先是否判断是有斜率
if (PTCWaterTempCanCmdData.LogicRuleDto == null)
{
//没有启动逻辑规则处理
PTCWaterTempCanCmdData.SignalCmdValue = WaterTemp;
}
else
{
//LogicRuleService.ApplyExpressionFast(SpeedData, SpeedCanCmdData.LogicRuleDto);
PTCWaterTempCanCmdData.SignalCmdValue = LogicRuleService.ApplyExpressionFast(WaterTemp, PTCWaterTempCanCmdData.LogicRuleDto);
//Console.WriteLine($"实时转换后转速值:{SpeedCanCmdData.SignalCmdValue}-SV值:{SpeedData}");
}
}
}
/// <summary>
@@ -288,14 +358,52 @@ namespace CapMachine.Wpf.Services
{
if (ToomossLinDrive.OpenState)
{
//来回取反设置
if (ToomossLinDrive.IsCycleSend == false)
{
if (CmdData.Count > 0)
{
ToomossLinDrive.IsCycleSend = true;
////订阅 CmdData 的数据变化事件,确保基于数据变化刷新调度表
//ToomossLinDrive.LoadCmdDataToDrive(CmdData);
ToomossLinDrive.CmdData = CmdData;
ToomossLinDrive.StartPrecisionCycleSendMsg();
//ToomossLinDrive.IsCycleSend = true;
//ToomossLinDrive.StartPrecisionCycleSendMsg();
//ToomossLinDrive.StartCycleSendMsg();
if (ToomossLinDrive.SchEnable)
{
//使用调度表的话,需要在调度表中配置信息后才可以进行操作
var GroupMsg = ToomossLinDrive.CmdData.GroupBy(a => a.MsgName).ToList();
foreach (var itemMsg in GroupMsg)
{
if (!ListLINScheduleConfig.ToList().Any(a => a.MsgName == itemMsg.Key))
{
System.Windows.MessageBox.Show($"你使能了调度表,但是调度表中没有设置【{itemMsg.Key}】信息,请设置后再操作", "提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Hand);
return;
}
}
if (ListLINScheduleConfig == null && ListLINScheduleConfig!.Count() == 0)
{
System.Windows.MessageBox.Show("调度表配置为空数据,请检查!将无法发送数据", "提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Hand);
return;
}
ToomossLinDrive.ListLINScheduleConfig = ListLINScheduleConfig!;
ToomossLinDrive.StartSchedule();
//ToomossLinDrive.StartCycleUpdateCmd();
}
else
{
//使用软件调度发送数据
ToomossLinDrive.StartPrecisionCycleSendMsg();
//ToomossCanDrive.StartCycleSendMsg();
}
ToomossLinDrive.IsCycleSend = true;
}
else
{
@@ -305,6 +413,11 @@ namespace CapMachine.Wpf.Services
else
{
ToomossLinDrive.IsCycleSend = false;
//如果是调度表的话,需要关闭调度表
if (ToomossLinDrive.SchEnable)
{
ToomossLinDrive.StopSchedule();
}
}
}