LoadPortViewModel.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. using Aitex.Core.UI.MVVM;
  2. using Aitex.Core.Util;
  3. using Aitex.Sorter.Common;
  4. using Aitex.Sorter.UI.Controls.Common;
  5. using MECF.Framework.Common.OperationCenter;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Windows;
  11. using System.Windows.Input;
  12. namespace Aitex.Sorter.UI.ViewModel.Maintenance
  13. {
  14. public class LoadPortViewModel : UIViewModelBase
  15. {
  16. public LoadPortViewModel() : base("LoadPortView")
  17. {
  18. OperationCommand = new DelegateCommand<DependencyObject>(Operation, x => !IsMaintenanceMode && !IsAutoMode);
  19. Command = new DelegateCommand<DependencyObject>(DoCommand, x => !IsMaintenanceMode && !IsAutoMode);
  20. }
  21. [Subscription(ParamName.IndicatiorLoad, DeviceName.LoadportA)]
  22. public IndicatorState LPAIndicatiorLoad
  23. {
  24. get;
  25. set;
  26. }
  27. [Subscription(ParamName.IndicatiorUnload, DeviceName.LoadportA)]
  28. public IndicatorState LPAIndicatiorUnload
  29. {
  30. get;
  31. set;
  32. }
  33. [Subscription(ParamName.IndicatiorPresence, DeviceName.LoadportA)]
  34. public IndicatorState LPAIndicatiorPresence
  35. {
  36. get;
  37. set;
  38. }
  39. [Subscription(ParamName.IndicatiorPlacement, DeviceName.LoadportA)]
  40. public IndicatorState LPAIndicatiorPlacement
  41. {
  42. get;
  43. set;
  44. }
  45. [Subscription(ParamName.IndicatiorOpAccess, DeviceName.LoadportA)]
  46. public IndicatorState LPAIndicatiorOpAccess
  47. {
  48. get;
  49. set;
  50. }
  51. [Subscription(ParamName.IndicatiorLoad, DeviceName.LoadportB)]
  52. public IndicatorState LPBIndicatiorLoad
  53. {
  54. get;
  55. set;
  56. }
  57. [Subscription(ParamName.IndicatiorUnload, DeviceName.LoadportB)]
  58. public IndicatorState LPBIndicatiorUnload
  59. {
  60. get;
  61. set;
  62. }
  63. [Subscription(ParamName.IndicatiorPresence, DeviceName.LoadportB)]
  64. public IndicatorState LPBIndicatiorPresence
  65. {
  66. get;
  67. set;
  68. }
  69. [Subscription(ParamName.IndicatiorPlacement, DeviceName.LoadportB)]
  70. public IndicatorState LPBIndicatiorPlacement
  71. {
  72. get;
  73. set;
  74. }
  75. [Subscription(ParamName.IndicatiorOpAccess, DeviceName.LoadportB)]
  76. public IndicatorState LPBIndicatiorOpAccess
  77. {
  78. get;
  79. set;
  80. }
  81. [Subscription(ParamName.FoupID, DeviceName.LoadportA)]
  82. public string LPAFoupID
  83. {
  84. get;
  85. set;
  86. }
  87. [Subscription(ParamName.FoupID, DeviceName.LoadportB)]
  88. public string LPBFoupID
  89. {
  90. get;
  91. set;
  92. }
  93. [Subscription(ParamName.CassetteState, DeviceName.LoadportA)]
  94. public LoadportCassetteState LPACassetteState { get; set; }
  95. [Subscription(ParamName.FoupClampState, DeviceName.LoadportA)]
  96. public FoupClampState LPAClampState { get; set; }
  97. [Subscription(ParamName.FoupDoorState, DeviceName.LoadportA)]
  98. public FoupDoorState LPADoorState { get; set; }
  99. [Subscription(ParamName.IndicatiorAlarm, DeviceName.LoadportA)]
  100. public IndicatorState LPAIndicatorAlarm { get; set; }
  101. [Subscription(ParamName.CassetteState, DeviceName.LoadportB)]
  102. public LoadportCassetteState LPBCassetteState { get; set; }
  103. [Subscription(ParamName.FoupClampState, DeviceName.LoadportB)]
  104. public FoupClampState LPBClampState { get; set; }
  105. [Subscription(ParamName.FoupDoorState, DeviceName.LoadportB)]
  106. public FoupDoorState LPBDoorState { get; set; }
  107. [Subscription(ParamName.IndicatiorAlarm, DeviceName.LoadportB)]
  108. public IndicatorState LPBIndicatorAlarm { get; set; }
  109. [Subscription(ParamName.LoadportState, DeviceName.LoadportA)]
  110. public DeviceState LPAStatus { get; set; }
  111. [Subscription(ParamName.LoadportState, DeviceName.LoadportB)]
  112. public DeviceState LPBStatus { get; set; }
  113. [Subscription(ParamName.RIDReaderState, DeviceName.RFIDReaderA)]
  114. public string RFIDReader1Status { get; set; }
  115. [Subscription(ParamName.RIDReaderState, DeviceName.RFIDReaderB)]
  116. public string RFIDReader2Status { get; set; }
  117. [Subscription(ParamName.FoupID, DeviceName.RFIDReaderA)]
  118. public string FoupAID
  119. {
  120. get;
  121. set;
  122. }
  123. [Subscription(ParamName.FoupID, DeviceName.RFIDReaderB)]
  124. public string FoupBID
  125. {
  126. get;
  127. set;
  128. }
  129. [Subscription(ParamName.RTStatus, SystemStateModule)]
  130. public int RoutManagerState
  131. {
  132. get;
  133. set;
  134. }
  135. public bool IsMaintenanceMode
  136. {
  137. get => RoutManagerState == (int)RtState.Maintenance;
  138. }
  139. [Subscription(ParamName.IsAutoMode, SystemStateModule)]
  140. public bool IsAutoMode { get; set; }
  141. public ICommand OperationCommand
  142. {
  143. get;
  144. private set;
  145. }
  146. public ICommand Command
  147. {
  148. get;
  149. private set;
  150. }
  151. void Operation(DependencyObject sender)
  152. {
  153. var command = CommandHelper.GetCommandItem(sender);
  154. InvokeClient.Instance.Service.DoOperation(command.CommandName, command.Parameters);
  155. }
  156. private void DoCommand(DependencyObject sender)
  157. {
  158. var command = CommandHelper.GetCommandItem(sender);
  159. var lstParameter = new List<object>(command.Parameters);
  160. lstParameter.Insert(0, command.Target);
  161. lstParameter.Insert(1, command.CommandName);
  162. InvokeClient.Instance.Service.DoOperation(OperationName.DeviceOperation, lstParameter.ToArray());
  163. }
  164. }
  165. }