一些优化:CAN和PLC地址的优化
This commit is contained in:
@@ -7,6 +7,7 @@ using CapMachine.Wpf.Dtos;
|
||||
using CapMachine.Wpf.PrismEvent;
|
||||
using CapMachine.Wpf.Services;
|
||||
using Ganss.Excel;
|
||||
using Microsoft.VisualBasic;
|
||||
using Microsoft.Win32;
|
||||
using NPOI.SS.UserModel.Charts;
|
||||
using Prism.Commands;
|
||||
@@ -18,6 +19,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
@@ -96,7 +98,6 @@ namespace CapMachine.Wpf.ViewModels
|
||||
/// </summary>
|
||||
private void InitLoadCanConfigPro()
|
||||
{
|
||||
|
||||
//CAN配置集合数据
|
||||
canLinConfigPros = FreeSql.Select<CanLinConfigPro>().Where(a => a.CANLINInfo == CANLIN.CAN)
|
||||
.Include(a => a.CANConfigExd)
|
||||
@@ -115,16 +116,32 @@ namespace CapMachine.Wpf.ViewModels
|
||||
{
|
||||
ListWriteCanLinRWConfigDto = new ObservableCollection<CanLinRWConfigDto>(Mapper.Map<List<CanLinRWConfigDto>>(WirteData));
|
||||
|
||||
//加载把当前的配置信息给指令
|
||||
CanDriveService.CmdData.Clear();
|
||||
foreach (var item in WirteData)
|
||||
{
|
||||
CanDriveService.CmdData.Add(new CanCmdData()
|
||||
{
|
||||
ConfigName = item.Name,
|
||||
MsgName = item.MsgFrameName,
|
||||
SignalName = item.SignalName,
|
||||
SignalCmdValue = double.TryParse(item.DefautValue, out double result) == true ? result : 0,
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
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));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private bool _IsCanConfigProActive = true;
|
||||
private bool _IsCanConfigProActive = false;
|
||||
/// <summary>
|
||||
/// CAN 配置是否被激活
|
||||
/// </summary>
|
||||
@@ -134,6 +151,27 @@ namespace CapMachine.Wpf.ViewModels
|
||||
set { _IsCanConfigProActive = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private bool _IsCANConfigDatagridActive = true;
|
||||
/// <summary>
|
||||
/// CANConfigDatagrid是否被触控
|
||||
/// 关联IsCanConfigProActive 取反
|
||||
/// </summary>
|
||||
public bool IsCANConfigDatagridActive
|
||||
{
|
||||
get { return _IsCANConfigDatagridActive; }
|
||||
set { _IsCANConfigDatagridActive = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private string _SelectCanLinConfigProConfigName;
|
||||
/// <summary>
|
||||
/// 选中的 CanLinConfigPro 名称
|
||||
/// </summary>
|
||||
public string SelectCanLinConfigProConfigName
|
||||
{
|
||||
get { return _SelectCanLinConfigProConfigName; }
|
||||
set { _SelectCanLinConfigProConfigName = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
private DelegateCommand<string> _CanLinConfigPromdCmd;
|
||||
/// <summary>
|
||||
@@ -191,7 +229,7 @@ namespace CapMachine.Wpf.ViewModels
|
||||
//加载默认的数据 CanLinRWConfig
|
||||
FreeSql.Insert<CanLinRWConfig>(new CanLinRWConfig()
|
||||
{
|
||||
Content = "Speed",
|
||||
SignalName = "Speed",
|
||||
DefautValue = "0",
|
||||
Name = "转速",
|
||||
RWInfo = RW.Write,
|
||||
@@ -200,7 +238,7 @@ namespace CapMachine.Wpf.ViewModels
|
||||
|
||||
FreeSql.Insert<CanLinRWConfig>(new CanLinRWConfig()
|
||||
{
|
||||
Content = "Vol",
|
||||
SignalName = "Vol",
|
||||
DefautValue = "0",
|
||||
Name = "电压",
|
||||
RWInfo = RW.Read,
|
||||
@@ -281,18 +319,19 @@ namespace CapMachine.Wpf.ViewModels
|
||||
{
|
||||
System.Windows.MessageBox.Show("选中后再操作", "提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Hand);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case "Active":
|
||||
if (SelectCanLinConfigPro != null)
|
||||
{
|
||||
//控件的激活
|
||||
IsCanConfigProActive = !IsCanConfigProActive;
|
||||
//控件的激活配置信息
|
||||
IsCANConfigDatagridActive = !IsCanConfigProActive;
|
||||
|
||||
//当前使用的CAN 配置信息
|
||||
CanDriveService.InitCanConfig(SelectCanLinConfigPro);
|
||||
|
||||
InitLoadCanConfigPro();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -375,6 +414,7 @@ namespace CapMachine.Wpf.ViewModels
|
||||
ListReadCanLinRWConfigDto = new ObservableCollection<CanLinRWConfigDto>(Mapper.Map<List<CanLinRWConfigDto>>(ReadData));
|
||||
}
|
||||
|
||||
SelectCanLinConfigProConfigName = SelectCanLinConfigPro.ConfigName;
|
||||
return;
|
||||
}
|
||||
//先判断是否是正确的集合数据,防止DataGrid的数据源刷新导致的触发事件
|
||||
@@ -384,7 +424,11 @@ namespace CapMachine.Wpf.ViewModels
|
||||
{
|
||||
SelectCanLinConfigPro = Selecteddata;
|
||||
|
||||
SelectCanLinConfigProConfigName = SelectCanLinConfigPro.ConfigName;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -606,7 +650,8 @@ namespace CapMachine.Wpf.ViewModels
|
||||
FreeSql.Insert<CanLinRWConfig>(new CanLinRWConfig()
|
||||
{
|
||||
Name = "",
|
||||
Content = SelectedCanDbcModel.SignalName,
|
||||
SignalName = SelectedCanDbcModel.SignalName,
|
||||
MsgFrameName = SelectedCanDbcModel.MsgName,
|
||||
CanLinConfigProId = SelectCanLinConfigPro.Id,
|
||||
DefautValue = "",
|
||||
RWInfo = RW.Write,
|
||||
@@ -621,7 +666,8 @@ namespace CapMachine.Wpf.ViewModels
|
||||
FreeSql.Insert<CanLinRWConfig>(new CanLinRWConfig()
|
||||
{
|
||||
Name = "",
|
||||
Content = SelectedCanDbcModel.SignalName,
|
||||
SignalName = SelectedCanDbcModel.SignalName,
|
||||
MsgFrameName = SelectedCanDbcModel.MsgName,
|
||||
CanLinConfigProId = SelectCanLinConfigPro.Id,
|
||||
DefautValue = "",
|
||||
RWInfo = RW.Read,
|
||||
@@ -683,16 +729,12 @@ namespace CapMachine.Wpf.ViewModels
|
||||
{
|
||||
//打开连接
|
||||
CanDriveService.ToomossCanDrive.StartCanDrive();
|
||||
|
||||
//CAN DBC配置 有DBC配置的话,则直接加载DBC信息
|
||||
if (!string.IsNullOrEmpty(SelectCanLinConfigPro.CANConfigExd.DbcPath))
|
||||
{
|
||||
var DbcData = CanDriveService.StartDbc(SelectedCANConfigExdDto.DbcPath);
|
||||
|
||||
ListCanDbcModel = DbcData;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -763,37 +805,35 @@ namespace CapMachine.Wpf.ViewModels
|
||||
//};
|
||||
// return;
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
System.Windows.MessageBox.Show("新建CAN配置名称后再操作", "提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Hand);
|
||||
}
|
||||
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case "SendTest1":
|
||||
case "HandSend"://手动发送
|
||||
|
||||
CanDriveService.ToomossCanDrive.SendCanMsg(new List<CanCmdData>()
|
||||
{
|
||||
new CanCmdData(){ MsgName="TX1",SignalName="COM_current_Power",SignalCmdValue=12},
|
||||
new CanCmdData(){ MsgName="TX1",SignalName="COM_Curr_dc",SignalCmdValue=12},
|
||||
});
|
||||
//手动发送数据
|
||||
CanDriveService.SendMsgToCanDrive();
|
||||
|
||||
//CanDriveService.ToomossCanDrive.SendCanMsg(new List<CanCmdData>()
|
||||
//{
|
||||
// new CanCmdData(){ MsgName="TX1",SignalName="COM_current_Power",SignalCmdValue=12},
|
||||
// new CanCmdData(){ MsgName="TX1",SignalName="COM_Curr_dc",SignalCmdValue=12},
|
||||
//});
|
||||
|
||||
break;
|
||||
case "SendTest2":
|
||||
case "CycleSend"://循环发送你
|
||||
//循环发送数据
|
||||
CanDriveService.CycleSendMsg();
|
||||
|
||||
CanDriveService.ToomossCanDrive.IsCycleRevice = true;
|
||||
CanDriveService.ToomossCanDrive.StartCycleReviceCanMsg();
|
||||
//Listen
|
||||
break;
|
||||
case "Listen":
|
||||
case "CycleRecive":
|
||||
CanDriveService.CycleReciveMsg();
|
||||
|
||||
CanDriveService.ToomossCanDrive.IsCycleRevice = true;
|
||||
CanDriveService.ToomossCanDrive.StartCycleReviceCanMsg();
|
||||
//Listen
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user