上下限监控
This commit is contained in:
153
MonitorModule/ViewModels/Dialogs/ValueLimitViewModel.cs
Normal file
153
MonitorModule/ViewModels/Dialogs/ValueLimitViewModel.cs
Normal file
@@ -0,0 +1,153 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using UIShare.GlobalVariable;
|
||||
using UIShare.UIViewModel;
|
||||
using UIShare.ViewModelBase;
|
||||
|
||||
namespace MonitorModule.ViewModels.Dialogs
|
||||
{
|
||||
public class ValueLimitViewModel : DialogViewModelBase
|
||||
{
|
||||
#region 属性
|
||||
private string _Title = "报警设置";
|
||||
|
||||
public string Title
|
||||
{
|
||||
get { return _Title; }
|
||||
set { SetProperty(ref _Title, value); }
|
||||
}
|
||||
|
||||
private ValueLimitVM _SelectValueLimitVM;
|
||||
|
||||
public ValueLimitVM SelectValueLimitVM
|
||||
{
|
||||
get => _SelectValueLimitVM;
|
||||
set => SetProperty(ref _SelectValueLimitVM, value);
|
||||
}
|
||||
private ObservableCollection<ValueLimitVM> _ValueLimitList;
|
||||
public ObservableCollection<ValueLimitVM> ValueLimitList
|
||||
{
|
||||
get => _ValueLimitList;
|
||||
set => SetProperty(ref _ValueLimitList, value);
|
||||
}
|
||||
private ObservableCollection<string> _DeviceSingleList = new();
|
||||
|
||||
public ObservableCollection<string> DeviceSingleList
|
||||
{
|
||||
get => _DeviceSingleList;
|
||||
set => SetProperty(ref _DeviceSingleList, value);
|
||||
}
|
||||
private string _SelectCurve;
|
||||
|
||||
public string SelectCurve
|
||||
{
|
||||
get => _SelectCurve;
|
||||
set => SetProperty(ref _SelectCurve, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region 命令
|
||||
public ICommand SaveCommand { get; set; }
|
||||
public ICommand CloseCommand { get; set; }
|
||||
public ICommand SelectSignalCommand { get; set; }
|
||||
public ICommand DeleteCommand { get; set; }
|
||||
|
||||
#endregion
|
||||
private GlobalInfo _globalInfo { get; set; }
|
||||
private SystemConfig _systemConfig { get; set; }
|
||||
private IScopedProvider _scope { get; set; }
|
||||
public ValueLimitViewModel(IContainerProvider containerProvider) : base(containerProvider)
|
||||
{
|
||||
_globalInfo = containerProvider.Resolve<GlobalInfo>();
|
||||
_eventAggregator = containerProvider.Resolve<IEventAggregator>();
|
||||
SaveCommand = new DelegateCommand(OnSave);
|
||||
CloseCommand = new DelegateCommand(OnClose);
|
||||
SelectSignalCommand = new DelegateCommand(SelectSignal);
|
||||
DeleteCommand = new DelegateCommand(Deletel);
|
||||
InitData();
|
||||
}
|
||||
#region 命令处理
|
||||
private void Deletel()
|
||||
{
|
||||
if (SelectValueLimitVM == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
ValueLimitList.Remove(SelectValueLimitVM);
|
||||
SelectValueLimitVM = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void InitData()
|
||||
{
|
||||
//ValueLimitList = new(_systemConfig.ValueLimitList);
|
||||
//foreach (var _PollingRead in _devices.PollingReadDic)
|
||||
//{
|
||||
// string deviceName = _PollingRead.Key;
|
||||
// PollingRead pollingRead = _PollingRead.Value;
|
||||
|
||||
// var props = pollingRead.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)
|
||||
// .Where(p => p.PropertyType == typeof(double));
|
||||
|
||||
// foreach (var prop in props)
|
||||
// {
|
||||
// DeviceSingleList.Add(deviceName + "." + prop.Name);
|
||||
// }
|
||||
//}
|
||||
//foreach (var Signal in _systemConfig.ConfigurationList)
|
||||
//{
|
||||
// DeviceSingleList.Add($"{Signal.Channel}/{Signal.MessageName}/{Signal.SignalName}");
|
||||
//}
|
||||
}
|
||||
|
||||
private void SelectSignal()
|
||||
{
|
||||
if (ValueLimitList.Where(x => x.SignalName == SelectCurve).Count() > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ValueLimitList.Add(new ValueLimitVM
|
||||
{
|
||||
SignalName = SelectCurve,
|
||||
Upper = 9999,
|
||||
Lower = -9999,
|
||||
UpperExtreme = 9999,
|
||||
LowerExtreme = -9999,
|
||||
});
|
||||
}
|
||||
|
||||
private void OnClose()
|
||||
{
|
||||
RequestClose.Invoke();
|
||||
}
|
||||
|
||||
private void OnSave()
|
||||
{
|
||||
_systemConfig.ValueLimitList = ValueLimitList;
|
||||
ConfigService.Save(_systemConfig);
|
||||
}
|
||||
#endregion
|
||||
public override void OnDialogOpened(IDialogParameters parameters)
|
||||
{
|
||||
// 1. 优先执行基类的打开逻辑(如果基类有需要初始化的通用事务)
|
||||
base.OnDialogOpened(parameters);
|
||||
|
||||
// 2. 解析参数
|
||||
if (parameters != null && parameters.ContainsKey("Scope")) // 修复:Prism 中应使用 ContainsKey
|
||||
{
|
||||
_scope = parameters.GetValue<IScopedProvider>("Scope");
|
||||
_systemConfig= _scope.Resolve<SystemConfig>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user