现场更改4

This commit is contained in:
2026-05-14 14:39:47 +08:00
parent 53ca705ab0
commit 985ad12d63
3 changed files with 15 additions and 17 deletions

View File

@@ -546,7 +546,6 @@ namespace CapMachine.Wpf.CanDrive
Marshal.FreeHGlobal(msgPtSend);
}
}
Console.WriteLine("");
//发送CAN数据
int SendedNum = USB2CAN.CAN_SendMsg(DevHandle, WriteCANIndex, CanMsg, (uint)CanMsg.Length);
if (SendedNum >= 0)
@@ -594,7 +593,6 @@ namespace CapMachine.Wpf.CanDrive
int CanNum = USB2CAN.CAN_GetMsgWithSize(DevHandle, ReadCANIndex, msgPtRead, CanMsgBuffer.Length);
if (CanNum > 0)
{
Console.WriteLine("Read CanMsgNum = {0}", CanNum);
for (int i = 0; i < CanNum; i++)
{
//CanMsgBuffer[i] = (USB2CAN.CAN_MSG)Marshal.PtrToStructure((IntPtr)((UInt32)msgPtRead + i * Marshal.SizeOf(typeof(USB2CAN.CAN_MSG))), typeof(USB2CAN.CAN_MSG)); //有溢出报错
@@ -603,10 +601,6 @@ namespace CapMachine.Wpf.CanDrive
//Console.WriteLine("CanMsg[{0}].ID = 0x{1}", i, CanMsgBuffer[i].ID.ToString("X8"));
//Console.WriteLine("CanMsg[{0}].TimeStamp = {1}", i, CanMsgBuffer[i].TimeStamp);
//Console.Write("CanMsg[{0}].Data = ", i);
for (int j = 0; j < CanMsgBuffer[i].DataLen; j++)
{
Console.Write("{0} ", CanMsgBuffer[i].Data[j].ToString("X2"));
}
//Console.WriteLine("");
//报文给高速记录的服务
@@ -627,8 +621,6 @@ namespace CapMachine.Wpf.CanDrive
{
//Console.WriteLine("Get CAN data error!");
}
Console.WriteLine("");
if (CanNum > 0)
{
lock (_dbcParserLock)
@@ -645,7 +637,6 @@ namespace CapMachine.Wpf.CanDrive
var valueSb = new StringBuilder(64);
CAN_DBCParser.DBC_GetSignalValueStr(DBCHandle, new StringBuilder(item.MsgName), new StringBuilder(item.SignalName), valueSb);
item.SignalRtValueSb = valueSb;
Console.Write(valueSb.ToString());
//}
}
}
@@ -717,7 +708,7 @@ namespace CapMachine.Wpf.CanDrive
CycleSendCts = cancellationTokenSource;//将取消标记源保存到类的成员变量CycleSendCts这样在外部调用停止方法时可以访问它
NextExecutionTime = 0;//初始化NextExecutionTime为0这个变量用于记录下一次执行的目标时间点
CycleSendTask = Task.Factory.StartNew(async () =>
CycleSendTask = Task.Run(async () =>
{
try
{
@@ -863,7 +854,7 @@ namespace CapMachine.Wpf.CanDrive
Stopwatcher.Stop();
}
}, token, TaskCreationOptions.LongRunning, TaskScheduler.Default);
}, token);
}

View File

@@ -255,10 +255,10 @@ namespace CapMachine.Wpf.Services
{
if (!ToomossCanDrive.IsCycleRevice) return 0;
if (ListCanDbcModel.Any(a => a.Name == Name))
var dbcModel = ListCanDbcModel.FindFirst(a => a.Name == Name);
if (dbcModel != null && !string.IsNullOrWhiteSpace(dbcModel.SignalRtValue))
{
//double.TryParse(ListCanDbcModel.FindFirst(a => a.Name == Name).SignalRtValue, out double Result1);
return double.TryParse(ListCanDbcModel.FindFirst(a => a.Name == Name).SignalRtValue.Split(" ")[0], out double Result) == true ? Result : 0;
return double.TryParse(dbcModel.SignalRtValue.Split(" ")[0], out double Result) == true ? Result : 0;
}
return 0;
}
@@ -274,10 +274,10 @@ namespace CapMachine.Wpf.Services
{
if (!ToomossCanDrive.IsCycleRevice) return 0;
if (ListCanDbcModel.Any(a => a.Name == Name))
var dbcModel = ListCanDbcModel.FindFirst(a => a.Name == Name);
if (dbcModel != null && !string.IsNullOrWhiteSpace(dbcModel.SignalRtValue))
{
//double.TryParse(ListCanDbcModel.FindFirst(a => a.Name == Name).SignalRtValue, out double Result1);
return double.TryParse(ListCanDbcModel.FindFirst(a => a.Name == Name).SignalRtValue.Split(" ")[0], out double Result) == true ? Result : 0;
return double.TryParse(dbcModel.SignalRtValue.Split(" ")[0], out double Result) == true ? Result : 0;
}
return 0;
}