123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- using Caliburn.Micro;
- using Caliburn.Micro.Core;
- using Aitex.Core.Common.DeviceData;
- using Aitex.Core.UI.ControlDataContext;
- using Aitex.Core.Util;
- using MECF.Framework.Common.DataCenter;
- using MECF.Framework.Common.OperationCenter;
- using MECF.Framework.Common.CommonData;
- using FurnaceUI.Models;
- using FurnaceUI.Views.Editors;
- using System.Collections.ObjectModel;
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using System.Reflection;
- using System;
- using Aitex.Core.RT.Log;
- using System.Linq;
- using System.Windows;
- namespace FurnaceUI.Views.Operations
- {
- public class StandbyFactorViewModel : FurnaceUIViewModelBase
- {
- public string MainRecipeName { get; set; }
- public ObservableCollection<StandbyFactorViewItem> StandbyFactorViewItems { get; set; } = new ObservableCollection<StandbyFactorViewItem>();
- private SerializableDictionary<string, bool> _conditionCheck;
- [Subscription("PM1.ConditionCheck")]
- public SerializableDictionary<string, bool> ConditionCheck
- {
- get
- {
- return _conditionCheck;
- }
- set
- {
- _conditionCheck = value;
- if (_conditionCheck != null && _conditionCheck.Count > 0)
- {
- bool needClear = false;
- foreach(var item in StandbyFactorViewItems)
- {
- if(!_conditionCheck.ContainsKey(item.Factor))
- {
- needClear = true;
- break;
- }
- }
- if(needClear)
- StandbyFactorViewItems.Clear();
- foreach (var key in _conditionCheck.Keys)
- {
- if(StandbyFactorViewItems.Any(x => x.Factor == key))
- {
- var item = StandbyFactorViewItems.SingleOrDefault(x => x.Factor == key);
- item.Result = _conditionCheck[key] ? "Success" : "Wait";
- item.IsBypassEnabled = !_conditionCheck[key];
- }
- else
- {
- StandbyFactorViewItems.Add(new StandbyFactorViewItem
- {
- Factor = key,
- Result = _conditionCheck[key] ? "Success" : "Wait",
- IsBypassEnabled = !_conditionCheck[key]
- });
- }
- }
- }
- }
- }
- public StandbyFactorViewModel()
- {
- }
- protected override void OnInitialize()
- {
- base.OnInitialize();
- }
- public void FactorAction(object target)
- {
- InvokeClient.Instance.Service.DoOperation($"PM1.BypassStandbyFactor", target.ToString());
- }
- public void ClosedCmd()
- {
- (GetView() as Window).Close();
- }
- }
- public class StandbyFactorViewItem : NotifiableItem
- {
- private string _factor;
- public string Factor
- {
- get => _factor;
- set
- {
- _factor = value;
- InvokePropertyChanged(nameof(Factor));
- }
- }
- private string _result;
- public string Result
- {
- get => _result;
- set
- {
- _result = value;
- InvokePropertyChanged(nameof(Result));
- }
- }
- private bool _isBypassEnabled;
- public bool IsBypassEnabled
- {
- get => _isBypassEnabled;
- set
- {
- _isBypassEnabled = value;
- InvokePropertyChanged(nameof(IsBypassEnabled));
- }
- }
- }
- }
|