StandardHotReservoirsViewModel.cs 44 KB

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