LIN 调度表 V1
This commit is contained in:
@@ -50,6 +50,12 @@ namespace CapMachine.Model.CANLIN
|
||||
///CAN 的调度表配置模式
|
||||
public List<CANScheduleConfig>? CanScheduleConfigs { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ///////////////////////////////////////////导航属性///////////////////////////////////////////////////////
|
||||
/// </summary>
|
||||
///LIN 的调度表配置模式
|
||||
public List<LINScheduleConfig>? LinScheduleConfigs { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ///////////////////////////////////////////导航属性 LIN 一对一///////////////////////////////////////////////////////
|
||||
|
||||
@@ -31,5 +31,12 @@ namespace CapMachine.Model.CANLIN
|
||||
/// </summary>
|
||||
[Column(Name = "LdfPath", IsNullable = false, StringLength = 500)]
|
||||
public string? LdfPath { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 调度表是否启用
|
||||
/// </summary>
|
||||
[Column(Name = "SchEnable")]
|
||||
public bool SchEnable { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
53
CapMachine.Model/CANLIN/LINScheduleConfig.cs
Normal file
53
CapMachine.Model/CANLIN/LINScheduleConfig.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using FreeSql.DataAnnotations;
|
||||
|
||||
namespace CapMachine.Model.CANLIN
|
||||
{
|
||||
/// <summary>
|
||||
/// 调度表的配置
|
||||
/// 其实这些调度表是在DBC中有的,但是图莫斯的驱动没有读取到这些信息
|
||||
/// 那么我们在系统层面进行操作和保存这些信息
|
||||
/// </summary>
|
||||
[Table(Name = "LINScheduleConfig")]
|
||||
public class LINScheduleConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
[Column(IsPrimary = true, IsIdentity = true)]
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 消息名称
|
||||
/// </summary>
|
||||
[Column(Name = "MsgName")]
|
||||
public string? MsgName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 消息的周期
|
||||
/// </summary>
|
||||
[Column(Name = "Cycle")]
|
||||
public int Cycle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 调度表的Index
|
||||
/// LDF中可能有多个调度器
|
||||
/// </summary>
|
||||
[Column(Name = "SchTabIndex")]
|
||||
public int SchTabIndex { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 调度表的名称
|
||||
/// LDF中可能有多个调度器名称
|
||||
/// </summary>
|
||||
[Column(Name = "SchTabName")]
|
||||
public int SchTabName { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ///////////////////////////////////////////导航属性///////////////////////////////////////////////////////
|
||||
/// </summary>
|
||||
|
||||
public long CanLinConfigProId { get; set; }
|
||||
public CanLinConfigPro? CanLinConfigPro { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -201,6 +201,7 @@ namespace CapMachine.Wpf
|
||||
containerRegistry.RegisterDialog<DialogSuperHeatCoolConfigView, DialogSuperHeatCoolConfigViewModel>();
|
||||
containerRegistry.RegisterDialog<DialogLogicRuleView, DialogLogicRuleViewModel>();
|
||||
containerRegistry.RegisterDialog<DialogCANSchConfigView, DialogCANSchConfigViewModel>();
|
||||
containerRegistry.RegisterDialog<DialogLINSchConfigView, DialogLINSchConfigViewModel>();
|
||||
|
||||
containerRegistry.RegisterDialog<SplashScreenView, SplashScreenViewModel>();
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
|
||||
@@ -43,5 +43,16 @@ namespace CapMachine.Wpf.Dtos
|
||||
get { return _LdfPath; }
|
||||
set { _LdfPath = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private bool _SchEnable;
|
||||
/// <summary>
|
||||
/// 调度表是否启用
|
||||
/// </summary>
|
||||
public bool SchEnable
|
||||
{
|
||||
get { return _SchEnable; }
|
||||
set { _SchEnable = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
82
CapMachine.Wpf/Dtos/LINScheduleConfigDto.cs
Normal file
82
CapMachine.Wpf/Dtos/LINScheduleConfigDto.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using CapMachine.Model.CANLIN;
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CapMachine.Wpf.Dtos
|
||||
{
|
||||
public class LINScheduleConfigDto : BindableBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
|
||||
private string? _MsgName;
|
||||
/// <summary>
|
||||
/// 消息名称/帧名称
|
||||
/// </summary>
|
||||
public string? MsgName
|
||||
{
|
||||
get { return _MsgName; }
|
||||
set { _MsgName = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private int _Cycle;
|
||||
/// <summary>
|
||||
/// 周期
|
||||
/// </summary>
|
||||
public int Cycle
|
||||
{
|
||||
get { return _Cycle; }
|
||||
set { _Cycle = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
private int _SchTabIndex;
|
||||
/// <summary>
|
||||
/// 调度表的Index序列
|
||||
/// </summary>
|
||||
public int SchTabIndex
|
||||
{
|
||||
get { return _SchTabIndex; }
|
||||
set { _SchTabIndex = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private string? _SchTabName;
|
||||
/// <summary>
|
||||
/// 调度表的名称
|
||||
/// </summary>
|
||||
public string? SchTabName
|
||||
{
|
||||
get { return _SchTabName; }
|
||||
set { _SchTabName = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 在更新调度表数据时,我们有一个整体的帧数据指令集合,但是这些帧数据集合,分属于不同的调度表,
|
||||
/// 这个在开始时生成整体的帧数据指令集合才会把这个MsgIndex分配上,这个不需要保存到数据库中,对接使用
|
||||
/// </summary>
|
||||
public int MsgIndex { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 程序的ID
|
||||
/// </summary>
|
||||
public long CanLinConfigProId { get; set; }
|
||||
|
||||
|
||||
private CanLinConfigPro _CanLinConfigPro;
|
||||
/// <summary>
|
||||
/// 所属的程序
|
||||
/// </summary>
|
||||
public CanLinConfigPro CanLinConfigPro
|
||||
{
|
||||
get { return _CanLinConfigPro; }
|
||||
set { _CanLinConfigPro = value; RaisePropertyChanged(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,6 +68,15 @@ namespace CapMachine.Wpf.LinDrive
|
||||
[DllImport("USB2XXX.dll")]
|
||||
public static extern Int32 LDF_ExeFrameToBus(UInt64 LDFHandle, StringBuilder pFrameName, byte FillBitValue);
|
||||
[DllImport("USB2XXX.dll")]
|
||||
public static extern Int32 LDF_ExeSchToBus(UInt64 LDFHandle, StringBuilder pSchName, byte FillBitValue);
|
||||
public static extern Int32 LDF_ExeSchToBus(UInt64 LDFHandle, StringBuilder pSchName, byte FillBitValue);
|
||||
|
||||
[DllImport("USB2XXX.dll")]
|
||||
public static extern Int32 LDF_SetSchToTable(UInt64 LDFHandle, StringBuilder pSchName, byte FillBitValue);
|
||||
[DllImport("USB2XXX.dll")]
|
||||
public static extern Int32 LDF_GetRawMsg(UInt64 LDFHandle, IntPtr pLINMsg, int BufferSize);
|
||||
[DllImport("USB2XXX.dll")]
|
||||
public static extern Int32 LDF_StopSchTable(UInt64 LDFHandle);
|
||||
[DllImport("USB2XXX.dll")]
|
||||
public static extern Int32 LDF_Release(UInt64 LDFHandle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace CapMachine.Wpf.LinDrive
|
||||
HighSpeedDataService = ContainerProvider.Resolve<HighSpeedDataService>();
|
||||
LoggerService = ContainerProvider.Resolve<ILogService>();
|
||||
|
||||
|
||||
|
||||
//Stopwatch.Frequency表示高精度计时器每秒的计数次数(ticks/秒)每毫秒的ticks数 = 每秒的ticks数 ÷ 1000
|
||||
TicksPerMs = Stopwatch.Frequency / 1000.0;
|
||||
}
|
||||
@@ -378,7 +378,7 @@ namespace CapMachine.Wpf.LinDrive
|
||||
|
||||
}
|
||||
|
||||
IsReviceOk= true;
|
||||
IsReviceOk = true;
|
||||
|
||||
//StringBuilder ValueStr = new StringBuilder(64);
|
||||
//LDFParser.LDF_ExeFrameToBus(LDFHandle, new StringBuilder("ID_DATA"), 1);
|
||||
@@ -614,7 +614,7 @@ namespace CapMachine.Wpf.LinDrive
|
||||
}
|
||||
}
|
||||
|
||||
IsSendOk=true;
|
||||
IsSendOk = true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -666,7 +666,61 @@ namespace CapMachine.Wpf.LinDrive
|
||||
|
||||
#endregion
|
||||
|
||||
#region 调度器发送报文
|
||||
|
||||
private bool _SchEnable;
|
||||
/// <summary>
|
||||
/// 调度表使能
|
||||
/// </summary>
|
||||
public bool SchEnable
|
||||
{
|
||||
get { return _SchEnable; }
|
||||
set
|
||||
{
|
||||
_SchEnable = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 调度表数量
|
||||
/// </summary>
|
||||
public int SchCount { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取调度表数量
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int GetSchCount()
|
||||
{
|
||||
SchCount = LDFParser.LDF_GetSchQuantity(LDFHandle);
|
||||
return SchCount;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void LinTest()
|
||||
{
|
||||
GetSchCount();
|
||||
|
||||
for (int i = 0; i < SchCount; i++)
|
||||
{
|
||||
StringBuilder pSchName = new StringBuilder();
|
||||
var Ret = LDFParser.LDF_GetSchName(LDFHandle, i, pSchName);
|
||||
if (Ret <= 0)
|
||||
{
|
||||
Console.WriteLine($"{pSchName.ToString()}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("执行失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 关闭设备
|
||||
|
||||
14
CapMachine.Wpf/MapperProfile/LINScheduleConfigProfile.cs
Normal file
14
CapMachine.Wpf/MapperProfile/LINScheduleConfigProfile.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using AutoMapper;
|
||||
using CapMachine.Model.CANLIN;
|
||||
using CapMachine.Wpf.Dtos;
|
||||
|
||||
namespace CapMachine.Wpf.MapperProfile
|
||||
{
|
||||
public class LINScheduleConfigProfile : Profile
|
||||
{
|
||||
public LINScheduleConfigProfile()
|
||||
{
|
||||
CreateMap<LINScheduleConfig, LINScheduleConfigDto>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
||||
325
CapMachine.Wpf/ViewModels/DialogLINSchConfigViewModel.cs
Normal file
325
CapMachine.Wpf/ViewModels/DialogLINSchConfigViewModel.cs
Normal file
@@ -0,0 +1,325 @@
|
||||
using AutoMapper;
|
||||
using CapMachine.Core;
|
||||
using CapMachine.Model.CANLIN;
|
||||
using CapMachine.Wpf.Dtos;
|
||||
using Prism.Commands;
|
||||
using Prism.Services.Dialogs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace CapMachine.Wpf.ViewModels
|
||||
{
|
||||
public class DialogLINSchConfigViewModel:DialogViewModel
|
||||
{
|
||||
public DialogLINSchConfigViewModel(IFreeSql freeSql, IMapper mapper)
|
||||
{
|
||||
Title = "调度表 LIN 配置";
|
||||
FreeSql = freeSql;
|
||||
Mapper = mapper;
|
||||
|
||||
//默认只能用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",
|
||||
//},
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public IFreeSql FreeSql { get; }
|
||||
public IMapper Mapper { get; }
|
||||
|
||||
private string name;
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
set { name = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private ObservableCollection<LINScheduleConfigDto> _ListLINScheduleConfigDto = new ObservableCollection<LINScheduleConfigDto>();
|
||||
/// <summary>
|
||||
/// LIN 调度表数据集合
|
||||
/// </summary>
|
||||
public ObservableCollection<LINScheduleConfigDto> ListLINScheduleConfigDto
|
||||
{
|
||||
get { return _ListLINScheduleConfigDto; }
|
||||
set { _ListLINScheduleConfigDto = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 消息/帧报文信息集合
|
||||
/// </summary>
|
||||
public List<string> ListMsg { get; set; }
|
||||
|
||||
private ObservableCollection<CbxItems> _MsgCbxItems;
|
||||
/// <summary>
|
||||
/// 消息名称 集合信息
|
||||
/// </summary>
|
||||
public ObservableCollection<CbxItems> MsgCbxItems
|
||||
{
|
||||
get { return _MsgCbxItems; }
|
||||
set { _MsgCbxItems = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 选中的程序的Id
|
||||
/// </summary>
|
||||
public long SelectCanLinConfigProId { get; set; }
|
||||
|
||||
|
||||
private ObservableCollection<CbxItems> _SchTabIndexCbxItems;
|
||||
/// <summary>
|
||||
/// 调度器序号 集合信息
|
||||
/// </summary>
|
||||
public ObservableCollection<CbxItems> SchTabIndexCbxItems
|
||||
{
|
||||
get { return _SchTabIndexCbxItems; }
|
||||
set { _SchTabIndexCbxItems = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private LINScheduleConfigDto _CurSelectedItem;
|
||||
/// <summary>
|
||||
/// 选中的数据
|
||||
/// </summary>
|
||||
public LINScheduleConfigDto CurSelectedItem
|
||||
{
|
||||
get { return _CurSelectedItem; }
|
||||
set { _CurSelectedItem = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
private DelegateCommand<object> _GridSelectionChangedCmd;
|
||||
/// <summary>
|
||||
/// 选中行数据命令
|
||||
/// </summary>
|
||||
public DelegateCommand<object> GridSelectionChangedCmd
|
||||
{
|
||||
set
|
||||
{
|
||||
_GridSelectionChangedCmd = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
if (_GridSelectionChangedCmd == null)
|
||||
{
|
||||
_GridSelectionChangedCmd = new DelegateCommand<object>((par) => GridSelectionChangedCmdMethod(par));
|
||||
}
|
||||
return _GridSelectionChangedCmd;
|
||||
}
|
||||
}
|
||||
private void GridSelectionChangedCmdMethod(object par)
|
||||
{
|
||||
//先判断是否是正确的集合数据,防止DataGrid的数据源刷新导致的触发事件
|
||||
var Selecteddata = par as LINScheduleConfigDto;
|
||||
|
||||
if (Selecteddata != null)
|
||||
{
|
||||
CurSelectedItem = Selecteddata;
|
||||
}
|
||||
}
|
||||
|
||||
//OpCmd
|
||||
private DelegateCommand<string> _OpCmd;
|
||||
/// <summary>
|
||||
/// 增加方法命令
|
||||
/// </summary>
|
||||
public DelegateCommand<string> OpCmd
|
||||
{
|
||||
set
|
||||
{
|
||||
_OpCmd = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
if (_OpCmd == null)
|
||||
{
|
||||
_OpCmd = new DelegateCommand<string>((Par) => OpCmdCall(Par));
|
||||
}
|
||||
return _OpCmd;
|
||||
}
|
||||
}
|
||||
|
||||
private void OpCmdCall(string Par)
|
||||
{
|
||||
switch (Par)
|
||||
{
|
||||
case "Add":
|
||||
ListLINScheduleConfigDto.Add(new LINScheduleConfigDto
|
||||
{
|
||||
CanLinConfigProId = SelectCanLinConfigProId,
|
||||
Cycle = 100,
|
||||
SchTabIndex = 0,
|
||||
});
|
||||
break;
|
||||
case "Delete":
|
||||
if (CurSelectedItem != null)
|
||||
{
|
||||
//直接删除掉,如果没有ID的话,这就不需要删除了
|
||||
FreeSql.Delete<LINScheduleConfig>(CurSelectedItem.Id).ExecuteAffrows();
|
||||
ListLINScheduleConfigDto.Remove(CurSelectedItem);
|
||||
|
||||
CurSelectedItem = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("请选中后再进行【删除】操作?", "提示", MessageBoxButton.OK, MessageBoxImage.Hand);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private DelegateCommand saveCmd;
|
||||
/// <summary>
|
||||
/// 保存命令
|
||||
/// </summary>
|
||||
public DelegateCommand SaveCmd
|
||||
{
|
||||
set
|
||||
{
|
||||
saveCmd = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
if (saveCmd == null)
|
||||
{
|
||||
saveCmd = new DelegateCommand(() => SaveCmdMethod());
|
||||
}
|
||||
return saveCmd;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存命令方法
|
||||
/// </summary>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void SaveCmdMethod()
|
||||
{
|
||||
//检查空的数据
|
||||
foreach (var item in ListLINScheduleConfigDto)
|
||||
{
|
||||
|
||||
if (string.IsNullOrEmpty(item.MsgName))
|
||||
{
|
||||
MessageBox.Show("请确认消息名称是否正确", "提示", MessageBoxButton.OK, MessageBoxImage.Hand);
|
||||
return;
|
||||
}
|
||||
if (item.Cycle == 0)
|
||||
{
|
||||
MessageBox.Show("请确认周期是否正确", "提示", MessageBoxButton.OK, MessageBoxImage.Hand);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//发送的控制帧都放到同一个调度表中,不需要检查了
|
||||
////检查重复设置问题
|
||||
//bool isRepeat = ListLINScheduleConfigDto.GroupBy(i => i.MsgName).Any(g => g.Count() > 1);
|
||||
//if (isRepeat)
|
||||
//{
|
||||
// MessageBox.Show("请确认是否重复设置", "提示", MessageBoxButton.OK, MessageBoxImage.Hand);
|
||||
// return;
|
||||
//}
|
||||
|
||||
//检查数据是否正常
|
||||
foreach (var item in ListLINScheduleConfigDto)
|
||||
{
|
||||
FreeSql.InsertOrUpdate<LINScheduleConfig>()
|
||||
.SetSource(Mapper.Map<LINScheduleConfig>(item)).
|
||||
ExecuteAffrows();
|
||||
}
|
||||
|
||||
ListLINScheduleConfigDto = new ObservableCollection<LINScheduleConfigDto>(Mapper.Map<List<LINScheduleConfigDto>>(FreeSql.Select<LINScheduleConfig>().Where(a => a.CanLinConfigProId == SelectCanLinConfigProId).ToList()));
|
||||
|
||||
DialogParameters pars = new DialogParameters
|
||||
{
|
||||
{ "ReturnValue", ListLINScheduleConfigDto }
|
||||
};
|
||||
|
||||
RaiseRequestClose(new DialogResult(ButtonResult.OK, pars));
|
||||
}
|
||||
|
||||
private DelegateCommand cancelCmd;
|
||||
/// <summary>
|
||||
/// 保存命令
|
||||
/// </summary>
|
||||
public DelegateCommand CancelCmd
|
||||
{
|
||||
set
|
||||
{
|
||||
cancelCmd = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
if (cancelCmd == null)
|
||||
{
|
||||
cancelCmd = new DelegateCommand(() => CancelCmdMethod());
|
||||
}
|
||||
return cancelCmd;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 取消命令方法
|
||||
/// </summary>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void CancelCmdMethod()
|
||||
{
|
||||
RaiseRequestClose(new DialogResult(ButtonResult.Cancel));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 窗口打开时的传递的参数
|
||||
/// </summary>
|
||||
/// <param name="parameters"></param>
|
||||
public override void OnDialogOpened(IDialogParameters parameters)
|
||||
{
|
||||
ListMsg = parameters.GetValue<List<string>>("ListMsg");
|
||||
// 转换为CbxItems集合,都是文本内容
|
||||
MsgCbxItems = new ObservableCollection<CbxItems>(
|
||||
ListMsg.Select(value => new CbxItems
|
||||
{
|
||||
Key = value,
|
||||
Text = value
|
||||
}));
|
||||
|
||||
ListLINScheduleConfigDto = parameters.GetValue<ObservableCollection<LINScheduleConfigDto>>("ListLINScheduleConfigDto");
|
||||
//防止返回的数据为空,就无法增加了
|
||||
if (ListLINScheduleConfigDto == null) ListLINScheduleConfigDto = new ObservableCollection<LINScheduleConfigDto>();
|
||||
//Name = parameters.GetValue<string>("Name");
|
||||
|
||||
SelectCanLinConfigProId = parameters.GetValue<long>("SelectCanLinConfigProId");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,6 +130,7 @@ namespace CapMachine.Wpf.ViewModels
|
||||
canLinConfigPros = FreeSql.Select<CanLinConfigPro>().Where(a => a.CANLINInfo == CANLIN.LIN)
|
||||
.Include(a => a.LINConfigExd)
|
||||
.IncludeMany(a => a.CanLinConfigContents)
|
||||
.IncludeMany(a => a.LinScheduleConfigs)
|
||||
.ToList();
|
||||
|
||||
ListCanLinConfigPro = new ObservableCollection<CanLinConfigPro>(canLinConfigPros);
|
||||
@@ -182,6 +183,12 @@ namespace CapMachine.Wpf.ViewModels
|
||||
ListReadCanLinRWConfigDto = new ObservableCollection<CanLinRWConfigDto>();
|
||||
}
|
||||
|
||||
//调度表配置信息
|
||||
if (SelectCanLinConfigPro.CanScheduleConfigs != null && SelectCanLinConfigPro.CanScheduleConfigs.Count() > 0)
|
||||
{
|
||||
ListLINScheduleConfigDto = new ObservableCollection<LINScheduleConfigDto>(Mapper.Map<List<LINScheduleConfigDto>>(SelectCanLinConfigPro.LinScheduleConfigs));
|
||||
}
|
||||
|
||||
//匹配选中的SelectCanLinConfigPro.CanLinConfigContents和ListLinLdfModel
|
||||
MatchSeletedAndLinLdfModel();
|
||||
}
|
||||
@@ -543,6 +550,18 @@ namespace CapMachine.Wpf.ViewModels
|
||||
}
|
||||
|
||||
SelectCanLinConfigProConfigName = SelectCanLinConfigPro.ConfigName;
|
||||
|
||||
//调度表配置信息
|
||||
if (SelectCanLinConfigPro.CanScheduleConfigs != null && SelectCanLinConfigPro.CanScheduleConfigs.Count() > 0)
|
||||
{
|
||||
ListLINScheduleConfigDto = new ObservableCollection<LINScheduleConfigDto>(Mapper.Map<List<LINScheduleConfigDto>>(SelectCanLinConfigPro.LinScheduleConfigs));
|
||||
}
|
||||
else
|
||||
{
|
||||
ListLINScheduleConfigDto = new ObservableCollection<LINScheduleConfigDto>();
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
//先判断是否是正确的集合数据,防止DataGrid的数据源刷新导致的触发事件
|
||||
@@ -1030,6 +1049,17 @@ namespace CapMachine.Wpf.ViewModels
|
||||
}
|
||||
|
||||
|
||||
private ObservableCollection<LINScheduleConfigDto> _ListLINScheduleConfigDto;
|
||||
/// <summary>
|
||||
///调度表集合
|
||||
/// </summary>
|
||||
public ObservableCollection<LINScheduleConfigDto> ListLINScheduleConfigDto
|
||||
{
|
||||
get { return _ListLINScheduleConfigDto; }
|
||||
set { _ListLINScheduleConfigDto = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
//private string _SelectedWriteName;
|
||||
///// <summary>
|
||||
///// 选中的写入的Name
|
||||
@@ -1174,6 +1204,47 @@ namespace CapMachine.Wpf.ViewModels
|
||||
System.Windows.MessageBox.Show("请选中后再进行【删除】操作?", "提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Hand);
|
||||
}
|
||||
|
||||
break;
|
||||
case "WriteSch"://调度表
|
||||
|
||||
LinDriveService.ToomossLinDrive.LinTest();
|
||||
|
||||
|
||||
//var data = LinDriveService.CmdData.GroupBy(a => a.MsgName).Select(a => a.Key).ToList();
|
||||
|
||||
//if (data != null && data.Count > 0)
|
||||
//{
|
||||
// //弹窗
|
||||
// DialogService.ShowDialog("DialogLINSchConfigView", new DialogParameters() {
|
||||
// {"ListMsg", LinDriveService.CmdData.GroupBy(a=>a.MsgName).Select(a=>a.Key).ToList() },
|
||||
// { "ListLINScheduleConfigDto",ListLINScheduleConfigDto},
|
||||
// { "SelectCanLinConfigProId",SelectCanLinConfigPro.Id},
|
||||
|
||||
// }, (par) =>
|
||||
// {
|
||||
// if (par.Result == ButtonResult.OK)
|
||||
// {
|
||||
// ////程序名称
|
||||
// ListLINScheduleConfigDto = par.Parameters.GetValue<ObservableCollection<LINScheduleConfigDto>>("ReturnValue");
|
||||
// //把更新后的最新值给当前的主集合中
|
||||
// SelectCanLinConfigPro.LinScheduleConfigs = Mapper.Map<List<LINScheduleConfig>>(ListLINScheduleConfigDto.ToList());
|
||||
|
||||
// }
|
||||
// else if (par.Result == ButtonResult.Cancel)
|
||||
// {
|
||||
// //取消
|
||||
|
||||
// }
|
||||
|
||||
// });
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// System.Windows.MessageBox.Show("未发现写入的执行的命令数据,无法配置?", "提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Hand);
|
||||
//}
|
||||
|
||||
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
206
CapMachine.Wpf/Views/DialogLINSchConfigView.xaml
Normal file
206
CapMachine.Wpf/Views/DialogLINSchConfigView.xaml
Normal file
@@ -0,0 +1,206 @@
|
||||
<UserControl
|
||||
x:Class="CapMachine.Wpf.Views.DialogLINSchConfigView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:local="clr-namespace:CapMachine.Wpf.Views"
|
||||
xmlns:localEx="clr-namespace:CapMachine.Wpf"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:prism="http://prismlibrary.com/"
|
||||
Width="1000"
|
||||
Height="800"
|
||||
mc:Ignorable="d">
|
||||
<UserControl.Resources>
|
||||
<localEx:BindingProxy x:Key="Proxy" Data="{Binding}" />
|
||||
<Style x:Key="myHeaderStyle" TargetType="{x:Type GridViewColumnHeader}">
|
||||
<Setter Property="FontSize" Value="24" />
|
||||
<Setter Property="Width" Value="218" />
|
||||
</Style>
|
||||
<Style x:Key="myHeaderStyle1" TargetType="{x:Type GridViewColumnHeader}">
|
||||
<Setter Property="FontSize" Value="16" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="60" />
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
|
||||
<Button
|
||||
Margin="10,0"
|
||||
Command="{Binding OpCmd}"
|
||||
CommandParameter="Add"
|
||||
FontWeight="Bold"
|
||||
Foreground="#404040"
|
||||
Style="{StaticResource MaterialDesignFlatAccentBgButton}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="/Assets/Fonts/#iconfont"
|
||||
FontSize="14"
|
||||
Foreground="#404040"
|
||||
Text=" " />
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
FontSize="14"
|
||||
Text="新增" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<!--<Button
|
||||
Margin="10,0"
|
||||
Command="{Binding CopyCmd}"
|
||||
FontWeight="Bold"
|
||||
Foreground="#404040"
|
||||
Style="{StaticResource MaterialDesignFlatAccentBgButton}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="/Assets/Fonts/#iconfont"
|
||||
FontSize="14"
|
||||
Foreground="#404040"
|
||||
Text="" />
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
FontSize="14"
|
||||
Text="复制" />
|
||||
</StackPanel>
|
||||
</Button>-->
|
||||
<Button
|
||||
Margin="10,0"
|
||||
Command="{Binding OpCmd}"
|
||||
CommandParameter="Delete"
|
||||
FontWeight="Bold"
|
||||
Foreground="#404040"
|
||||
Style="{StaticResource MaterialDesignFlatAccentBgButton}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Margin="0,0,5,0"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="/Assets/Fonts/#iconfont"
|
||||
FontSize="14"
|
||||
Foreground="#404040"
|
||||
Text="" />
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
FontSize="14"
|
||||
Text="删除" />
|
||||
</StackPanel>
|
||||
</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"
|
||||
Margin="5"
|
||||
AutoGenerateColumns="False"
|
||||
CanUserAddRows="False"
|
||||
HeadersVisibility="Column"
|
||||
ItemsSource="{Binding ListLINScheduleConfigDto}"
|
||||
SelectionMode="Extended"
|
||||
SelectionUnit="FullRow">
|
||||
<DataGrid.Columns>
|
||||
<!--<DataGridTextColumn
|
||||
Binding="{Binding Index}"
|
||||
Header="序号"
|
||||
IsReadOnly="True" />-->
|
||||
|
||||
<DataGridTemplateColumn Width="260" Header="消息名">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<ComboBox
|
||||
DisplayMemberPath="Text"
|
||||
ItemsSource="{Binding Source={StaticResource Proxy}, Path=Data.MsgCbxItems}"
|
||||
SelectedValue="{Binding MsgName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
SelectedValuePath="Key" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<DataGridTextColumn
|
||||
Width="100"
|
||||
Binding="{Binding Cycle}"
|
||||
Header="周期" />
|
||||
|
||||
<!--<DataGridTemplateColumn Width="200" Header="发送方式">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<ComboBox
|
||||
DisplayMemberPath="Text"
|
||||
ItemsSource="{Binding Source={StaticResource Proxy}, Path=Data.SendOrderCbxItems}"
|
||||
SelectedValue="{Binding OrderSend, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
SelectedValuePath="Key" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>-->
|
||||
|
||||
<DataGridTemplateColumn Width="160" Header="调度器序号">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<ComboBox
|
||||
DisplayMemberPath="Text"
|
||||
ItemsSource="{Binding Source={StaticResource Proxy}, Path=Data.SchTabIndexCbxItems}"
|
||||
SelectedValue="{Binding SchTabIndex, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
SelectedValuePath="Key" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<!--<DataGridCheckBoxColumn Binding="{Binding IsEnable}" Header="是否启用" />-->
|
||||
</DataGrid.Columns>
|
||||
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="SelectionChanged">
|
||||
<prism:InvokeCommandAction Command="{Binding GridSelectionChangedCmd}" CommandParameter="{Binding ElementName=MainDatagrid, Path=SelectedItem}" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
|
||||
<StackPanel
|
||||
Grid.Row="2"
|
||||
HorizontalAlignment="Right"
|
||||
Orientation="Horizontal">
|
||||
<Button
|
||||
Margin="10,10"
|
||||
Command="{Binding SaveCmd}"
|
||||
Content="确定"
|
||||
Foreground="White" />
|
||||
<Button
|
||||
Margin="10,0"
|
||||
Command="{Binding CancelCmd}"
|
||||
Content="取消"
|
||||
Foreground="White" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
28
CapMachine.Wpf/Views/DialogLINSchConfigView.xaml.cs
Normal file
28
CapMachine.Wpf/Views/DialogLINSchConfigView.xaml.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace CapMachine.Wpf.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// DialogLINSchConfigView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class DialogLINSchConfigView : UserControl
|
||||
{
|
||||
public DialogLINSchConfigView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -583,10 +583,9 @@
|
||||
<StackPanel
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Margin="-10,0"
|
||||
Margin="-20,0"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Margin="0,0,10,0"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="/Assets/Fonts/#iconfont"
|
||||
FontSize="20"
|
||||
@@ -597,7 +596,7 @@
|
||||
Text="报文状态:" />
|
||||
|
||||
<Border
|
||||
Margin="5,12"
|
||||
Margin="0,12"
|
||||
BorderThickness="1"
|
||||
CornerRadius="5">
|
||||
<Border.Style>
|
||||
@@ -619,7 +618,7 @@
|
||||
</Border>
|
||||
|
||||
<Border
|
||||
Margin="10,12"
|
||||
Margin="2,12"
|
||||
BorderThickness="1"
|
||||
CornerRadius="5">
|
||||
<Border.Style>
|
||||
@@ -639,7 +638,24 @@
|
||||
Foreground="White"
|
||||
Text="接收" />
|
||||
</Border>
|
||||
|
||||
<TextBlock
|
||||
Margin="5,0,0,0"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="/Assets/Fonts/#iconfont"
|
||||
FontSize="20"
|
||||
Text="" />
|
||||
<TextBlock
|
||||
Width="90"
|
||||
Style="{StaticResource TextBlockStyle}"
|
||||
Text="启用调度表:" />
|
||||
<ToggleButton
|
||||
Width="40"
|
||||
Margin="5,2"
|
||||
Command="{Binding SchEnableCmd}"
|
||||
CommandParameter="{Binding SelectedCANConfigExdDto.SchEnable}"
|
||||
IsChecked="{Binding SelectedCANConfigExdDto.SchEnable}"
|
||||
Style="{StaticResource MaterialDesignSwitchToggleButton}"
|
||||
ToolTip="启用调度表" />
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
@@ -700,6 +716,24 @@
|
||||
Margin="0,0,15,0"
|
||||
HorizontalAlignment="Right"
|
||||
Orientation="Horizontal">
|
||||
<Button
|
||||
Margin="5,0"
|
||||
Command="{Binding WriteCmd}"
|
||||
CommandParameter="WriteSch"
|
||||
Foreground="White">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Margin="2,0"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="/Assets/Fonts/#iconfont"
|
||||
FontSize="18"
|
||||
Text="" />
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
FontSize="14"
|
||||
Text="调度表" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button
|
||||
Margin="5,0"
|
||||
Command="{Binding WriteCmd}"
|
||||
|
||||
Reference in New Issue
Block a user