123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- using System;
- using System.Collections.Generic;
- using System.Windows.Forms.VisualStyles;
- using Aitex.Core.RT.SCCore;
- using Aitex.Core.UI.MVVM;
- using Aitex.Core.Utilities;
- using Aitex.Triton160.Common;
- using Aitex.Triton160.UI.Config;
- namespace Aitex.Triton160.UI.ViewModel
- {
- public class UIViewModelBase : SubscriptionViewModelBase
- {
- protected const string SystemDeviceModule = "Device.System";
- protected const string SystemStateModule = "System";
- [IgnorePropertyChange]
- protected SCValue SCLocal
- {
- get;
- set;
- }
- [IgnorePropertyChange]
- private List<Tuple<string, string, string, bool>> _allDataItems = new List<Tuple<string, string, string, bool>>();
- public UIViewModelBase(string vmName)
- : base(vmName)
- {
- SCLocal = new SCValue();
- PollDataFunction = (IEnumerable<string> keys) =>
- {
- return Triton160UiSystem.Instance.WCF.Query.PollData(keys);
- };
- InvokeFunction = (string[] param) =>
- {
- if (param.Length == 1)
- Triton160UiSystem.Instance.WCF.InvokeService_DoOperation(param[0]);
- else if (param.Length == 2)
- Triton160UiSystem.Instance.WCF.InvokeService_DoOperation(param[0], param[1]);
- else if (param.Length == 3)
- Triton160UiSystem.Instance.WCF.InvokeService_DoOperation(param[0], param[1], param[2]);
- };
- DeviceFunction = (string deviceName, string operationName) =>
- {
- Triton160UiSystem.Instance.WCF.InvokeService_DoOperation(TritonOperation.DeviceOperation.ToString(), deviceName, operationName);
- };
- DeviceControlFunction = (object[] args) =>
- {
- if (args.Length == 2)
- Triton160UiSystem.Instance.WCF.InvokeService_DoOperation(TritonOperation.DeviceOperation.ToString(), args[0], args[1]);
- else if (args.Length == 3)
- Triton160UiSystem.Instance.WCF.InvokeService_DoOperation(TritonOperation.DeviceOperation.ToString(), args[0], args[1], args[2]);
- else if (args.Length == 4)
- Triton160UiSystem.Instance.WCF.InvokeService_DoOperation(TritonOperation.DeviceOperation.ToString(), args[0], args[1], args[2], args[3]);
- };
- _allDataItems = SystemConfigManager.Instance.GetMonitorDataList();
- }
- public void UpdateAllConfig()
- {
- SCLocal.Update(Triton160UiSystem.Instance.WCF.Query.PollConfig(SCLocal.GetKeys()));
- }
- public Dictionary<string, Tuple<string, string, bool>> GetDataElements(string culture)
- {
- Dictionary<string, Tuple<string, string, bool>> result = new Dictionary<string, Tuple<string, string, bool>>();
- Dictionary<string, Tuple<string, string, string, bool>> all = GetDataElements();
- foreach (var tuple in all)
- {
- result.Add(tuple.Key, Tuple.Create(tuple.Value.Item1, culture==CultureSupported.Chinese ? tuple.Value.Item3 : tuple.Value.Item2, tuple.Value.Item4));
- }
- return result;
- }
- public Dictionary<string, Tuple<string, string, string, bool>> GetDataElements()
- {
- UpdateAllConfig();
- Dictionary<string, Tuple<string, string, string, bool>> dicItems = new Dictionary<string, Tuple<string, string, string, bool>>();
- foreach (var dataItem in _allDataItems)
- {
- dicItems[dataItem.Item1] = dataItem;
- }
- //更新Gas
- UpdateGasItem(SCLocal.GasLineConfig.Gas1Enable, SCLocal.GasLineConfig.Gas1Name, "Gas1", "System.IoMfc.MfcGas1.FeedBack", dicItems);
- UpdateGasItem(SCLocal.GasLineConfig.Gas1Enable, SCLocal.GasLineConfig.Gas1Name, "Gas1", "System.IoMfc.MfcGas1.SetPoint", dicItems);
- UpdateGasItem(SCLocal.GasLineConfig.Gas2Enable, SCLocal.GasLineConfig.Gas2Name, "Gas2", "System.IoMfc.MfcGas2.FeedBack", dicItems);
- UpdateGasItem(SCLocal.GasLineConfig.Gas2Enable, SCLocal.GasLineConfig.Gas2Name, "Gas2", "System.IoMfc.MfcGas2.SetPoint", dicItems);
- UpdateGasItem(SCLocal.GasLineConfig.Gas3Enable, SCLocal.GasLineConfig.Gas3Name, "Gas3", "System.IoMfc.MfcGas3.FeedBack", dicItems);
- UpdateGasItem(SCLocal.GasLineConfig.Gas3Enable, SCLocal.GasLineConfig.Gas3Name, "Gas3", "System.IoMfc.MfcGas3.SetPoint", dicItems);
- UpdateGasItem(SCLocal.GasLineConfig.Gas4Enable, SCLocal.GasLineConfig.Gas4Name, "Gas4", "System.IoMfc.MfcGas4.FeedBack", dicItems);
- UpdateGasItem(SCLocal.GasLineConfig.Gas4Enable, SCLocal.GasLineConfig.Gas4Name, "Gas4", "System.IoMfc.MfcGas4.SetPoint", dicItems);
- UpdateGasItem(SCLocal.GasLineConfig.Gas5Enable, SCLocal.GasLineConfig.Gas5Name, "Gas5", "System.IoMfc.MfcGas5.FeedBack", dicItems);
- UpdateGasItem(SCLocal.GasLineConfig.Gas5Enable, SCLocal.GasLineConfig.Gas5Name, "Gas5", "System.IoMfc.MfcGas5.SetPoint", dicItems);
- //更新TV
- if (!SCLocal.PressureControlConfig.EnableThrottleValve)
- {
- dicItems.Remove("System.IoThrottleValve.ThrottleValve.TVPosition");
- dicItems.Remove("System.IoThrottleValve.ThrottleValve.TVPositionSetPoint");
- dicItems.Remove("System.IoThrottleValve.ThrottleValve.TVPressure");
- dicItems.Remove("System.IoThrottleValve.ThrottleValve.TVPressureSetPoint");
- }
- if (!SCLocal.PressureControlConfig.PumpEnableN2Pressure)
- {
- dicItems.Remove("System.IoPump.MainPump.N2PressureValue");
- }
- if (!SCLocal.PressureControlConfig.PumpEnableWaterFlow)
- {
- dicItems.Remove("System.IoPump.MainPump.WaterFlowValue");
- }
- return dicItems;
- }
- void UpdateGasItem(bool enable, string display, string id, string key, Dictionary<string, Tuple<string, string, string, bool>> dicItems)
- {
- if (enable && dicItems.ContainsKey(key))
- {
- dicItems[key] = Tuple.Create(key,
- dicItems[key].Item2.Replace(id, display),
- dicItems[key].Item3.Replace(id, display),
- dicItems[key].Item4);
- }
- else
- {
- dicItems.Remove(key);
- }
- }
- }
- }
|