123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405 |
- using System;
- using System.CodeDom;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Windows;
- using System.Windows.Media;
- using Aitex.Core.Account;
- using Aitex.Core.Common.DeviceData;
- using Aitex.Core.RT.SCCore;
- using Aitex.Core.UI.MVVM;
- using System.Windows.Input;
- using Aitex.Core.Util;
- using Aitex.Sorter.Common;
- using Aitex.Sorter.UI;
- using Aitex.Sorter.UI.Config;
- using Aitex.Sorter.UI.ViewModel;
- using MECF.Framework.Common.OperationCenter;
- using MECF.Framework.UI.Core.Accounts;
- namespace Sorter.UI.ViewModel
- {
- public class TopViewModel : UIViewModelBase
- {
- public string SoftwareVersion
- {
- get;
- set;
- }
- [Subscription(ParamName.ControlStatus, SystemStateModule)]
- public string HostControlStatus
- {
- get;
- set;
- }
- public string HostControlStatusBackground
- {
- get
- {
- switch (HostControlStatus)
- {
- case "Unknown":
- return "Yellow";
- case "EquipmentOffline":
- case "AttemptOnline":
- case "HostOffline":
- return "Transparent";
- case "OnlineLocal":
- case "OnlineRemote":
- return "LawnGreen";
- default:
- return "Yellow";
- }
- }
- }
- [Subscription(ParamName.CommunicationStatus, SystemStateModule)]
- public string HostCommunicationStatus
- {
- get;
- set;
- }
- /// Disabled = 0,
- /// Enabled = 1,
- /// EnabledNotCommunicating = 2,
- /// EnabledCommunicating = 3,
- /// WaitCRA = 4,
- /// WaitDelay = 5,
- /// WaitCRFromHost = 6,
- public string HostCommunicationStatusBackground
- {
- get
- {
- switch (HostControlStatus)
- {
- case "Disabled":
- return "Yellow";
- case "Enabled":
- case "EnabledNotCommunicating":
- case "WaitCRA":
- case "WaitDelay":
- case "WaitCRFromHost":
- return "Transparent";
- case "EnabledCommunicating":
- return "LawnGreen";
- default:
- return "Yellow";
- }
- }
- }
- [Subscription(ParamName.RTStatus, SystemStateModule)]
- public int RoutManagerState
- {
- get;
- set;
- }
- public string SystemStatus
- {
- get { return ((RtState)RoutManagerState).ToString(); }
- }
- public string SystemStatusBackground
- {
- get
- {
- switch (RoutManagerState)
- {
- case (int)RtState.Init:
- return "Yellow";
- case (int)RtState.Initializing:
- case (int)RtState.ManualTransfer:
- case (int)RtState.Transfer:
- case (int)RtState.Cycle:
- case (int)RtState.PrepareCycle:
- case (int)RtState.PostCycle:
- case (int)RtState.Reset:
- case (int)RtState.Processing:
- case (int)RtState.PostProcess:
- case (int)RtState.PauseProcess:
- case (int)RtState.SetSpeed:
- return "LawnGreen";
- case (int)RtState.Error:
- case (int)RtState.Maintenance:
- return "Red";
- case (int)RtState.Idle:
- return "Transparent";
- default:
- return "Goldenrod";
- }
- }
- }
- [Subscription(ParamName.LoadportState, DeviceName.LoadportA)]
- public string LoadPort1Status
- {
- get;
- set;
- }
- public string LoadPort1StatusBackground
- {
- get { return GetUnitStatusBackground(LoadPort1Status); }
- }
- [Subscription(ParamName.LoadportState, DeviceName.LoadportB)]
- public string LoadPort2Status
- {
- get;
- set;
- }
- public string LoadPort2StatusBackground
- {
- get { return GetUnitStatusBackground(LoadPort2Status); }
- }
- [Subscription(ParamName.AlignerState, DeviceName.Aligner)]
- public string AlignerStatus
- {
- get;
- set;
- }
- public string AlignerStatusBackground
- {
- get { return GetUnitStatusBackground(AlignerStatus); }
- }
- [Subscription(ParamName.RobotState, DeviceName.Robot)]
- public string RobotStatus
- {
- get;
- set;
- }
- public string RobotStatusBackground
- {
- get { return GetUnitStatusBackground(RobotStatus); }
- }
- [Subscription(DeviceName.SignalTower, SystemDeviceModule)]
- public AITSignalTowerData SignalTower
- {
- get;
- set;
- }
- [Subscription(ParamName.IsAutoMode, SystemStateModule)]
- public bool IsAutoMode { get; set; }
-
- private bool _simulatorMode = false;
- public bool IsManualButtonEnabled
- {
- get
- {
- return IsAutoMode;
- }
- }
- public bool IsAutoButtonEnabled
- {
- get
- {
- return !IsAutoMode;
- }
- }
- public string GetUnitStatusBackground(string status)
- {
- if (status!=null)
- status = status.Trim().ToLower();
- switch (status)
- {
- case "unknown":
- return "Yellow";
- case "idle":
- return "Transparent";
- case "busy":
- return "LawnGreen";
- default:
- return "Yellow";
- }
- }
- public string TopViewBackground
- {
- get
- {
- return _simulatorMode ? "Goldenrod" : "Transparent";
- }
- }
- public string User
- {
- get
- {
- return AccountClient.Instance.CurrentUser== null ? "" : AccountClient.Instance.CurrentUser.AccountId;
- }
- }
- public string Role
- {
- get
- {
- return AccountClient.Instance.CurrentUser == null ? "" : AccountClient.Instance.CurrentUser.Role;
- }
- }
- //public int _language;
- //public string LanguageButtonDisplay
- //{
- // get
- // {
- // //显示的文字,和实际的语言相反,用于切换
- // return _language == 1 ? "中文" : "EN";
- // }
- //}
- //public bool EnableEnButton
- //{
- // get
- // {
- // return _language != 1;
- // }
- //}
- //public bool EnableCnButton
- //{
- // get
- // {
- // return _language != 2;
- // }
- //}
- public string LogoSource
- {
- get
- {
- string file = SystemConfigManager.Instance.GetTopviewLogoFile();
- if (string.IsNullOrEmpty(file))
- file = "LogoEmpty.png";
- return "/Core;component/Resources/Main/" + file;
- }
- }
- public ICommand SwitchOffBuzzerCommand
- {
- get;
- private set;
- }
- public ICommand SwitchLanguageCommand
- {
- get;
- private set;
- }
- public bool IsManualMode
- {
- get
- {
- return !IsAutoMode;
- }
- }
- public FACommunicationState FACommunicationState
- {
- get
- {
- return string.IsNullOrEmpty(HostCommunicationStatus) ? FACommunicationState.Disabled
- : (FACommunicationState)Enum.Parse(typeof(FACommunicationState), HostCommunicationStatus);
- }
- }
- public bool IsFAEnableButtonEnabled
- {
- get { return FACommunicationState == FACommunicationState.Disabled; }
- }
- public bool IsFADisableButtonEnabled
- {
- get { return FACommunicationState != FACommunicationState.Disabled; }
- }
- public TopViewModel()
- : base("TopViewModel")
- {
- SwitchOffBuzzerCommand = new DelegateCommand<object>(OnSwitchOffBuzzer);
- SwitchLanguageCommand = new DelegateCommand<object>(OnSwitchOffLanguage);
- SoftwareVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
- InvokePropertyChanged("SoftwareVersion");
- }
- public void Reset()
- {
- InvokeClient.Instance.Service.DoOperation(OperationName.Reset);
- }
- void OnSwitchOffBuzzer(object param)
- {
- InvokeClient.Instance.Service.DoOperation(OperationName.DeviceOperation.ToString(), new object[] { DeviceName.SignalTower.ToString(), AITSignalTowerOperation.SwitchOffBuzzer.ToString() });
- }
- void OnSwitchOffLanguage(object param)
- {
- //int language = param.ToString().ToLower() == "en" ? 1 : 2;
- //InvokeClient.Instance.Service.DoOperation(OperationName.SetConfig.ToString(), SCName.System_Language, language);
- }
- protected override void InvokeBeforeUpdateProperty(Dictionary<string, object> data)
- {
- Application.Current.Dispatcher.Invoke(new Action(() =>
- {
- //int language = (int)QueryDataClient.Instance.Service.GetConfig(SCName.System_Language);
- //if (language != _language)
- //{
- // _language = language;
- // SorterUiSystem.Instance.SetCulture(_language == 2 ? "zh-CN" : "en-US");
- //}
- //_simulatorMode = (bool) QueryDataClient.Instance.Service.GetConfig(SCName.System_IsSimulatorMode);
- }));
- }
- public override bool PerformInvokeFunctionCheck(string[] param)
- {
- if (param != null && (param[0]== "SetAutoMode" || param[0] == "SetManualMode"))
- {
- if (param.Length == 1)
- { return true; }
- if (param.Length == 2 && param[1].ToLower() == "True".ToLower())
- {
- PasswordMsgBox passwordMsgBox = new PasswordMsgBox();
- if (passwordMsgBox.DialogResult != true)
- {
- return false;
- }
- }
- }
- return true;
- }
- }
- }
|