E84Info.xaml.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. using System.ComponentModel;
  2. using System.Windows;
  3. using System.Windows.Controls;
  4. using System.Windows.Input;
  5. using Aitex.Core.UI.MVVM;
  6. using Aitex.Core.Util;
  7. using Aitex.Core.Utilities;
  8. using MECF.Framework.Common.DataCenter;
  9. using MECF.Framework.Common.OperationCenter;
  10. using MECF.Framework.UI.Client.ClientBase;
  11. using MECF.Framework.UI.Core.View.Common;
  12. namespace MECF.Framework.UI.Client.CenterViews.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. ConfigBorder1.DataContext = _e84InfoViewModel;
  29. Inputs.DataContext = this;
  30. Outputs.DataContext = this;
  31. //BindingErrorTraceListener.SetTrace();
  32. E84Command = new DelegateCommand<string>(DoLoadPortCmd);
  33. IsVisibleChanged += E84Info_IsVisibleChanged;
  34. }
  35. public ICommand E84Command { get; set; }
  36. public string LoadPortName
  37. {
  38. get => (string) GetValue(LoadPortNameProperty);
  39. set => SetValue(LoadPortNameProperty, value);
  40. }
  41. public E84InfoData E84Data
  42. {
  43. get => (E84InfoData) GetValue(E84DataProperty);
  44. set => SetValue(E84DataProperty, value);
  45. }
  46. private void DoLoadPortCmd(string cmd)
  47. {
  48. var deviceName = LoadPortName;
  49. var param = new object[] {deviceName};
  50. InvokeClient.Instance.Service.DoOperation($"{param[0]}.{cmd}");
  51. }
  52. private void E84Info_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
  53. {
  54. (DataContext as E84InfoViewModel)?.EnableTimer(IsVisible);
  55. }
  56. }
  57. internal class E84InfoViewModel : UiViewModelBase
  58. {
  59. public E84InfoViewModel()
  60. {
  61. SetConfigCommand = new DelegateCommand<object>(SetConfig);
  62. ConfigFeedback = new E84SCs();
  63. ConfigSetPoint = new E84SCs();
  64. ConfigFeedback.UpdateKeys(typeof(E84SCs).GetProperties());
  65. ConfigSetPoint.UpdateKeys(typeof(E84SCs).GetProperties());
  66. UpdateConfig();
  67. }
  68. [IgnorePropertyChange] public ICommand SetConfigCommand { get; }
  69. [IgnorePropertyChange] public E84SCs ConfigFeedback { get; set; }
  70. [IgnorePropertyChange] public E84SCs ConfigSetPoint { get; set; }
  71. public bool AutomaticMode { get; set; }
  72. public bool KeepClampedAfterRun { get; set; }
  73. public bool KeepDockAfterRun { get; set; }
  74. public bool CloseDoorAfterMap { get; set; }
  75. [Subscription("E84State")] public string E84Status { get; set; }
  76. private void SetConfig(object param)
  77. {
  78. var sc = (object[]) param;
  79. InvokeClient.Instance.Service.DoOperation("System.SetConfig", sc[0].ToString(), sc[1].ToString());
  80. UpdateConfig();
  81. }
  82. public void UpdateConfig()
  83. {
  84. ConfigFeedback.Update(QueryDataClient.Instance.Service.PollConfig(ConfigFeedback.GetKeys()));
  85. ConfigSetPoint.Update(QueryDataClient.Instance.Service.PollConfig(ConfigSetPoint.GetKeys()));
  86. Refresh();
  87. }
  88. protected override void Poll()
  89. {
  90. Refresh();
  91. base.Poll();
  92. }
  93. }
  94. public class E84SCs : PageSCValue
  95. {
  96. public int Fa_E84_TP1 { get; set; }
  97. public int Fa_E84_TP2 { get; set; }
  98. public int Fa_E84_TP3 { get; set; }
  99. public int Fa_E84_TP4 { get; set; }
  100. public int Fa_E84_TP5 { get; set; }
  101. public int Fa_E84_TP6 { get; set; }
  102. public bool LoadPort_CarrierIDReaderInUse { get; set; }
  103. public int LoadPort_DataReadSize { get; set; }
  104. public int LoadPort_StartPage { get; set; }
  105. public int LoadPort_DefaultPage { get; set; }
  106. }
  107. public class E84InfoData : INotifyPropertyChanged
  108. {
  109. private bool _busy;
  110. private string _carrierId;
  111. private bool _continuousTransfer;
  112. private bool _cs0;
  113. private bool _cs1;
  114. private string _e84State;
  115. private bool _emergencyOk;
  116. private bool _errorOnPlacementTimeout;
  117. private bool _handoffAvailable;
  118. private string _loadPortState;
  119. private string _AccessMode;
  120. //Factory Outputs
  121. private bool _loadRequest;
  122. private bool _podDocked;
  123. private bool _podLatched;
  124. private bool _podOpen;
  125. private bool _podPlaced;
  126. private bool _podReserved;
  127. private string _portState;
  128. private bool _potPresent;
  129. private bool _readyToTransfer;
  130. private string _slotMap;
  131. private bool _transferComplete;
  132. private bool _transferRequest;
  133. private bool _unloadRequest;
  134. //Factory Inputs
  135. private bool _valid;
  136. private bool _virtualMode;
  137. private string _carrierIDStatus;
  138. public string CarrierIDStatus
  139. {
  140. get => _carrierIDStatus;
  141. set
  142. {
  143. _carrierIDStatus = value;
  144. OnPropertyChanged("CarrierIDStatus");
  145. }
  146. }
  147. private string _slotmapStatus;
  148. public string SlotMapStatus
  149. {
  150. get => _slotmapStatus;
  151. set
  152. {
  153. _slotmapStatus = value;
  154. OnPropertyChanged("SlotMapStatus");
  155. }
  156. }
  157. private string _accessStatus;
  158. public string AccessStatus
  159. {
  160. get => _accessStatus;
  161. set
  162. {
  163. _accessStatus = value;
  164. OnPropertyChanged("AccessStatus");
  165. }
  166. }
  167. public bool PodPresent
  168. {
  169. get => _potPresent;
  170. set
  171. {
  172. _potPresent = value;
  173. OnPropertyChanged("PodPresent");
  174. }
  175. }
  176. public bool PodPlaced
  177. {
  178. get => _podPlaced;
  179. set
  180. {
  181. _podPlaced = value;
  182. OnPropertyChanged("PodPlaced");
  183. }
  184. }
  185. public bool PodLatched
  186. {
  187. get => _podLatched;
  188. set
  189. {
  190. _podLatched = value;
  191. OnPropertyChanged("PodLatched");
  192. }
  193. }
  194. public bool PodDocked
  195. {
  196. get => _podDocked;
  197. set
  198. {
  199. _podDocked = value;
  200. OnPropertyChanged("PodDocked");
  201. }
  202. }
  203. public bool PodOpen
  204. {
  205. get => _podOpen;
  206. set
  207. {
  208. _podOpen = value;
  209. OnPropertyChanged("PodOpen");
  210. }
  211. }
  212. public string LoadPortState
  213. {
  214. get => $"_{_loadPortState}";
  215. set
  216. {
  217. _loadPortState = value;
  218. OnPropertyChanged("LoadPortState");
  219. }
  220. }
  221. public string AccessMode
  222. {
  223. get => $"{_AccessMode}";
  224. set
  225. {
  226. _AccessMode = value;
  227. OnPropertyChanged("AccessMode");
  228. }
  229. }
  230. public bool VirtualMode
  231. {
  232. get => _virtualMode;
  233. set
  234. {
  235. _virtualMode = value;
  236. OnPropertyChanged("VirtualMode");
  237. }
  238. }
  239. public bool PodReserved
  240. {
  241. get => _podReserved;
  242. set
  243. {
  244. _podReserved = value;
  245. OnPropertyChanged("PodReserved");
  246. }
  247. }
  248. public string PortState
  249. {
  250. get =>$"{_portState}";
  251. set
  252. {
  253. _portState = value;
  254. OnPropertyChanged("PortState");
  255. }
  256. }
  257. public string CarrierID
  258. {
  259. get => _carrierId;
  260. set
  261. {
  262. _carrierId = value;
  263. OnPropertyChanged("CarrierID");
  264. }
  265. }
  266. public string SlotMap
  267. {
  268. get => _slotMap;
  269. set
  270. {
  271. _slotMap = value;
  272. OnPropertyChanged("SlotMap");
  273. }
  274. }
  275. public bool Valid
  276. {
  277. get => _valid;
  278. set
  279. {
  280. _valid = value;
  281. OnPropertyChanged("Valid");
  282. }
  283. }
  284. public bool TransferRequest
  285. {
  286. get => _transferRequest;
  287. set
  288. {
  289. _transferRequest = value;
  290. OnPropertyChanged("TransferRequest");
  291. }
  292. }
  293. public bool Busy
  294. {
  295. get => _busy;
  296. set
  297. {
  298. _busy = value;
  299. OnPropertyChanged("Busy");
  300. }
  301. }
  302. public bool TransferComplete
  303. {
  304. get => _transferComplete;
  305. set
  306. {
  307. _transferComplete = value;
  308. OnPropertyChanged("TransferComplete");
  309. }
  310. }
  311. public bool CS0
  312. {
  313. get => _cs0;
  314. set
  315. {
  316. _cs0 = value;
  317. OnPropertyChanged("CS0");
  318. }
  319. }
  320. public bool CS1
  321. {
  322. get => _cs1;
  323. set
  324. {
  325. _cs1 = value;
  326. OnPropertyChanged("CS1");
  327. }
  328. }
  329. public bool ContinuousTransfer
  330. {
  331. get => _continuousTransfer;
  332. set
  333. {
  334. _continuousTransfer = value;
  335. OnPropertyChanged("ContinuousTransfer");
  336. }
  337. }
  338. public bool LoadRequest
  339. {
  340. get => _loadRequest;
  341. set
  342. {
  343. _loadRequest = value;
  344. OnPropertyChanged("LoadRequest");
  345. }
  346. }
  347. public bool UnloadRequest
  348. {
  349. get => _unloadRequest;
  350. set
  351. {
  352. _unloadRequest = value;
  353. OnPropertyChanged("UnloadRequest");
  354. }
  355. }
  356. public bool ReadyToTransfer
  357. {
  358. get => _readyToTransfer;
  359. set
  360. {
  361. _readyToTransfer = value;
  362. OnPropertyChanged("ReadyToTransfer");
  363. }
  364. }
  365. public bool HandoffAvailable
  366. {
  367. get => _handoffAvailable;
  368. set
  369. {
  370. _handoffAvailable = value;
  371. OnPropertyChanged("HandoffAvailable");
  372. }
  373. }
  374. public bool EmergencyOk
  375. {
  376. get => _emergencyOk;
  377. set
  378. {
  379. _emergencyOk = value;
  380. OnPropertyChanged("EmergencyOk");
  381. }
  382. }
  383. public bool ErrorOnPlacementTimeout
  384. {
  385. get => _errorOnPlacementTimeout;
  386. set
  387. {
  388. _errorOnPlacementTimeout = value;
  389. OnPropertyChanged("ErrorOnPlacementTimeout");
  390. }
  391. }
  392. public string E84State
  393. {
  394. get => _e84State;
  395. set
  396. {
  397. _e84State = value;
  398. OnPropertyChanged("E84State");
  399. }
  400. }
  401. #region INotifyPropertyChanged Members
  402. public event PropertyChangedEventHandler PropertyChanged;
  403. protected virtual void OnPropertyChanged(string propertyName)
  404. {
  405. PropertyChangedEventHandler handler = this.PropertyChanged;
  406. if (handler != null)
  407. handler(this, new PropertyChangedEventArgs(propertyName));
  408. }
  409. #endregion
  410. }
  411. }