GasPanelViewModel.cs 33 KB

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