CAN FD 调度表初步更改

This commit is contained in:
2026-01-14 17:55:45 +08:00
parent 427cdc5305
commit 4d16b474c6
19 changed files with 2130 additions and 186 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>
@@ -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;
}
}
}