LIN Schedule
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using CapMachine.Wpf.CanDrive;
|
||||
using CapMachine.Model.CANLIN;
|
||||
using CapMachine.Wpf.CanDrive;
|
||||
using CapMachine.Wpf.Services;
|
||||
using ImTools;
|
||||
using Microsoft.VisualBasic;
|
||||
@@ -379,16 +380,6 @@ namespace CapMachine.Wpf.LinDrive
|
||||
}
|
||||
|
||||
IsReviceOk = true;
|
||||
|
||||
//StringBuilder ValueStr = new StringBuilder(64);
|
||||
//LDFParser.LDF_ExeFrameToBus(LDFHandle, new StringBuilder("ID_DATA"), 1);
|
||||
//LDFParser.LDF_GetSignalValueStr(LDFHandle, new StringBuilder("ID_DATA"), new StringBuilder("Supplier_ID"), ValueStr);
|
||||
//Console.WriteLine("ID_DATA.Supplier_ID={0}", ValueStr);
|
||||
//LDFParser.LDF_GetSignalValueStr(LDFHandle, new StringBuilder("ID_DATA"), new StringBuilder("Machine_ID"), ValueStr);
|
||||
//Console.WriteLine("ID_DATA.Machine_ID={0}", ValueStr);
|
||||
//LDFParser.LDF_GetSignalValueStr(LDFHandle, new StringBuilder("ID_DATA"), new StringBuilder("Chip_ID"), ValueStr);
|
||||
//Console.WriteLine("ID_DATA.Chip_ID={0}", ValueStr);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -666,6 +657,7 @@ namespace CapMachine.Wpf.LinDrive
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 调度器发送报文
|
||||
|
||||
private bool _SchEnable;
|
||||
@@ -682,11 +674,61 @@ namespace CapMachine.Wpf.LinDrive
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 调度表数量
|
||||
/// </summary>
|
||||
public int SchCount { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取LIN的LINScheduleConfig
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<LINScheduleConfig> GetLINScheduleConfigs()
|
||||
{
|
||||
List<LINScheduleConfig> LINScheduleConfigs = new List<LINScheduleConfig>();
|
||||
SchCount = GetSchCount();
|
||||
for (int i = 0; i < SchCount; i++)
|
||||
{
|
||||
var SchName = GetSchName(i);
|
||||
var FrameCount = GetSchFrameCount(SchName);
|
||||
for (int j = 0; j < FrameCount; j++)
|
||||
{
|
||||
LINScheduleConfigs.Add(new LINScheduleConfig()
|
||||
{
|
||||
SchTabName = GetSchName(i),
|
||||
SchTabIndex = i,
|
||||
MsgName = GetSchFrameName(SchName, j),
|
||||
MsgNameIndex = j,
|
||||
Cycle = 10,
|
||||
IsActive = false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return LINScheduleConfigs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取调度的帧的信号个数
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int GetSchFrameCount(string SchName)
|
||||
{
|
||||
return LDFParser.LDF_GetSchFrameQuantity(LDFHandle, new StringBuilder(SchName));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取调度的帧的名称
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetSchFrameName(string SchName, int FrameIndex)
|
||||
{
|
||||
StringBuilder FrameName = new StringBuilder();
|
||||
LDFParser.LDF_GetSchFrameName(LDFHandle, new StringBuilder(SchName), FrameIndex, FrameName);
|
||||
return FrameName.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取调度表数量
|
||||
@@ -699,6 +741,62 @@ namespace CapMachine.Wpf.LinDrive
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取调度表数量
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetSchName(int index)
|
||||
{
|
||||
StringBuilder pSchName = new StringBuilder();
|
||||
var SchResult = LDFParser.LDF_GetSchName(LDFHandle, index, pSchName);
|
||||
return pSchName.ToString();
|
||||
}
|
||||
|
||||
Random Random=new Random();
|
||||
|
||||
/// <summary>
|
||||
/// 开始调度表执行
|
||||
/// </summary>
|
||||
public void StartSchedule()
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void LinTest()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user