E84Info.xaml.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. using System.Windows;
  2. using System.Windows.Controls;
  3. using System.Windows.Input;
  4. using Aitex.Core.UI.MVVM;
  5. using Aitex.Core.Util;
  6. using Aitex.Core.Utilities;
  7. using Aitex.Sorter.Common;
  8. using Aitex.Sorter.UI.ViewModel;
  9. using MECF.Framework.Common.DataCenter;
  10. using MECF.Framework.Common.OperationCenter;
  11. using MECF.Framework.UI.Core.View.Common;
  12. namespace EfemUI.Controls
  13. {
  14. public partial class E84Info : UserControl
  15. {
  16. public static readonly DependencyProperty LoadPortNameProperty = DependencyProperty.Register(
  17. "LoadPortName", typeof(string), typeof(E84Info), new
  18. PropertyMetadata(""));
  19. public static readonly DependencyProperty E84DataProperty = DependencyProperty.Register(
  20. "E84Data", typeof(E84InfoData), typeof(E84Info), new PropertyMetadata(null));
  21. private readonly E84InfoViewModel _e84InfoViewModel;
  22. public E84Info()
  23. {
  24. InitializeComponent();
  25. root.DataContext = this;
  26. _e84InfoViewModel = new E84InfoViewModel();
  27. ConfigBorder.DataContext = _e84InfoViewModel;
  28. Inputs.DataContext = this;
  29. Outputs.DataContext = this;
  30. //BindingErrorTraceListener.SetTrace();
  31. E84Command = new DelegateCommand<string>(DoLoadPortCmd);
  32. IsVisibleChanged += E84Info_IsVisibleChanged;
  33. }
  34. public ICommand E84Command { get; set; }
  35. public string LoadPortName
  36. {
  37. get => (string) GetValue(LoadPortNameProperty);
  38. set => SetValue(LoadPortNameProperty, value);
  39. }
  40. public E84InfoData E84Data
  41. {
  42. get => (E84InfoData) GetValue(E84DataProperty);
  43. set => SetValue(E84DataProperty, value);
  44. }
  45. private void DoLoadPortCmd(string cmd)
  46. {
  47. var deviceName = LoadPortName;
  48. var param = new object[] {deviceName};
  49. InvokeClient.Instance.Service.DoOperation($"{param[0]}.{cmd}");
  50. }
  51. private void E84Info_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
  52. {
  53. (DataContext as E84InfoViewModel)?.EnableTimer(IsVisible);
  54. }
  55. }
  56. internal class E84InfoViewModel : UIViewModelBase
  57. {
  58. public E84InfoViewModel() : base("E84InfoViewModel")
  59. {
  60. SetConfigCommand = new DelegateCommand<object>(SetConfig);
  61. ConfigFeedback = new E84SCs();
  62. ConfigSetPoint = new E84SCs();
  63. ConfigFeedback.UpdateKeys(typeof(E84SCs).GetProperties());
  64. ConfigSetPoint.UpdateKeys(typeof(E84SCs).GetProperties());
  65. UpdateConfig();
  66. }
  67. [IgnorePropertyChange] public ICommand SetConfigCommand { get; }
  68. [IgnorePropertyChange] public E84SCs ConfigFeedback { get; set; }
  69. [IgnorePropertyChange] public E84SCs ConfigSetPoint { get; set; }
  70. public bool AutomaticMode { get; set; }
  71. public bool KeepClampedAfterRun { get; set; }
  72. public bool KeepDockAfterRun { get; set; }
  73. public bool CloseDoorAfterMap { get; set; }
  74. [Subscription("E84State")] public string E84Status { get; set; }
  75. private void SetConfig(object param)
  76. {
  77. var sc = (object[]) param;
  78. InvokeClient.Instance.Service.DoOperation("System.SetConfig", sc[0].ToString(), sc[1].ToString());
  79. UpdateConfig();
  80. }
  81. public void UpdateConfig()
  82. {
  83. ConfigFeedback.Update(QueryDataClient.Instance.Service.PollConfig(ConfigFeedback.GetKeys()));
  84. ConfigSetPoint.Update(QueryDataClient.Instance.Service.PollConfig(ConfigSetPoint.GetKeys()));
  85. InvokeAllPropertyChanged();
  86. }
  87. }
  88. public class E84SCs : PageSCValue
  89. {
  90. public int Fa_E84_TP1 { get; set; }
  91. public int Fa_E84_TP2 { get; set; }
  92. public int Fa_E84_TP3 { get; set; }
  93. public int Fa_E84_TP4 { get; set; }
  94. public int Fa_E84_TP5 { get; set; }
  95. public int Fa_E84_TP6 { get; set; }
  96. }
  97. public class E84InfoData : NotifyPropertyChangedBase
  98. {
  99. private bool _busy;
  100. private string _carrierId;
  101. private bool _continuousTransfer;
  102. private bool _cs0;
  103. private bool _cs1;
  104. private string _e84State;
  105. private bool _emergencyOk;
  106. private bool _errorOnPlacementTimeout;
  107. private bool _handoffAvailable;
  108. private string _loadPortState;
  109. //Factory Outputs
  110. private bool _loadRequest;
  111. private bool _podDocked;
  112. private bool _podLatched;
  113. private bool _podOpen;
  114. private bool _podPlaced;
  115. private bool _podReserved;
  116. private string _portState;
  117. private bool _potPresent;
  118. private bool _readyToTransfer;
  119. private string _slotMap;
  120. private bool _transferComplete;
  121. private bool _transferRequest;
  122. private bool _unloadRequest;
  123. //Factory Inputs
  124. private bool _valid;
  125. private bool _virtualMode;
  126. public bool PodPresent
  127. {
  128. get => _potPresent;
  129. set
  130. {
  131. _potPresent = value;
  132. OnPropertyChanged("PodPresent");
  133. }
  134. }
  135. public bool PodPlaced
  136. {
  137. get => _podPlaced;
  138. set
  139. {
  140. _podPlaced = value;
  141. OnPropertyChanged("PodPlaced");
  142. }
  143. }
  144. public bool PodLatched
  145. {
  146. get => _podLatched;
  147. set
  148. {
  149. _podLatched = value;
  150. OnPropertyChanged("PodLatched");
  151. }
  152. }
  153. public bool PodDocked
  154. {
  155. get => _podDocked;
  156. set
  157. {
  158. _podDocked = value;
  159. OnPropertyChanged("PodDocked");
  160. }
  161. }
  162. public bool PodOpen
  163. {
  164. get => _podOpen;
  165. set
  166. {
  167. _podOpen = value;
  168. OnPropertyChanged("PodOpen");
  169. }
  170. }
  171. public string LoadPortState
  172. {
  173. get => _loadPortState;
  174. set
  175. {
  176. _loadPortState = value;
  177. OnPropertyChanged("LoadPortState");
  178. }
  179. }
  180. public bool VirtualMode
  181. {
  182. get => _virtualMode;
  183. set
  184. {
  185. _virtualMode = value;
  186. OnPropertyChanged("VirtualMode");
  187. }
  188. }
  189. public bool PodReserved
  190. {
  191. get => _podReserved;
  192. set
  193. {
  194. _podReserved = value;
  195. OnPropertyChanged("PodReserved");
  196. }
  197. }
  198. public string PortState
  199. {
  200. get => _portState;
  201. set
  202. {
  203. _portState = value;
  204. OnPropertyChanged("PortState");
  205. }
  206. }
  207. public string CarrierID
  208. {
  209. get => _carrierId;
  210. set
  211. {
  212. _carrierId = value;
  213. OnPropertyChanged("CarrierID");
  214. }
  215. }
  216. public string SlotMap
  217. {
  218. get => _slotMap;
  219. set
  220. {
  221. _slotMap = value;
  222. OnPropertyChanged("SlotMap");
  223. }
  224. }
  225. public bool Valid
  226. {
  227. get => _valid;
  228. set
  229. {
  230. _valid = value;
  231. OnPropertyChanged("Valid");
  232. }
  233. }
  234. public bool TransferRequest
  235. {
  236. get => _transferRequest;
  237. set
  238. {
  239. _transferRequest = value;
  240. OnPropertyChanged("TransferRequest");
  241. }
  242. }
  243. public bool Busy
  244. {
  245. get => _busy;
  246. set
  247. {
  248. _busy = value;
  249. OnPropertyChanged("Busy");
  250. }
  251. }
  252. public bool TransferComplete
  253. {
  254. get => _transferComplete;
  255. set
  256. {
  257. _transferComplete = value;
  258. OnPropertyChanged("TransferComplete");
  259. }
  260. }
  261. public bool CS0
  262. {
  263. get => _cs0;
  264. set
  265. {
  266. _cs0 = value;
  267. OnPropertyChanged("CS0");
  268. }
  269. }
  270. public bool CS1
  271. {
  272. get => _cs1;
  273. set
  274. {
  275. _cs1 = value;
  276. OnPropertyChanged("CS1");
  277. }
  278. }
  279. public bool ContinuousTransfer
  280. {
  281. get => _continuousTransfer;
  282. set
  283. {
  284. _continuousTransfer = value;
  285. OnPropertyChanged("ContinuousTransfer");
  286. }
  287. }
  288. public bool LoadRequest
  289. {
  290. get => _loadRequest;
  291. set
  292. {
  293. _loadRequest = value;
  294. OnPropertyChanged("LoadRequest");
  295. }
  296. }
  297. public bool UnloadRequest
  298. {
  299. get => _unloadRequest;
  300. set
  301. {
  302. _unloadRequest = value;
  303. OnPropertyChanged("UnloadRequest");
  304. }
  305. }
  306. public bool ReadyToTransfer
  307. {
  308. get => _readyToTransfer;
  309. set
  310. {
  311. _readyToTransfer = value;
  312. OnPropertyChanged("ReadyToTransfer");
  313. }
  314. }
  315. public bool HandoffAvailable
  316. {
  317. get => _handoffAvailable;
  318. set
  319. {
  320. _handoffAvailable = value;
  321. OnPropertyChanged("HandoffAvailable");
  322. }
  323. }
  324. public bool EmergencyOk
  325. {
  326. get => _emergencyOk;
  327. set
  328. {
  329. _emergencyOk = value;
  330. OnPropertyChanged("EmergencyOk");
  331. }
  332. }
  333. public bool ErrorOnPlacementTimeout
  334. {
  335. get => _errorOnPlacementTimeout;
  336. set
  337. {
  338. _errorOnPlacementTimeout = value;
  339. OnPropertyChanged("ErrorOnPlacementTimeout");
  340. }
  341. }
  342. public string E84State
  343. {
  344. get => _e84State;
  345. set
  346. {
  347. _e84State = value;
  348. OnPropertyChanged("E84State");
  349. }
  350. }
  351. }
  352. }