diff --git a/CapMachine.Wpf/LinDrive/ToomossLin.cs b/CapMachine.Wpf/LinDrive/ToomossLin.cs
index b3a33e5..06d5d18 100644
--- a/CapMachine.Wpf/LinDrive/ToomossLin.cs
+++ b/CapMachine.Wpf/LinDrive/ToomossLin.cs
@@ -1,5 +1,6 @@
using CapMachine.Model.CANLIN;
using CapMachine.Wpf.CanDrive;
+using CapMachine.Wpf.Dtos;
using CapMachine.Wpf.Services;
using ImTools;
using Microsoft.VisualBasic;
@@ -675,11 +676,25 @@ namespace CapMachine.Wpf.LinDrive
}
+ ///
+ /// 定时扫描更新数据 扫描Task
+ ///
+ private static Task CycleUpdateCmdTask { get; set; }
+
+ ///
+ /// 定时更新时间
+ ///
+ private int UpdateCycle { get; set; } = 500;
+
///
/// 调度表数量
///
public int SchCount { get; set; }
+ ///
+ /// LIN 调度表的配置信息
+ ///
+ public List ListLINScheduleConfig { get; set; }
///
/// 获取LIN的LINScheduleConfig
@@ -701,7 +716,7 @@ namespace CapMachine.Wpf.LinDrive
SchTabIndex = i,
MsgName = GetSchFrameName(SchName, j),
MsgNameIndex = j,
- Cycle = 10,
+ Cycle = 100,
IsActive = false,
});
}
@@ -752,7 +767,7 @@ namespace CapMachine.Wpf.LinDrive
return pSchName.ToString();
}
- Random Random=new Random();
+ Random Random = new Random();
///
/// 开始调度表执行
@@ -788,15 +803,77 @@ namespace CapMachine.Wpf.LinDrive
}
}
- LDFParser.LDF_ExeSchToBus(LDFHandle, new StringBuilder(itemMsg.Key),1);
- LDFParser.LDF_SetSchToTable(LDFHandle, new StringBuilder(itemMsg.Key),1);
+ LDFParser.LDF_ExeSchToBus(LDFHandle, new StringBuilder(itemMsg.Key), 1);
+ LDFParser.LDF_SetSchToTable(LDFHandle, new StringBuilder(itemMsg.Key), 1);
}
-
+
}
+ ///
+ /// 循环更新调度表的指令数据
+ /// 定时更新数据到调度表中
+ ///
+ public void StartCycleUpdateCmd()
+ {
+ CycleUpdateCmdTask = Task.Run(async () =>
+ {
+ while (IsCycleSend)
+ {
+ await Task.Delay(UpdateCycle);
+ try
+ {
+
+ if (CmdData.Count() == 0) return;
+
+ //防止有多个不同的消息名称/帧,每个帧单独处理发送
+ var GroupMsg = CmdData.GroupBy(x => x.MsgName);
+ foreach (var itemMsg in GroupMsg)
+ {
+ foreach (var itemSignal in itemMsg)
+ {
+ if (itemSignal.ConfigName.Contains("速"))
+ {
+ itemSignal.SignalCmdValue = Random.NextDouble() * 1000;
+ }
+ //主机写操作,发送数据给从机
+ LDFParser.LDF_SetSignalValue(LDFHandle, new StringBuilder(itemMsg.Key), new StringBuilder(itemSignal.SignalName), itemSignal.SignalCmdValue);
+ }
+
+ ////【0】参数注意
+ //LDFParser.LDF_ExeFrameToBus(LDFHandle, new StringBuilder(itemMsg.Key), 0);
+
+ //读取当前的指令帧数据,LDF_ExeFrameToBus执行后就可以读取本身的数据
+ foreach (var item in ListLinLdfModel)
+ {
+ if (CmdData.Any(a => a.MsgName == item.MsgName))
+ {
+ LDFParser.LDF_GetSignalValueStr(LDFHandle, new StringBuilder(item.MsgName), new StringBuilder(item.SignalName), ReadValueStr);
+ item.SignalRtValueSb = ReadValueStr;
+ }
+ }
+
+ LDFParser.LDF_ExeSchToBus(LDFHandle, new StringBuilder(itemMsg.Key), 1);
+ LDFParser.LDF_SetSchToTable(LDFHandle, new StringBuilder(itemMsg.Key), 1);
+ }
+
+
+ }
+ catch (Exception ex)
+ {
+ IsSendOk = false;
+ LoggerService.Info($"时间:{DateTime.Now.ToString()}-【MSG】-{ex.Message}");
+ }
+ }
+
+ IsSendOk = false;
+ });
+ }
+
+
+
public void LinTest()
{
diff --git a/CapMachine.Wpf/Services/LinDriveService.cs b/CapMachine.Wpf/Services/LinDriveService.cs
index 4f97a3e..325c894 100644
--- a/CapMachine.Wpf/Services/LinDriveService.cs
+++ b/CapMachine.Wpf/Services/LinDriveService.cs
@@ -1,4 +1,5 @@
using CapMachine.Model.CANLIN;
+using CapMachine.Wpf.Dtos;
using CapMachine.Wpf.LinDrive;
using ImTools;
using Prism.Ioc;
@@ -121,6 +122,11 @@ namespace CapMachine.Wpf.Services
///
public List CmdData { get; set; } = new List();
+ ///
+ /// 调度表LIN配置信息
+ ///
+ public List ListLINScheduleConfig { get; set; } = new List();
+
///
/// 增加发送的指令数据
///
@@ -356,10 +362,42 @@ namespace CapMachine.Wpf.Services
{
if (CmdData.Count > 0)
{
- ToomossLinDrive.IsCycleSend = true;
+ //ToomossLinDrive.IsCycleSend = true;
ToomossLinDrive.CmdData = CmdData;
- ToomossLinDrive.StartPrecisionCycleSendMsg();
+ //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
{
diff --git a/CapMachine.Wpf/ViewModels/LinConfigViewModel.cs b/CapMachine.Wpf/ViewModels/LinConfigViewModel.cs
index 12a422a..bab14d8 100644
--- a/CapMachine.Wpf/ViewModels/LinConfigViewModel.cs
+++ b/CapMachine.Wpf/ViewModels/LinConfigViewModel.cs
@@ -901,6 +901,48 @@ namespace CapMachine.Wpf.ViewModels
set { _DataBaudRateCbxItems = value; RaisePropertyChanged(); }
}
+
+ private DelegateCommand