123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- using System;
- using System.Collections.Generic;
- using System.Reflection;
- using System.Windows.Input;
- using Aitex.Core.Common.DeviceData;
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.SCCore;
- using Aitex.Core.UI.MVVM;
- using Aitex.Core.Util;
- using Aitex.Core.Utilities;
- using Aitex.Triton160.Common;
- namespace Aitex.Triton160.UI.ViewModel
- {
- public class HardwareConfigViewModel : UIViewModelBase
- {
- [Subscription(TritonDevice.StatisticsRfOnTime, SystemDeviceModule)]
- public AITStatisticsData RfStatistics
- {
- get;
- set;
- }
- [Subscription(TritonDevice.StatisticsPumpOnTime, SystemDeviceModule)]
- public AITStatisticsData PumpStatistics
- {
- get;
- set;
- }
- public ICommand SetConfigCommand
- {
- get;
- private set;
- }
- [IgnorePropertyChange]
- public ICommand ResetCommand
- {
- get;
- set;
- }
- [IgnorePropertyChange]
- public SCValue ConfigFeedBack
- {
- get;
- set;
- }
- [IgnorePropertyChange]
- public SCValue ConfigSetPoint
- {
- get;
- set;
- }
- public HardwareConfigViewModel()
- : base("HardwareConfigViewModel")
- {
- SetConfigCommand = new DelegateCommand<object>(SetConfig);
- ResetCommand = new DelegateCommand<object>(Reset);
- ConfigFeedBack = new SCValue();
- ConfigSetPoint = new SCValue();
- ConfigFeedBack.RetrieveAll();
- ConfigSetPoint.RetrieveAll();
- }
- void SetConfig(object param)
- {
- string stringParam = param.ToString();
- string[] values = stringParam.Split(';');
- foreach (var value in values)
- {
- if (string.IsNullOrEmpty(value))
- continue;
- string[] props = value.Split('.');
- if (props.Length != 3)
- {
- LOG.Error("Error SetConfig parameter" + param);
- continue;
- }
- string scName = props[1] + "_" + props[2];
- object scValue = null;
- PropertyInfo[] property = typeof(SCValue).GetProperties();
- foreach (PropertyInfo fiGroup in property)
- {
- if (fiGroup.Name == props[1])
- {
- object objGroup = fiGroup.GetValue(ConfigSetPoint, null);
- foreach (PropertyInfo fiItem in objGroup.GetType().GetProperties())
- {
- if (fiItem.Name == props[2])
- {
- scValue = fiItem.GetValue(objGroup, null);
- Triton160UiSystem.Instance.WCF.InvokeService_DoOperation(TritonOperation.SetConfig.ToString(), scName, scValue);
- break;
- }
- }
- break;
- }
- }
- }
- }
- void Reset(object param)
- {
- Triton160UiSystem.Instance.WCF.InvokeService_DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { param.ToString(), AITStatisticsOperation.Reset.ToString() });
- }
- public void UpdateConfig()
- {
- ConfigFeedBack.Update(Triton160UiSystem.Instance.WCF.Query.PollConfig(ConfigFeedBack.GetKeys()));
- ConfigSetPoint.Update(Triton160UiSystem.Instance.WCF.Query.PollConfig(ConfigSetPoint.GetKeys()));
- InvokeAllPropertyChanged();
- }
- protected override void InvokeBeforeUpdateProperty(Dictionary<string, object> data)
- {
- if (RfStatistics == null)
- {
- string key = SystemDeviceModule + "." + TritonDevice.StatisticsRfOnTime;
- if (data.ContainsKey(key))
- {
- AITStatisticsData statistics = data[key] as AITStatisticsData;
- if (statistics != null)
- {
- //RfStatisticsPMIntervalSetPoint = statistics.PMInterval.ToString();
- InvokePropertyChanged("RfStatisticsPMIntervalSetPoint");
- }
- }
- }
- if (PumpStatistics == null)
- {
- string key = SystemDeviceModule + "." + TritonDevice.StatisticsPumpOnTime;
- if (data.ContainsKey(key))
- {
- AITStatisticsData statistics = data[key] as AITStatisticsData;
- if (statistics != null)
- {
- //PumpStatisticsPMIntervalSetPoint = statistics.PMInterval.ToString();
- InvokePropertyChanged("PumpStatisticsPMIntervalSetPoint");
- }
- }
- }
- }
- }
- }
|