GasPanelViewModel.cs 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142
  1. using Aitex.Core.Common.DeviceData;
  2. using Aitex.Core.RT.Log;
  3. using Aitex.Core.UI.ControlDataContext;
  4. using Aitex.Core.UI.MVVM;
  5. using Aitex.Core.Util;
  6. using MECF.Framework.Common.DataCenter;
  7. using MECF.Framework.Common.OperationCenter;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Reflection;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. using System.Windows;
  15. using System.Windows.Input;
  16. using FurnaceGasPanelUI.Models;
  17. using MECF.Framework.UI.Core.Control;
  18. using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
  19. using Aitex.Core.UI.Control;
  20. using OpenSEMI.ClientBase;
  21. using Aitex.Core.UI.DeviceControl;
  22. using MECF.Framework.UI.Core.ExtendedControls;
  23. namespace FurnaceGasPanelUI.Views.Maintenances.NTP
  24. {
  25. public class GasPanelViewModel : ThermalGasPanelUIViewModelBase
  26. {
  27. public ICommand CmdSetMfcFlow { get; set; }
  28. public bool _ismanagerPermission = true;
  29. public Window WinOwner { get; set; }
  30. public bool IsManagerPermission
  31. {
  32. get
  33. {
  34. return _ismanagerPermission;
  35. }
  36. set
  37. {
  38. _ismanagerPermission = value;
  39. NotifyOfPropertyChange("IsManagerPermission");
  40. }
  41. }
  42. private bool _isRecipeEdit = false;
  43. public bool ManualEnable { get; set; } = true;
  44. public string ManualEnableColor
  45. {
  46. get
  47. {
  48. if (ManualEnable)
  49. {
  50. return "Green";
  51. }
  52. return "#FFB0D1F1";
  53. }
  54. }
  55. public void SwichManualEnable()
  56. {
  57. ManualEnable = true;
  58. }
  59. public void SwichMonitor()
  60. {
  61. ManualEnable = false;
  62. }
  63. public void SwichRecipe()
  64. {
  65. IsRecipeEdit = true;
  66. }
  67. public bool MonitorChecked { get; set; } = true;
  68. public bool ManualChecked { get; set; } = false;
  69. public bool IsRecipeEdit
  70. {
  71. get
  72. {
  73. return _isRecipeEdit;
  74. }
  75. set
  76. {
  77. _isRecipeEdit = value;
  78. NotifyOfPropertyChange("IsRecipeEdit");
  79. }
  80. }
  81. public bool EditTrue { get; set; } = false;
  82. [Subscription("PM1.SensorRecipeOK")]
  83. public AITSensorData SensorRecipeOK { get; set; }
  84. [Subscription("PM1.SensorPROCManualOK")]
  85. public AITSensorData SensorPROCManualOK { get; set; }
  86. [Subscription("System.VentValve.DeviceData")]
  87. public AITValveData VentValveData { get; set; }
  88. [Subscription("System.PumpValve.DeviceData")]
  89. public AITValveData PumpValveData { get; set; }
  90. [Subscription("PM1.SensorTubeATMPressure.DeviceData")]
  91. public AITSensorData SensorTubeATMPressure { get; set; }
  92. [Subscription("System.TubePressure.DeviceData")]
  93. public AITPressureMeterData TubePressureData { get; set; }
  94. [Subscription("PM1.SensorVAC1.Value")]
  95. public bool VAC1 { get; set; }
  96. [Subscription("PM1.SensorVAC2.Value")]
  97. public bool VAC2 { get; set; }
  98. [Subscription("PM1.SensorVAC3.Value")]
  99. public bool VAC3 { get; set; }
  100. #region Valves
  101. [Subscription("PM1.ValveAV1.DeviceData")]
  102. public AITValveData ValveAV1 { get; set; }
  103. [Subscription("PM1.ValveAV2.DeviceData")]
  104. public AITValveData ValveAV2 { get; set; }
  105. [Subscription("PM1.ValveAV3.DeviceData")]
  106. public AITValveData ValveAV3 { get; set; }
  107. [Subscription("PM1.ValveAV4.DeviceData")]
  108. public AITValveData ValveAV4 { get; set; }
  109. [Subscription("PM1.ValveAV5.DeviceData")]
  110. public AITValveData ValveAV5 { get; set; }
  111. [Subscription("PM1.ValveAV6.DeviceData")]
  112. public AITValveData ValveAV6 { get; set; }
  113. [Subscription("PM1.ValveAV7.DeviceData")]
  114. public AITValveData ValveAV7 { get; set; }
  115. [Subscription("PM1.ValveAV8.DeviceData")]
  116. public AITValveData ValveAV8 { get; set; }
  117. [Subscription("PM1.ValveAV9.DeviceData")]
  118. public AITValveData ValveAV9 { get; set; }
  119. [Subscription("PM1.ValveAV10.DeviceData")]
  120. public AITValveData ValveAV10 { get; set; }
  121. [Subscription("PM1.ValveAV11.DeviceData")]
  122. public AITValveData ValveAV11 { get; set; }
  123. [Subscription("PM1.ValveAV12.DeviceData")]
  124. public AITValveData ValveAV12 { get; set; }
  125. [Subscription("PM1.ValveAV13.DeviceData")]
  126. public AITValveData ValveAV13 { get; set; }
  127. [Subscription("PM1.ValveAV14.DeviceData")]
  128. public AITValveData ValveAV14 { get; set; }
  129. [Subscription("PM1.ValveAV15.DeviceData")]
  130. public AITValveData ValveAV15 { get; set; }
  131. [Subscription("PM1.ValveAV16.DeviceData")]
  132. public AITValveData ValveAV16 { get; set; }
  133. [Subscription("PM1.ValveAV17.DeviceData")]
  134. public AITValveData ValveAV17 { get; set; }
  135. [Subscription("PM1.ValveAV18.DeviceData")]
  136. public AITValveData ValveAV18 { get; set; }
  137. [Subscription("PM1.ValveAV19.DeviceData")]
  138. public AITValveData ValveAV19 { get; set; }
  139. [Subscription("PM1.ValveAV20.DeviceData")]
  140. public AITValveData ValveAV20 { get; set; }
  141. [Subscription("PM1.ValveAV21.DeviceData")]
  142. public AITValveData ValveAV21 { get; set; }
  143. [Subscription("PM1.ValveAV22.DeviceData")]
  144. public AITValveData ValveAV22 { get; set; }
  145. [Subscription("PM1.ValveAV23.DeviceData")]
  146. public AITValveData ValveAV23 { get; set; }
  147. [Subscription("PM1.ValveAV24.DeviceData")]
  148. public AITValveData ValveAV24 { get; set; }
  149. [Subscription("PM1.ValveAV25.DeviceData")]
  150. public AITValveData ValveAV25 { get; set; }
  151. [Subscription("PM1.ValveAV26.DeviceData")]
  152. public AITValveData ValveAV26 { get; set; }
  153. [Subscription("PM1.ValveAV27.DeviceData")]
  154. public AITValveData ValveAV27 { get; set; }
  155. [Subscription("PM1.ValveAV28.DeviceData")]
  156. public AITValveData ValveAV28 { get; set; }
  157. [Subscription("PM1.ValveAV29.DeviceData")]
  158. public AITValveData ValveAV29 { get; set; }
  159. [Subscription("PM1.ValveAV30.DeviceData")]
  160. public AITValveData ValveAV30 { get; set; }
  161. [Subscription("PM1.ValveAV31.DeviceData")]
  162. public AITValveData ValveAV31 { get; set; }
  163. [Subscription("PM1.ValveAV32.DeviceData")]
  164. public AITValveData ValveAV32 { get; set; }
  165. [Subscription("PM1.ValveAV33.DeviceData")]
  166. public AITValveData ValveAV33 { get; set; }
  167. [Subscription("PM1.ValveAV34.DeviceData")]
  168. public AITValveData ValveAV34 { get; set; }
  169. [Subscription("PM1.ValveAV35.DeviceData")]
  170. public AITValveData ValveAV35 { get; set; }
  171. [Subscription("PM1.ValveAV36.DeviceData")]
  172. public AITValveData ValveAV36 { get; set; }
  173. [Subscription("PM1.ValveAV37.DeviceData")]
  174. public AITValveData ValveAV37 { get; set; }
  175. [Subscription("PM1.ValveAV38.DeviceData")]
  176. public AITValveData ValveAV38 { get; set; }
  177. [Subscription("PM1.ValveAV39.DeviceData")]
  178. public AITValveData ValveAV39 { get; set; }
  179. [Subscription("PM1.ValveAV52.DeviceData")]
  180. public AITValveData ValveAV52 { get; set; }
  181. [Subscription("PM1.ValveAV54.DeviceData")]
  182. public AITValveData ValveAV54 { get; set; }
  183. [Subscription("PM1.ValveAV56.DeviceData")]
  184. public AITValveData ValveAV56 { get; set; }
  185. [Subscription("PM1.ValveAV57.DeviceData")]
  186. public AITValveData ValveAV57 { get; set; }
  187. [Subscription("PM1.ValveAV58.DeviceData")]
  188. public AITValveData ValveAV58 { get; set; }
  189. [Subscription("PM1.ValveAV59.DeviceData")]
  190. public AITValveData ValveAV59 { get; set; }
  191. [Subscription("PM1.ValveAV60.DeviceData")]
  192. public AITValveData ValveAV60 { get; set; }
  193. [Subscription("PM1.ValveFIMS1N2Purge.DeviceData")]
  194. public AITValveData ValveAV63 { get; set; }
  195. [Subscription("PM1.ValveFIMS2N2Purge.DeviceData")]
  196. public AITValveData ValveAV64 { get; set; }
  197. [Subscription("PM1.ValveAV65.DeviceData")]
  198. public AITValveData ValveAV65 { get; set; }
  199. [Subscription("PM1.ValveAV66.DeviceData")]
  200. public AITValveData ValveAV66 { get; set; }
  201. [Subscription("PM1.ValveAV68.DeviceData")]
  202. public AITValveData ValveAV68 { get; set; }
  203. [Subscription("PM1.APC.ModeFeedback")]
  204. public int APCModeFeedback { get; set; }
  205. [Subscription("PM1.ValveAV71.DeviceData")] public AITValveData ValveAV71Data { get; set; }
  206. public AITValveData ValveAV71
  207. {
  208. get
  209. {
  210. return new AITValveData()
  211. {
  212. DeviceName = ValveAV71Data.DeviceName,
  213. DisplayName = ValveAV71Data.DisplayName,
  214. UniqueName = ValveAV71Data.UniqueName,
  215. DefaultValue = ValveAV71Data.DefaultValue,
  216. SetPoint = ValveAV71Data.SetPoint,
  217. Feedback = APCModeFeedback != 5,
  218. VirtualFeedback = ValveAV71Data.VirtualFeedback
  219. };
  220. }
  221. }
  222. [Subscription("PM1.ValveAV72.DeviceData")]
  223. public AITValveData ValveAV72 { get; set; }
  224. [Subscription("PM1.ValveAV73.DeviceData")]
  225. public AITValveData ValveAV73 { get; set; }
  226. [Subscription("PM1.ValveAV74.DeviceData")]
  227. public AITValveData ValveAV74 { get; set; }
  228. [Subscription("PM1.ValveAV75.DeviceData")]
  229. public AITValveData ValveAV75 { get; set; }
  230. [Subscription("PM1.ValveAV77.DeviceData")]
  231. public AITValveData ValveAV77 { get; set; }
  232. [Subscription("PM1.ValveAV81.DeviceData")]
  233. public AITValveData ValveAV81 { get; set; }
  234. [Subscription("PM1.ValveAV82.DeviceData")]
  235. public AITValveData ValveAV82 { get; set; }
  236. [Subscription("PM1.ValveAV83.DeviceData")]
  237. public AITValveData ValveAV83 { get; set; }
  238. [Subscription("PM1.ValveAV91.DeviceData")]
  239. public AITValveData ValveDPR { get; set; }
  240. public string ValveDPRBrush
  241. {
  242. get
  243. {
  244. if (ValveDPR != null && ValveDPR.Feedback)
  245. {
  246. return "Green";
  247. }
  248. return "#FFB0D1F1";
  249. }
  250. }
  251. [Subscription("PM1.ValveBlowerPowerOn.DeviceData")]
  252. public AITValveData ValveBWR { get; set; }
  253. public string ValveBWRBrush
  254. {
  255. get
  256. {
  257. if (ValveBWR != null && ValveBWR.Feedback)
  258. {
  259. return "Green";
  260. }
  261. return "#FFB0D1F1";
  262. }
  263. }
  264. [Subscription("PM1.IsF2ClnOn")]
  265. public bool IsF2ClnOn { get; set; }
  266. public string F2ClnBrush
  267. {
  268. get
  269. {
  270. if (IsF2ClnOn)
  271. {
  272. return "Green";
  273. }
  274. return "#FFB0D1F1";
  275. }
  276. }
  277. [Subscription("PM1.IsHFClnOn")]
  278. public bool IsHFClnOn { get; set; }
  279. public string HFClnBrush
  280. {
  281. get
  282. {
  283. if (IsHFClnOn)
  284. {
  285. return "Green";
  286. }
  287. return "#FFB0D1F1";
  288. }
  289. }
  290. [Subscription("PM1.HTR1Enable")]
  291. public bool IsHTR1Enable { get; set; }
  292. public string HTR1Brush
  293. {
  294. get
  295. {
  296. if (IsHTR1Enable)
  297. {
  298. return "Green";
  299. }
  300. return "#FFB0D1F1";
  301. }
  302. }
  303. [Subscription("PM1.HTR2Enable")]
  304. public bool IsHTR2Enable { get; set; }
  305. public string HTR2Brush
  306. {
  307. get
  308. {
  309. if (IsHTR2Enable)
  310. {
  311. return "Green";
  312. }
  313. return "#FFB0D1F1";
  314. }
  315. }
  316. [Subscription("PM1.AUCPump.DeviceData")]
  317. public AITValveData AUCPump { get; set; }
  318. public string AUCPumpBrush
  319. {
  320. get
  321. {
  322. if (AUCPump != null && AUCPump.Feedback)
  323. {
  324. return "Green";
  325. }
  326. return "#FFB0D1F1";
  327. }
  328. }
  329. [Subscription("PM1.BothPump.DeviceData")]
  330. public AITValveData BothPump { get; set; }
  331. public string BothPumpBrush
  332. {
  333. get
  334. {
  335. if (BothPump != null && BothPump.Feedback)
  336. {
  337. return "Green";
  338. }
  339. return "#FFB0D1F1";
  340. }
  341. }
  342. [Subscription("PM1.AGVPump.DeviceData")]
  343. public AITValveData AGVPump { get; set; }
  344. public string AGVPumpBrush
  345. {
  346. get
  347. {
  348. if (AGVPump != null && AGVPump.Feedback)
  349. {
  350. return "Green";
  351. }
  352. return "#FFB0D1F1";
  353. }
  354. }
  355. #endregion
  356. #region MFCs
  357. [Subscription("PM1.MFC1.DeviceData")]
  358. public AITMfcData MFC1Data { get; set; }
  359. [Subscription("PM1.MFC2.DeviceData")]
  360. public AITMfcData MFC2Data { get; set; }
  361. [Subscription("PM1.MFC3.DeviceData")]
  362. public AITMfcData MFC3Data { get; set; }
  363. [Subscription("PM1.MFC4.DeviceData")]
  364. public AITMfcData MFC4Data { get; set; }
  365. [Subscription("PM1.MFC5.DeviceData")]
  366. public AITMfcData MFC5Data { get; set; }
  367. [Subscription("PM1.MFC6.DeviceData")]
  368. public AITMfcData MFC6Data { get; set; }
  369. [Subscription("PM1.MFC7.DeviceData")]
  370. public AITMfcData MFC7Data { get; set; }
  371. [Subscription("PM1.MFC8.DeviceData")]
  372. public AITMfcData MFC8Data { get; set; }
  373. [Subscription("PM1.MFC9.DeviceData")]
  374. public AITMfcData MFC9Data { get; set; }
  375. [Subscription("PM1.MFC10.DeviceData")]
  376. public AITMfcData MFC10Data { get; set; }
  377. [Subscription("PM1.MFC11.DeviceData")]
  378. public AITMfcData MFC11Data { get; set; }
  379. [Subscription("PM1.MFC12.DeviceData")]
  380. public AITMfcData MFC12Data { get; set; }
  381. [Subscription("PM1.MFC51.DeviceData")]
  382. public AITMfcData MFC51Data { get; set; }
  383. #endregion
  384. [Subscription("PM1.MFM57.DeviceData")]
  385. public AITWaterFlowMeterData MFM57Flow { get; set; }
  386. [Subscription("PM1.RfPower.IsPowerOn")]
  387. public bool IsPowerOn { get; set; }
  388. [Subscription("PM1.RfPower.PowerSetPoint")]
  389. public float PowerSetPoint { get; set; }
  390. [Subscription("PM1.RfPower.ForwardPower")]
  391. public float ForwardPower { get; set; }
  392. [Subscription("PM1.RfMatch.Capacitance1PositionFeedBack")]
  393. public float Capacitance1PositionFeedBack { get; set; }
  394. [Subscription("PM1.RfMatch.Capacitance2PositionFeedBack")]
  395. public float Capacitance2PositionFeedBack { get; set; }
  396. [Subscription("PM1.RfMatch.VppFeedBack")]
  397. public float VppFeedBack { get; set; }
  398. public ICommand CmdSetValve { get; set; }
  399. private GasPanelStateType _selectedGasStateType = GasPanelStateType.Monitor;
  400. public GasPanelStateType SelectedGasStateType
  401. {
  402. get
  403. {
  404. return _selectedGasStateType;
  405. }
  406. set
  407. {
  408. _selectedGasStateType = value;
  409. NotifyOfPropertyChange(nameof(SelectedGasStateType));
  410. }
  411. }
  412. public AnalogDeviceDataItem MFC1
  413. {
  414. get
  415. {
  416. return new AnalogDeviceDataItem
  417. {
  418. Type = "MFC",
  419. DeviceName = MFC1Data.UniqueName,
  420. DeviceId = MFC1Data.DeviceSchematicId,
  421. DisplayName = MFC1Data.DisplayName,
  422. Scale = MFC1Data.Scale,
  423. Unit = MFC1Data.Unit,
  424. FeedBack = MFC1Data.FeedBack,
  425. SetPoint = MFC1Data.SetPoint,
  426. VirtualFeedBack = MFC1Data.VirtualFeedBack
  427. };
  428. }
  429. }
  430. public AnalogDeviceDataItem MFC2
  431. {
  432. get
  433. {
  434. return new AnalogDeviceDataItem
  435. {
  436. Type = "MFC",
  437. DeviceName = MFC2Data.UniqueName,
  438. DeviceId = MFC2Data.DeviceSchematicId,
  439. DisplayName = MFC2Data.DisplayName,
  440. Scale = MFC2Data.Scale,
  441. Unit = MFC2Data.Unit,
  442. FeedBack = MFC2Data.FeedBack,
  443. SetPoint = MFC2Data.SetPoint,
  444. VirtualFeedBack = MFC2Data.VirtualFeedBack
  445. };
  446. }
  447. }
  448. public AnalogDeviceDataItem MFC3
  449. {
  450. get
  451. {
  452. return new AnalogDeviceDataItem
  453. {
  454. Type = "MFC",
  455. DeviceName = MFC3Data.UniqueName,
  456. DeviceId = MFC3Data.DeviceSchematicId,
  457. DisplayName = MFC3Data.DisplayName,
  458. Scale = MFC3Data.Scale,
  459. Unit = MFC3Data.Unit,
  460. FeedBack = MFC3Data.FeedBack,
  461. SetPoint = MFC3Data.SetPoint,
  462. VirtualFeedBack = MFC3Data.VirtualFeedBack
  463. };
  464. }
  465. }
  466. public AnalogDeviceDataItem MFC4
  467. {
  468. get
  469. {
  470. return new AnalogDeviceDataItem
  471. {
  472. Type = "MFC",
  473. DeviceName = MFC4Data.UniqueName,
  474. DeviceId = MFC4Data.DeviceSchematicId,
  475. DisplayName = MFC4Data.DisplayName,
  476. Scale = MFC4Data.Scale,
  477. Unit = MFC4Data.Unit,
  478. FeedBack = MFC4Data.FeedBack,
  479. SetPoint = MFC4Data.SetPoint,
  480. VirtualFeedBack = MFC4Data.VirtualFeedBack
  481. };
  482. }
  483. }
  484. public AnalogDeviceDataItem MFC5
  485. {
  486. get
  487. {
  488. return new AnalogDeviceDataItem
  489. {
  490. Type = "MFC",
  491. DeviceName = MFC5Data.UniqueName,
  492. DeviceId = MFC5Data.DeviceSchematicId,
  493. DisplayName = MFC5Data.DisplayName,
  494. Scale = MFC5Data.Scale,
  495. Unit = MFC5Data.Unit,
  496. FeedBack = MFC5Data.FeedBack,
  497. SetPoint = MFC5Data.SetPoint,
  498. VirtualFeedBack = MFC5Data.VirtualFeedBack
  499. };
  500. }
  501. }
  502. public AnalogDeviceDataItem MFC6
  503. {
  504. get
  505. {
  506. return new AnalogDeviceDataItem
  507. {
  508. Type = "MFC",
  509. DeviceName = MFC6Data.UniqueName,
  510. DeviceId = MFC6Data.DeviceSchematicId,
  511. DisplayName = MFC6Data.DisplayName,
  512. Scale = MFC6Data.Scale,
  513. Unit = MFC6Data.Unit,
  514. FeedBack = MFC6Data.FeedBack,
  515. SetPoint = MFC6Data.SetPoint,
  516. VirtualFeedBack = MFC6Data.VirtualFeedBack
  517. };
  518. }
  519. }
  520. public AnalogDeviceDataItem MFC7
  521. {
  522. get
  523. {
  524. return new AnalogDeviceDataItem
  525. {
  526. Type = "MFC",
  527. DeviceName = MFC7Data.UniqueName,
  528. DeviceId = MFC7Data.DeviceSchematicId,
  529. DisplayName = MFC7Data.DisplayName,
  530. Scale = MFC7Data.Scale,
  531. Unit = MFC7Data.Unit,
  532. FeedBack = MFC7Data.FeedBack,
  533. SetPoint = MFC7Data.SetPoint,
  534. VirtualFeedBack = MFC7Data.VirtualFeedBack
  535. };
  536. }
  537. }
  538. public AnalogDeviceDataItem MFC8
  539. {
  540. get
  541. {
  542. return new AnalogDeviceDataItem
  543. {
  544. Type = "MFC",
  545. DeviceName = MFC8Data.UniqueName,
  546. DeviceId = MFC8Data.DeviceSchematicId,
  547. DisplayName = MFC8Data.DisplayName,
  548. Scale = MFC8Data.Scale,
  549. Unit = MFC8Data.Unit,
  550. FeedBack = MFC8Data.FeedBack,
  551. SetPoint = MFC8Data.SetPoint,
  552. VirtualFeedBack = MFC8Data.VirtualFeedBack
  553. };
  554. }
  555. }
  556. public AnalogDeviceDataItem MFC9
  557. {
  558. get
  559. {
  560. return new AnalogDeviceDataItem
  561. {
  562. Type = "MFC",
  563. DeviceName = MFC9Data.UniqueName,
  564. DeviceId = MFC9Data.DeviceSchematicId,
  565. DisplayName = MFC9Data.DisplayName,
  566. Scale = MFC9Data.Scale,
  567. Unit = MFC9Data.Unit,
  568. FeedBack = MFC9Data.FeedBack,
  569. SetPoint = MFC9Data.SetPoint,
  570. VirtualFeedBack = MFC9Data.VirtualFeedBack
  571. };
  572. }
  573. }
  574. public AnalogDeviceDataItem MFC10
  575. {
  576. get
  577. {
  578. return new AnalogDeviceDataItem
  579. {
  580. Type = "MFC",
  581. DeviceName = MFC10Data.UniqueName,
  582. DeviceId = MFC10Data.DeviceSchematicId,
  583. DisplayName = MFC10Data.DisplayName,
  584. Scale = MFC10Data.Scale,
  585. Unit = MFC10Data.Unit,
  586. FeedBack = MFC10Data.FeedBack,
  587. SetPoint = MFC10Data.SetPoint,
  588. VirtualFeedBack = MFC10Data.VirtualFeedBack
  589. };
  590. }
  591. }
  592. public AnalogDeviceDataItem MFC11
  593. {
  594. get
  595. {
  596. return new AnalogDeviceDataItem
  597. {
  598. Type = "MFC",
  599. DeviceName = MFC11Data.UniqueName,
  600. DeviceId = MFC11Data.DeviceSchematicId,
  601. DisplayName = MFC11Data.DisplayName,
  602. Scale = MFC11Data.Scale,
  603. Unit = MFC11Data.Unit,
  604. FeedBack = MFC11Data.FeedBack,
  605. SetPoint = MFC11Data.SetPoint,
  606. VirtualFeedBack = MFC11Data.VirtualFeedBack
  607. };
  608. }
  609. }
  610. public AnalogDeviceDataItem MFC12
  611. {
  612. get
  613. {
  614. return new AnalogDeviceDataItem
  615. {
  616. Type = "MFC",
  617. DeviceName = MFC12Data.UniqueName,
  618. DeviceId = MFC12Data.DeviceSchematicId,
  619. DisplayName = MFC12Data.DisplayName,
  620. Scale = MFC12Data.Scale,
  621. Unit = MFC12Data.Unit,
  622. FeedBack = MFC12Data.FeedBack,
  623. SetPoint = MFC12Data.SetPoint,
  624. VirtualFeedBack = MFC12Data.VirtualFeedBack
  625. };
  626. }
  627. }
  628. public AnalogDeviceDataItem MFC51
  629. {
  630. get
  631. {
  632. return new AnalogDeviceDataItem
  633. {
  634. Type = "MFC",
  635. DeviceName = MFC51Data.UniqueName,
  636. DeviceId = MFC51Data.DeviceSchematicId,
  637. DisplayName = MFC51Data.DisplayName,
  638. Scale = MFC51Data.Scale,
  639. Unit = MFC51Data.Unit,
  640. FeedBack = MFC51Data.FeedBack,
  641. SetPoint = MFC51Data.SetPoint,
  642. VirtualFeedBack = MFC51Data.VirtualFeedBack
  643. };
  644. }
  645. }
  646. public AnalogDeviceDataItem MFM57
  647. {
  648. get
  649. {
  650. return new AnalogDeviceDataItem
  651. {
  652. Type = "MFM",
  653. DeviceId = MFM57Flow.DeviceSchematicId,
  654. DisplayName = MFM57Flow.DisplayName,
  655. Scale = MFM57Flow.Scale,
  656. Unit = MFM57Flow.Unit,
  657. FeedBack = MFM57Flow.FeedBack,
  658. SetPoint = MFM57Flow.SetPoint,
  659. };
  660. }
  661. }
  662. public string IsRfPowerOn
  663. {
  664. get
  665. {
  666. return IsPowerOn ? "On" : "Off";
  667. }
  668. }
  669. private bool _manualCheckSelect = false;
  670. private bool _manualCheck = true;
  671. public bool ManualCheck
  672. {
  673. get => _manualCheck;
  674. set
  675. {
  676. _manualCheck = value;
  677. NotifyOfPropertyChange(nameof(ManualCheck));
  678. }
  679. }
  680. private bool _manualCheckHide;
  681. public bool ManumalCheckHide
  682. {
  683. get => _manualCheckHide;
  684. set
  685. {
  686. _manualCheckHide = value;
  687. NotifyOfPropertyChange(nameof(ManumalCheckHide));
  688. }
  689. }
  690. public bool ValveTrue { get; set; } = true;
  691. public bool ValveFalse { get; set; } = false;
  692. private bool _enablePLCPointControl = false;
  693. public bool EnablePLCPointControl
  694. {
  695. get => _enablePLCPointControl;
  696. set
  697. {
  698. _enablePLCPointControl = value;
  699. NotifyOfPropertyChange(nameof(EnablePLCPointControl));
  700. }
  701. }
  702. public GasPanelViewModel()
  703. {
  704. CmdSetMfcFlow = new DelegateCommand<object>(PerformCmdSetMfcFlow);
  705. }
  706. public void SelectedGasStateTypeCmd(string cmd)
  707. {
  708. switch (cmd)
  709. {
  710. case "Manual":
  711. SelectedGasStateType = GasPanelStateType.Manual;
  712. ManualEnable = true;
  713. break;
  714. case "Monitor":
  715. SelectedGasStateType = GasPanelStateType.Monitor;
  716. ManualEnable = true;
  717. break;
  718. case "Recipe":
  719. SelectedGasStateType = GasPanelStateType.Recipe;
  720. ManualEnable = false;
  721. break;
  722. default:
  723. break;
  724. }
  725. }
  726. protected override void OnActivate()
  727. {
  728. base.OnActivate();
  729. // EnableServiceControl = (bool)QueryDataClient.Instance.Service.GetConfig("System.IsServiceControlMode");
  730. // IsMfcNRInstalled = (bool)QueryDataClient.Instance.Service.GetConfig("PM1.MFC.MfcNR.IsMFCInstalled");
  731. }
  732. public void SetEditClick()
  733. {
  734. IsRecipeEdit = true;
  735. // EnableServiceControl = false;
  736. }
  737. protected override void OnDeactivate(bool close)
  738. {
  739. base.OnDeactivate(close);
  740. //IsManagerPermission = false;
  741. }
  742. public void SetManual()
  743. {
  744. if (!_manualCheckSelect)
  745. {
  746. _manualCheckSelect = !_manualCheckSelect;
  747. IsManagerPermission = true;
  748. EnablePLCPointControl = false;
  749. }
  750. else
  751. {
  752. IsManagerPermission = true;
  753. ManualCheck = false;
  754. ManumalCheckHide = true;
  755. _manualCheckSelect = !_manualCheckSelect;
  756. EnablePLCPointControl = true;
  757. }
  758. }
  759. public void OpenAll()
  760. {
  761. if (!VentValveData.IsOpen)
  762. InvokeClient.Instance.Service.DoOperation($"{VentValveData.UniqueName}.{AITValveOperation.GVTurnValve}", true);
  763. if (!PumpValveData.IsOpen)
  764. InvokeClient.Instance.Service.DoOperation($"{PumpValveData.UniqueName}.{AITValveOperation.GVTurnValve}", true);
  765. }
  766. public void CloseAll()
  767. {
  768. if (PumpValveData.IsOpen)
  769. InvokeClient.Instance.Service.DoOperation($"{PumpValveData.UniqueName}.{AITValveOperation.GVTurnValve}", false);
  770. if (VentValveData.IsOpen)
  771. InvokeClient.Instance.Service.DoOperation($"{VentValveData.UniqueName}.{AITValveOperation.GVTurnValve}", false);
  772. }
  773. private void PerformCmdSetMfcFlow(object param)
  774. {
  775. object[] args = (object[])param; //0:devicename, 1:operation, 2:args
  776. if (args.Length == 3)
  777. {
  778. InvokeClient.Instance.Service.DoOperation($"{args[0]}.{args[1]}", args[2]);
  779. }
  780. }
  781. bool isSensorRecipeOK = false;
  782. Dictionary<string, object> oldresult;
  783. private Dictionary<string, object> ClearNotChangedValue(Dictionary<string, object> result)
  784. {
  785. Dictionary<string, object> temp = result;
  786. if (oldresult == null)
  787. {
  788. oldresult = result;
  789. }
  790. else
  791. {
  792. try
  793. {
  794. List<string> strkeys = new List<string>();
  795. foreach (var key in result.Keys)
  796. {
  797. if (_subscribedKeys.Contains(key) && oldresult.ContainsKey(key) && result.ContainsKey(key))
  798. {
  799. if (result[key].GetType() == typeof(AITValveData) && (((AITValveData)oldresult[key]).Feedback != ((AITValveData)result[key]).Feedback
  800. || ((AITValveData)oldresult[key]).VirtualFeedback != ((AITValveData)result[key]).VirtualFeedback))
  801. {
  802. strkeys.Add(key);
  803. }
  804. else if (result[key].GetType() == typeof(AITSensorData) && ((AITSensorData)oldresult[key]).Value != ((AITSensorData)result[key]).Value)
  805. {
  806. strkeys.Add(key);
  807. }
  808. else if (result[key].GetType() == typeof(AITMfcData) && (((AITMfcData)oldresult[key]).FeedBack != ((AITMfcData)result[key]).FeedBack ||
  809. ((AITMfcData)oldresult[key]).VirtualFeedBack != ((AITMfcData)result[key]).VirtualFeedBack))
  810. {
  811. strkeys.Add(key);
  812. }
  813. else if (result[key].GetType() == typeof(float) && (float)oldresult[key] == (float)result[key])
  814. {
  815. strkeys.Add(key);
  816. }
  817. else if (result[key].GetType() == typeof(int) && (int)oldresult[key] == (int)result[key])
  818. {
  819. strkeys.Add(key);
  820. }
  821. else if (result[key].GetType() == typeof(bool) && (bool)oldresult[key] == (bool)result[key])
  822. {
  823. strkeys.Add(key);
  824. }
  825. }
  826. }
  827. for (int i = 0; i < strkeys.Count; i++)
  828. {
  829. temp.Remove(strkeys[i]);
  830. }
  831. }
  832. catch (Exception ex)
  833. {
  834. LOG.Error("由RT返回的数据更新失败" + "ClearNotChangedValue", ex);
  835. }
  836. }
  837. return temp;
  838. }
  839. protected override void Poll()
  840. {
  841. if (_subscribedKeys.Count > 0)
  842. {
  843. Dictionary<string, object> result = QueryDataClient.Instance.Service.PollData(_subscribedKeys);
  844. Dictionary<string, object> Tempresult = new Dictionary<string, object>(result);
  845. if (SelectedGasStateType != GasPanelStateType.Monitor)
  846. {
  847. result = ClearNotChangedValue(result);
  848. }
  849. oldresult = Tempresult;
  850. if (result == null)
  851. {
  852. LOG.Error("获取RT数据失败");
  853. return;
  854. }
  855. if (result.Count != _subscribedKeys.Count)
  856. {
  857. string unknowKeys = string.Empty;
  858. foreach (string key in _subscribedKeys)
  859. {
  860. if (!result.ContainsKey(key))
  861. {
  862. unknowKeys += key + "\r\n";
  863. }
  864. }
  865. }
  866. InvokeBeforeUpdateProperty(result);
  867. UpdateValue(result);
  868. Application.Current?.Dispatcher.Invoke(new Action(() =>
  869. {
  870. if (result.Count != 0)
  871. {
  872. InvokePropertyChanged();
  873. }
  874. InvokeAfterUpdateProperty(result);
  875. }));
  876. }
  877. }
  878. protected override void InvokeBeforeUpdateProperty(Dictionary<string, object> data)
  879. {
  880. //List<string> aITValveDataKeys = new List<string>();
  881. //List<string> aITSensorDataKeys = new List<string>();
  882. //List<string> aITMfcDataKeys = new List<string>();
  883. //foreach (var item in data.Keys)
  884. //{
  885. // try
  886. // {
  887. // if (data[item].GetType() == typeof(AITValveData))
  888. // {
  889. // var array = item.Split('.');
  890. // if (array.Length > 1)
  891. // {
  892. // var name = array[1];
  893. // var property = this.GetType().GetProperties().Where(x => x.Name == name).FirstOrDefault();
  894. // object value = property.GetValue(this, null);
  895. // if (value != null && ((AITValveData)value).Equals((AITValveData)data[item]))
  896. // aITValveDataKeys.Add(item);
  897. // }
  898. // }
  899. // else if (data[item].GetType() == typeof(AITSensorData))
  900. // {
  901. // var array = item.Split('.');
  902. // if (array.Length > 1)
  903. // {
  904. // var name = array[1];
  905. // var property = this.GetType().GetProperties().Where(x => x.Name == name).FirstOrDefault();
  906. // object value = property.GetValue(this, null);
  907. // if (value != null && ((AITSensorData)value).Equals((AITSensorData)data[item]))
  908. // aITSensorDataKeys.Add(item);
  909. // }
  910. // }
  911. // else if (data[item].GetType() == typeof(AITMfcData))
  912. // {
  913. // var array = item.Split('.');
  914. // if (array.Length > 1)
  915. // {
  916. // var name = array[1];
  917. // var property = this.GetType().GetProperties().Where(x => x.Name == $"{name}Data").FirstOrDefault();
  918. // object value = property.GetValue(this, null);
  919. // if (value != null && ((AITMfcData)value).Equals((AITMfcData)data[item]))
  920. // aITMfcDataKeys.Add(item);
  921. // }
  922. // }
  923. // }
  924. // catch (Exception ex)
  925. // {
  926. // Console.WriteLine(ex.Message);
  927. // }
  928. //}
  929. //if (aITValveDataKeys.Count > 0)
  930. //{
  931. // foreach (var item in aITValveDataKeys)
  932. // {
  933. // data.Remove(item);
  934. // }
  935. //}
  936. //if (aITSensorDataKeys.Count > 0)
  937. //{
  938. // foreach (var item in aITSensorDataKeys)
  939. // {
  940. // data.Remove(item);
  941. // }
  942. //}
  943. //if (aITMfcDataKeys.Count > 0)
  944. //{
  945. // foreach (var item in aITMfcDataKeys)
  946. // {
  947. // data.Remove(item);
  948. // }
  949. //}
  950. base.InvokeBeforeUpdateProperty(data);
  951. }
  952. protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)
  953. {
  954. base.InvokeAfterUpdateProperty(data);
  955. if (SensorRecipeOK != null && SensorRecipeOK.Value)
  956. {
  957. if (isSensorRecipeOK != SensorRecipeOK.Value)
  958. {
  959. _manualCheckSelect = false;
  960. IsManagerPermission = true;
  961. IsRecipeEdit = true;
  962. // EnableServiceControl = false;
  963. }
  964. isSensorRecipeOK = SensorRecipeOK.Value;
  965. }
  966. }
  967. public void SwichValue(string name)
  968. {
  969. if (SelectedGasStateType == GasPanelStateType.Monitor || SelectedGasStateType == GasPanelStateType.Recipe) return;
  970. var dialog = new SwitchValueDialog { };
  971. dialog.IsOpen = true;
  972. switch (name.ToUpper())
  973. {
  974. case "BWR":
  975. dialog.IsOpen = ValveBWR.Feedback;
  976. break;
  977. case "DPR":
  978. dialog.IsOpen = ValveDPR.Feedback;
  979. break;
  980. case "F2":
  981. dialog.IsOpen = IsF2ClnOn;
  982. break;
  983. case "HF":
  984. dialog.IsOpen = IsHFClnOn;
  985. break;
  986. }
  987. dialog.Owner = WinOwner;
  988. dialog.Topmost = true;
  989. dialog.WindowStartupLocation = WindowStartupLocation.CenterScreen;
  990. dialog.DeviceName = $"Swich {name}";
  991. dialog.ShowDialog();
  992. if ((bool)dialog.IsSave)
  993. {
  994. switch (name.ToUpper())
  995. {
  996. case "BWR":
  997. InvokeClient.Instance.Service.DoOperation($"{ValveBWR.UniqueName}.{AITValveOperation.GVTurnValve}", dialog.IsOpen);
  998. break;
  999. case "DPR":
  1000. InvokeClient.Instance.Service.DoOperation($"{ValveDPR.UniqueName}.{AITValveOperation.GVTurnValve}", dialog.IsOpen);
  1001. break;
  1002. case "F2":
  1003. InvokeClient.Instance.Service.DoOperation($"PM1.SetF2ClnEnable", dialog.IsOpen);
  1004. break;
  1005. case "HF":
  1006. InvokeClient.Instance.Service.DoOperation($"PM1.SetHFClnEnable", dialog.IsOpen);
  1007. break;
  1008. }
  1009. }
  1010. }
  1011. public void SetEnable(string name)
  1012. {
  1013. if (SelectedGasStateType == GasPanelStateType.Monitor || SelectedGasStateType == GasPanelStateType.Recipe) return;
  1014. var dialog = new SwitchValueDialog2 { };
  1015. dialog.IsOpen = true;
  1016. switch (name.ToUpper())
  1017. {
  1018. case "HTR1":
  1019. dialog.IsOpen = IsHTR1Enable;
  1020. break;
  1021. case "HTR2":
  1022. dialog.IsOpen = IsHTR2Enable;
  1023. break;
  1024. }
  1025. dialog.Owner = WinOwner;
  1026. dialog.Topmost = true;
  1027. dialog.WindowStartupLocation = WindowStartupLocation.CenterScreen;
  1028. dialog.DeviceName = $"Swich {name}";
  1029. dialog.ShowDialog();
  1030. if ((bool)dialog.IsSave)
  1031. {
  1032. switch (name.ToUpper())
  1033. {
  1034. case "HTR1":
  1035. InvokeClient.Instance.Service.DoOperation($"PM1.SetHTR1Enable", dialog.IsOpen);
  1036. break;
  1037. case "HTR2":
  1038. InvokeClient.Instance.Service.DoOperation($"PM1.SetHTR2Enable", dialog.IsOpen);
  1039. break;
  1040. }
  1041. }
  1042. }
  1043. public void SelectPump(string _pumpname)
  1044. {
  1045. if (SelectedGasStateType == GasPanelStateType.Monitor || SelectedGasStateType == GasPanelStateType.Recipe) return;
  1046. if (!DialogBox.Confirm($"Are you sure change {_pumpname} status?"))
  1047. return;
  1048. if (_pumpname == "AUC")
  1049. {
  1050. InvokeClient.Instance.Service.DoOperation($"{AUCPump.UniqueName}.{AITValveOperation.GVTurnValve}", !AUCPump.Feedback);
  1051. }
  1052. if (_pumpname == "AGV")
  1053. {
  1054. InvokeClient.Instance.Service.DoOperation($"{AGVPump.UniqueName}.{AITValveOperation.GVTurnValve}", !AGVPump.Feedback);
  1055. }
  1056. if (_pumpname == "Both")
  1057. {
  1058. InvokeClient.Instance.Service.DoOperation($"{BothPump.UniqueName}.{AITValveOperation.GVTurnValve}", !BothPump.Feedback);
  1059. }
  1060. }
  1061. }
  1062. }