切换CANLIN配置程序后的数据刷新,如果当前的没有,则刷新,不需要展示上一次的数据
This commit is contained in:
@@ -625,6 +625,8 @@ namespace CapMachine.Wpf.CanDrive
|
||||
await Task.Delay(10, token);
|
||||
}
|
||||
}
|
||||
|
||||
IsSendOk = false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -1033,6 +1035,9 @@ namespace CapMachine.Wpf.CanDrive
|
||||
//LogService.Info($"时间:{DateTime.Now.ToString()}-【Meter】-{ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IsReviceOk = false;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -514,6 +514,7 @@ namespace CapMachine.Wpf.CanDrive
|
||||
RaisePropertyChanged();
|
||||
_IsSendOk = value;
|
||||
}
|
||||
//RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -760,6 +761,8 @@ namespace CapMachine.Wpf.CanDrive
|
||||
LoggerService.Info($"精确周期发送CAN数据-{ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
IsSendOk = false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -843,7 +846,7 @@ namespace CapMachine.Wpf.CanDrive
|
||||
/// <summary>
|
||||
/// 定时更新时间
|
||||
/// </summary>
|
||||
private int UpdateCycle = 500;
|
||||
private int UpdateCycle = 100;
|
||||
|
||||
/// <summary>
|
||||
/// CNA 调度表的配置信息
|
||||
@@ -853,7 +856,7 @@ namespace CapMachine.Wpf.CanDrive
|
||||
Random random = new Random();
|
||||
|
||||
/// <summary>
|
||||
/// 更新数据
|
||||
/// 更新数据 测试用废弃了
|
||||
/// </summary>
|
||||
public void UpdateValue()
|
||||
{
|
||||
@@ -928,10 +931,13 @@ namespace CapMachine.Wpf.CanDrive
|
||||
//每个分组就是一个帧指令/消息数据
|
||||
SchCanMsg[Index] = (USB2CAN.CAN_MSG)Marshal.PtrToStructure(msgPtSend, typeof(USB2CAN.CAN_MSG));
|
||||
//分配当前消息帧在集合中的位置信息到ListCANScheduleConfig中,方便实时更新时定位帧的位置
|
||||
if (ListCANScheduleConfig.Any(a=>a.MsgName== itemMsg.Key))
|
||||
if (ListCANScheduleConfig.Any(a => a.MsgName == itemMsg.Key))
|
||||
{
|
||||
//把帧的位置给ListCANScheduleConfig,方便更新时定位数据
|
||||
ListCANScheduleConfig.FindFirst(a => a.MsgName == itemMsg.Key).MsgIndex = Index;
|
||||
|
||||
//设置当前这个报文的在调度表中的发送周期
|
||||
SchCanMsg[Index].TimeStamp = (uint)ListCANScheduleConfig.FindFirst(a => a.MsgName == itemMsg.Key).Cycle;
|
||||
}
|
||||
Index++;
|
||||
}
|
||||
@@ -941,10 +947,13 @@ namespace CapMachine.Wpf.CanDrive
|
||||
Marshal.FreeHGlobal(msgPtSend);
|
||||
|
||||
//********就是可以设置多个调度表放那里,但是运行时同一个时刻只能运行调度表其中的一个 ********
|
||||
//****** 控制报文SchCanMsg和调度器中第一个调度器中的报文集合和要更新的报文集合都是同一个变量SchCanMsg, ********
|
||||
// *** SchCanMsg的Index序号和ListCANScheduleConfig的MsgIndex是一样的 ***
|
||||
|
||||
//Sample:总共3个调度表,第一个表里面包含3帧数据,第二个调度表包含6帧数据,第三个调度表包含11帧数据
|
||||
//预设5个调度表,约定每个调度表对应5个帧
|
||||
MsgTabNum = new Byte[MsgTabCount] { 5, 5, 5, 5, 5 };
|
||||
//图莫斯的Sample:总共3个调度表,第一个表里面包含3帧数据,第二个调度表包含6帧数据,第三个调度表包含11帧数据
|
||||
//预设5个调度表,但是我们只用其中第一个调度表,第一个调度表中包括多少消息帧,由系统的控制指令的帧的分布决定,SchCanMsg.Count()是所需要的控制发送的帧,都放到第一个调度表中
|
||||
|
||||
MsgTabNum = new Byte[MsgTabCount] { (byte)SchCanMsg.Count(), 1, 1, 1, 1 };
|
||||
//0xFFFF:调度表循环发送数据,X:调度表循环发送的次数
|
||||
//设置每个调度表的发送方式,约定全部为循环发送
|
||||
SendTimes = new UInt16[MsgTabCount] { 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF };
|
||||
@@ -962,36 +971,48 @@ namespace CapMachine.Wpf.CanDrive
|
||||
return;
|
||||
}
|
||||
|
||||
//约定使用Index=0 1号调度器
|
||||
|
||||
|
||||
foreach (var itemGroupMsg in GroupMsg)
|
||||
//约定使用Index=0 1号调度器,因为同一个时刻只能有一个调度器工作,把所有的报文都要放到这个调度器中
|
||||
//CAN_MSG的TimeStamp就是这个报文发送的周期,由调度器协调
|
||||
ret = USB2CAN.CAN_StartSchedule(DevHandle, WriteCANIndex, (byte)0, (byte)100, (byte)ListCANScheduleConfig.FirstOrDefault()!.OrderSend);
|
||||
if (ret == USB2CAN.CAN_SUCCESS)
|
||||
{
|
||||
if (itemGroupMsg == null) continue;
|
||||
if (ListCANScheduleConfig.Any(a => a.MsgName!.Contains(itemGroupMsg.Key)))
|
||||
{
|
||||
var CANScheduleConfig = ListCANScheduleConfig.FindFirst(a => a.MsgName!.Contains(itemGroupMsg.Key));
|
||||
//配置表里面包括这个报文消息内容
|
||||
ret = USB2CAN.CAN_StartSchedule(DevHandle, WriteCANIndex, (byte)CANScheduleConfig.SchTabIndex, (byte)CANScheduleConfig.Cycle, (byte)CANScheduleConfig.OrderSend);
|
||||
if (ret == USB2CAN.CAN_SUCCESS)
|
||||
{
|
||||
Console.WriteLine($"Start CAN Schedule 1 Success,SchTabIndex:{(byte)CANScheduleConfig.SchTabIndex} - Cycle:{(byte)CANScheduleConfig.Cycle} - OrderSend:{(byte)CANScheduleConfig.OrderSend}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Start CAN Schedule 1 Error ret = {0}", ret);
|
||||
LoggerService.Info($"Start CAN Schedule 1 Error;消息名称:{CANScheduleConfig.MsgName}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LoggerService.Info($"调度表配置未发现对应的消息报文信息;报文信息{itemGroupMsg.Key}");
|
||||
}
|
||||
Console.WriteLine($"Start CAN Schedule 1 Success,SchTabIndex:{(byte)0} - Cycle:{(byte)100} - OrderSend:{(byte)1}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Start CAN Schedule 1 Error ret = {0}", ret);
|
||||
LoggerService.Info($"Start CAN Schedule 1 Error;");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//foreach (var itemGroupMsg in GroupMsg)
|
||||
//{
|
||||
// if (itemGroupMsg == null) continue;
|
||||
// if (ListCANScheduleConfig.Any(a => a.MsgName!.Contains(itemGroupMsg.Key)))
|
||||
// {
|
||||
// var CANScheduleConfig = ListCANScheduleConfig.FindFirst(a => a.MsgName!.Contains(itemGroupMsg.Key));
|
||||
// //配置表里面包括这个报文消息内容
|
||||
// ret = USB2CAN.CAN_StartSchedule(DevHandle, WriteCANIndex, (byte)CANScheduleConfig.SchTabIndex, (byte)CANScheduleConfig.Cycle, (byte)CANScheduleConfig.OrderSend);
|
||||
// if (ret == USB2CAN.CAN_SUCCESS)
|
||||
// {
|
||||
// Console.WriteLine($"Start CAN Schedule 1 Success,SchTabIndex:{(byte)CANScheduleConfig.SchTabIndex} - Cycle:{(byte)CANScheduleConfig.Cycle} - OrderSend:{(byte)CANScheduleConfig.OrderSend}");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Console.WriteLine("Start CAN Schedule 1 Error ret = {0}", ret);
|
||||
// LoggerService.Info($"Start CAN Schedule 1 Error;消息名称:{CANScheduleConfig.MsgName}");
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// LoggerService.Info($"调度表配置未发现对应的消息报文信息;报文信息{itemGroupMsg.Key}");
|
||||
// }
|
||||
//}
|
||||
|
||||
//走到这里说明调度表执行的是OK的
|
||||
IsSendOk = true;
|
||||
//IsSendOk = true;
|
||||
|
||||
}
|
||||
|
||||
@@ -1004,6 +1025,7 @@ namespace CapMachine.Wpf.CanDrive
|
||||
ret = USB2CAN.CAN_StopSchedule(DevHandle, WriteCANIndex);//启动第一个调度表,表里面的CAN帧并行发送
|
||||
if (ret == USB2CAN.CAN_SUCCESS)
|
||||
{
|
||||
IsSendOk = false;
|
||||
Console.WriteLine("Stop CAN Schedule");
|
||||
LoggerService.Info($"Stop CAN Schedule");
|
||||
}
|
||||
@@ -1013,6 +1035,8 @@ namespace CapMachine.Wpf.CanDrive
|
||||
LoggerService.Info($"Stop CAN Schedule");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1033,6 +1057,7 @@ namespace CapMachine.Wpf.CanDrive
|
||||
await Task.Delay(UpdateCycle);
|
||||
try
|
||||
{
|
||||
|
||||
//通过DBC进行对消息赋值
|
||||
IntPtr msgPtSend = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(USB2CAN.CAN_MSG)));
|
||||
CycleUpdateIndex = 0;
|
||||
@@ -1041,7 +1066,7 @@ namespace CapMachine.Wpf.CanDrive
|
||||
{
|
||||
foreach (var itemSignal in itemMsg)
|
||||
{
|
||||
itemSignal.SignalCmdValue = random.Next(0, 10); //仿真测试数据使用
|
||||
//itemSignal.SignalCmdValue = random.Next(0, 100); //仿真测试数据使用
|
||||
CAN_DBCParser.DBC_SetSignalValue(DBCHandle, new StringBuilder(itemMsg.Key), new StringBuilder(itemSignal.SignalName), itemSignal.SignalCmdValue);
|
||||
}
|
||||
CAN_DBCParser.DBC_SyncValueToCANMsg(DBCHandle, new StringBuilder(itemMsg.Key), msgPtSend);
|
||||
@@ -1055,34 +1080,60 @@ namespace CapMachine.Wpf.CanDrive
|
||||
//释放申请的临时缓冲区
|
||||
Marshal.FreeHGlobal(msgPtSend);
|
||||
|
||||
//配置信息
|
||||
foreach (var itemMsgSchConfig in ListCANScheduleConfig)
|
||||
//CAN_UpdateSchedule 官网解释
|
||||
// ---MsgTabIndex CAN调度表索引号
|
||||
// ---MsgIndex 开始更新帧起始索引,若起始索引大于调度表帧数,则将帧添加到调度表后面
|
||||
// ---pCanMsg 需要更新的CAN帧指针
|
||||
// ---MsgNum pCanMsgTab里面包含的有效帧数
|
||||
|
||||
//CAN_UpdateSchedule中的MsgIndex表示当前的调度器中的帧Index序号
|
||||
//因为调度表中的帧集合和控制帧的集合和要更新的帧集合都是同一个集合SchCanMsg
|
||||
//默认1号调度表,一个更新所有的帧数据
|
||||
var ret = USB2CAN.CAN_UpdateSchedule(DevHandle, WriteCANIndex, (byte)0, (byte)(0), SchCanMsg, (byte)SchCanMsg.Count());//配置调度表,该函数耗时可能会比较长,但是只需要执行一次即可
|
||||
if (ret == USB2CAN.CAN_SUCCESS)
|
||||
{
|
||||
//USB2CAN.CAN_MSG[] SchCanMsg1=new CAN_MSG[1];
|
||||
//SchCanMsg1[0] = SchCanMsg[itemMsgSchConfig.MsgIndex];
|
||||
|
||||
// MsgTabIndex CAN调度表索引号 ;MsgIndex 开始更新帧起始索引,若起始索引大于调度表帧数,则将帧添加到调度表后面, ;
|
||||
// pCanMsg 需要更新的CAN帧指针,消息数据 ; MsgNum pCanMsgTab里面包含的有效帧数,一个调度表对应一个帧/消息,即为:1 (byte)(itemMsgSchConfig.MsgIndex+0)
|
||||
var ret = USB2CAN.CAN_UpdateSchedule(DevHandle, WriteCANIndex, (byte)(itemMsgSchConfig.SchTabIndex), (byte)(0), SchCanMsg, 1);//配置调度表,该函数耗时可能会比较长,但是只需要执行一次即可
|
||||
if (ret == USB2CAN.CAN_SUCCESS)
|
||||
{
|
||||
Console.WriteLine($"Update CAN Schedule Success -- SchTabIndex:{(byte)itemMsgSchConfig.SchTabIndex} -- MsgIndex:{(byte)(0)} ");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"Update CAN Schedule Error ret = {ret} -- SchTabIndex:{(byte)itemMsgSchConfig.SchTabIndex} -- MsgIndex:{(byte)(0)}");
|
||||
//return;
|
||||
}
|
||||
|
||||
IsSendOk = true;
|
||||
Console.WriteLine($"Update CAN Schedule Success -- SchTabIndex:{(byte)0} -- MsgIndex:{(byte)(0)} ");
|
||||
}
|
||||
else
|
||||
{
|
||||
IsSendOk = false;
|
||||
Console.WriteLine($"Update CAN Schedule Error ret = {ret} -- SchTabIndex:{(byte)0} -- MsgIndex:{(byte)(0)}");
|
||||
//return;
|
||||
}
|
||||
|
||||
//一个报文帧一个报文帧进行更新数据
|
||||
////配置信息 默认启用1号调度器,MsgTabIndex=0;
|
||||
//foreach (var itemMsgSchConfig in ListCANScheduleConfig)
|
||||
//{
|
||||
// //USB2CAN.CAN_MSG[] SchCanMsg1=new CAN_MSG[1];
|
||||
// //SchCanMsg1[0] = SchCanMsg[itemMsgSchConfig.MsgIndex];
|
||||
|
||||
// // MsgTabIndex CAN调度表索引号 ;MsgIndex 开始更新帧起始索引,若起始索引大于调度表帧数,则将帧添加到调度表后面, ;
|
||||
// // pCanMsg 需要更新的CAN帧指针,消息数据 ; MsgNum pCanMsgTab里面包含的有效帧数,一个调度表对应一个帧/消息,即为:1 (byte)(itemMsgSchConfig.MsgIndex+0)
|
||||
// var ret = USB2CAN.CAN_UpdateSchedule(DevHandle, WriteCANIndex, (byte)0, (byte)(itemMsgSchConfig.MsgIndex), SchCanMsg, 1);//配置调度表,该函数耗时可能会比较长,但是只需要执行一次即可
|
||||
// if (ret == USB2CAN.CAN_SUCCESS)
|
||||
// {
|
||||
// Console.WriteLine($"Update CAN Schedule Success -- SchTabIndex:{(byte)itemMsgSchConfig.SchTabIndex} -- MsgIndex:{(byte)(itemMsgSchConfig.MsgIndex)} ");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Console.WriteLine($"Update CAN Schedule Error ret = {ret} -- SchTabIndex:{(byte)itemMsgSchConfig.SchTabIndex} -- MsgIndex:{(byte)(itemMsgSchConfig.MsgIndex)}");
|
||||
// //return;
|
||||
// }
|
||||
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
IsSendOk = false;
|
||||
LoggerService.Info($"时间:{DateTime.Now.ToString()}-【MSG】-{ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
IsSendOk = false;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1102,11 +1153,11 @@ namespace CapMachine.Wpf.CanDrive
|
||||
try
|
||||
{
|
||||
//另外一个CAN通道读取数据
|
||||
USB2CAN.CAN_MSG[] CanMsgBuffer = new USB2CAN.CAN_MSG[128];
|
||||
USB2CAN.CAN_MSG[] CanMsgBuffer = new USB2CAN.CAN_MSG[1024];
|
||||
//申请数据缓冲区
|
||||
IntPtr msgPtRead = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(USB2CAN.CAN_MSG)) * CanMsgBuffer.Length);
|
||||
//int CanNum = USB2CAN.CAN_GetMsgWithSize(DevHandle, ReadCANIndex, msgPtRead, CanMsgBuffer.Length);
|
||||
int CanNum = USB2CAN.CAN_GetMsgWithSize(DevHandle, 1, msgPtRead, CanMsgBuffer.Length);
|
||||
int CanNum = USB2CAN.CAN_GetMsgWithSize(DevHandle, ReadCANIndex, msgPtRead, CanMsgBuffer.Length);
|
||||
//int CanNum = USB2CAN.CAN_GetMsgWithSize(DevHandle, 1, msgPtRead, CanMsgBuffer.Length);//测试用,CAN卡 CAN1和CAN2 短接时测试用
|
||||
if (CanNum > 0)
|
||||
{
|
||||
IsReviceOk = true;
|
||||
@@ -1183,7 +1234,12 @@ namespace CapMachine.Wpf.CanDrive
|
||||
IsReviceOk = false;
|
||||
LoggerService.Info("接收出现异常");
|
||||
}
|
||||
//finally
|
||||
//{
|
||||
// IsReviceOk = false;
|
||||
//}
|
||||
}
|
||||
IsReviceOk = false;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1246,6 +1302,10 @@ namespace CapMachine.Wpf.CanDrive
|
||||
DbcParserState = false;
|
||||
IsCycleRevice = false;
|
||||
IsCycleSend = false;
|
||||
if (SchEnable)
|
||||
{
|
||||
StopSchedule();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
|
||||
@@ -396,6 +396,7 @@ namespace CapMachine.Wpf.LinDrive
|
||||
LoggerService.Info($"{ex.Message}");
|
||||
}
|
||||
}
|
||||
IsReviceOk = false;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -631,6 +632,8 @@ namespace CapMachine.Wpf.LinDrive
|
||||
await Task.Delay(10, token);
|
||||
}
|
||||
}
|
||||
|
||||
IsSendOk = false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -315,7 +315,6 @@ namespace CapMachine.Wpf.Services
|
||||
{
|
||||
|
||||
ToomossCanDrive.CmdData = CmdData;
|
||||
ToomossCanDrive.SchEnable = true;
|
||||
|
||||
if (ToomossCanDrive.SchEnable)
|
||||
{
|
||||
@@ -342,7 +341,8 @@ namespace CapMachine.Wpf.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
ToomossCanDrive.StartCycleSendMsg();
|
||||
ToomossCanDrive.StartPrecisionCycleSendMsg();
|
||||
//ToomossCanDrive.StartCycleSendMsg();
|
||||
}
|
||||
|
||||
ToomossCanDrive.IsCycleSend = true;
|
||||
|
||||
@@ -221,11 +221,20 @@ namespace CapMachine.Wpf.ViewModels
|
||||
//});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ListWriteCanLinRWConfigDto = new ObservableCollection<CanLinRWConfigDto>();
|
||||
}
|
||||
|
||||
var ReadData = SelectCanLinConfigPro.CanLinConfigContents!.Where(a => a.RWInfo == RW.Read).ToList();
|
||||
if (ReadData != null && ReadData.Count > 0)
|
||||
{
|
||||
ListReadCanLinRWConfigDto = new ObservableCollection<CanLinRWConfigDto>(Mapper.Map<List<CanLinRWConfigDto>>(ReadData));
|
||||
}
|
||||
else
|
||||
{
|
||||
ListReadCanLinRWConfigDto = new ObservableCollection<CanLinRWConfigDto>();
|
||||
}
|
||||
//调度表配置信息
|
||||
if (SelectCanLinConfigPro.CanScheduleConfigs != null && SelectCanLinConfigPro.CanScheduleConfigs.Count() > 0)
|
||||
{
|
||||
@@ -583,11 +592,19 @@ namespace CapMachine.Wpf.ViewModels
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ListWriteCanLinRWConfigDto = new ObservableCollection<CanLinRWConfigDto>();
|
||||
}
|
||||
var ReadData = SelectCanLinConfigPro.CanLinConfigContents!.Where(a => a.RWInfo == RW.Read).ToList();
|
||||
if (ReadData != null && ReadData.Count > 0)
|
||||
{
|
||||
ListReadCanLinRWConfigDto = new ObservableCollection<CanLinRWConfigDto>(Mapper.Map<List<CanLinRWConfigDto>>(ReadData));
|
||||
}
|
||||
else
|
||||
{
|
||||
ListReadCanLinRWConfigDto = new ObservableCollection<CanLinRWConfigDto>();
|
||||
}
|
||||
|
||||
SelectCanLinConfigProConfigName = SelectCanLinConfigPro.ConfigName;
|
||||
|
||||
|
||||
@@ -245,11 +245,19 @@ namespace CapMachine.Wpf.ViewModels
|
||||
//});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ListWriteCanLinRWConfigDto = new ObservableCollection<CanLinRWConfigDto>();
|
||||
}
|
||||
var ReadData = SelectCanLinConfigPro.CanLinConfigContents!.Where(a => a.RWInfo == RW.Read).ToList();
|
||||
if (ReadData != null && ReadData.Count > 0)
|
||||
{
|
||||
ListReadCanLinRWConfigDto = new ObservableCollection<CanLinRWConfigDto>(Mapper.Map<List<CanLinRWConfigDto>>(ReadData));
|
||||
}
|
||||
else
|
||||
{
|
||||
ListReadCanLinRWConfigDto = new ObservableCollection<CanLinRWConfigDto>();
|
||||
}
|
||||
|
||||
//匹配选中的SelectCanLinConfigPro.CanLinConfigContents和ListCanDbcModel
|
||||
MatchSeletedAndCanDbcModel();
|
||||
|
||||
@@ -4,6 +4,7 @@ using CapMachine.Model;
|
||||
using CapMachine.Model.CANLIN;
|
||||
using CapMachine.Wpf.Dtos;
|
||||
using CapMachine.Wpf.Services;
|
||||
using ImTools;
|
||||
using Prism.Commands;
|
||||
using Prism.Services.Dialogs;
|
||||
using System;
|
||||
@@ -43,28 +44,30 @@ namespace CapMachine.Wpf.ViewModels
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
//默认只能用1号调度器
|
||||
SchTabIndexCbxItems = new ObservableCollection<CbxItems>()
|
||||
{
|
||||
new CbxItems(){
|
||||
Key="0",
|
||||
Text="0",
|
||||
},
|
||||
new CbxItems(){
|
||||
Key="1",
|
||||
Text="1",
|
||||
},
|
||||
new CbxItems(){
|
||||
Key="2",
|
||||
Text="2",
|
||||
},
|
||||
new CbxItems(){
|
||||
Key="3",
|
||||
Text="3",
|
||||
},
|
||||
new CbxItems(){
|
||||
Key="4",
|
||||
Text="4",
|
||||
},
|
||||
//new CbxItems(){
|
||||
// Key="1",
|
||||
// Text="1",
|
||||
//},
|
||||
//new CbxItems(){
|
||||
// Key="2",
|
||||
// Text="2",
|
||||
//},
|
||||
//new CbxItems(){
|
||||
// Key="3",
|
||||
// Text="3",
|
||||
//},
|
||||
//new CbxItems(){
|
||||
// Key="4",
|
||||
// Text="4",
|
||||
//},
|
||||
};
|
||||
|
||||
}
|
||||
@@ -123,6 +126,17 @@ namespace CapMachine.Wpf.ViewModels
|
||||
}
|
||||
|
||||
|
||||
private string? _CurSendOrder;
|
||||
/// <summary>
|
||||
/// 当前发送方式
|
||||
/// </summary>
|
||||
public string? CurSendOrder
|
||||
{
|
||||
get { return _CurSendOrder; }
|
||||
set { _CurSendOrder = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
private ObservableCollection<CbxItems> _SchTabIndexCbxItems;
|
||||
/// <summary>
|
||||
/// 调度器序号 集合信息
|
||||
@@ -256,6 +270,9 @@ namespace CapMachine.Wpf.ViewModels
|
||||
//检查空的数据
|
||||
foreach (var item in ListCANScheduleConfigDto)
|
||||
{
|
||||
//整个的发送方式赋值给每个子项
|
||||
item.OrderSend = CurSendOrder == "0" ? 0 : 1;
|
||||
|
||||
if (string.IsNullOrEmpty(item.MsgName))
|
||||
{
|
||||
MessageBox.Show("请确认消息名称是否正确", "提示", MessageBoxButton.OK, MessageBoxImage.Hand);
|
||||
@@ -272,13 +289,16 @@ namespace CapMachine.Wpf.ViewModels
|
||||
return;
|
||||
}
|
||||
}
|
||||
//检查重复设置问题
|
||||
bool isRepeat = ListCANScheduleConfigDto.GroupBy(i => i.MsgName).Any(g => g.Count() > 1);
|
||||
if (isRepeat)
|
||||
{
|
||||
MessageBox.Show("请确认是否重复设置", "提示", MessageBoxButton.OK, MessageBoxImage.Hand);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//发送的控制帧都放到同一个调度表中,不需要检查了
|
||||
////检查重复设置问题
|
||||
//bool isRepeat = ListCANScheduleConfigDto.GroupBy(i => i.MsgName).Any(g => g.Count() > 1);
|
||||
//if (isRepeat)
|
||||
//{
|
||||
// MessageBox.Show("请确认是否重复设置", "提示", MessageBoxButton.OK, MessageBoxImage.Hand);
|
||||
// return;
|
||||
//}
|
||||
|
||||
//检查数据是否正常
|
||||
foreach (var item in ListCANScheduleConfigDto)
|
||||
@@ -347,6 +367,9 @@ namespace CapMachine.Wpf.ViewModels
|
||||
//防止返回的数据为空,就无法增加了
|
||||
if (ListCANScheduleConfigDto == null) ListCANScheduleConfigDto = new ObservableCollection<CANScheduleConfigDto>();
|
||||
//Name = parameters.GetValue<string>("Name");
|
||||
if (ListCANScheduleConfigDto.Count > 0) {
|
||||
CurSendOrder = ListCANScheduleConfigDto.FirstOrDefault()!.OrderSend.ToString();
|
||||
}
|
||||
|
||||
SelectCanLinConfigProId = parameters.GetValue<long>("SelectCanLinConfigProId");
|
||||
}
|
||||
|
||||
@@ -55,6 +55,17 @@ namespace CapMachine.Wpf.ViewModels
|
||||
//MachineDataService = machineDataService;
|
||||
DialogService = dialogService;
|
||||
|
||||
//数据波特率
|
||||
DataBaudRateCbxItems = new ObservableCollection<CbxItems>()
|
||||
{
|
||||
new CbxItems(){ Key="38400",Text="38400"},
|
||||
new CbxItems(){ Key="19200",Text="19200"},
|
||||
new CbxItems(){ Key="14400",Text="14400"},
|
||||
new CbxItems(){ Key="9600",Text="9600"},
|
||||
new CbxItems(){ Key="4800",Text="4800"},
|
||||
new CbxItems(){ Key="2400",Text="2400"},
|
||||
};
|
||||
|
||||
WriteNameCbxItems = new ObservableCollection<CbxItems>()
|
||||
{
|
||||
new CbxItems(){ Key="转速",Text="转速"},
|
||||
@@ -156,11 +167,20 @@ namespace CapMachine.Wpf.ViewModels
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ListWriteCanLinRWConfigDto = new ObservableCollection<CanLinRWConfigDto>();
|
||||
}
|
||||
|
||||
var ReadData = SelectCanLinConfigPro.CanLinConfigContents!.Where(a => a.RWInfo == RW.Read).ToList();
|
||||
if (ReadData != null && ReadData.Count > 0)
|
||||
{
|
||||
ListReadCanLinRWConfigDto = new ObservableCollection<CanLinRWConfigDto>(Mapper.Map<List<CanLinRWConfigDto>>(ReadData));
|
||||
}
|
||||
else
|
||||
{
|
||||
ListReadCanLinRWConfigDto = new ObservableCollection<CanLinRWConfigDto>();
|
||||
}
|
||||
|
||||
//匹配选中的SelectCanLinConfigPro.CanLinConfigContents和ListLinLdfModel
|
||||
MatchSeletedAndLinLdfModel();
|
||||
@@ -508,11 +528,19 @@ namespace CapMachine.Wpf.ViewModels
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ListWriteCanLinRWConfigDto = new ObservableCollection<CanLinRWConfigDto>();
|
||||
}
|
||||
var ReadData = SelectCanLinConfigPro.CanLinConfigContents!.Where(a => a.RWInfo == RW.Read).ToList();
|
||||
if (ReadData != null && ReadData.Count > 0)
|
||||
{
|
||||
ListReadCanLinRWConfigDto = new ObservableCollection<CanLinRWConfigDto>(Mapper.Map<List<CanLinRWConfigDto>>(ReadData));
|
||||
}
|
||||
else
|
||||
{
|
||||
ListReadCanLinRWConfigDto = new ObservableCollection<CanLinRWConfigDto>();
|
||||
}
|
||||
|
||||
SelectCanLinConfigProConfigName = SelectCanLinConfigPro.ConfigName;
|
||||
return;
|
||||
@@ -792,6 +820,16 @@ namespace CapMachine.Wpf.ViewModels
|
||||
set { _SelectedLINConfigExdDto = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private ObservableCollection<CbxItems> _DataBaudRateCbxItems;
|
||||
/// <summary>
|
||||
/// CAN 数据波特率
|
||||
/// </summary>
|
||||
public ObservableCollection<CbxItems> DataBaudRateCbxItems
|
||||
{
|
||||
get { return _DataBaudRateCbxItems; }
|
||||
set { _DataBaudRateCbxItems = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private DelegateCommand<string> _LinOpCmd;
|
||||
/// <summary>
|
||||
/// LIN操作的指令
|
||||
|
||||
@@ -94,6 +94,32 @@
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel
|
||||
Margin="30,0"
|
||||
HorizontalAlignment="Right"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Margin="10,0,5,0"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="/Assets/Fonts/#iconfont"
|
||||
FontSize="22"
|
||||
Text="" />
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="20"
|
||||
Text="报文发送方式:"
|
||||
TextAlignment="Center" />
|
||||
<ComboBox
|
||||
Width="120"
|
||||
DisplayMemberPath="Text"
|
||||
FontSize="20"
|
||||
ItemsSource="{Binding SendOrderCbxItems}"
|
||||
SelectedValue="{Binding CurSendOrder, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
SelectedValuePath="Key" />
|
||||
|
||||
</StackPanel>
|
||||
|
||||
<Grid Grid.Row="1">
|
||||
<DataGrid
|
||||
x:Name="MainDatagrid"
|
||||
@@ -127,7 +153,7 @@
|
||||
Binding="{Binding Cycle}"
|
||||
Header="周期" />
|
||||
|
||||
<DataGridTemplateColumn Width="200" Header="发送方式">
|
||||
<!--<DataGridTemplateColumn Width="200" Header="发送方式">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<ComboBox
|
||||
@@ -137,7 +163,7 @@
|
||||
SelectedValuePath="Key" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGridTemplateColumn>-->
|
||||
|
||||
<DataGridTemplateColumn Width="160" Header="调度器序号">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
|
||||
@@ -406,7 +406,14 @@
|
||||
FontSize="18"
|
||||
Text="" />
|
||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="波特率" />
|
||||
<TextBox Style="{StaticResource TextBoxStyle}" Text="{Binding SelectedLINConfigExdDto.BaudRate}" />
|
||||
<ComboBox
|
||||
Width="100"
|
||||
DisplayMemberPath="Text"
|
||||
FontSize="16"
|
||||
ItemsSource="{Binding DataBaudRateCbxItems}"
|
||||
SelectedValue="{Binding SelectedLINConfigExdDto.BaudRate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
SelectedValuePath="Key" />
|
||||
<!--<TextBox Style="{StaticResource TextBoxStyle}" Text="{Binding SelectedLINConfigExdDto.BaudRate}" />-->
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Row="1" Orientation="Horizontal">
|
||||
|
||||
Reference in New Issue
Block a user