LIN SCH的更改
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 定时扫描更新数据 扫描Task
|
||||
/// </summary>
|
||||
private static Task CycleUpdateCmdTask { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 定时更新时间
|
||||
/// </summary>
|
||||
private int UpdateCycle { get; set; } = 500;
|
||||
|
||||
/// <summary>
|
||||
/// 调度表数量
|
||||
/// </summary>
|
||||
public int SchCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// LIN 调度表的配置信息
|
||||
/// </summary>
|
||||
public List<LINScheduleConfigDto> ListLINScheduleConfig { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取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();
|
||||
|
||||
/// <summary>
|
||||
/// 开始调度表执行
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 循环更新调度表的指令数据
|
||||
/// 定时更新数据到调度表中
|
||||
/// </summary>
|
||||
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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user