SV2功能增加
一些功能的修复
This commit is contained in:
162
CapMachine.Wpf/ViewModels/DialogMeterExdViewModel.cs
Normal file
162
CapMachine.Wpf/ViewModels/DialogMeterExdViewModel.cs
Normal file
@@ -0,0 +1,162 @@
|
||||
using CapMachine.Core;
|
||||
using CapMachine.Wpf.Dtos;
|
||||
using CapMachine.Wpf.Models;
|
||||
using CapMachine.Wpf.Services;
|
||||
using Prism.Commands;
|
||||
using Prism.Services.Dialogs;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace CapMachine.Wpf.ViewModels
|
||||
{
|
||||
public class DialogMeterExdViewModel : DialogViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
public DialogMeterExdViewModel(MachineRtDataService machineRtDataService)
|
||||
{
|
||||
Title = "拓展控制";
|
||||
MachineRtDataService = machineRtDataService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前的仪表命令消息
|
||||
/// </summary>
|
||||
public MeterCmdMsg CurMeterCmdMsg { get; set; }
|
||||
|
||||
private string name;
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
set { name = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private int _Value;
|
||||
/// <summary>
|
||||
/// 值和数据
|
||||
/// </summary>
|
||||
public int Value
|
||||
{
|
||||
get { return _Value; }
|
||||
set { _Value = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
private DelegateCommand _SendDataCmd;
|
||||
/// <summary>
|
||||
/// 发送数据命令
|
||||
/// </summary>
|
||||
public DelegateCommand SendDataCmd
|
||||
{
|
||||
set
|
||||
{
|
||||
_SendDataCmd = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
if (_SendDataCmd == null)
|
||||
{
|
||||
_SendDataCmd = new DelegateCommand(() => SendDataCmdMethod());
|
||||
}
|
||||
return _SendDataCmd;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 发送数据命令方法
|
||||
/// </summary>
|
||||
private void SendDataCmdMethod()
|
||||
{
|
||||
switch (CurMeterCmdMsg.Name)
|
||||
{
|
||||
case "PTC功率":
|
||||
//发送数据 SV2
|
||||
MachineRtDataService.SiemensDrive.Write("VW434", (short)Value);
|
||||
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()
|
||||
{
|
||||
DialogParameters pars = new DialogParameters
|
||||
{
|
||||
{ "NewData", "" }
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
public MachineRtDataService MachineRtDataService { get; }
|
||||
|
||||
|
||||
/// <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)
|
||||
{
|
||||
//Name = parameters.GetValue<string>("Name");
|
||||
CurMeterCmdMsg = parameters.GetValue<MeterCmdMsg>("MeterCmdMsg");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user