LPSensorViewModel.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. using Caliburn.Micro;
  2. using Caliburn.Micro.Core;
  3. using Aitex.Core.Common.DeviceData;
  4. using Aitex.Core.UI.ControlDataContext;
  5. using Aitex.Core.Util;
  6. using MECF.Framework.Common.DataCenter;
  7. using MECF.Framework.Common.OperationCenter;
  8. using FurnaceUI.Models;
  9. using FurnaceUI.Views.Editors;
  10. using System.Collections.ObjectModel;
  11. using System.Collections.Generic;
  12. using System.Threading.Tasks;
  13. using System.Reflection;
  14. using System;
  15. using Aitex.Core.RT.Log;
  16. using System.Linq;
  17. using System.Windows;
  18. using Aitex.Core.RT.SCCore;
  19. using MECF.Framework.Common.SubstrateTrackings;
  20. using OpenSEMI.ClientBase;
  21. using DocumentFormat.OpenXml.Office.Word;
  22. namespace FurnaceUI.Views.Maintenances
  23. {
  24. public class LPSensorViewModel : FurnaceModuleUIViewModelBase
  25. {
  26. public bool IsManagerPermission { get => this.Permission == 3; }
  27. [Subscription("Rt.Status")]
  28. public string RtStatus { get; set; }
  29. public bool IsEnableManualOperation => IsSystemStaus;
  30. public bool IsSystemStaus => (RtStatus != "AutoRunning");
  31. #region stage sensors
  32. //[Subscription("System.SensorStation17Presence.DeviceData")]
  33. //public AITSensorData SensorStation17Presence { get; set; }
  34. //[Subscription("System.SensorStation18Presence.DeviceData")]
  35. //public AITSensorData SensorStation18Presence { get; set; }
  36. //[Subscription("System.SensorStation17APresence.DeviceData")]
  37. //public AITSensorData SensorStation17APresence { get; set; }
  38. //[Subscription("System.SensorStation18APresence.DeviceData")]
  39. //public AITSensorData SensorStation18APresence { get; set; }
  40. //[Subscription("System.Valve1EX.DeviceData")]
  41. //public AITSensorData Valve1EX { get; set; }
  42. //[Subscription("System.Valve1RE.DeviceData")]
  43. //public AITSensorData Valve1RE { get; set; }
  44. //[Subscription("System.Valve2EX.DeviceData")]
  45. //public AITSensorData Valve2EX { get; set; }
  46. //[Subscription("System.Valve2RE.DeviceData")]
  47. //public AITSensorData Valve2RE { get; set; }
  48. [Subscription("LP1.Status")]
  49. public string LP1State { get; set; }
  50. [Subscription("LP2.Status")]
  51. public string LP2State { get; set; }
  52. [Subscription("LP3.Status")]
  53. public string LP3State { get; set; }
  54. [Subscription("LP4.Status")]
  55. public string LP4State { get; set; }
  56. [Subscription("LP1.AccessMode")]
  57. public string LP1AccessMode { get; set; }
  58. [Subscription("LP2.AccessMode")]
  59. public string LP2AccessMode { get; set; }
  60. [Subscription("LP3.AccessMode")]
  61. public string LP3AccessMode { get; set; }
  62. [Subscription("LP4.AccessMode")]
  63. public string LP4AccessMode { get; set; }
  64. [Subscription("LP1.DeviceStatus")]
  65. public string LP1DeviceStatus { get; set; }
  66. [Subscription("LP2.DeviceStatus")]
  67. public string LP2DeviceStatus { get; set; }
  68. [Subscription("LP3.DeviceStatus")]
  69. public string LP3DeviceStatus { get; set; }
  70. [Subscription("LP4.DeviceStatus")]
  71. public string LP4DeviceStatus { get; set; }
  72. [Subscription("LP1.Carrier")]
  73. public CarrierInfo LP1CarrierInfo { get; set; }
  74. [Subscription("LP2.Carrier")]
  75. public CarrierInfo LP2CarrierInfo { get; set; }
  76. [Subscription("LP3.Carrier")]
  77. public CarrierInfo LP3CarrierInfo { get; set; }
  78. [Subscription("LP4.Carrier")]
  79. public CarrierInfo LP4CarrierInfo { get; set; }
  80. #endregion
  81. private int _tabSelectIndex = 0;
  82. public int TabSelectIndex
  83. {
  84. get => _tabSelectIndex;
  85. set
  86. {
  87. _tabSelectIndex = value;
  88. NotifyOfPropertyChange(nameof(TabSelectIndex));
  89. }
  90. }
  91. private bool _lP4BorderVisibility = true;
  92. public bool LP4BorderVisibility
  93. {
  94. get => _lP4BorderVisibility;
  95. set
  96. {
  97. _lP4BorderVisibility = value;
  98. NotifyOfPropertyChange(nameof(LP4BorderVisibility));
  99. }
  100. }
  101. private bool _lP3BorderVisibility = true;
  102. public bool LP3BorderVisibility
  103. {
  104. get => _lP3BorderVisibility;
  105. set
  106. {
  107. _lP3BorderVisibility = value;
  108. NotifyOfPropertyChange(nameof(LP3BorderVisibility));
  109. }
  110. }
  111. private bool _lP2BorderVisibility = true;
  112. public bool LP2BorderVisibility
  113. {
  114. get => _lP2BorderVisibility;
  115. set
  116. {
  117. _lP2BorderVisibility = value;
  118. NotifyOfPropertyChange(nameof(LP2BorderVisibility));
  119. }
  120. }
  121. private bool _lP1BorderVisibility = true;
  122. public bool LP1BorderVisibility
  123. {
  124. get => _lP1BorderVisibility;
  125. set
  126. {
  127. _lP1BorderVisibility = value;
  128. NotifyOfPropertyChange(nameof(LP1BorderVisibility));
  129. }
  130. }
  131. // public ObservableCollection<SensorViewItem> LPSensors { get; set; } = new ObservableCollection<SensorViewItem>();
  132. public LPSensorViewModel()
  133. {
  134. }
  135. protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)
  136. {
  137. base.InvokeAfterUpdateProperty(data);
  138. }
  139. //protected override void InvokeBeforeUpdateProperty(Dictionary<string, object> data)
  140. //{
  141. // base.InvokeBeforeUpdateProperty(data);
  142. //}
  143. //public override void UpdateSubscribe(Dictionary<string, object> data, object target, string module = null)
  144. //{
  145. // Parallel.ForEach(target.GetType().GetProperties().Where(_hasSubscriptionAttribute),
  146. // property =>
  147. // {
  148. // PropertyInfo pi = (PropertyInfo)property;
  149. // SubscriptionAttribute subscription = property.GetCustomAttributes(false).First(_isSubscriptionAttribute) as SubscriptionAttribute;
  150. // string key = subscription.ModuleKey;
  151. // key = module == null ? key : string.Format("{0}.{1}", module, key);
  152. // if (_subscribedKeys.Contains(key) && data.ContainsKey(key))
  153. // {
  154. // try
  155. // {
  156. // var convertedValue = Convert.ChangeType(data[key], pi.PropertyType);
  157. // var originValue = Convert.ChangeType(pi.GetValue(target, null), pi.PropertyType);
  158. // if ((convertedValue as AITSensorData) != null && originValue != convertedValue)
  159. // {
  160. // pi.SetValue(target, convertedValue, null);
  161. // //if ((convertedValue as AITSensorData).DeviceName.ToLower().Contains(_para))
  162. // //{
  163. // Update(LPSensors, convertedValue as AITSensorData);
  164. // //}
  165. // }
  166. // }
  167. // catch (Exception ex)
  168. // {
  169. // LOG.Error("由RT返回的数据更新失败" + key, ex);
  170. // }
  171. // }
  172. // });
  173. // base.UpdateSubscribe(data, target, module);
  174. //}
  175. //private void Update(ObservableCollection<SensorViewItem> sensors, object obj)
  176. //{
  177. // AITSensorData data = obj as AITSensorData;
  178. // if (data != null && sensors.Count > 0)
  179. // {
  180. // var item = sensors.SingleOrDefault(x => x.Name == data.DeviceName);
  181. // if (item != null)
  182. // {
  183. // item.Value = data.Value;
  184. // }
  185. // }
  186. //}
  187. public void DoLoadPortCmd(string deviceName, string cmd)
  188. {
  189. if (cmd == "SetAMHS" && deviceName == "LP1" && LP1CarrierInfo != null && !LP1CarrierInfo.IsEmpty)
  190. {
  191. DialogBox.ShowWarning($"{deviceName} change to auto failed, for FOUP present");
  192. return;
  193. }
  194. if (cmd == "SetAMHS" && deviceName == "LP2" && LP2CarrierInfo != null && !LP2CarrierInfo.IsEmpty)
  195. {
  196. DialogBox.ShowWarning($"{deviceName} change to auto failed, for FOUP present");
  197. return;
  198. }
  199. if (cmd == "SetAMHS" && deviceName == "LP3" && LP3CarrierInfo != null && !LP3CarrierInfo.IsEmpty)
  200. {
  201. DialogBox.ShowWarning($"{deviceName} change to auto failed, for FOUP present");
  202. return;
  203. }
  204. if (cmd == "SetAMHS" && deviceName == "LP4" && LP4CarrierInfo != null && !LP4CarrierInfo.IsEmpty)
  205. {
  206. DialogBox.ShowWarning($"{deviceName} change to auto failed, for FOUP present");
  207. return;
  208. }
  209. InvokeClient.Instance.Service.DoOperation($"{deviceName}.{cmd}");
  210. }
  211. public void Home(object para)
  212. {
  213. InvokeClient.Instance.Service.DoOperation($"{para}.Home", "");
  214. }
  215. public void SetClamp(object para)
  216. {
  217. InvokeClient.Instance.Service.DoOperation($"{para}.Unload", "");
  218. }
  219. public void SetRelease(object para)
  220. {
  221. InvokeClient.Instance.Service.DoOperation($"{para}.Load", "");
  222. }
  223. public void ReadCarrierId(string moduleID)
  224. {
  225. InvokeClient.Instance.Service.DoOperation($"{moduleID}.ReadCarrierId");
  226. }
  227. public void ClosedCmd()
  228. {
  229. (GetView() as Window).Close();
  230. }
  231. }
  232. }