| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 | using System;using System.Collections.Generic;using System.Linq;using System.Text;using Prism.Commands;using Prism.Mvvm;using Venus_MainPages.Unity;using Venus_MainPages.Views;using System.Threading.Tasks;using Aitex.Core.Util;using FabConnect.SecsGemInterface.GemModel;using MECF.Framework.Common.OperationCenter;using Aitex.Core.RT.OperationCenter;using System.Windows.Threading;using Aitex.Core.Common.DeviceData;using MECF.Framework.Common.DataCenter;using MECF.Framework.Common.Equipment;using Aitex.Core.RT.Log;namespace Venus_MainPages.ViewModels{    public class FaViewModel:BindableBase    {        private readonly GEMController _gem = new GEMController();        private List<string> m_RtDataKeys = new List<string>();        private Dictionary<string, object> m_RtDataValues;        private string m_HostCommunicationStatus;        private string m_HostControlStatus;        private int m_SpoolingState;        private string m_SpoolingActual;        private string m_SpoolingTotal;        private string m_SpoolingFullTime;        private string m_SpoolingStartTime;        private  bool  m_IsSpoolingEnable;        #region 私有变量        public enum ConmmunicationState        {            Disabled,            Enabled,            EnabledNotCommunicating,            EnabledCommunicating,            WaitCRA,            WaitDelay,            WaitCRFromHost,        }        public enum ControlState        {            Unknown,            EquipmentOffline,            AttemptOnline,            HostOffline,            OnlineLocal,            OnlineRemote,        }        #endregion        #region 命令              private DelegateCommand _FaEnableCommand;        public DelegateCommand FaEnableCommand =>        _FaEnableCommand ?? (_FaEnableCommand = new DelegateCommand(FaEnable));        private DelegateCommand _FaDisableCommand;        public DelegateCommand FaDisableCommand =>        _FaDisableCommand ?? (_FaDisableCommand = new DelegateCommand(FaDisable));        private DelegateCommand _FaOnlineCommand;        public DelegateCommand FaOnlineCommand =>        _FaOnlineCommand ?? (_FaOnlineCommand = new DelegateCommand(FaOnline));        private DelegateCommand _FaOfflineCommand;        public DelegateCommand FaOfflineCommand =>        _FaOfflineCommand ?? (_FaOfflineCommand = new DelegateCommand(FaOffline));        private DelegateCommand _FaLocalCommand;        public DelegateCommand FaLocalCommand =>        _FaLocalCommand ?? (_FaLocalCommand = new DelegateCommand(FaLocal));        private DelegateCommand _FaRemoteCommand;        public DelegateCommand FaRemoteCommand =>        _FaRemoteCommand ?? (_FaRemoteCommand = new DelegateCommand(FaRemote));        private DelegateCommand _FaEnableSpoolingCommand;        public DelegateCommand FaEnableSpoolingCommand =>        _FaEnableSpoolingCommand ?? (_FaEnableSpoolingCommand = new DelegateCommand(FaEnableSpooling));        private DelegateCommand _FaDisableSpoolingCommand;        public DelegateCommand FaDisableSpoolingCommand =>        _FaDisableSpoolingCommand ?? (_FaDisableSpoolingCommand = new DelegateCommand(FaDisableSpooling));        #endregion        #region 属性        public string HostCommunicationStatus        {            get { return m_HostCommunicationStatus; }            set { SetProperty(ref m_HostCommunicationStatus, value); }        }        public string HostControlStatus         {            get { return m_HostControlStatus; }            set { SetProperty(ref m_HostControlStatus, value); }        }        public int SpoolingState         {            get { return m_SpoolingState; }            set { SetProperty(ref m_SpoolingState, value); }        }        public string SpoolingActual         {            get { return m_SpoolingActual; }            set { SetProperty(ref m_SpoolingActual, value); }        }        public string SpoolingTotal         {           get { return m_SpoolingTotal; }             set { SetProperty(ref m_SpoolingTotal, value); }        }        public string SpoolingFullTime         {         get { return m_SpoolingFullTime; }         set { SetProperty(ref m_SpoolingFullTime, value); }        }        public string SpoolingStartTime         {         get { return m_SpoolingStartTime; }          set { SetProperty(ref m_SpoolingStartTime, value); }        }        public bool IsSpoolingEnable        {           get { return m_IsSpoolingEnable; }          set { SetProperty(ref m_IsSpoolingEnable, value); }        }        public Dictionary<string, object> RtDataValues        {            get { return m_RtDataValues; }            set { SetProperty(ref m_RtDataValues, value); }        }        public CommunicationState FACommunicationState        {            get            {                return string.IsNullOrEmpty(HostCommunicationStatus) ? CommunicationState.Disabled                    : (CommunicationState)Enum.Parse(typeof(CommunicationState), HostCommunicationStatus);            }        }        public ControlState FAControlState        {            get            {                return string.IsNullOrEmpty(HostControlStatus) ? ControlState.Unknown                    : (ControlState)Enum.Parse(typeof(ControlState), HostControlStatus);            }        }        public bool _IsDisableEnable;        public bool IsEnableEnable        {            get { return _IsDisableEnable; }            set {  SetProperty(ref _IsDisableEnable, value);}            }        public bool _IsEnableDisable;        public bool IsEnableDisable        {            get { return _IsEnableDisable; }            set { SetProperty(ref _IsEnableDisable, value); }        }        public bool _IsEnableOnline;        public bool IsEnableOnline        {            get { return _IsEnableOnline; }            set { SetProperty(ref _IsEnableOnline, value); }        }        public bool _IsEnableOffline;        public bool IsEnableOffline        {            get { return _IsEnableOffline; }            set { SetProperty(ref _IsEnableOffline, value); }        }        public bool _IsEnableLocal;        public bool IsEnableLocal        {            get { return _IsEnableLocal; }            set { SetProperty(ref _IsEnableLocal, value); }        }        public bool _IsEnableRemote;        public bool IsEnableRemote        {            get { return _IsEnableRemote; }            set { SetProperty(ref _IsEnableRemote, value); }        }        public bool _IsEnableEnableSpooling;        public bool IsEnableEnableSpooling        {            get { return _IsEnableEnableSpooling; }            set { SetProperty(ref _IsEnableEnableSpooling, value); }        }        public bool IsEnableDisableSpooling        {            get            {                return IsSpoolingEnable;            }        }        #endregion        #region 构造函数        public FaViewModel()        {            addDataKeys();            DispatcherTimer timer = new DispatcherTimer();            timer.Interval = TimeSpan.FromSeconds(0.5);            timer.Tick += timer_Tick;            timer.Start();                    }        #endregion        #region        void timer_Tick(object sender, EventArgs e)        {               IsEnableEnable = FACommunicationState == CommunicationState.Disabled;            IsEnableDisable= FACommunicationState != CommunicationState.Disabled;            IsEnableOnline = FAControlState == ControlState.Unknown || FAControlState == ControlState.EquipmentOffline;            IsEnableOffline = FAControlState == ControlState.Unknown || FAControlState != ControlState.EquipmentOffline;            IsEnableRemote = FAControlState == ControlState.OnlineLocal;            IsEnableLocal = FAControlState == ControlState.OnlineRemote;            IsEnableEnableSpooling = !IsSpoolingEnable;            RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);            HostCommunicationStatus = CommonFunction.GetValue<String>(RtDataValues, "System.CommunicationStatus");            HostControlStatus = CommonFunction.GetValue<String>(RtDataValues, "System.ControlStatus");            SpoolingState = CommonFunction.GetValue<int>(RtDataValues, "System.SpoolingState");            SpoolingActual = CommonFunction.GetValue<string>(RtDataValues, "System.SpoolingActual");            SpoolingTotal= CommonFunction.GetValue<string>(RtDataValues, "System.SpoolingTotal");            SpoolingFullTime = CommonFunction.GetValue<string>(RtDataValues, "System.SpoolingFullTime");            SpoolingStartTime = CommonFunction.GetValue<string>(RtDataValues, "System.SpoolingStartTime");            IsSpoolingEnable = CommonFunction.GetValue<bool>(RtDataValues, "System.IsSpoolingEnable");        }        private void addDataKeys()        {            m_RtDataKeys.Add("System.CommunicationStatus");            m_RtDataKeys.Add("System.ControlStatus");            m_RtDataKeys.Add("System.SpoolingState");            m_RtDataKeys.Add("System.SpoolingActual");            m_RtDataKeys.Add("System.SpoolingTotal");            m_RtDataKeys.Add("System.SpoolingFullTime");            m_RtDataKeys.Add("System.SpoolingStartTime");            m_RtDataKeys.Add("System.IsSpoolingEnable");           }            public void FaEnable()        {            InvokeClient.Instance.Service.DoOperation("System.FACommand", "FAEnable");        }        public void FaDisable()        {                        InvokeClient.Instance.Service.DoOperation("System.FACommand", "FADisable");        }        public void FaOnline()        {            InvokeClient.Instance.Service.DoOperation("System.FACommand", "FAOnline");        }        public void FaOffline()        {            InvokeClient.Instance.Service.DoOperation("System.FACommand", "FAOffline");        }        public void FaLocal()        {            InvokeClient.Instance.Service.DoOperation("System.FACommand", "FALocal");        }        public void FaRemote()        {            InvokeClient.Instance.Service.DoOperation("System.FACommand", "FARemote");        }        public void FaEnableSpooling()        {                        InvokeClient.Instance.Service.DoOperation("System.FACommand", "FAEnableSpooling");        }        public void FaDisableSpooling()        {                       InvokeClient.Instance.Service.DoOperation("System.FACommand", "FADisableSpooling");        }         #endregion    }}
 |