LIN驱动程序的更改
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using CapMachine.Wpf.CanDrive;
|
using CapMachine.Wpf.CanDrive;
|
||||||
using CapMachine.Wpf.Services;
|
using CapMachine.Wpf.Services;
|
||||||
|
using ImTools;
|
||||||
using Microsoft.VisualBasic;
|
using Microsoft.VisualBasic;
|
||||||
using Prism.Ioc;
|
using Prism.Ioc;
|
||||||
using Prism.Mvvm;
|
using Prism.Mvvm;
|
||||||
@@ -77,7 +78,7 @@ namespace CapMachine.Wpf.LinDrive
|
|||||||
IsExistsDllFile();
|
IsExistsDllFile();
|
||||||
ScanDevice();
|
ScanDevice();
|
||||||
OpenDevice();
|
OpenDevice();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _IsCycleRevice;
|
private bool _IsCycleRevice;
|
||||||
@@ -266,7 +267,7 @@ namespace CapMachine.Wpf.LinDrive
|
|||||||
//当前帧为主机读数据帧
|
//当前帧为主机读数据帧
|
||||||
Console.WriteLine("[MR]Frame[{0}].Name={1},Publisher={2}", i, FrameName, PublisherName);
|
Console.WriteLine("[MR]Frame[{0}].Name={1},Publisher={2}", i, FrameName, PublisherName);
|
||||||
}
|
}
|
||||||
|
|
||||||
//读取信号信息
|
//读取信号信息
|
||||||
int SignalNum = LDFParser.LDF_GetFrameSignalQuantity(LDFHandle, FrameName);
|
int SignalNum = LDFParser.LDF_GetFrameSignalQuantity(LDFHandle, FrameName);
|
||||||
for (int j = 0; j < SignalNum; j++)
|
for (int j = 0; j < SignalNum; j++)
|
||||||
@@ -310,6 +311,7 @@ namespace CapMachine.Wpf.LinDrive
|
|||||||
LDFParser.LDF_SetSignalValue(LDFHandle, new StringBuilder(itemMsg.Key), new StringBuilder(itemSignal.SignalName), itemSignal.SignalCmdValue);
|
LDFParser.LDF_SetSignalValue(LDFHandle, new StringBuilder(itemMsg.Key), new StringBuilder(itemSignal.SignalName), itemSignal.SignalCmdValue);
|
||||||
}
|
}
|
||||||
LDFParser.LDF_ExeFrameToBus(LDFHandle, new StringBuilder(itemMsg.Key), 1);
|
LDFParser.LDF_ExeFrameToBus(LDFHandle, new StringBuilder(itemMsg.Key), 1);
|
||||||
|
//LDFParser.LDF_ExeSchToBus(LDFHandle, new StringBuilder(itemMsg.Key), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -337,14 +339,27 @@ namespace CapMachine.Wpf.LinDrive
|
|||||||
await Task.Delay(ReviceCycle);
|
await Task.Delay(ReviceCycle);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//主机读操作,读取从机返回的数据值
|
var GroupMsg = ListLinLdfModel.GroupBy(x => x.MsgName);
|
||||||
foreach (var item in ListLinLdfModel)
|
foreach (var itemMsg in GroupMsg)
|
||||||
{
|
{
|
||||||
LDFParser.LDF_ExeFrameToBus(LDFHandle, new StringBuilder(item.MsgName), 1);
|
var data = itemMsg.FirstOrDefault();
|
||||||
LDFParser.LDF_GetSignalValueStr(LDFHandle, new StringBuilder(item.MsgName), new StringBuilder(item.SignalName), ReadValueStr);
|
//非主机发送的指令帧就可以读取数据,因为函数 LDF_ExeFrameToBus【执行帧到总线,若该帧的发布者是主机,那么就是主机写数据,否则就是主机读数据】
|
||||||
item.SignalRtValueSb = ReadValueStr;
|
//那么主机发送和读取都是同一个函数。会导致跟Master主机也会在这里执行写入,导致冲突,出现错误。所以做一个排出
|
||||||
|
if (data != null && !data.IsMasterFrame!.Contains("是"))
|
||||||
|
{
|
||||||
|
//主机读操作,读取从机返回的数据值
|
||||||
|
LDFParser.LDF_ExeFrameToBus(LDFHandle, new StringBuilder(itemMsg.Key), 1);
|
||||||
|
foreach (var itemSignal in itemMsg)
|
||||||
|
{
|
||||||
|
//LDFParser.LDF_ExeFrameToBus(LDFHandle, new StringBuilder(itemMsg.Key), 1);
|
||||||
|
LDFParser.LDF_GetSignalValueStr(LDFHandle, new StringBuilder(itemMsg.Key), new StringBuilder(itemSignal.SignalName), ReadValueStr);
|
||||||
|
itemSignal.SignalRtValueSb = ReadValueStr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//StringBuilder ValueStr = new StringBuilder(64);
|
//StringBuilder ValueStr = new StringBuilder(64);
|
||||||
//LDFParser.LDF_ExeFrameToBus(LDFHandle, new StringBuilder("ID_DATA"), 1);
|
//LDFParser.LDF_ExeFrameToBus(LDFHandle, new StringBuilder("ID_DATA"), 1);
|
||||||
//LDFParser.LDF_GetSignalValueStr(LDFHandle, new StringBuilder("ID_DATA"), new StringBuilder("Supplier_ID"), ValueStr);
|
//LDFParser.LDF_GetSignalValueStr(LDFHandle, new StringBuilder("ID_DATA"), new StringBuilder("Supplier_ID"), ValueStr);
|
||||||
@@ -385,7 +400,18 @@ namespace CapMachine.Wpf.LinDrive
|
|||||||
//主机写操作,发送数据给从机
|
//主机写操作,发送数据给从机
|
||||||
LDFParser.LDF_SetSignalValue(LDFHandle, new StringBuilder(itemMsg.Key), new StringBuilder(itemSignal.SignalName), itemSignal.SignalCmdValue);
|
LDFParser.LDF_SetSignalValue(LDFHandle, new StringBuilder(itemMsg.Key), new StringBuilder(itemSignal.SignalName), itemSignal.SignalCmdValue);
|
||||||
}
|
}
|
||||||
LDFParser.LDF_ExeFrameToBus(LDFHandle, new StringBuilder(itemMsg.Key), 1);
|
//【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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////主机写操作,发送数据给从机
|
////主机写操作,发送数据给从机
|
||||||
|
|||||||
Reference in New Issue
Block a user