CAN/LIN 导入和导出功能

This commit is contained in:
2026-04-09 21:56:22 +08:00
parent 48514b3162
commit 532374d1c4
46 changed files with 20232 additions and 109 deletions

View File

@@ -1,5 +1,6 @@
using CapMachine.Model.CANLIN;
using CapMachine.Wpf.CanDrive;
using CapMachine.Wpf.Dtos;
using CapMachine.Wpf.Models;
using CapMachine.Wpf.Models.ProModelPars;
using ImTools;
@@ -25,9 +26,9 @@ namespace CapMachine.Wpf.Services
/// <summary>
/// 实例化函数
/// </summary>
public CanFdDriveService(HighSpeedDataService highSpeedDataService, IContainerProvider containerProvider, LogicRuleService logicRuleService)
public CanFdDriveService(HighSpeedDataService highSpeedDataService, IContainerProvider containerProvider, LogicRuleService logicRuleService, ILogService logService)
{
ToomossCanFDDrive = new ToomossCanFD(containerProvider);
ToomossCanFDDrive = new ToomossCanFD(containerProvider, logService);
//高速数据服务
HighSpeedDataService = highSpeedDataService;
LogicRuleService = logicRuleService;
@@ -126,6 +127,11 @@ namespace CapMachine.Wpf.Services
/// </summary>
public List<CanCmdData> CmdData { get; set; } = new List<CanCmdData>();
/// <summary>
/// CNA 调度表的配置信息
/// </summary>
public List<CANFdScheduleConfigDto> ListCANFdScheduleConfig { get; set; }
/// <summary>
/// 增加发送的指令数据
/// </summary>
@@ -212,7 +218,7 @@ namespace CapMachine.Wpf.Services
{
if (PwLimitCanCmdData != null)
{
if (PwLimitCanCmdData.LogicRuleDto==null)
if (PwLimitCanCmdData.LogicRuleDto == null)
{
PwLimitCanCmdData.SignalCmdValue = PwLimit;
return;
@@ -264,7 +270,7 @@ namespace CapMachine.Wpf.Services
PTCFlowCanCmdData.SignalCmdValue = Flow;
return;
}
PTCFlowCanCmdData.SignalCmdValue = LogicRuleService.ApplyExpressionFast(Flow, PTCFlowCanCmdData.LogicRuleDto!);
PTCFlowCanCmdData.SignalCmdValue = LogicRuleService.ApplyExpressionFast(Flow, PTCFlowCanCmdData.LogicRuleDto!);
}
}
@@ -322,10 +328,39 @@ namespace CapMachine.Wpf.Services
{
if (CmdData.Count > 0)
{
ToomossCanFDDrive.IsCycleSend = true;
//把指令数据赋值给CAN 驱动
ToomossCanFDDrive.CmdData = CmdData;
//ToomossCanFDDrive.StartCycleSendMsg();
ToomossCanFDDrive.StartPrecisionCycleSendMsg();
if (ToomossCanFDDrive.SchEnable)
{
//使用调度表的话,需要在调度表中配置信息后才可以进行操作
var GroupMsg = ToomossCanFDDrive.CmdData.GroupBy(a => a.MsgName).ToList();
foreach (var itemMsg in GroupMsg)
{
if (!ListCANFdScheduleConfig.ToList().Any(a => a.MsgName == itemMsg.Key))
{
System.Windows.MessageBox.Show($"你使能了调度表,但是调度表中没有设置【{itemMsg.Key}】信息,请设置后再操作", "提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Hand);
return;
}
}
if (ListCANFdScheduleConfig == null && ListCANFdScheduleConfig!.Count() == 0)
{
System.Windows.MessageBox.Show("调度表配置为空数据,请检查!将无法发送数据", "提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Hand);
return;
}
ToomossCanFDDrive.ListCANScheduleConfig = ListCANFdScheduleConfig!;
ToomossCanFDDrive.StartSchedule();
//ToomossCanFDDrive.StartCycleUpdateCmd();
}
else
{
ToomossCanFDDrive.StartPrecisionCycleSendMsg();
//ToomossCanFDDrive.StartCycleSendMsg();
}
ToomossCanFDDrive.IsCycleSend = true;
}
else
{
@@ -334,7 +369,15 @@ namespace CapMachine.Wpf.Services
}
else
{
ToomossCanFDDrive.IsCycleSend = false;
if (ToomossCanFDDrive.SchEnable)
{
ToomossCanFDDrive.IsCycleSend = false;
ToomossCanFDDrive.StopSchedule();
}
else
{
ToomossCanFDDrive.IsCycleSend = false;
}
}
}