V1版本
This commit is contained in:
@@ -1,22 +1,45 @@
|
||||
using CapMachine.Core;
|
||||
using CapMachine.Shared.Controls;
|
||||
using CapMachine.Wpf.Dtos;
|
||||
using CapMachine.Wpf.Models;
|
||||
using CapMachine.Wpf.Models.Tag;
|
||||
using CapMachine.Wpf.PrismEvent;
|
||||
using CapMachine.Wpf.Services;
|
||||
using Prism.Commands;
|
||||
using Prism.Events;
|
||||
using Prism.Services.Dialogs;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows.Controls.Primitives;
|
||||
|
||||
namespace CapMachine.Wpf.ViewModels
|
||||
{
|
||||
public class MonitorViewModel : NavigationViewModel
|
||||
{
|
||||
public MonitorViewModel(IEventAggregator eventAggregator)
|
||||
public MonitorViewModel(ConfigService configService, IEventAggregator eventAggregator,
|
||||
DataRecordService dataRecordService, SysRunService sysRunService,
|
||||
MachineRtDataService machineRtDataService, IDialogService dialogService)
|
||||
{
|
||||
ConfigService = configService;
|
||||
//事件服务
|
||||
_EventAggregator = eventAggregator;
|
||||
DataRecordService = dataRecordService;
|
||||
SysRunServer = sysRunService;
|
||||
MachineRtDataService = machineRtDataService;
|
||||
DialogService = dialogService;
|
||||
TagManager = MachineRtDataService.TagManger;
|
||||
_EventAggregator.GetEvent<ChartRtEvent>().Subscribe(GetChartRtEvent);
|
||||
|
||||
ListTag = new ObservableCollection<ITag>(TagManager.DicTags.Values.ToList());
|
||||
ListMeterTag = TagManager.DicTags.Values.Where(a => a.IsMeter == true).ToList();
|
||||
}
|
||||
|
||||
public ConfigService ConfigService { get; }
|
||||
|
||||
private IEventAggregator _EventAggregator { get; set; }
|
||||
|
||||
public DataRecordService DataRecordService { get; }
|
||||
public SysRunService SysRunServer { get; }
|
||||
public MachineRtDataService MachineRtDataService { get; }
|
||||
public IDialogService DialogService { get; }
|
||||
public List<ChartRtValue> ListChartRtValue { get; set; } = new List<ChartRtValue>()
|
||||
{
|
||||
new ChartRtValue(){ Name="温度",Value=12.3,Unit="℃"},
|
||||
@@ -24,6 +47,217 @@ namespace CapMachine.Wpf.ViewModels
|
||||
new ChartRtValue(){ Name="湿度",Value=12.3,Unit="%"},
|
||||
};
|
||||
|
||||
private ObservableCollection<ITag> _ListTag;
|
||||
/// <summary>
|
||||
/// 标签集合信息
|
||||
/// </summary>
|
||||
public ObservableCollection<ITag> ListTag
|
||||
{
|
||||
get { return _ListTag; }
|
||||
set { _ListTag = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private List<ITag> _ListMeterTag;
|
||||
/// <summary>
|
||||
/// 标签集合信息 仪表的参数
|
||||
/// </summary>
|
||||
public List<ITag> ListMeterTag
|
||||
{
|
||||
get { return _ListMeterTag; }
|
||||
set { _ListMeterTag = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 标签中心
|
||||
/// </summary>
|
||||
public TagManager TagManager { get; set; }
|
||||
|
||||
private DelegateCommand<string> _OperCmd;
|
||||
/// <summary>
|
||||
/// 操作指令你
|
||||
/// </summary>
|
||||
public DelegateCommand<string> OperCmd
|
||||
{
|
||||
set
|
||||
{
|
||||
_OperCmd = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
if (_OperCmd == null)
|
||||
{
|
||||
_OperCmd = new DelegateCommand<string>((p) => OperCmdCall(p));
|
||||
}
|
||||
return _OperCmd;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 操作指令执行方法
|
||||
/// </summary>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void OperCmdCall(string Par)
|
||||
{
|
||||
switch (Par)
|
||||
{
|
||||
case "开始":
|
||||
this.SysRunServer.MachineRunState1.FireStart();
|
||||
|
||||
DataRecordService.StartRecord();
|
||||
break;
|
||||
case "结束":
|
||||
this.SysRunServer.MachineRunState1.FireEnd();
|
||||
DataRecordService.EndRecord();
|
||||
break;
|
||||
case "复位":
|
||||
this.SysRunServer.MachineRunState1.FireReset();
|
||||
DataRecordService.EndRecord();
|
||||
break;
|
||||
case "消音":
|
||||
//ShowDialogExpInfo();
|
||||
break;
|
||||
case "试验信息":
|
||||
ShowDialogExpInfo();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private DelegateCommand<object> _AutoHandCmd;
|
||||
/// <summary>
|
||||
/// 操作指令你
|
||||
/// </summary>
|
||||
public DelegateCommand<object> AutoHandCmd
|
||||
{
|
||||
set
|
||||
{
|
||||
_AutoHandCmd = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
if (_AutoHandCmd == null)
|
||||
{
|
||||
_AutoHandCmd = new DelegateCommand<object>((p) => AutoHandCmdCall(p));
|
||||
}
|
||||
return _AutoHandCmd;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 操作指令执行方法
|
||||
/// </summary>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void AutoHandCmdCall(object Par)
|
||||
{
|
||||
if (Par != null && Par is Meter)
|
||||
{
|
||||
var MeterControl = (Meter)Par;
|
||||
Console.WriteLine($"{MeterControl.MeterName}-{MeterControl.AutoHandState}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private DelegateCommand<object> _HandValueCmd;
|
||||
/// <summary>
|
||||
/// 手动给值
|
||||
/// </summary>
|
||||
public DelegateCommand<object> HandValueCmd
|
||||
{
|
||||
set
|
||||
{
|
||||
_HandValueCmd = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
if (_HandValueCmd == null)
|
||||
{
|
||||
_HandValueCmd = new DelegateCommand<object>((p) => HandValueCmdCall(p));
|
||||
}
|
||||
return _HandValueCmd;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 手动给值执行方法
|
||||
/// </summary>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void HandValueCmdCall(object Par)
|
||||
{
|
||||
if (Par != null && Par is MeterChannelValue)
|
||||
{
|
||||
var ChannelValue = (MeterChannelValue)Par;
|
||||
Console.WriteLine($"{ChannelValue.Name}-{ChannelValue.Value}-{ChannelValue.Type}");
|
||||
}
|
||||
}
|
||||
|
||||
private int _HandValueParameter = 80;
|
||||
/// <summary>
|
||||
/// 手动的值,直接和控件绑定,初始的时候用,也可以用做更新采集的数据到界面上
|
||||
/// 当前是所有的控件都绑定的
|
||||
/// </summary>
|
||||
public int HandValueParameter
|
||||
{
|
||||
get { return _HandValueParameter; }
|
||||
set { _HandValueParameter = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
private DelegateCommand<object> _HandEnableCmd;
|
||||
/// <summary>
|
||||
/// 阀门的手自动切换
|
||||
/// </summary>
|
||||
public DelegateCommand<object> HandEnableCmd
|
||||
{
|
||||
set
|
||||
{
|
||||
_HandEnableCmd = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
if (_HandEnableCmd == null)
|
||||
{
|
||||
_HandEnableCmd = new DelegateCommand<object>((p) => HandEnableCmdCall(p));
|
||||
}
|
||||
return _HandEnableCmd;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 操作指令执行方法
|
||||
/// </summary>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void HandEnableCmdCall(object Par)
|
||||
{
|
||||
if (Par != null && Par is ToggleButton)
|
||||
{
|
||||
var ControlData = Par as ToggleButton;
|
||||
var Name = ControlData.Name;
|
||||
var Data = ControlData.IsChecked;
|
||||
//ToDo cmd
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void ShowDialogExpInfo()
|
||||
{
|
||||
//弹窗
|
||||
DialogService.ShowDialog("DialogExpInfoView", new DialogParameters() { { "Name", "" } }, (par) =>
|
||||
{
|
||||
if (par.Result == ButtonResult.OK)
|
||||
{
|
||||
//试验信息
|
||||
var ListChartTabGroupDto = par.Parameters.GetValue<ExpInfoDto>("ReturnValue");
|
||||
|
||||
|
||||
}
|
||||
else if (par.Result == ButtonResult.Cancel)
|
||||
{
|
||||
//取消
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取曲线的实时值
|
||||
/// 数据是发布过来
|
||||
|
||||
Reference in New Issue
Block a user