周立功的CAN /FD实现
This commit is contained in:
@@ -4,6 +4,7 @@ using CapMachine.Model.CANLIN;
|
||||
using CapMachine.Wpf.Dtos;
|
||||
using CapMachine.Wpf.LinDrive;
|
||||
using CapMachine.Wpf.Services;
|
||||
using CapMachine.Wpf.Views;
|
||||
using ImTools;
|
||||
using Microsoft.Win32;
|
||||
using Prism.Commands;
|
||||
@@ -78,6 +79,25 @@ namespace CapMachine.Wpf.ViewModels
|
||||
/// </summary>
|
||||
public CanLinConfigPro? SelectCanLinConfigPro { get; set; }
|
||||
|
||||
private ObservableCollection<CanLinRWConfigDto> _listWriteCanLinRWConfigDto = new ObservableCollection<CanLinRWConfigDto>();
|
||||
public ObservableCollection<CanLinRWConfigDto> ListWriteCanLinRWConfigDto
|
||||
{
|
||||
get { return _listWriteCanLinRWConfigDto; }
|
||||
set { _listWriteCanLinRWConfigDto = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private ObservableCollection<CanLinRWConfigDto> _listReadCanLinRWConfigDto = new ObservableCollection<CanLinRWConfigDto>();
|
||||
public ObservableCollection<CanLinRWConfigDto> ListReadCanLinRWConfigDto
|
||||
{
|
||||
get { return _listReadCanLinRWConfigDto; }
|
||||
set { _listReadCanLinRWConfigDto = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
public bool IsRwEditable
|
||||
{
|
||||
get { return !ZlgLinDriveService.OpenState; }
|
||||
}
|
||||
|
||||
private LINConfigExdDto? _SelectedLINConfigExdDto;
|
||||
/// <summary>
|
||||
/// 选中的 LIN 配置 DTO。
|
||||
@@ -146,6 +166,14 @@ namespace CapMachine.Wpf.ViewModels
|
||||
{
|
||||
if (SelectCanLinConfigPro == null) return;
|
||||
SelectedLINConfigExdDto = Mapper.Map<LINConfigExdDto>(SelectCanLinConfigPro.LINConfigExd);
|
||||
|
||||
var writeData = SelectCanLinConfigPro.CanLinConfigContents?.Where(a => a.RWInfo == RW.Write).ToList() ?? new List<CanLinRWConfig>();
|
||||
ListWriteCanLinRWConfigDto = new ObservableCollection<CanLinRWConfigDto>(Mapper.Map<List<CanLinRWConfigDto>>(writeData));
|
||||
|
||||
var readData = SelectCanLinConfigPro.CanLinConfigContents?.Where(a => a.RWInfo == RW.Read).ToList() ?? new List<CanLinRWConfig>();
|
||||
ListReadCanLinRWConfigDto = new ObservableCollection<CanLinRWConfigDto>(Mapper.Map<List<CanLinRWConfigDto>>(readData));
|
||||
|
||||
RaisePropertyChanged(nameof(IsRwEditable));
|
||||
}
|
||||
|
||||
private DelegateCommand<object>? _LinConfigProGridSelectionChangedCmd;
|
||||
@@ -270,11 +298,15 @@ namespace CapMachine.Wpf.ViewModels
|
||||
{
|
||||
ConfigService.CanLinRunStateModel.CurSysSelectedCanLin = CanLinEnum.Lin;
|
||||
}
|
||||
|
||||
RaisePropertyChanged(nameof(IsRwEditable));
|
||||
break;
|
||||
|
||||
case "Close":
|
||||
ZlgLinDriveService.CloseDevice();
|
||||
ConfigService.CanLinRunStateModel.CurSysSelectedCanLin = CanLinEnum.No;
|
||||
|
||||
RaisePropertyChanged(nameof(IsRwEditable));
|
||||
break;
|
||||
|
||||
case "Save":
|
||||
@@ -315,6 +347,113 @@ namespace CapMachine.Wpf.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private DelegateCommand? _openRwDialogCmd;
|
||||
public DelegateCommand OpenRwDialogCmd
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_openRwDialogCmd == null)
|
||||
{
|
||||
_openRwDialogCmd = new DelegateCommand(OpenRwDialogCmdMethod);
|
||||
}
|
||||
return _openRwDialogCmd;
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenRwDialogCmdMethod()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (SelectCanLinConfigPro == null)
|
||||
{
|
||||
MessageBox.Show("选中LIN配置名称后再操作", "提示", MessageBoxButton.OK, MessageBoxImage.Hand);
|
||||
return;
|
||||
}
|
||||
|
||||
var writeClones = new ObservableCollection<CanLinRWConfigDto>(
|
||||
(ListWriteCanLinRWConfigDto ?? new ObservableCollection<CanLinRWConfigDto>())
|
||||
.Select(CloneRwDto));
|
||||
|
||||
foreach (var item in writeClones)
|
||||
{
|
||||
item.RWInfo = RW.Write;
|
||||
}
|
||||
|
||||
var readClones = new ObservableCollection<CanLinRWConfigDto>(
|
||||
(ListReadCanLinRWConfigDto ?? new ObservableCollection<CanLinRWConfigDto>())
|
||||
.Select(CloneRwDto));
|
||||
|
||||
foreach (var item in readClones)
|
||||
{
|
||||
item.RWInfo = RW.Read;
|
||||
}
|
||||
|
||||
var candidates = new ObservableCollection<DialogZlgCanLinRwConfigViewModel.SignalCandidate>();
|
||||
if (ZlgLinDriveService.ListLinLdfModel != null)
|
||||
{
|
||||
foreach (var sig in ZlgLinDriveService.ListLinLdfModel)
|
||||
{
|
||||
candidates.Add(new DialogZlgCanLinRwConfigViewModel.SignalCandidate
|
||||
{
|
||||
MsgName = sig.MsgName,
|
||||
SignalName = sig.SignalName,
|
||||
Name = sig.Name,
|
||||
Desc = sig.SignalDesc,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var pars = new DialogParameters
|
||||
{
|
||||
{ "Title", "读写设置" },
|
||||
{ "CanLinConfigProId", SelectCanLinConfigPro.Id },
|
||||
{ "IsEditable", IsRwEditable },
|
||||
{ "WriteConfigs", writeClones },
|
||||
{ "ReadConfigs", readClones },
|
||||
{ "SignalCandidates", candidates },
|
||||
};
|
||||
|
||||
DialogService.ShowDialog(nameof(DialogZlgCanLinRwConfigView), pars, r =>
|
||||
{
|
||||
if (r.Result == ButtonResult.OK)
|
||||
{
|
||||
ReloadCurrentConfigPro();
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ReloadCurrentConfigPro()
|
||||
{
|
||||
var id = SelectCanLinConfigPro?.Id;
|
||||
InitLoadLinConfigPro();
|
||||
|
||||
if (id != null)
|
||||
{
|
||||
SelectCanLinConfigPro = linConfigPros.Find(a => a.Id == id.Value);
|
||||
SyncSelectedConfig();
|
||||
}
|
||||
}
|
||||
|
||||
private static CanLinRWConfigDto CloneRwDto(CanLinRWConfigDto src)
|
||||
{
|
||||
return new CanLinRWConfigDto
|
||||
{
|
||||
Id = src.Id,
|
||||
RWInfo = src.RWInfo,
|
||||
Name = src.Name,
|
||||
MsgFrameName = src.MsgFrameName,
|
||||
SignalName = src.SignalName,
|
||||
DefautValue = src.DefautValue,
|
||||
LogicRuleId = src.LogicRuleId,
|
||||
LogicRuleDto = src.LogicRuleDto,
|
||||
};
|
||||
}
|
||||
|
||||
private DelegateCommand<object>? _SchEnableCmd;
|
||||
/// <summary>
|
||||
/// 调度表使能写入驱动。
|
||||
|
||||
Reference in New Issue
Block a user