LPSensorViewModel.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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("LP2.LoadportState")]
  53. //public string LP2State { get; set; }
  54. //[Subscription("LP3.LoadportState")]
  55. //public string LP3State { get; set; }
  56. //[Subscription("LP4.LoadportState")]
  57. //public string LP4State { get; set; }
  58. //[Subscription("LP1.CarrierId")]
  59. //public string LP1CarrierId { get; set; }
  60. //[Subscription("LP2.CarrierId")]
  61. //public string LP2CarrierId { get; set; }
  62. //[Subscription("LP3.CarrierId")]
  63. //public string LP3CarrierId { get; set; }
  64. //[Subscription("LP4.CarrierId")]
  65. //public string LP4CarrierId { get; set; }
  66. [Subscription("LP1.AccessMode")]
  67. public string LP1AccessMode { get; set; }
  68. [Subscription("LP2.AccessMode")]
  69. public string LP2AccessMode { get; set; }
  70. [Subscription("LP1.DeviceStatus")]
  71. public string LP1DeviceStatus { get; set; }
  72. [Subscription("LP2.DeviceStatus")]
  73. public string LP2DeviceStatus { get; set; }
  74. [Subscription("LP1.Carrier")]
  75. public CarrierInfo LP1CarrierInfo { get; set; }
  76. [Subscription("LP2.Carrier")]
  77. public CarrierInfo LP2CarrierInfo { get; set; }
  78. #endregion
  79. private bool _lP2BorderVisibility = true;
  80. public bool LP2BorderVisibility
  81. {
  82. get => _lP2BorderVisibility;
  83. set
  84. {
  85. _lP2BorderVisibility = value;
  86. NotifyOfPropertyChange(nameof(LP2BorderVisibility));
  87. }
  88. }
  89. private bool _lP1BorderVisibility = true;
  90. public bool LP1BorderVisibility
  91. {
  92. get => _lP1BorderVisibility;
  93. set
  94. {
  95. _lP1BorderVisibility = value;
  96. NotifyOfPropertyChange(nameof(LP1BorderVisibility));
  97. }
  98. }
  99. // public ObservableCollection<SensorViewItem> LPSensors { get; set; } = new ObservableCollection<SensorViewItem>();
  100. public LPSensorViewModel()
  101. {
  102. }
  103. protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)
  104. {
  105. base.InvokeAfterUpdateProperty(data);
  106. }
  107. //protected override void InvokeBeforeUpdateProperty(Dictionary<string, object> data)
  108. //{
  109. // base.InvokeBeforeUpdateProperty(data);
  110. //}
  111. //public override void UpdateSubscribe(Dictionary<string, object> data, object target, string module = null)
  112. //{
  113. // Parallel.ForEach(target.GetType().GetProperties().Where(_hasSubscriptionAttribute),
  114. // property =>
  115. // {
  116. // PropertyInfo pi = (PropertyInfo)property;
  117. // SubscriptionAttribute subscription = property.GetCustomAttributes(false).First(_isSubscriptionAttribute) as SubscriptionAttribute;
  118. // string key = subscription.ModuleKey;
  119. // key = module == null ? key : string.Format("{0}.{1}", module, key);
  120. // if (_subscribedKeys.Contains(key) && data.ContainsKey(key))
  121. // {
  122. // try
  123. // {
  124. // var convertedValue = Convert.ChangeType(data[key], pi.PropertyType);
  125. // var originValue = Convert.ChangeType(pi.GetValue(target, null), pi.PropertyType);
  126. // if ((convertedValue as AITSensorData) != null && originValue != convertedValue)
  127. // {
  128. // pi.SetValue(target, convertedValue, null);
  129. // //if ((convertedValue as AITSensorData).DeviceName.ToLower().Contains(_para))
  130. // //{
  131. // Update(LPSensors, convertedValue as AITSensorData);
  132. // //}
  133. // }
  134. // }
  135. // catch (Exception ex)
  136. // {
  137. // LOG.Error("由RT返回的数据更新失败" + key, ex);
  138. // }
  139. // }
  140. // });
  141. // base.UpdateSubscribe(data, target, module);
  142. //}
  143. //private void Update(ObservableCollection<SensorViewItem> sensors, object obj)
  144. //{
  145. // AITSensorData data = obj as AITSensorData;
  146. // if (data != null && sensors.Count > 0)
  147. // {
  148. // var item = sensors.SingleOrDefault(x => x.Name == data.DeviceName);
  149. // if (item != null)
  150. // {
  151. // item.Value = data.Value;
  152. // }
  153. // }
  154. //}
  155. public void DoLoadPortCmd(string deviceName, string cmd)
  156. {
  157. if (cmd == "SetAMHS" && deviceName == "LP1" && LP1CarrierInfo != null && !LP1CarrierInfo.IsEmpty)
  158. {
  159. DialogBox.ShowWarning($"{deviceName} change to auto failed, for FOUP present");
  160. return;
  161. }
  162. if (cmd == "SetAMHS" && deviceName == "LP2" && LP2CarrierInfo != null && !LP2CarrierInfo.IsEmpty)
  163. {
  164. DialogBox.ShowWarning($"{deviceName} change to auto failed, for FOUP present");
  165. return;
  166. }
  167. InvokeClient.Instance.Service.DoOperation($"{deviceName}.{cmd}");
  168. }
  169. public void Home(object para)
  170. {
  171. InvokeClient.Instance.Service.DoOperation($"{para}.Home", "");
  172. }
  173. public void SetClamp(object para)
  174. {
  175. InvokeClient.Instance.Service.DoOperation($"{para}.Unload", "");
  176. }
  177. public void SetRelease(object para)
  178. {
  179. InvokeClient.Instance.Service.DoOperation($"{para}.Load", "");
  180. }
  181. public void ReadCarrierId(string moduleID)
  182. {
  183. InvokeClient.Instance.Service.DoOperation($"{moduleID}.ReadCarrierId");
  184. }
  185. public void ClosedCmd()
  186. {
  187. (GetView() as Window).Close();
  188. }
  189. }
  190. }