切换CANLIN配置程序后的数据刷新,如果当前的没有,则刷新,不需要展示上一次的数据

This commit is contained in:
2025-08-13 17:12:04 +08:00
parent 1d32e59360
commit d6f6022482
11 changed files with 272 additions and 85 deletions

View File

@@ -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;

View File

@@ -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();

View File

@@ -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");
}

View File

@@ -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操作的指令
@@ -835,7 +873,7 @@ namespace CapMachine.Wpf.ViewModels
//系统使用了LIN
ConfigService.CanLinRunStateModel.CurSysSelectedCanLin = CanLinEnum.Lin;
}
//LIN LDF配置 有LDF配置的话则直接加载LDF信息
if (!string.IsNullOrEmpty(SelectCanLinConfigPro.LINConfigExd.LdfPath))
{