FAViewModel.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. using Aitex.Core.Util;
  2. using MECF.Framework.Common.OperationCenter;
  3. using System;
  4. using VirgoUI.Client.Models.Sys;
  5. namespace VirgoUI.Client.Models.Operate.FA
  6. {
  7. public class FAViewModel : UiViewModelBase
  8. {
  9. public enum CommunicationState
  10. {
  11. Disabled,
  12. Enabled,
  13. EnabledNotCommunicating,
  14. EnabledCommunicating,
  15. WaitCRA,
  16. WaitDelay,
  17. WaitCRFromHost,
  18. }
  19. public enum ControlState
  20. {
  21. Unknown,
  22. EquipmentOffline,
  23. AttemptOnline,
  24. HostOffline,
  25. OnlineLocal,
  26. OnlineRemote,
  27. }
  28. [Subscription("System.CommunicationStatus")]
  29. public string HostCommunicationStatus { get; set; }
  30. [Subscription("System.ControlStatus")]
  31. public string HostControlStatus { get; set; }
  32. [Subscription("System.SpoolingState")]
  33. public int SpoolingState { get; set; }
  34. [Subscription("System.SpoolingActual")]
  35. public string SpoolingActual { get; set; }
  36. [Subscription("System.SpoolingTotal")]
  37. public string SpoolingTotal { get; set; }
  38. [Subscription("System.SpoolingFullTime")]
  39. public string SpoolingFullTime { get; set; }
  40. [Subscription("System.SpoolingStartTime")]
  41. public string SpoolingStartTime { get; set; }
  42. [Subscription("System.IsSpoolingEnable")]
  43. public bool IsSpoolingEnable { get; set; }
  44. public CommunicationState FACommunicationState
  45. {
  46. get
  47. {
  48. return string.IsNullOrEmpty(HostCommunicationStatus) ? CommunicationState.Disabled
  49. : (CommunicationState)Enum.Parse(typeof(CommunicationState), HostCommunicationStatus);
  50. }
  51. }
  52. public ControlState FAControlState
  53. {
  54. get
  55. {
  56. return string.IsNullOrEmpty(HostControlStatus) ? ControlState.Unknown
  57. : (ControlState)Enum.Parse(typeof(ControlState), HostControlStatus);
  58. }
  59. }
  60. public bool IsEnableEnable
  61. {
  62. get { return FACommunicationState == CommunicationState.Disabled; }
  63. }
  64. public bool IsEnableDisable
  65. {
  66. get { return FACommunicationState != CommunicationState.Disabled; }
  67. }
  68. //Unknown,
  69. //EquipmentOffline,
  70. //AttemptOnline,
  71. //HostOffline,
  72. //OnlineLocal,
  73. //OnlineRemote,
  74. public bool IsEnableOnline
  75. {
  76. get { return FAControlState == ControlState.Unknown || FAControlState == ControlState.EquipmentOffline; }
  77. }
  78. public bool IsEnableOffline
  79. {
  80. get { return FAControlState == ControlState.Unknown || FAControlState != ControlState.EquipmentOffline; }
  81. }
  82. public bool IsEnableLocal
  83. {
  84. get { return FAControlState == ControlState.OnlineRemote; }
  85. }
  86. public bool IsEnableRemote
  87. {
  88. get { return FAControlState == ControlState.OnlineLocal; }
  89. }
  90. public bool IsEnableEnableSpooling
  91. {
  92. get
  93. {
  94. return !IsSpoolingEnable;//SpoolingState == FASpoolingState.Inactive.ToString();
  95. }
  96. }
  97. public bool IsEnableDisableSpooling
  98. {
  99. get
  100. {
  101. return IsSpoolingEnable;// SpoolingState == FASpoolingState.Active.ToString();
  102. }
  103. }
  104. public FAViewModel()
  105. {
  106. this.DisplayName = "FA";
  107. }
  108. protected override void OnInitialize()
  109. {
  110. base.OnInitialize();
  111. }
  112. public void FaEnable()
  113. {
  114. InvokeClient.Instance.Service.DoOperation("System.FACommand","FAEnable");
  115. }
  116. public void FaDisable()
  117. {
  118. InvokeClient.Instance.Service.DoOperation("System.FACommand", "FADisable");
  119. }
  120. public void FaOnline()
  121. {
  122. InvokeClient.Instance.Service.DoOperation("System.FACommand", "FAOnline");
  123. }
  124. public void FaOffline()
  125. {
  126. InvokeClient.Instance.Service.DoOperation("System.FACommand", "FAOffline");
  127. }
  128. public void FaLocal()
  129. {
  130. InvokeClient.Instance.Service.DoOperation("System.FACommand", "FALocal");
  131. }
  132. public void FaRemote()
  133. {
  134. InvokeClient.Instance.Service.DoOperation("System.FACommand", "FARemote");
  135. }
  136. public void FaEnableSpooling()
  137. {
  138. InvokeClient.Instance.Service.DoOperation("System.FACommand", "FAEnableSpooling");
  139. }
  140. public void FaDisableSpooling()
  141. {
  142. InvokeClient.Instance.Service.DoOperation("System.FACommand", "FADisableSpooling");
  143. }
  144. }
  145. }