ReservoirsCatholyteViewModel.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. using Aitex.Core.RT.DataCenter;
  2. using Aitex.Core.RT.Log;
  3. using Aitex.Core.UI.MVVM;
  4. using CyberX8_Core;
  5. using CyberX8_MainPages.Model;
  6. using CyberX8_Themes.CustomControls;
  7. using ExcelLibrary.BinaryFileFormat;
  8. using MECF.Framework.Common.CommonData.Metal;
  9. using MECF.Framework.Common.CommonData.Reservoir;
  10. using MECF.Framework.Common.CommonData.TemperatureControl;
  11. using MECF.Framework.Common.DataCenter;
  12. using MECF.Framework.Common.OperationCenter;
  13. using MECF.Framework.Common.Persistent.Reservoirs;
  14. using MECF.Framework.Common.RecipeCenter;
  15. using MECF.Framework.Common.Utilities;
  16. using OpenSEMI.ClientBase.Command;
  17. using Prism.Mvvm;
  18. using System;
  19. using System.Collections.Generic;
  20. using System.Collections.ObjectModel;
  21. using System.Linq;
  22. using System.Text;
  23. using System.Threading.Tasks;
  24. using System.Windows.Input;
  25. using System.Windows.Threading;
  26. namespace CyberX8_MainPages.ViewModels
  27. {
  28. public class ReservoirsCatholyteViewModel : BindableBase
  29. {
  30. #region 常量
  31. private const string RESERVOIRS_DATA = "ReservoirsData";
  32. private const string RESERVOIRS = "reservoirs";
  33. private const string PERSISTENT_VALUE = "PersistentValue";
  34. #endregion
  35. #region 内部变量
  36. private string _module;
  37. private string _recipeContent;
  38. private string _operatingMode;
  39. private string _state;
  40. private string _recipeMode;
  41. private List<string> _rtDataKeys = new List<string>();
  42. DispatcherTimer _timer;
  43. private Dictionary<string, object> _rtDataValueDic = new Dictionary<string, object>();
  44. private ObservableCollection<RecipeNode> _recipeNodes;
  45. private string _currentRecipeFileName;
  46. private string _recipeType;
  47. private string _tcName;
  48. private double _caPumpSpeed;
  49. private bool _isDIReplenFault;
  50. private double _flowAdjustDelta;
  51. private double _maxFlowDelta;
  52. private bool _isFolwDeltaUnBlance = false;
  53. private bool _isHighLevel;
  54. private bool _isLowLevel;
  55. private bool _isLeakDetected;
  56. private bool _cdaOn;
  57. private bool _isError;
  58. private ResRecipe _currentRecipe;
  59. private double _avgCALevel;
  60. /// <summary>
  61. /// 是否配置Exhaust
  62. /// </summary>
  63. private bool _isEvaporatorConfig;
  64. /// <summary>
  65. /// 是否正在手动注水
  66. /// </summary>
  67. private bool _isManualReplen;
  68. /// <summary>
  69. /// 手动注水时长(秒)
  70. /// </summary>
  71. private int _manualFillSeconds;
  72. /// <summary>
  73. /// DIValveMaxOnTime
  74. /// </summary>
  75. private double _diValveMaxOnTime;
  76. /// <summary>
  77. /// TemperatureControl Module Name
  78. /// </summary>
  79. private TemperatureControllerData _temperatureControlData;
  80. /// <summary>
  81. /// Persistent
  82. /// </summary>
  83. private ReservoirsPersistentValue _reservoirsPersistent;
  84. /// <summary>
  85. /// Reservoir数据
  86. /// </summary>
  87. private CompactMembranReservoirData _reservoirData;
  88. /// <summary>
  89. /// CellModuleName集合
  90. /// </summary>
  91. private ObservableCollection<string> _cellModuleNameCollection = new ObservableCollection<string>();
  92. /// <summary>
  93. /// Cell A面Flow集合
  94. /// </summary>
  95. private ObservableCollection<double> _cellModuleNameFlowCollection = new ObservableCollection<double>();
  96. /// <summary>
  97. /// MetalData
  98. /// </summary>
  99. private ObservableCollection<CompactMembranMetalDeviceData> _metalDatas = new ObservableCollection<CompactMembranMetalDeviceData>();
  100. /// <summary>
  101. /// MetalData的CellFlow集合
  102. /// </summary>
  103. private ObservableCollection<double> _metalCellFlowDatas = new ObservableCollection<double>();
  104. /// <summary>
  105. /// 页面功能启用
  106. /// </summary>
  107. private bool _isEnabled;
  108. /// <summary>
  109. /// AutoMode页面功能启用
  110. /// </summary>
  111. private bool _isAutoEnabled;
  112. /// <summary>
  113. /// Meatl UI数据
  114. /// </summary>
  115. private ObservableCollection<ReservoirsUIData> _reservoirsUIDatas = new ObservableCollection<ReservoirsUIData>();
  116. /// <summary>
  117. /// TC Enable状态
  118. /// </summary>
  119. private string _tcEnableStatus;
  120. #endregion
  121. #region 属性
  122. public double AvgCALevel
  123. {
  124. get { return _avgCALevel; }
  125. set { SetProperty(ref _avgCALevel, value); }
  126. }
  127. public string CurrentRecipeFileName
  128. {
  129. get { return _currentRecipeFileName; }
  130. set { SetProperty(ref _currentRecipeFileName, value); }
  131. }
  132. public ObservableCollection<RecipeNode> RecipeNodes
  133. {
  134. get { return _recipeNodes; }
  135. set { SetProperty(ref _recipeNodes, value); }
  136. }
  137. public string Module { get { return _module; } set { SetProperty(ref _module, value); } }
  138. public string ReservoirRecipeContent
  139. {
  140. get { return _recipeContent; }
  141. set { SetProperty(ref _recipeContent, value); }
  142. }
  143. public string OperatingMode
  144. {
  145. get { return _operatingMode; }
  146. set { SetProperty(ref _operatingMode, value); }
  147. }
  148. public string State
  149. {
  150. get { return _state; }
  151. set { SetProperty(ref _state, value); }
  152. }
  153. public string RecipeMode
  154. {
  155. get { return _recipeMode; }
  156. set { SetProperty(ref _recipeMode, value); }
  157. }
  158. public string RecipeType
  159. {
  160. get { return _recipeType; }
  161. set { SetProperty(ref _recipeType, value); }
  162. }
  163. public double CAPumpSpeed
  164. {
  165. get { return _caPumpSpeed; }
  166. set
  167. {
  168. SetProperty(ref _caPumpSpeed, value);
  169. }
  170. }
  171. public ResRecipe CurrentRecipe
  172. {
  173. get { return _currentRecipe; }
  174. set { SetProperty(ref _currentRecipe, value); }
  175. }
  176. /// <summary>
  177. /// Threshold
  178. /// </summary>
  179. public ReservoirsPersistentValue ReservoirsPersistent
  180. {
  181. get { return _reservoirsPersistent; }
  182. set { SetProperty(ref _reservoirsPersistent, value); }
  183. }
  184. /// <summary>
  185. /// CellModuleName集合
  186. /// </summary>
  187. public ObservableCollection<string> CellModuleNameCollection
  188. {
  189. get { return _cellModuleNameCollection; }
  190. set { SetProperty(ref _cellModuleNameCollection, value); }
  191. }
  192. /// <summary>
  193. /// 模块Flow集合
  194. /// </summary>
  195. public ObservableCollection<double> CellModuleNameFlowCollection
  196. {
  197. get { return _cellModuleNameFlowCollection; }
  198. set { SetProperty(ref _cellModuleNameFlowCollection, value); }
  199. }
  200. /// <summary>
  201. /// Reservoir数据
  202. /// </summary>
  203. public CompactMembranReservoirData ReservoirData
  204. {
  205. get { return _reservoirData; }
  206. set { SetProperty(ref _reservoirData, value); }
  207. }
  208. /// <summary>
  209. /// MetalData
  210. /// </summary>
  211. public ObservableCollection<CompactMembranMetalDeviceData> MetalDatas
  212. {
  213. get { return _metalDatas; }
  214. set { SetProperty(ref _metalDatas, value); }
  215. }
  216. /// <summary>
  217. /// MetalDataCellFlow
  218. /// </summary>
  219. public ObservableCollection<double> MetalCellFlowDatas
  220. {
  221. get { return _metalCellFlowDatas; }
  222. set { SetProperty(ref _metalCellFlowDatas, value); }
  223. }
  224. /// <summary>
  225. /// 是否Error
  226. /// </summary>
  227. public bool IsError
  228. {
  229. get { return _isError; }
  230. set { SetProperty(ref _isError, value); }
  231. }
  232. /// <summary>
  233. /// 正在手动注水
  234. /// </summary>
  235. public bool IsManualReplen
  236. {
  237. get { return _isManualReplen; }
  238. set { SetProperty(ref _isManualReplen, value); }
  239. }
  240. /// <summary>
  241. /// 手动注水时长
  242. /// </summary>
  243. public int ManualFillSeconds
  244. {
  245. get { return _manualFillSeconds; }
  246. set { SetProperty(ref _manualFillSeconds, value); }
  247. }
  248. /// <summary>
  249. /// 单次注水最大时长
  250. /// </summary>
  251. public double DIValveMaxOnTime
  252. {
  253. get { return _diValveMaxOnTime; }
  254. set { SetProperty(ref _diValveMaxOnTime, value); }
  255. }
  256. /// <summary>
  257. /// 是否补水异常
  258. /// </summary>
  259. public bool IsDIReplenFault
  260. {
  261. get { return _isDIReplenFault; }
  262. set { SetProperty(ref _isDIReplenFault, value); }
  263. }
  264. /// <summary>
  265. /// metal cell 水位最大值和最小值之差
  266. /// </summary>
  267. public double FlowAdjustDelta
  268. {
  269. get { return _flowAdjustDelta; }
  270. set { SetProperty(ref _flowAdjustDelta, value); }
  271. }
  272. /// <summary>
  273. /// 流量误差是否超过0.5
  274. /// </summary>
  275. public bool IsFolwDeltaUnBlance
  276. {
  277. get { return _isFolwDeltaUnBlance; }
  278. set { SetProperty(ref _isFolwDeltaUnBlance, value); }
  279. }
  280. /// <summary>
  281. /// 是否触发高水位
  282. /// </summary>
  283. public bool IsHighLevel
  284. {
  285. get { return _isHighLevel; }
  286. set { SetProperty(ref _isHighLevel, value); }
  287. }
  288. /// <summary>
  289. /// 是否触发低水位
  290. /// </summary>
  291. public bool IsLowLevel
  292. {
  293. get { return _isLowLevel; }
  294. set { SetProperty(ref _isLowLevel, value); }
  295. }
  296. /// <summary>
  297. /// TemperatureControl Module Name
  298. /// </summary>
  299. public TemperatureControllerData TemperatureControlData
  300. {
  301. get { return _temperatureControlData; }
  302. set { SetProperty(ref _temperatureControlData, value); }
  303. }
  304. /// <summary>
  305. /// 页面功能启用
  306. /// </summary>
  307. public bool IsEnabled
  308. {
  309. get { return _isEnabled; }
  310. set { SetProperty(ref _isEnabled, value); }
  311. }
  312. /// <summary>
  313. /// AutoMode页面功能启用
  314. /// </summary>
  315. public bool IsAutoEnabled
  316. {
  317. get { return _isAutoEnabled; }
  318. set { SetProperty(ref _isAutoEnabled, value); }
  319. }
  320. /// <summary>
  321. /// metal ui数据
  322. /// </summary>
  323. public ObservableCollection<ReservoirsUIData> ReservoirsUIDatas
  324. {
  325. get { return _reservoirsUIDatas; }
  326. set { SetProperty(ref _reservoirsUIDatas, value); }
  327. }
  328. /// <summary>
  329. /// 是否配有排气模块
  330. /// </summary>
  331. public bool IsEvaporatorConfig
  332. {
  333. get { return _isEvaporatorConfig; }
  334. set { SetProperty(ref _isEvaporatorConfig, value); }
  335. }
  336. /// <summary>
  337. /// 排期模块是否检测到漏液
  338. /// </summary>
  339. public bool IsLeakDetected
  340. {
  341. get { return _isLeakDetected; }
  342. set { SetProperty(ref _isLeakDetected, value); }
  343. }
  344. /// <summary>
  345. /// 排气是否打开
  346. /// </summary>
  347. public bool CdaOn
  348. {
  349. get { return _cdaOn; }
  350. set { SetProperty(ref _cdaOn, value); }
  351. }
  352. /// <summary>
  353. /// TC Enable状态
  354. /// </summary>
  355. public string TCEnableStatus
  356. {
  357. get { return _tcEnableStatus; }
  358. set { SetProperty(ref _tcEnableStatus, value); }
  359. }
  360. #endregion
  361. #region 指令
  362. public ICommand ControlValveCommand { get; private set; }
  363. public ICommand ManualDireplenCommand { get; set; }
  364. public ICommand ResetTotalCommand { get; set; }
  365. public ICommand CAPumpSpeedCommand { get; private set; }
  366. public ICommand BackCommand { get; set; }
  367. public ICommand JumpToTCCommand { get; set; }
  368. public ICommand DIReplenClearErrorCommand { get; set; }
  369. #endregion
  370. public ReservoirsCatholyteViewModel()
  371. {
  372. ControlValveCommand = new DelegateCommand<object>(OnControlValve);
  373. ManualDireplenCommand = new DelegateCommand<object>(ManualDireplenAction);
  374. ResetTotalCommand = new DelegateCommand<object>(ResetTotalAction);
  375. CAPumpSpeedCommand = new DelegateCommand<object>(CAPumpSpeedAction);
  376. BackCommand = new DelegateCommand<object>(BackAction);
  377. JumpToTCCommand = new DelegateCommand<object>(JumpToTCAction);
  378. DIReplenClearErrorCommand = new DelegateCommand<object>(DIReplenClearErrorAction);
  379. }
  380. #region 命令方法
  381. /// <summary>
  382. /// DIReplen Clear Error
  383. /// </summary>
  384. /// <param name="obj"></param>
  385. private void DIReplenClearErrorAction(object obj)
  386. {
  387. InvokeClient.Instance.Service.DoOperation($"{Module}.DIReplenClearError");
  388. }
  389. /// <summary>
  390. /// 回到Reservoir主页面
  391. /// </summary>
  392. /// <param name="param"></param>
  393. private void BackAction(object param)
  394. {
  395. GlobalEvents.OnSwitchFixedChildSubItem(Module, Module);
  396. }
  397. /// <summary>
  398. /// 跳转到对应的TC页面
  399. /// </summary>
  400. /// <param name="param"></param>
  401. private void JumpToTCAction(object param)
  402. {
  403. if (_tcName != null)
  404. {
  405. GlobalEvents.OnSwitchFixedTabItem("HardWare", "TemperatureController", $"{_tcName.Substring(0, 3)}");
  406. }
  407. else
  408. {
  409. GlobalEvents.OnSwitchFixedTabItem("HardWare", "TemperatureController", "");
  410. }
  411. }
  412. /// <summary>
  413. /// Control Valve
  414. /// </summary>
  415. /// <param name="obj"></param>
  416. private void OnControlValve(object obj)
  417. {
  418. CommonValveControl commonValveControl = (CommonValveControl)obj;
  419. if (commonValveControl.IsCanEdit == true)
  420. {
  421. string cmd = commonValveControl.OperationName;
  422. if (!commonValveControl.Status)
  423. {
  424. commonValveControl.Status = !commonValveControl.Status;
  425. InvokeClient.Instance.Service.DoOperation($"{cmd}On");
  426. }
  427. else
  428. {
  429. commonValveControl.Status = !commonValveControl.Status;
  430. InvokeClient.Instance.Service.DoOperation($"{cmd}Off");
  431. }
  432. }
  433. }
  434. /// <summary>
  435. /// CA Pump调速
  436. /// </summary>
  437. /// <param name="obj"></param>
  438. private void CAPumpSpeedAction(object obj)
  439. {
  440. object[] objects = (object[])obj;
  441. if (objects.Length >= 2)
  442. {
  443. InvokeClient.Instance.Service.DoOperation($"{Module}.CAPumpSpeed", objects[1]);
  444. }
  445. }
  446. /// <summary>
  447. /// 手动注水
  448. /// </summary>
  449. /// <param name="param"></param>
  450. private void ManualDireplenAction(object param)
  451. {
  452. InvokeClient.Instance.Service.DoOperation($"{Module}.ManualCADiReplen", ManualFillSeconds);
  453. }
  454. /// <summary>
  455. /// 重置TotalTime
  456. /// </summary>
  457. private void ResetTotalAction(object param)
  458. {
  459. InvokeClient.Instance.Service.DoOperation($"{Module}.ResetTotalTime");
  460. }
  461. #endregion
  462. public void LoadData(string systemName)
  463. {
  464. RecipeType = "res";
  465. Module = systemName;
  466. _rtDataKeys.Clear();
  467. _rtDataKeys.Add($"{Module}.Metals");
  468. Dictionary<string, object> tmpMetals = QueryDataClient.Instance.Service.PollData(_rtDataKeys);
  469. if (tmpMetals != null)
  470. {
  471. List<string> strMetals = CommonFunction.GetValue<List<string>>(tmpMetals, $"{Module}.Metals");
  472. int cellsCount = strMetals.Count;
  473. if (strMetals != null)
  474. {
  475. CellModuleNameCollection.Clear();
  476. CellModuleNameFlowCollection.Clear();
  477. MetalDatas.Clear();
  478. MetalCellFlowDatas.Clear();
  479. ReservoirsUIDatas.Clear();
  480. for (int i = 0; i < cellsCount; i++)
  481. {
  482. CellModuleNameCollection.Add(strMetals[i]);
  483. CellModuleNameFlowCollection.Add(0);
  484. MetalDatas.Add(null);
  485. MetalCellFlowDatas.Add(0);
  486. ReservoirsUIData reservoirsUIData = new ReservoirsUIData();
  487. reservoirsUIData.Name = strMetals[i];
  488. ReservoirsUIDatas.Add(reservoirsUIData);
  489. }
  490. }
  491. }
  492. _rtDataKeys.Clear();
  493. for (int i = 0; i < CellModuleNameCollection.Count; i++)
  494. {
  495. _rtDataKeys.Add($"{CellModuleNameCollection[i]}.CellFlow");
  496. _rtDataKeys.Add($"{CellModuleNameCollection[i]}.MetalData");
  497. }
  498. _rtDataKeys.Add($"{Module}.{PERSISTENT_VALUE}");
  499. _rtDataKeys.Add($"{Module}.ReservoirData");
  500. _rtDataKeys.Add($"{Module}.IsManualCAReplen");
  501. _rtDataKeys.Add($"{Module}.DIValveMaxOnTime");
  502. _rtDataKeys.Add($"{Module}.CAPumpSpeed");
  503. _rtDataKeys.Add($"{Module}.IsCAHighLevel");
  504. _rtDataKeys.Add($"{Module}.IsCALowLevel");
  505. _rtDataKeys.Add($"{Module}.IsDIReplenInFault");
  506. _rtDataKeys.Add($"{Module}.TemperatureControllerData");
  507. _rtDataKeys.Add($"{Module}.CurrentRecipe");
  508. _rtDataKeys.Add($"{Module}.FsmState");
  509. _rtDataKeys.Add($"{Module}.EvaporatorType");
  510. _rtDataKeys.Add($"{Module}.ReservoirAverageCALevel");
  511. _rtDataKeys.Add($"System.Facilities.CDAEnable");
  512. if (_timer == null)
  513. {
  514. _timer = new DispatcherTimer();
  515. _timer.Interval = TimeSpan.FromMilliseconds(200);
  516. _timer.Tick += Timer_Tick;
  517. }
  518. _timer.Start();
  519. }
  520. private void Timer_Tick(object sender, EventArgs e)
  521. {
  522. if (_rtDataKeys.Count != 0)
  523. {
  524. _rtDataValueDic = QueryDataClient.Instance.Service.PollData(_rtDataKeys);
  525. if (_rtDataValueDic != null)
  526. {
  527. State = CommonFunction.GetValue<string>(_rtDataValueDic, $"{Module}.FsmState");
  528. IsError = "Error".Equals(State) ? true : false;
  529. ReservoirsPersistent = CommonFunction.GetValue<ReservoirsPersistentValue>(_rtDataValueDic, $"{Module}.{PERSISTENT_VALUE}");
  530. ReservoirData = CommonFunction.GetValue<CompactMembranReservoirData>(_rtDataValueDic, $"{Module}.ReservoirData");
  531. AvgCALevel = CommonFunction.GetValue<double>(_rtDataValueDic, $"{Module}.ReservoirAverageCALevel");
  532. CurrentRecipe = CommonFunction.GetValue<ResRecipe>(_rtDataValueDic, $"{Module}.CurrentRecipe");
  533. IsManualReplen = CommonFunction.GetValue<bool>(_rtDataValueDic, $"{Module}.IsManualCAReplen");
  534. DIValveMaxOnTime = CommonFunction.GetValue<double>(_rtDataValueDic, $"{Module}.DIValveMaxOnTime");
  535. CAPumpSpeed = CommonFunction.GetValue<double>(_rtDataValueDic, $"{Module}.CAPumpSpeed");
  536. IsHighLevel = CommonFunction.GetValue<bool>(_rtDataValueDic, $"{Module}.IsCAHighLevel");
  537. IsLowLevel = CommonFunction.GetValue<bool>(_rtDataValueDic, $"{Module}.IsCALowLevel");
  538. IsDIReplenFault = CommonFunction.GetValue<bool>(_rtDataValueDic, $"{Module}.IsDIReplenInFault");
  539. CdaOn = CommonFunction.GetValue<bool>(_rtDataValueDic, $"System.Facilities.CDAEnable");
  540. TemperatureControlData = CommonFunction.GetValue<TemperatureControllerData>(_rtDataValueDic, $"{Module}.TemperatureControllerData");
  541. TCEnableStatus = TemperatureControlData.ControlOperationModel == 0 ? "Disable" : "Enable";
  542. _tcName = TemperatureControlData.Name;
  543. for (int i = 0; i < CellModuleNameCollection.Count; i++)
  544. {
  545. CellModuleNameFlowCollection[i] = CommonFunction.GetValue<double>(_rtDataValueDic, $"{CellModuleNameCollection[i]}.CellFlow");
  546. MetalDatas[i] = CommonFunction.GetValue<CompactMembranMetalDeviceData>(_rtDataValueDic, $"{CellModuleNameCollection[i]}.MetalData");
  547. MetalCellFlowDatas[i] = MetalDatas[i].CellFlow;
  548. ReservoirsUIDatas[i].MetalCellFlow = MetalCellFlowDatas[i];
  549. ReservoirsUIDatas[i].IsFlowing3 = MetalDatas[i].CellFlowValve;
  550. ReservoirsUIDatas[i].IsFlowing2 = MetalDatas[i].WHUnclamp;
  551. ReservoirsUIDatas[i].IsFlowing1 = MetalDatas[i].WHClamp;
  552. ReservoirsUIDatas[i].IsEnable = IsEnabled;
  553. ReservoirsUIDatas[i].IsAutoEnable = IsAutoEnabled;
  554. }
  555. //list记录参与循环的metal阴极的流量情况
  556. List<double> list = new List<double>();
  557. for (int i = 0; i < CellModuleNameCollection.Count; i++)
  558. {
  559. if (MetalDatas[i].CellFlowValve)
  560. {
  561. list.Add(MetalDatas[i].CellFlow);
  562. }
  563. }
  564. //如果参与循环的流量全是0或者没有参与循环的metal,直接跳过流量差相关逻辑
  565. if (list.Count==0 || list.All(num => num == 0))
  566. {
  567. for (int i = 0; i < CellModuleNameCollection.Count; i++)
  568. {
  569. ReservoirsUIDatas[i].IsMetalCellHigh = false;
  570. ReservoirsUIDatas[i].IsMetalCellLow = false;
  571. }
  572. }
  573. else
  574. {
  575. FlowAdjustDelta = list.Max() - list.Min();
  576. IsFolwDeltaUnBlance = FlowAdjustDelta > 0.5 ? true : false;
  577. if (IsFolwDeltaUnBlance)
  578. {
  579. for (int i = 0; i < CellModuleNameCollection.Count; i++)
  580. {
  581. if (list.Max() == MetalDatas[i].CellFlow && MetalDatas[i].CellFlowValve)
  582. {
  583. ReservoirsUIDatas[i].IsMetalCellHigh = true;
  584. }
  585. else
  586. {
  587. ReservoirsUIDatas[i].IsMetalCellHigh = false;
  588. }
  589. if (list.Min() == MetalDatas[i].CellFlow && MetalDatas[i].CellFlowValve)
  590. {
  591. ReservoirsUIDatas[i].IsMetalCellLow = true;
  592. }
  593. else
  594. {
  595. ReservoirsUIDatas[i].IsMetalCellLow = false;
  596. }
  597. }
  598. }
  599. else
  600. {
  601. for (int i = 0; i < CellModuleNameCollection.Count; i++)
  602. {
  603. ReservoirsUIDatas[i].IsMetalCellHigh = false;
  604. ReservoirsUIDatas[i].IsMetalCellLow = false;
  605. }
  606. }
  607. }
  608. list.Clear();
  609. if ("Manual".Equals(ReservoirsPersistent.OperatingMode))
  610. {
  611. IsEnabled = true;
  612. IsAutoEnabled = true;
  613. }
  614. else if ("Auto".Equals(ReservoirsPersistent.OperatingMode))
  615. {
  616. IsAutoEnabled = true;
  617. IsEnabled = false;
  618. }
  619. else
  620. {
  621. State = "Stopped";
  622. IsEnabled = false;
  623. IsAutoEnabled = false;
  624. }
  625. string evaporatorType = CommonFunction.GetValue<string>(_rtDataValueDic, $"{Module}.EvaporatorType");
  626. if ("STD".Equals(evaporatorType))
  627. {
  628. IsEvaporatorConfig = true;
  629. }
  630. else
  631. {
  632. IsEvaporatorConfig = false;
  633. }
  634. }
  635. }
  636. }
  637. /// <summary>
  638. /// 隐藏
  639. /// </summary>
  640. public void Hide()
  641. {
  642. if (_timer != null)
  643. {
  644. _timer.Stop();
  645. }
  646. }
  647. }
  648. }