更改了CAN和LIN的标志着色问题

保存图片触发两次
CANLIN的一些数据回读到PLC
This commit is contained in:
2025-01-12 15:32:02 +08:00
parent e49a48fb25
commit 914a8b3dbc
15 changed files with 333 additions and 46 deletions

View File

@@ -7,6 +7,7 @@ using CapMachine.Wpf.Dtos;
using CapMachine.Wpf.PrismEvent;
using CapMachine.Wpf.Services;
using Ganss.Excel;
using ImTools;
using Microsoft.VisualBasic;
using Microsoft.Win32;
using NPOI.SS.UserModel.Charts;
@@ -113,9 +114,12 @@ namespace CapMachine.Wpf.ViewModels
if (SelectCanLinConfigPro != null)
{
SelectCanLinConfigPro = canLinConfigPros.Where(a => a.Id == SelectCanLinConfigPro.Id).FirstOrDefault()!;
//无数据就返回
if (SelectCanLinConfigPro == null) return;
SelectedCANConfigExdDto = Mapper.Map<CANConfigExdDto>(SelectCanLinConfigPro!.CANConfigExd);
//配置信息
var WirteData = SelectCanLinConfigPro.CanLinConfigContents!.Where(a => a.RWInfo == RW.Write).ToList();
if (WirteData != null && WirteData.Count > 0)
{
@@ -140,19 +144,55 @@ namespace CapMachine.Wpf.ViewModels
// 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));
}
//匹配选中的SelectCanLinConfigPro.CanLinConfigContents和ListCanDbcModel
MatchSeletedAndCanDbcModel();
}
}
/// <summary>
/// 匹配选中的SelectCanLinConfigPro.CanLinConfigContents和ListCanDbcModel
/// 为了标注和着色使用
/// </summary>
private void MatchSeletedAndCanDbcModel()
{
//通过CanLinConfigContents标注ListCanDbcModel的选中状态属性,方便着色
if (ListCanDbcModel != null && ListCanDbcModel!.Count() > 0 && SelectCanLinConfigPro.CanLinConfigContents != null && SelectCanLinConfigPro.CanLinConfigContents.Count() > 0)
{
foreach (var itemCanDbcModel in ListCanDbcModel)
{
var FindData = SelectCanLinConfigPro.CanLinConfigContents.FindFirst(a => a.SignalName == itemCanDbcModel.SignalName);
if (FindData != null)//找到了就标注
{
switch (FindData.RWInfo)
{
case RW.Write:
itemCanDbcModel.IsSeletedInfo = 1;
break;
case RW.Read:
itemCanDbcModel.IsSeletedInfo = 2;
break;
default:
break;
}
}
else
{
//没有找到了就标注为0
itemCanDbcModel.IsSeletedInfo = 0;
}
}
}
}
private bool _IsCanConfigProActive = false;
/// <summary>
/// CAN 配置是否被激活
@@ -335,7 +375,7 @@ namespace CapMachine.Wpf.ViewModels
case "Active":
//激活到取消的状态的判断
if (IsCanConfigProActive==true)
if (IsCanConfigProActive == true)
{
//控件的激活
IsCanConfigProActive = !IsCanConfigProActive;
@@ -467,6 +507,7 @@ namespace CapMachine.Wpf.ViewModels
}
SelectCanLinConfigProConfigName = SelectCanLinConfigPro.ConfigName;
return;
}
//先判断是否是正确的集合数据防止DataGrid的数据源刷新导致的触发事件
@@ -653,8 +694,8 @@ namespace CapMachine.Wpf.ViewModels
return;
}
if ((par as SelectionChangedEventArgs)!.AddedItems[0] == null)
//(par as SelectionChangedEventArgs)!.AddedItems[0] == null
if ((par as SelectionChangedEventArgs)!.AddedItems.Count==0)
{
return;
}
@@ -777,7 +818,7 @@ namespace CapMachine.Wpf.ViewModels
switch (Par)
{
case "Open":
if (ComActionService.IsCanToDoWork()==false)
if (ComActionService.IsCanToDoWork() == false)
{
System.Windows.MessageBox.Show("请关闭LIN连接后才能开启CAN同一个时刻只能有一个通信驱动压缩机", "提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Hand);
return;
@@ -793,7 +834,13 @@ namespace CapMachine.Wpf.ViewModels
{
var DbcData = CanDriveService.StartDbc(SelectedCANConfigExdDto.DbcPath);
ListCanDbcModel = DbcData;
//ListCanDbcModel有数据后就要看看是否有配置信息有的话就要标注
//匹配选中的SelectCanLinConfigPro.CanLinConfigContents和ListCanDbcModel
MatchSeletedAndCanDbcModel();
}
}
else
{