StandardHotReservoirsViewModel.cs 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075
  1. using MECF.Framework.Common.CommonData.Metal;
  2. using MECF.Framework.Common.CommonData.Reservoir;
  3. using MECF.Framework.Common.DataCenter;
  4. using MECF.Framework.Common.OperationCenter;
  5. using MECF.Framework.Common.Persistent.Reservoirs;
  6. using MECF.Framework.Common.RecipeCenter;
  7. using MECF.Framework.Common.Utilities;
  8. using CyberX8_Core;
  9. using CyberX8_MainPages.PMs;
  10. using Prism.Commands;
  11. using Prism.Mvvm;
  12. using System;
  13. using System.Collections.Generic;
  14. using System.Collections.ObjectModel;
  15. using System.Windows.Input;
  16. using System.Windows.Threading;
  17. using MECF.Framework.Common.CommonData.TemperatureControl;
  18. using MECF.Framework.Common.CommonData.PowerSupplier;
  19. using MECF.Framework.Common.Device.Safety;
  20. using MECF.Framework.Common.ProcessCell;
  21. namespace CyberX8_MainPages.ViewModels
  22. {
  23. public class StandardHotReservoirsViewModel : BindableBase
  24. {
  25. #region 常量
  26. private const string RESERVOIRS_DATA = "ReservoirsData";
  27. private const string RESERVOIRS = "reservoirs";
  28. private const string PERSISTENT_VALUE = "PersistentValue";
  29. private const string METALDEVICEDATA = "MetalDeviceData";
  30. private const string RESERVOIRDEVICEDATA = "ReservoirDeviceData";
  31. private const string REPLEN_PERSISTENT_VALUE = "ReplenPersistentValue";
  32. #endregion
  33. #region 内部变量
  34. #region system
  35. /// <summary>
  36. /// rt查询key
  37. /// </summary>
  38. private List<string> _rtDataKeys = new List<string>();
  39. /// <summary>
  40. /// 时钟
  41. /// </summary>
  42. DispatcherTimer _timer;
  43. /// <summary>
  44. /// rt查询数据
  45. /// </summary>
  46. private Dictionary<string, object> _rtDataValueDic = new Dictionary<string, object>();
  47. #endregion
  48. #region Common
  49. private double _avgLevel;
  50. /// <summary>
  51. /// Module
  52. /// </summary>
  53. private string _module;
  54. /// <summary>
  55. /// Operation Mode
  56. /// </summary>
  57. private string _operatingMode;
  58. /// <summary>
  59. /// 状态
  60. /// </summary>
  61. private string _state;
  62. /// <summary>
  63. /// Reservoirs Persistent数据
  64. /// </summary>
  65. private ReservoirsPersistentValue _reservoirsPersistent;
  66. /// <summary>
  67. /// Reservoir数据
  68. /// </summary>
  69. private StandardHotReservoirData _reservoirData;
  70. /// <summary>
  71. /// Metal数据集合
  72. /// </summary>
  73. private ObservableCollection<StandardHotMetalDeviceData> _metalDataCollection = new ObservableCollection<StandardHotMetalDeviceData>();
  74. /// <summary>
  75. /// CellModuleName集合
  76. /// </summary>
  77. private ObservableCollection<string> _cellModuleNameCollection = new ObservableCollection<string>();
  78. /// <summary>
  79. /// Cells数量
  80. /// </summary>
  81. private int _cellsCount;
  82. /// <summary>
  83. /// 手动注水时长(秒)
  84. /// </summary>
  85. private int _manualFillSeconds;
  86. /// <summary>
  87. /// 是否正在手动注水
  88. /// </summary>
  89. private bool _isManualReplen;
  90. /// <summary>
  91. /// DIValveMaxOnTime
  92. /// </summary>
  93. private double _diValveMaxOnTime;
  94. /// <summary>
  95. /// 是否超过PH值下限
  96. /// </summary>
  97. private bool _isPHLowLimit;
  98. /// <summary>
  99. /// 是否超过PH值下限
  100. /// </summary>
  101. private bool _isPHHighLimit;
  102. /// <summary>
  103. /// TemperatureControl Module Name
  104. /// </summary>
  105. private TemperatureControllerData _temperatureControlData;
  106. /// <summary>
  107. /// PowerSupply Module Name
  108. /// </summary>
  109. private PowerSupplierData _cmmPowerSupplierData;
  110. /// <summary>
  111. /// 是否超过HighLevel
  112. /// </summary>
  113. private bool _isHighLevel;
  114. /// <summary>
  115. /// 是否超过LowLevel
  116. /// </summary>
  117. private bool _isLowLevel;
  118. /// <summary>
  119. /// 是否触发highsafety
  120. /// </summary>
  121. private bool _isHighSafety;
  122. /// <summary>
  123. /// HED Flow
  124. /// </summary>
  125. private bool _hedFlowIsOn;
  126. /// <summary>
  127. /// DiReplen是否报错
  128. /// </summary>
  129. private bool _isDiReplenFault;
  130. /// <summary>
  131. /// Safety Data
  132. /// </summary>
  133. private SafetyData _safetyData;
  134. /// <summary>
  135. /// 页面功能启用
  136. /// </summary>
  137. private bool _isEnabled;
  138. /// <summary>
  139. /// AutoMode页面功能启用
  140. /// </summary>
  141. private bool _isAutoEnabled;
  142. /// <summary>
  143. /// DosingSystem是否启用
  144. /// </summary>
  145. private bool _isDosingSystemEnabled;
  146. /// <summary>
  147. /// TC Enable状态
  148. /// </summary>
  149. private string _tcEnableStatus;
  150. /// <summary>
  151. /// 是否error状态
  152. /// </summary>
  153. private bool _isError;
  154. #endregion
  155. #region Recipe
  156. /// <summary>
  157. /// 当前的recipe
  158. /// </summary>
  159. private ResRecipe _currentRecipe;
  160. /// <summary>
  161. /// Recipe Mode
  162. /// </summary>
  163. private string _recipeMode;
  164. /// <summary>
  165. /// Selected Recipe Node
  166. /// </summary>
  167. private RecipeNode _selectedRecipeNode;
  168. /// <summary>
  169. /// Recipe Type
  170. /// </summary>
  171. private string _recipeType;
  172. /// <summary>
  173. /// Recipe Manager
  174. /// </summary>
  175. private UiRecipeManager _uiRecipeManager = new UiRecipeManager();
  176. #endregion
  177. #region CMM
  178. /// <summary>
  179. /// Flow High 状态(Warning:黄色,Error:红色)
  180. /// </summary>
  181. private string _flowHighStatus = "";
  182. /// <summary>
  183. /// Flow Low 状态(Warning:黄色,Error:红色)
  184. /// </summary>
  185. private string _flowLowStatus = "";
  186. /// <summary>
  187. /// PowerSupplier High电流状态
  188. /// </summary>
  189. private string _currentHighStatus = "";
  190. /// <summary>
  191. /// PowerSupplier Low电流状态
  192. /// </summary>
  193. private string _currentLowStatus = "";
  194. /// <summary>
  195. /// 是否低于最小电压
  196. /// </summary>
  197. private bool _isBelowMinVoltage = false;
  198. /// <summary>
  199. /// CMM Anode AHrs
  200. /// </summary>
  201. private double _reservoirCMMAnodeAHrs;
  202. /// <summary>
  203. /// CMM Cathode AHrs
  204. /// </summary>
  205. private double _reservoirCMMCathodeAHrs;
  206. /// <summary>
  207. /// CMM Anode用电量
  208. /// </summary>
  209. private double _cmmAnodeUsage;
  210. /// <summary>
  211. /// CMM Cathode用电量
  212. /// </summary>
  213. private double _cmmCathodeUsage;
  214. /// <summary>
  215. /// CMM Flow High Warning
  216. /// </summary>
  217. private double _reservoirCMMFlowHighWarning;
  218. /// <summary>
  219. /// CMM Flow High Error
  220. /// </summary>
  221. private double _reservoirCMMFlowHighError;
  222. /// <summary>
  223. /// CMM Flow Low Warning
  224. /// </summary>
  225. private double _reservoirCMMFlowLowWarning;
  226. /// <summary>
  227. /// CMM Flow Low Error
  228. /// </summary>
  229. private double _reservoirCMMFlowLowError;
  230. /// <summary>
  231. /// CMM Anode LifeTime AHrs
  232. /// </summary>
  233. private double _reservoirCMMAnodeLifeTimeAHrs;
  234. /// <summary>
  235. /// CMM Cathode LifeTime AHrs
  236. /// </summary>
  237. private double _reservoirCMMCathodeLifeTimeAHrs;
  238. /// <summary>
  239. /// HighLevel
  240. /// </summary>
  241. private double _reservoirHighLevel;
  242. /// <summary>
  243. /// LowLevel
  244. /// </summary>
  245. private double _reservoirLowLevel;
  246. /// <summary>
  247. /// CMM电量limit
  248. /// </summary>
  249. private double _cmmAnodeTotalAmpHoursWarningLimit;
  250. private double _cmmAnodeTotalAmpHoursFaultLimit;
  251. private double _cmmCathodeTotalAmpHoursWarningLimit;
  252. private double _cmmCathodeTotalAmpHoursFaultLimit;
  253. /// <summary>
  254. /// CMM电量报警灯
  255. /// </summary>
  256. private bool _isCMMAnodeTotalAmpHoursWarning;
  257. private bool _isCMMAnodeTotalAmpHoursFault;
  258. private bool _isCMMCathodeTotalAmpHoursWarning;
  259. private bool _isCMMCathodeTotalAmpHoursFault;
  260. #endregion
  261. #endregion
  262. #region 属性
  263. #region Common
  264. public double AvgLevel
  265. {
  266. get { return _avgLevel; }
  267. set { SetProperty(ref _avgLevel, value); }
  268. }
  269. /// <summary>
  270. /// Module
  271. /// </summary>
  272. public string Module
  273. {
  274. get { return _module; }
  275. set { SetProperty(ref _module, value); }
  276. }
  277. /// <summary>
  278. /// Operation Mode
  279. /// </summary>
  280. public string OperatingMode
  281. {
  282. get { return _operatingMode; }
  283. set { SetProperty(ref _operatingMode, value); }
  284. }
  285. /// <summary>
  286. /// 状态
  287. /// </summary>
  288. public string State
  289. {
  290. get { return _state; }
  291. set { SetProperty(ref _state, value); }
  292. }
  293. /// <summary>
  294. /// Reservoirs Persistent数据
  295. /// </summary>
  296. public ReservoirsPersistentValue ReservoirsPersistent
  297. {
  298. get { return _reservoirsPersistent; }
  299. set { SetProperty(ref _reservoirsPersistent, value); }
  300. }
  301. /// <summary>
  302. /// Reservoir数据
  303. /// </summary>
  304. public StandardHotReservoirData ReservoirData
  305. {
  306. get { return _reservoirData; }
  307. set { SetProperty(ref _reservoirData, value); }
  308. }
  309. /// <summary>
  310. /// Metal数据集合
  311. /// </summary>
  312. public ObservableCollection<StandardHotMetalDeviceData> MetalDataCollection
  313. {
  314. get { return _metalDataCollection; }
  315. set { SetProperty(ref _metalDataCollection, value); }
  316. }
  317. /// <summary>
  318. /// CellModuleName集合
  319. /// </summary>
  320. public ObservableCollection<string> CellModuleNameCollection
  321. {
  322. get { return _cellModuleNameCollection; }
  323. set { SetProperty(ref _cellModuleNameCollection, value); }
  324. }
  325. /// <summary>
  326. /// Cells数量
  327. /// </summary>
  328. public int CellsCount
  329. {
  330. get { return _cellsCount; }
  331. set { SetProperty(ref _cellsCount, value); }
  332. }
  333. /// <summary>
  334. /// 是否超过PH值下限
  335. /// </summary>
  336. public bool IsPHLowLimit
  337. {
  338. get { return _isPHLowLimit; }
  339. set { SetProperty(ref _isPHLowLimit, value); }
  340. }
  341. /// <summary>
  342. /// 是否超过PH值下限
  343. /// </summary>
  344. public bool IsPHHighLimit
  345. {
  346. get { return _isPHHighLimit; }
  347. set { SetProperty(ref _isPHHighLimit, value); }
  348. }
  349. /// <summary>
  350. /// 手动注水时长(秒)
  351. /// </summary>
  352. public int ManualFillSeconds
  353. {
  354. get { return _manualFillSeconds; }
  355. set { SetProperty(ref _manualFillSeconds, value); }
  356. }
  357. /// <summary>
  358. /// 是否正在手动注水
  359. /// </summary>
  360. public bool IsManualReplen
  361. {
  362. get { return _isManualReplen; }
  363. set { SetProperty(ref _isManualReplen, value); }
  364. }
  365. /// <summary>
  366. /// DIValveMaxOnTime
  367. /// </summary>
  368. public double DIValveMaxOnTime
  369. {
  370. get { return _diValveMaxOnTime; }
  371. set { SetProperty(ref _diValveMaxOnTime, value);}
  372. }
  373. /// <summary>
  374. /// TemperatureControl Module Name
  375. /// </summary>
  376. public TemperatureControllerData TemperatureControlData
  377. {
  378. get { return _temperatureControlData; }
  379. set { SetProperty(ref _temperatureControlData, value); }
  380. }
  381. /// <summary>
  382. /// PowerSupply Module Name
  383. /// </summary>
  384. public PowerSupplierData CmmPowerSupplierData
  385. {
  386. get { return _cmmPowerSupplierData; }
  387. set { SetProperty(ref _cmmPowerSupplierData, value); }
  388. }
  389. /// <summary>
  390. /// 是否超过HighLevel
  391. /// </summary>
  392. public bool IsHighLevel
  393. {
  394. get { return _isHighLevel; }
  395. set { SetProperty(ref _isHighLevel, value); }
  396. }
  397. /// <summary>
  398. /// 是否超过LowLevel
  399. /// </summary>
  400. public bool IsLowLevel
  401. {
  402. get { return _isLowLevel; }
  403. set { SetProperty(ref _isLowLevel, value); }
  404. }
  405. /// <summary>
  406. /// 是否触发Highsafety
  407. /// </summary>
  408. public bool IsHighSafety
  409. {
  410. get { return _isHighSafety; }
  411. set { SetProperty(ref _isHighSafety, value); }
  412. }
  413. /// <summary>
  414. /// HED Flow
  415. /// </summary>
  416. public bool HEDFlowIsOn
  417. {
  418. get { return _hedFlowIsOn; }
  419. set { SetProperty(ref _hedFlowIsOn, value); }
  420. }
  421. /// <summary>
  422. /// DI Replen是否报错
  423. /// </summary>
  424. public bool IsDiReplenFault
  425. {
  426. get { return _isDiReplenFault; }
  427. set { SetProperty(ref _hedFlowIsOn, value); }
  428. }
  429. /// <summary>
  430. /// Safety数据
  431. /// </summary>
  432. public SafetyData CommonSafetyData
  433. {
  434. get { return _safetyData; }
  435. set { SetProperty(ref _safetyData, value); }
  436. }
  437. /// <summary>
  438. /// 页面功能启用
  439. /// </summary>
  440. public bool IsEnabled
  441. {
  442. get { return _isEnabled; }
  443. set { SetProperty(ref _isEnabled, value); }
  444. }
  445. /// <summary>
  446. /// AutoMode页面功能启用
  447. /// </summary>
  448. public bool IsAutoEnabled
  449. {
  450. get { return _isAutoEnabled; }
  451. set { SetProperty(ref _isAutoEnabled, value); }
  452. }
  453. /// <summary>
  454. /// DosingSystem是否启用
  455. /// </summary>
  456. public bool IsDosingSystemEnabled
  457. {
  458. get { return _isDosingSystemEnabled; }
  459. set { SetProperty(ref _isDosingSystemEnabled, value); }
  460. }
  461. /// <summary>
  462. /// TC Enable状态
  463. /// </summary>
  464. public string TCEnableStatus
  465. {
  466. get { return _tcEnableStatus; }
  467. set { SetProperty(ref _tcEnableStatus, value); }
  468. }
  469. /// <summary>
  470. /// 是否Error
  471. /// </summary>
  472. public bool IsError
  473. {
  474. get { return _isError; }
  475. set { SetProperty(ref _isError, value); }
  476. }
  477. #endregion
  478. #region Recipe
  479. /// <summary>
  480. /// Recipe内容
  481. /// </summary>
  482. public ResRecipe CurrentRecipe
  483. {
  484. get { return _currentRecipe; }
  485. set { SetProperty(ref _currentRecipe, value); }
  486. }
  487. /// <summary>
  488. /// Selected Recipe Node
  489. /// </summary>
  490. public RecipeNode SelectedRecipeNode
  491. {
  492. get { return _selectedRecipeNode; }
  493. set { SetProperty(ref _selectedRecipeNode, value); }
  494. }
  495. /// <summary>
  496. /// Recipe Mode
  497. /// </summary>
  498. public string RecipeMode
  499. {
  500. get { return _recipeMode; }
  501. set { SetProperty(ref _recipeMode, value); }
  502. }
  503. /// <summary>
  504. /// Recipe Type
  505. /// </summary>
  506. public string RecipeType
  507. {
  508. get { return _recipeType; }
  509. set { SetProperty(ref _recipeType, value); }
  510. }
  511. #endregion
  512. #region CMM
  513. /// <summary>
  514. /// Flow High 状态(Warning:黄色,Error:红色)
  515. /// </summary>
  516. public string FlowHighStatus
  517. {
  518. get { return _flowHighStatus; }
  519. set { SetProperty(ref _flowHighStatus, value); }
  520. }
  521. /// <summary>
  522. /// Flow Low 状态(Warning:黄色,Error:红色)
  523. /// </summary>
  524. public string FlowLowStatus
  525. {
  526. get { return _flowLowStatus; }
  527. set { SetProperty(ref _flowLowStatus, value); }
  528. }
  529. /// <summary>
  530. /// PowerSupplier High电流状态
  531. /// </summary>
  532. public string CurrentHighStatus
  533. {
  534. get { return _currentHighStatus; }
  535. set { SetProperty(ref _currentHighStatus, value); }
  536. }
  537. /// <summary>
  538. /// PowerSupplier Low电流状态
  539. /// </summary>
  540. public string CurrentLowStatus
  541. {
  542. get { return _currentLowStatus; }
  543. set { SetProperty(ref _currentLowStatus, value); }
  544. }
  545. /// <summary>
  546. /// 是否低于最小电压
  547. /// </summary>
  548. public bool IsBelowMinVoltage
  549. {
  550. get { return _isBelowMinVoltage; }
  551. set { SetProperty(ref _isBelowMinVoltage, value); }
  552. }
  553. /// <summary>
  554. /// CMM Anode 用电量
  555. /// </summary>
  556. public double CMMAnodeAHrs
  557. {
  558. get { return _reservoirCMMAnodeAHrs; ; }
  559. set { SetProperty(ref _reservoirCMMAnodeAHrs, value); }
  560. }
  561. /// <summary>
  562. /// CMM Cathode 用电量
  563. /// </summary>
  564. public double CMMCathodeAHrs
  565. {
  566. get { return _reservoirCMMCathodeAHrs; ; }
  567. set { SetProperty(ref _reservoirCMMCathodeAHrs, value); }
  568. }
  569. #endregion
  570. #region Config
  571. /// <summary>
  572. /// CMM Anode LifeTime用电量
  573. /// </summary>
  574. public double CMMAnodeLifeTimeAHrs
  575. {
  576. get { return _reservoirCMMAnodeLifeTimeAHrs; ; }
  577. set { SetProperty(ref _reservoirCMMAnodeLifeTimeAHrs, value); }
  578. }
  579. /// <summary>
  580. /// CMM Cathode LifeTime用电量
  581. /// </summary>
  582. public double CMMCathodeLifeTimeAHrs
  583. {
  584. get { return _reservoirCMMCathodeLifeTimeAHrs; ; }
  585. set { SetProperty(ref _reservoirCMMCathodeLifeTimeAHrs, value); }
  586. }
  587. /// <summary>
  588. /// CMM Anode用电量
  589. /// </summary>
  590. public double CMMAnodeUsage
  591. {
  592. get { return _cmmAnodeUsage; ; }
  593. set { SetProperty(ref _cmmAnodeUsage, value); }
  594. }
  595. /// <summary>
  596. /// CMM Cathode用电量
  597. /// </summary>
  598. public double CMMCathodeUsage
  599. {
  600. get { return _cmmCathodeUsage; ; }
  601. set { SetProperty(ref _cmmCathodeUsage, value); }
  602. }
  603. /// <summary>
  604. /// CMM电量报警灯
  605. /// </summary>
  606. public bool IsCMMAnodeTotalAmpHoursWarning
  607. {
  608. get { return _isCMMAnodeTotalAmpHoursWarning; }
  609. set { SetProperty(ref _isCMMAnodeTotalAmpHoursWarning, value); }
  610. }
  611. public bool IsCMMAnodeTotalAmpHoursFault
  612. {
  613. get { return _isCMMAnodeTotalAmpHoursFault; }
  614. set { SetProperty(ref _isCMMAnodeTotalAmpHoursFault, value); }
  615. }
  616. public bool IsCMMCathodeTotalAmpHoursWarning
  617. {
  618. get { return _isCMMCathodeTotalAmpHoursWarning; }
  619. set { SetProperty(ref _isCMMCathodeTotalAmpHoursWarning, value); }
  620. }
  621. public bool IsCMMCathodeTotalAmpHoursFault
  622. {
  623. get { return _isCMMCathodeTotalAmpHoursFault; }
  624. set { SetProperty(ref _isCMMCathodeTotalAmpHoursFault, value); }
  625. }
  626. #endregion
  627. #endregion
  628. #region 命令
  629. public ICommand InitializeCommand { get; set; }
  630. public ICommand OpenDIReplenValveCommand { get; set; }
  631. public ICommand CloseDIReplenValveCommand { get; set; }
  632. public ICommand OpenCellFlow1Command { get; set; }
  633. public ICommand OpenCellBypass1Command { get; set; }
  634. public ICommand OpenCellFlow2Command { get; set; }
  635. public ICommand OpenCellBypass2Command { get; set; }
  636. public ICommand OpenClampValve1Command { get; set; }
  637. public ICommand CloseClampValve1Command { get; set; }
  638. public ICommand OpenClampValve2Command { get; set; }
  639. public ICommand CloseClampValve2Command { get; set; }
  640. public ICommand ManualDireplenCommand { get; set; }
  641. public ICommand ResetTotalCommand { get; set; }
  642. public ICommand GotoPMCounterCommand { get; set; }
  643. public ICommand JumpDosingSystemCommand { get; set; }
  644. #endregion
  645. /// <summary>
  646. /// 构造函数
  647. /// </summary>
  648. public StandardHotReservoirsViewModel()
  649. {
  650. InitializeCommand = new DelegateCommand<object>(InitializeAction);
  651. OpenDIReplenValveCommand = new DelegateCommand<object>(OnOpenDIReplenValve);
  652. CloseDIReplenValveCommand = new DelegateCommand<object>(OnCloseDIReplenValve);
  653. OpenCellFlow1Command = new DelegateCommand<object>(OnCellFlow1);
  654. OpenCellBypass1Command = new DelegateCommand<object>(OnCellBypass1);
  655. OpenCellFlow2Command = new DelegateCommand<object>(OnCellFlow2);
  656. OpenCellBypass2Command = new DelegateCommand<object>(OnCellBypass2);
  657. OpenClampValve1Command = new DelegateCommand<object>(OnOpenClampValve1);
  658. CloseClampValve1Command = new DelegateCommand<object>(OnCloseClampValve1);
  659. OpenClampValve2Command = new DelegateCommand<object>(OnOpenClampValve2);
  660. CloseClampValve2Command = new DelegateCommand<object>(OnCloseClampValve2);
  661. ManualDireplenCommand = new DelegateCommand<object>(ManualDireplenAction);
  662. ResetTotalCommand = new DelegateCommand(ResetTotalAction);
  663. GotoPMCounterCommand = new DelegateCommand<object>(GotoPMCounterAction);
  664. JumpDosingSystemCommand = new DelegateCommand<object>(JumpDosingSystemAction);
  665. }
  666. /// <summary>
  667. /// 加载数据
  668. /// </summary>
  669. public void LoadData(string systemName)
  670. {
  671. RecipeType = "res";
  672. Module = systemName;
  673. _rtDataKeys.Clear();
  674. _rtDataKeys.Add($"{Module}.Metals");
  675. _rtDataKeys.Add($"{Module}.ReplenType");
  676. Dictionary<string,object> tmpMetals = QueryDataClient.Instance.Service.PollData(_rtDataKeys);
  677. if (tmpMetals != null)
  678. {
  679. string replenType = CommonFunction.GetValue<string>(tmpMetals, $"{Module}.ReplenType");
  680. IsDosingSystemEnabled = replenType != "" ? true : false;
  681. List<string> strMetals = CommonFunction.GetValue<List<string>>(tmpMetals, $"{Module}.Metals");
  682. CellsCount = strMetals.Count;
  683. if(strMetals!=null&& CellsCount>= 2)
  684. {
  685. CellModuleNameCollection.Clear();
  686. MetalDataCollection.Clear();
  687. for (int i = 0; i < CellsCount; i++)
  688. {
  689. string metal=strMetals[i];
  690. if (!string.IsNullOrEmpty(metal))
  691. {
  692. CellModuleNameCollection.Add(metal);
  693. _rtDataKeys.Add($"{metal}.MetalData");
  694. }
  695. MetalDataCollection.Add(new StandardHotMetalDeviceData());
  696. }
  697. }
  698. }
  699. _rtDataKeys.Add($"{Module}.ReservoirData");
  700. _rtDataKeys.Add($"{Module}.PersistentValue");
  701. _rtDataKeys.Add($"{Module}.IsManualReplen");
  702. _rtDataKeys.Add($"{Module}.DIValveMaxOnTime");
  703. _rtDataKeys.Add($"{Module}.CurrentRecipe");
  704. _rtDataKeys.Add($"{Module}.TemperatureControllerData");
  705. _rtDataKeys.Add($"{Module}.CmmPowerSupplierData");
  706. _rtDataKeys.Add($"Safety.SafetyData");
  707. _rtDataKeys.Add($"{Module}.FsmState");
  708. _rtDataKeys.Add($"{Module}.ReservoirAverageLevel");
  709. _rtDataKeys.Add($"{Module}.ReservoirUsage");
  710. if (_timer == null)
  711. {
  712. _timer = new DispatcherTimer();
  713. _timer.Interval = TimeSpan.FromMilliseconds(200);
  714. _timer.Tick += Timer_Tick;
  715. }
  716. _timer.Start();
  717. //加载Config
  718. _reservoirCMMFlowHighWarning = Convert.ToDouble(QueryDataClient.Instance.Service.GetConfig("Reservoir.CMM.CMMFlowHighWarning"));
  719. _reservoirCMMFlowHighError = Convert.ToDouble(QueryDataClient.Instance.Service.GetConfig("Reservoir.CMM.CMMFlowHighFault"));
  720. _reservoirCMMFlowLowWarning = Convert.ToDouble(QueryDataClient.Instance.Service.GetConfig("Reservoir.CMM.CMMFlowLowWarning"));
  721. _reservoirCMMFlowLowError = Convert.ToDouble(QueryDataClient.Instance.Service.GetConfig("Reservoir.CMM.CMMFlowLowFault"));
  722. CMMAnodeLifeTimeAHrs = Convert.ToDouble(QueryDataClient.Instance.Service.GetConfig("Reservoir.CMM.CMMAnodeLifeTimeAHrs"));
  723. CMMCathodeLifeTimeAHrs = Convert.ToDouble(QueryDataClient.Instance.Service.GetConfig("Reservoir.CMM.CMMCathodeLifeTimeAHrs"));
  724. _reservoirHighLevel = Convert.ToDouble(QueryDataClient.Instance.Service.GetConfig($"Reservoir.{Module}.HighLevel"));
  725. _cmmAnodeTotalAmpHoursWarningLimit = (double)Convert.ToDouble(QueryDataClient.Instance.Service.GetConfig("Reservoir.CMM.CMMAnodeTotalAmpHoursWarningLimit"));
  726. _cmmAnodeTotalAmpHoursFaultLimit = (double)Convert.ToDouble(QueryDataClient.Instance.Service.GetConfig("Reservoir.CMM.CMMAnodeTotalAmpHoursFaultLimit"));
  727. _cmmCathodeTotalAmpHoursWarningLimit = (double)Convert.ToDouble(QueryDataClient.Instance.Service.GetConfig("Reservoir.CMM.CMMCathodeTotalAmpHoursWarningLimit"));
  728. _cmmCathodeTotalAmpHoursFaultLimit = (double)Convert.ToDouble(QueryDataClient.Instance.Service.GetConfig("Reservoir.CMM.CMMCathodeTotalAmpHoursFaultLimit"));
  729. }
  730. #region 命令方法
  731. /// <summary>
  732. /// 初始化
  733. /// </summary>
  734. /// <param name="param"></param>
  735. private void InitializeAction(object param)
  736. {
  737. InvokeClient.Instance.Service.DoOperation($"{Module}.InitializeAll");
  738. }
  739. /// <summary>
  740. /// 重置TotalTime
  741. /// </summary>
  742. private void ResetTotalAction()
  743. {
  744. InvokeClient.Instance.Service.DoOperation($"{Module}.ResetTotalTime");
  745. }
  746. /// <summary>
  747. /// Cell1三向阀开启CellFlow
  748. /// </summary>
  749. /// <param name="obj"></param>
  750. private void OnCellFlow1(object param)
  751. {
  752. if(CellModuleNameCollection[0] != "")
  753. {
  754. InvokeClient.Instance.Service.DoOperation($"{CellModuleNameCollection[0]}.CellSwitchToFlow");
  755. }
  756. }
  757. /// <summary>
  758. /// Cell1三向阀开启CellBypass
  759. /// </summary>
  760. private void OnCellBypass1(object param)
  761. {
  762. if(CellModuleNameCollection[0] != "")
  763. {
  764. InvokeClient.Instance.Service.DoOperation($"{CellModuleNameCollection[0]}.CellSwitchToBypass");
  765. }
  766. }
  767. /// <summary>
  768. /// Cell2三向阀开启CellFlow
  769. /// </summary>
  770. /// <param name="obj"></param>
  771. private void OnCellFlow2(object param)
  772. {
  773. if(CellModuleNameCollection[1] != "")
  774. {
  775. InvokeClient.Instance.Service.DoOperation($"{CellModuleNameCollection[1]}.CellSwitchToFlow");
  776. }
  777. }
  778. /// <summary>
  779. /// Cell2三向阀开启CellBypass
  780. /// </summary>
  781. private void OnCellBypass2(object param)
  782. {
  783. if (CellModuleNameCollection[1] != "")
  784. {
  785. InvokeClient.Instance.Service.DoOperation($"{CellModuleNameCollection[1]}.CellSwitchToBypass");
  786. }
  787. }
  788. /// <summary>
  789. /// Cell1 Open Clamp Valve
  790. /// </summary>
  791. private void OnOpenClampValve1(object param)
  792. {
  793. if (CellModuleNameCollection[0] != "")
  794. {
  795. InvokeClient.Instance.Service.DoOperation($"{CellModuleNameCollection[0]}.ClampOn");
  796. }
  797. }
  798. /// <summary>
  799. /// Cell1 Close Clamp Valve
  800. /// </summary>
  801. private void OnCloseClampValve1(object param)
  802. {
  803. if (CellModuleNameCollection[0] != "")
  804. {
  805. InvokeClient.Instance.Service.DoOperation($"{CellModuleNameCollection[0]}.ClampOff");
  806. }
  807. }
  808. /// <summary>
  809. /// Cell2 Open Clamp Valve
  810. /// </summary>
  811. private void OnOpenClampValve2(object param)
  812. {
  813. if (CellModuleNameCollection[1] != "")
  814. {
  815. InvokeClient.Instance.Service.DoOperation($"{CellModuleNameCollection[1]}.ClampOn");
  816. }
  817. }
  818. /// <summary>
  819. /// Cell2 Close Clamp Valve
  820. /// </summary>
  821. private void OnCloseClampValve2(object param)
  822. {
  823. if (CellModuleNameCollection[1] != "")
  824. {
  825. InvokeClient.Instance.Service.DoOperation($"{CellModuleNameCollection[1]}.ClampOff");
  826. }
  827. }
  828. /// <summary>
  829. /// Open DI Replen Valve
  830. /// </summary>
  831. private void OnOpenDIReplenValve(object param)
  832. {
  833. InvokeClient.Instance.Service.DoOperation($"{Module}.DiReplenOn");
  834. }
  835. /// <summary>
  836. /// Close DI Replen Valve
  837. /// </summary>
  838. private void OnCloseDIReplenValve(object param)
  839. {
  840. InvokeClient.Instance.Service.DoOperation($"{Module}.DiReplenOff");
  841. }
  842. /// <summary>
  843. /// Manual DireplenAction
  844. /// </summary>
  845. /// <param name="param"></param>
  846. private void ManualDireplenAction(object param)
  847. {
  848. InvokeClient.Instance.Service.DoOperation($"{Module}.ManualDiReplen",ManualFillSeconds);
  849. }
  850. /// <summary>
  851. /// 进入PMCounter页面
  852. /// </summary>
  853. /// <param name="param"></param>
  854. private void GotoPMCounterAction(object param)
  855. {
  856. GlobalEvents.OnSwitchFixedChildSubItem(Module, $"PMCounter{Module.Substring(9, 1)}");
  857. }
  858. /// <summary>
  859. /// 跳转DosingSystem
  860. /// </summary>
  861. /// <param name="param"></param>
  862. private void JumpDosingSystemAction(object param)
  863. {
  864. GlobalEvents.OnSwitchFixedChildSubItem(Module, $"DosingSystem1");
  865. }
  866. #endregion
  867. /// <summary>
  868. /// 时钟
  869. /// </summary>
  870. /// <param name="sender"></param>
  871. /// <param name="e"></param>
  872. private void Timer_Tick(object sender, EventArgs e)
  873. {
  874. if (_rtDataKeys.Count != 0)
  875. {
  876. _rtDataValueDic = QueryDataClient.Instance.Service.PollData(_rtDataKeys);
  877. if (_rtDataValueDic != null)
  878. {
  879. ReservoirsPersistent = CommonFunction.GetValue<ReservoirsPersistentValue>(_rtDataValueDic, $"{Module}.PersistentValue");
  880. IsManualReplen = CommonFunction.GetValue<bool>(_rtDataValueDic, $"{Module}.IsManualReplen");
  881. DIValveMaxOnTime = CommonFunction.GetValue<double>(_rtDataValueDic, $"{Module}.DIValveMaxOnTime");
  882. CurrentRecipe = CommonFunction.GetValue<ResRecipe>(_rtDataValueDic, $"{Module}.CurrentRecipe");
  883. TemperatureControlData = CommonFunction.GetValue<TemperatureControllerData>(_rtDataValueDic, $"{Module}.TemperatureControllerData");
  884. TCEnableStatus = TemperatureControlData.ControlOperationModel == 0 ? "Disable" : "Enable";
  885. CmmPowerSupplierData = CommonFunction.GetValue<PowerSupplierData>(_rtDataValueDic, $"{Module}.CmmPowerSupplierData");
  886. CommonSafetyData = CommonFunction.GetValue<SafetyData>(_rtDataValueDic, $"Safety.SafetyData");
  887. State = CommonFunction.GetValue<string>(_rtDataValueDic, $"{Module}.FsmState");
  888. AvgLevel = CommonFunction.GetValue<double>(_rtDataValueDic, $"{Module}.ReservoirAverageLevel");
  889. ReservoirUsage reservoirUsage = CommonFunction.GetValue<ReservoirUsage>(_rtDataValueDic, $"{Module}.ReservoirUsage");
  890. if(reservoirUsage != null)
  891. {
  892. CMMAnodeUsage = reservoirUsage.CMMAnodeUsage;
  893. CMMCathodeUsage = reservoirUsage.CMMMembranceUsage;
  894. //CMM AnodeUsage
  895. if (CMMAnodeUsage > _cmmAnodeTotalAmpHoursFaultLimit)
  896. {
  897. IsCMMAnodeTotalAmpHoursFault = true;
  898. IsCMMAnodeTotalAmpHoursWarning = false;
  899. }
  900. else if(CMMAnodeUsage > _cmmAnodeTotalAmpHoursWarningLimit)
  901. {
  902. IsCMMAnodeTotalAmpHoursWarning = true;
  903. IsCMMAnodeTotalAmpHoursFault = false;
  904. }
  905. else
  906. {
  907. IsCMMAnodeTotalAmpHoursWarning = false;
  908. IsCMMAnodeTotalAmpHoursFault = false;
  909. }
  910. //CMM CathodeUsage
  911. if (CMMCathodeUsage > _cmmCathodeTotalAmpHoursFaultLimit)
  912. {
  913. IsCMMCathodeTotalAmpHoursFault = true;
  914. IsCMMCathodeTotalAmpHoursWarning = false;
  915. }
  916. else if (CMMCathodeUsage > _cmmCathodeTotalAmpHoursWarningLimit)
  917. {
  918. IsCMMCathodeTotalAmpHoursWarning = true;
  919. IsCMMCathodeTotalAmpHoursFault = false;
  920. }
  921. else
  922. {
  923. IsCMMCathodeTotalAmpHoursWarning = false;
  924. IsCMMCathodeTotalAmpHoursFault = false;
  925. }
  926. }
  927. if ("Manual".Equals(ReservoirsPersistent.OperatingMode))
  928. {
  929. IsEnabled = true;
  930. IsAutoEnabled = true;
  931. }
  932. else if ("Auto".Equals(ReservoirsPersistent.OperatingMode))
  933. {
  934. IsAutoEnabled = true;
  935. IsEnabled = false;
  936. }
  937. else
  938. {
  939. State = "Stopped";
  940. IsEnabled = false;
  941. IsAutoEnabled = false;
  942. }
  943. for (int i = 0;i < CellsCount;i++)
  944. {
  945. MetalDataCollection[i] = CommonFunction.GetValue<StandardHotMetalDeviceData>(_rtDataValueDic, $"{CellModuleNameCollection[i]}.MetalData");
  946. }
  947. ReservoirData = CommonFunction.GetValue<StandardHotReservoirData>(_rtDataValueDic, $"{Module}.ReservoirData");
  948. if (CurrentRecipe != null)
  949. {
  950. //PHLow报警灯
  951. IsPHLowLimit = (ReservoirData != null && ReservoirData.PHValue < CurrentRecipe.PHErrorLow) ? true : false;
  952. //PHHigh报警灯
  953. IsPHHighLimit = (ReservoirData != null && ReservoirData.PHValue > CurrentRecipe.PHErrorHigh) ? true : false;
  954. if(CmmPowerSupplierData != null)
  955. {
  956. //PowerSupply High报警灯
  957. if (CmmPowerSupplierData.Current <= CurrentRecipe.CMMCurrentSetPoint * (1 + (double)CurrentRecipe.CMMCurrentWarningPercent/100))
  958. {
  959. CurrentHighStatus = "Normal";
  960. }
  961. else if (CmmPowerSupplierData.Current > CurrentRecipe.CMMCurrentSetPoint * (1 + (double)CurrentRecipe.CMMCurrentFaultPercent/100))
  962. {
  963. CurrentHighStatus = "Error";
  964. }
  965. else
  966. {
  967. CurrentHighStatus = "Warning";
  968. }
  969. //PowerSupply Low报警灯
  970. if (CmmPowerSupplierData.Current >= CurrentRecipe.CMMCurrentSetPoint * (1 - (double)CurrentRecipe.CMMCurrentWarningPercent/100))
  971. {
  972. CurrentLowStatus = "Normal";
  973. }
  974. else if (CmmPowerSupplierData.Current < CurrentRecipe.CMMCurrentSetPoint * (1 - (double)CurrentRecipe.CMMCurrentFaultPercent/100))
  975. {
  976. CurrentLowStatus = "Error";
  977. }
  978. else
  979. {
  980. CurrentLowStatus = "Warning";
  981. }
  982. IsBelowMinVoltage = CmmPowerSupplierData.Voltage < CurrentRecipe.CMMMinVoltage ? true : false;
  983. }
  984. }
  985. if (ReservoirData != null)
  986. {
  987. //CMM Flow High报警灯
  988. if (ReservoirData.Flow <= _reservoirCMMFlowHighWarning)
  989. {
  990. FlowHighStatus = "Normal";
  991. }
  992. else if (ReservoirData.Flow > _reservoirCMMFlowHighError)
  993. {
  994. FlowHighStatus = "Error";
  995. }
  996. else
  997. {
  998. FlowHighStatus = "Warning";
  999. }
  1000. //CMM Flow Low报警灯
  1001. if (ReservoirData.Flow >= _reservoirCMMFlowLowWarning)
  1002. {
  1003. FlowLowStatus = "Normal";
  1004. }
  1005. else if (ReservoirData.Flow < _reservoirCMMFlowLowError)
  1006. {
  1007. FlowLowStatus = "Error";
  1008. }
  1009. else
  1010. {
  1011. FlowLowStatus = "Warning";
  1012. }
  1013. //High Level报警灯
  1014. IsHighLevel = (ReservoirData.WaterLevel > _reservoirHighLevel) ? true : false;
  1015. //Low Level报警灯
  1016. IsLowLevel = ReservoirData.LowLevel;
  1017. //HighSafety
  1018. if(CommonSafetyData != null) IsHighSafety = CommonSafetyData.ReservoirHighLevel;
  1019. //HedFlow管流
  1020. HEDFlowIsOn = (ReservoirData.HedFlow > 0) ? true : false;
  1021. //DIReplenFault
  1022. IsDiReplenFault = false;
  1023. IsError = State== "Error" ? true : false;
  1024. }
  1025. }
  1026. }
  1027. }
  1028. /// <summary>
  1029. /// 隐藏
  1030. /// </summary>
  1031. public void Hide()
  1032. {
  1033. if (_timer != null)
  1034. {
  1035. _timer.Stop();
  1036. }
  1037. }
  1038. }
  1039. }