StandardHotReservoirsViewModel.cs 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073
  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>= 1)
  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($"{Module}.FsmState");
  707. _rtDataKeys.Add($"{Module}.ReservoirAverageLevel");
  708. _rtDataKeys.Add($"{Module}.ReservoirUsage");
  709. if (_timer == null)
  710. {
  711. _timer = new DispatcherTimer();
  712. _timer.Interval = TimeSpan.FromMilliseconds(200);
  713. _timer.Tick += Timer_Tick;
  714. }
  715. _timer.Start();
  716. //加载Config
  717. _reservoirCMMFlowHighWarning = Convert.ToDouble(QueryDataClient.Instance.Service.GetConfig("Reservoir.CMM.CMMFlowHighWarning"));
  718. _reservoirCMMFlowHighError = Convert.ToDouble(QueryDataClient.Instance.Service.GetConfig("Reservoir.CMM.CMMFlowHighFault"));
  719. _reservoirCMMFlowLowWarning = Convert.ToDouble(QueryDataClient.Instance.Service.GetConfig("Reservoir.CMM.CMMFlowLowWarning"));
  720. _reservoirCMMFlowLowError = Convert.ToDouble(QueryDataClient.Instance.Service.GetConfig("Reservoir.CMM.CMMFlowLowFault"));
  721. CMMAnodeLifeTimeAHrs = Convert.ToDouble(QueryDataClient.Instance.Service.GetConfig("Reservoir.CMM.CMMAnodeLifeTimeAHrs"));
  722. CMMCathodeLifeTimeAHrs = Convert.ToDouble(QueryDataClient.Instance.Service.GetConfig("Reservoir.CMM.CMMCathodeLifeTimeAHrs"));
  723. _reservoirHighLevel = Convert.ToDouble(QueryDataClient.Instance.Service.GetConfig($"Reservoir.{Module}.HighLevel"));
  724. _cmmAnodeTotalAmpHoursWarningLimit = (double)Convert.ToDouble(QueryDataClient.Instance.Service.GetConfig("Reservoir.CMM.CMMAnodeTotalAmpHoursWarningLimit"));
  725. _cmmAnodeTotalAmpHoursFaultLimit = (double)Convert.ToDouble(QueryDataClient.Instance.Service.GetConfig("Reservoir.CMM.CMMAnodeTotalAmpHoursFaultLimit"));
  726. _cmmCathodeTotalAmpHoursWarningLimit = (double)Convert.ToDouble(QueryDataClient.Instance.Service.GetConfig("Reservoir.CMM.CMMCathodeTotalAmpHoursWarningLimit"));
  727. _cmmCathodeTotalAmpHoursFaultLimit = (double)Convert.ToDouble(QueryDataClient.Instance.Service.GetConfig("Reservoir.CMM.CMMCathodeTotalAmpHoursFaultLimit"));
  728. }
  729. #region 命令方法
  730. /// <summary>
  731. /// 初始化
  732. /// </summary>
  733. /// <param name="param"></param>
  734. private void InitializeAction(object param)
  735. {
  736. InvokeClient.Instance.Service.DoOperation($"{Module}.InitializeAll");
  737. }
  738. /// <summary>
  739. /// 重置TotalTime
  740. /// </summary>
  741. private void ResetTotalAction()
  742. {
  743. InvokeClient.Instance.Service.DoOperation($"{Module}.ResetTotalTime");
  744. }
  745. /// <summary>
  746. /// Cell1三向阀开启CellFlow
  747. /// </summary>
  748. /// <param name="obj"></param>
  749. private void OnCellFlow1(object param)
  750. {
  751. if(CellModuleNameCollection[0] != "")
  752. {
  753. InvokeClient.Instance.Service.DoOperation($"{CellModuleNameCollection[0]}.CellSwitchToFlow");
  754. }
  755. }
  756. /// <summary>
  757. /// Cell1三向阀开启CellBypass
  758. /// </summary>
  759. private void OnCellBypass1(object param)
  760. {
  761. if(CellModuleNameCollection[0] != "")
  762. {
  763. InvokeClient.Instance.Service.DoOperation($"{CellModuleNameCollection[0]}.CellSwitchToBypass");
  764. }
  765. }
  766. /// <summary>
  767. /// Cell2三向阀开启CellFlow
  768. /// </summary>
  769. /// <param name="obj"></param>
  770. private void OnCellFlow2(object param)
  771. {
  772. if(CellModuleNameCollection[1] != "")
  773. {
  774. InvokeClient.Instance.Service.DoOperation($"{CellModuleNameCollection[1]}.CellSwitchToFlow");
  775. }
  776. }
  777. /// <summary>
  778. /// Cell2三向阀开启CellBypass
  779. /// </summary>
  780. private void OnCellBypass2(object param)
  781. {
  782. if (CellModuleNameCollection[1] != "")
  783. {
  784. InvokeClient.Instance.Service.DoOperation($"{CellModuleNameCollection[1]}.CellSwitchToBypass");
  785. }
  786. }
  787. /// <summary>
  788. /// Cell1 Open Clamp Valve
  789. /// </summary>
  790. private void OnOpenClampValve1(object param)
  791. {
  792. if (CellModuleNameCollection[0] != "")
  793. {
  794. InvokeClient.Instance.Service.DoOperation($"{CellModuleNameCollection[0]}.ClampOn");
  795. }
  796. }
  797. /// <summary>
  798. /// Cell1 Close Clamp Valve
  799. /// </summary>
  800. private void OnCloseClampValve1(object param)
  801. {
  802. if (CellModuleNameCollection[0] != "")
  803. {
  804. InvokeClient.Instance.Service.DoOperation($"{CellModuleNameCollection[0]}.ClampOff");
  805. }
  806. }
  807. /// <summary>
  808. /// Cell2 Open Clamp Valve
  809. /// </summary>
  810. private void OnOpenClampValve2(object param)
  811. {
  812. if (CellModuleNameCollection[1] != "")
  813. {
  814. InvokeClient.Instance.Service.DoOperation($"{CellModuleNameCollection[1]}.ClampOn");
  815. }
  816. }
  817. /// <summary>
  818. /// Cell2 Close Clamp Valve
  819. /// </summary>
  820. private void OnCloseClampValve2(object param)
  821. {
  822. if (CellModuleNameCollection[1] != "")
  823. {
  824. InvokeClient.Instance.Service.DoOperation($"{CellModuleNameCollection[1]}.ClampOff");
  825. }
  826. }
  827. /// <summary>
  828. /// Open DI Replen Valve
  829. /// </summary>
  830. private void OnOpenDIReplenValve(object param)
  831. {
  832. InvokeClient.Instance.Service.DoOperation($"{Module}.DiReplenOn");
  833. }
  834. /// <summary>
  835. /// Close DI Replen Valve
  836. /// </summary>
  837. private void OnCloseDIReplenValve(object param)
  838. {
  839. InvokeClient.Instance.Service.DoOperation($"{Module}.DiReplenOff");
  840. }
  841. /// <summary>
  842. /// Manual DireplenAction
  843. /// </summary>
  844. /// <param name="param"></param>
  845. private void ManualDireplenAction(object param)
  846. {
  847. InvokeClient.Instance.Service.DoOperation($"{Module}.ManualDiReplen",ManualFillSeconds);
  848. }
  849. /// <summary>
  850. /// 进入PMCounter页面
  851. /// </summary>
  852. /// <param name="param"></param>
  853. private void GotoPMCounterAction(object param)
  854. {
  855. GlobalEvents.OnSwitchFixedChildSubItem(Module, $"PMCounter{Module.Substring(9, 1)}");
  856. }
  857. /// <summary>
  858. /// 跳转DosingSystem
  859. /// </summary>
  860. /// <param name="param"></param>
  861. private void JumpDosingSystemAction(object param)
  862. {
  863. GlobalEvents.OnSwitchFixedChildSubItem(Module, $"DosingSystem1");
  864. }
  865. #endregion
  866. /// <summary>
  867. /// 时钟
  868. /// </summary>
  869. /// <param name="sender"></param>
  870. /// <param name="e"></param>
  871. private void Timer_Tick(object sender, EventArgs e)
  872. {
  873. if (_rtDataKeys.Count != 0)
  874. {
  875. _rtDataValueDic = QueryDataClient.Instance.Service.PollData(_rtDataKeys);
  876. if (_rtDataValueDic != null)
  877. {
  878. ReservoirsPersistent = CommonFunction.GetValue<ReservoirsPersistentValue>(_rtDataValueDic, $"{Module}.PersistentValue");
  879. IsManualReplen = CommonFunction.GetValue<bool>(_rtDataValueDic, $"{Module}.IsManualReplen");
  880. DIValveMaxOnTime = CommonFunction.GetValue<double>(_rtDataValueDic, $"{Module}.DIValveMaxOnTime");
  881. CurrentRecipe = CommonFunction.GetValue<ResRecipe>(_rtDataValueDic, $"{Module}.CurrentRecipe");
  882. TemperatureControlData = CommonFunction.GetValue<TemperatureControllerData>(_rtDataValueDic, $"{Module}.TemperatureControllerData");
  883. TCEnableStatus = TemperatureControlData.ControlOperationModel == 0 ? "Disable" : "Enable";
  884. CmmPowerSupplierData = CommonFunction.GetValue<PowerSupplierData>(_rtDataValueDic, $"{Module}.CmmPowerSupplierData");
  885. State = CommonFunction.GetValue<string>(_rtDataValueDic, $"{Module}.FsmState");
  886. AvgLevel = CommonFunction.GetValue<double>(_rtDataValueDic, $"{Module}.ReservoirAverageLevel");
  887. ReservoirUsage reservoirUsage = CommonFunction.GetValue<ReservoirUsage>(_rtDataValueDic, $"{Module}.ReservoirUsage");
  888. if(reservoirUsage != null)
  889. {
  890. CMMAnodeUsage = reservoirUsage.CMMAnodeUsage;
  891. CMMCathodeUsage = reservoirUsage.CMMMembranceUsage;
  892. //CMM AnodeUsage
  893. if (CMMAnodeUsage > _cmmAnodeTotalAmpHoursFaultLimit)
  894. {
  895. IsCMMAnodeTotalAmpHoursFault = true;
  896. IsCMMAnodeTotalAmpHoursWarning = false;
  897. }
  898. else if(CMMAnodeUsage > _cmmAnodeTotalAmpHoursWarningLimit)
  899. {
  900. IsCMMAnodeTotalAmpHoursWarning = true;
  901. IsCMMAnodeTotalAmpHoursFault = false;
  902. }
  903. else
  904. {
  905. IsCMMAnodeTotalAmpHoursWarning = false;
  906. IsCMMAnodeTotalAmpHoursFault = false;
  907. }
  908. //CMM CathodeUsage
  909. if (CMMCathodeUsage > _cmmCathodeTotalAmpHoursFaultLimit)
  910. {
  911. IsCMMCathodeTotalAmpHoursFault = true;
  912. IsCMMCathodeTotalAmpHoursWarning = false;
  913. }
  914. else if (CMMCathodeUsage > _cmmCathodeTotalAmpHoursWarningLimit)
  915. {
  916. IsCMMCathodeTotalAmpHoursWarning = true;
  917. IsCMMCathodeTotalAmpHoursFault = false;
  918. }
  919. else
  920. {
  921. IsCMMCathodeTotalAmpHoursWarning = false;
  922. IsCMMCathodeTotalAmpHoursFault = false;
  923. }
  924. }
  925. if ("Manual".Equals(ReservoirsPersistent.OperatingMode))
  926. {
  927. IsEnabled = true;
  928. IsAutoEnabled = true;
  929. }
  930. else if ("Auto".Equals(ReservoirsPersistent.OperatingMode))
  931. {
  932. IsAutoEnabled = true;
  933. IsEnabled = false;
  934. }
  935. else
  936. {
  937. State = "Stopped";
  938. IsEnabled = false;
  939. IsAutoEnabled = false;
  940. }
  941. for (int i = 0;i < CellsCount;i++)
  942. {
  943. MetalDataCollection[i] = CommonFunction.GetValue<StandardHotMetalDeviceData>(_rtDataValueDic, $"{CellModuleNameCollection[i]}.MetalData");
  944. }
  945. ReservoirData = CommonFunction.GetValue<StandardHotReservoirData>(_rtDataValueDic, $"{Module}.ReservoirData");
  946. if (CurrentRecipe != null)
  947. {
  948. //PHLow报警灯
  949. IsPHLowLimit = (ReservoirData != null && ReservoirData.PHValue < CurrentRecipe.PHErrorLow) ? true : false;
  950. //PHHigh报警灯
  951. IsPHHighLimit = (ReservoirData != null && ReservoirData.PHValue > CurrentRecipe.PHErrorHigh) ? true : false;
  952. if(CmmPowerSupplierData != null)
  953. {
  954. //PowerSupply High报警灯
  955. if (CmmPowerSupplierData.Current <= CurrentRecipe.CMMCurrentSetPoint * (1 + (double)CurrentRecipe.CMMCurrentWarningPercent/100))
  956. {
  957. CurrentHighStatus = "Normal";
  958. }
  959. else if (CmmPowerSupplierData.Current > CurrentRecipe.CMMCurrentSetPoint * (1 + (double)CurrentRecipe.CMMCurrentFaultPercent/100))
  960. {
  961. CurrentHighStatus = "Error";
  962. }
  963. else
  964. {
  965. CurrentHighStatus = "Warning";
  966. }
  967. //PowerSupply Low报警灯
  968. if (CmmPowerSupplierData.Current >= CurrentRecipe.CMMCurrentSetPoint * (1 - (double)CurrentRecipe.CMMCurrentWarningPercent/100))
  969. {
  970. CurrentLowStatus = "Normal";
  971. }
  972. else if (CmmPowerSupplierData.Current < CurrentRecipe.CMMCurrentSetPoint * (1 - (double)CurrentRecipe.CMMCurrentFaultPercent/100))
  973. {
  974. CurrentLowStatus = "Error";
  975. }
  976. else
  977. {
  978. CurrentLowStatus = "Warning";
  979. }
  980. IsBelowMinVoltage = CmmPowerSupplierData.Voltage < CurrentRecipe.CMMMinVoltage ? true : false;
  981. }
  982. }
  983. if (ReservoirData != null)
  984. {
  985. //CMM Flow High报警灯
  986. if (ReservoirData.Flow <= _reservoirCMMFlowHighWarning)
  987. {
  988. FlowHighStatus = "Normal";
  989. }
  990. else if (ReservoirData.Flow > _reservoirCMMFlowHighError)
  991. {
  992. FlowHighStatus = "Error";
  993. }
  994. else
  995. {
  996. FlowHighStatus = "Warning";
  997. }
  998. //CMM Flow Low报警灯
  999. if (ReservoirData.Flow >= _reservoirCMMFlowLowWarning)
  1000. {
  1001. FlowLowStatus = "Normal";
  1002. }
  1003. else if (ReservoirData.Flow < _reservoirCMMFlowLowError)
  1004. {
  1005. FlowLowStatus = "Error";
  1006. }
  1007. else
  1008. {
  1009. FlowLowStatus = "Warning";
  1010. }
  1011. //High Level报警灯
  1012. IsHighLevel = (ReservoirData.WaterLevel > _reservoirHighLevel) ? true : false;
  1013. //Low Level报警灯
  1014. IsLowLevel = ReservoirData.LowLevel;
  1015. //HighSafety
  1016. if(CommonSafetyData != null) IsHighSafety = CommonSafetyData.ReservoirHighLevel;
  1017. //HedFlow管流
  1018. HEDFlowIsOn = (ReservoirData.HedFlow > 0) ? true : false;
  1019. //DIReplenFault
  1020. IsDiReplenFault = false;
  1021. IsError = State== "Error" ? true : false;
  1022. }
  1023. }
  1024. }
  1025. }
  1026. /// <summary>
  1027. /// 隐藏
  1028. /// </summary>
  1029. public void Hide()
  1030. {
  1031. if (_timer != null)
  1032. {
  1033. _timer.Stop();
  1034. }
  1035. }
  1036. }
  1037. }