StandardHotReservoirDevice.cs 109 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330
  1. using Aitex.Core.RT.DataCenter;
  2. using Aitex.Core.RT.Device;
  3. using Aitex.Core.RT.Log;
  4. using Aitex.Core.RT.OperationCenter;
  5. using Aitex.Core.RT.RecipeCenter;
  6. using Aitex.Core.RT.SCCore;
  7. using Aitex.Core.Util;
  8. using MECF.Framework.Common.Beckhoff.ModuleIO;
  9. using MECF.Framework.Common.CommonData.Reservoir;
  10. using MECF.Framework.Common.Persistent.Reservoirs;
  11. using MECF.Framework.Common.RecipeCenter;
  12. using MECF.Framework.Common.ToolLayout;
  13. using MECF.Framework.Common.TwinCat;
  14. using CyberX8_Core;
  15. using CyberX8_RT.Devices.Facilities;
  16. using CyberX8_RT.Devices.Metal;
  17. using CyberX8_RT.Modules.Reservoir;
  18. using System;
  19. using System.Collections.Generic;
  20. using System.Reflection;
  21. using CyberX8_RT.Modules;
  22. using System.Collections.ObjectModel;
  23. using CyberX8_RT.Devices.Dose;
  24. using CyberX8_RT.Modules.Metal;
  25. using CyberX8_RT.Devices.Temperature;
  26. using CyberX8_RT.Devices.PowerSupplier;
  27. using System.Linq;
  28. using CyberX8_RT.Devices.Safety;
  29. using MECF.Framework.Common.ProcessCell;
  30. using MECF.Framework.Common.Alarm;
  31. using MECF.Framework.Common.IOCore;
  32. using Aitex.Core.RT.Routine;
  33. namespace CyberX8_RT.Devices.Reservoir
  34. {
  35. public class StandardHotReservoirDevice : BaseDevice, IDevice
  36. {
  37. private enum ReservoirOperation
  38. {
  39. None,
  40. ManualDiReplen,
  41. AutoDiReplen
  42. }
  43. private enum DosingOperation
  44. {
  45. None,
  46. ManualDosing,
  47. AutoDosing,
  48. }
  49. #region 常量
  50. private const string AUTO = "Auto";
  51. private const string MANUAL = "Manual";
  52. private const string DISABLE = "Disable";
  53. private const string STRATUS = "Stratus";
  54. private const string PERSISTENT_VALUE = "PersistentValue";
  55. private const string FLOW = "Flow";
  56. private const string HED_FLOW = "HedFlow";
  57. private const string PH_FLOW_VALVE = "PHFlowValve";
  58. private const string PH_VALUE = "PHValue";
  59. private const string WATER_LEVEL = "WaterLevel";
  60. private const string LOW_LEVEL = "LowLevel";
  61. private const string HIGH_LEVEL = "HighLevel";
  62. private const string SAFETY_HIGH_LEVEL = "SafetyHighLevel";
  63. private const string DI_REPLEN = "DiReplen";
  64. private const string RESERVOIRDEVICEDATA = "ReservoirDeviceData";
  65. private const string REPLEN_LEVEL = "ReplenLevel";
  66. private const string RESPOWERON = "ResPowerOn";
  67. private const string HEDPOWERON = "HedPowerOn";
  68. private const double PUMP_SPEED_CONVERT = 0.0672;
  69. private const int ENABLE = 5;
  70. private const string REGULATE_PUMP = "RegulatePumpOn";
  71. private const string REGULATE_PUMP_SIGNAL_IN = "RegulatePumpSignalIn";
  72. private const string REGULATE_PUMP_SPEED = "RegulatePumpSpeed";
  73. #endregion
  74. #region 内部变量
  75. /// <summary>
  76. /// Level取样平均值
  77. /// </summary>
  78. private double _avgLevel;
  79. /// <summary>
  80. /// AN Level取样队列
  81. /// </summary>
  82. private Queue<double> _LevelSamples;
  83. /// <summary>
  84. /// Level计算平均值取样数
  85. /// </summary>
  86. private int levelSampleCount;
  87. /// <summary>
  88. /// Prewet 持久性数值对象
  89. /// </summary>
  90. private ReservoirsPersistentValue _persistentValue;
  91. /// <summary>
  92. /// 定时器Job
  93. /// </summary>
  94. PeriodicJob _periodicJob = null;
  95. /// <summary>
  96. /// 变量是否初始化字典
  97. /// </summary>
  98. private Dictionary<string, bool> _variableInitializeDic = new Dictionary<string, bool>();
  99. /// <summary>
  100. /// Reservoir数据
  101. /// </summary>
  102. private StandardHotReservoirData _reservoirData = new StandardHotReservoirData();
  103. /// <summary>
  104. /// 当前操作
  105. /// </summary>
  106. private ReservoirOperation _currentOperation = ReservoirOperation.None;
  107. /// <summary>
  108. /// 手动注水时间(秒)
  109. /// </summary>
  110. private int _manualReplenSecond = 0;
  111. /// <summary>
  112. /// 注水是否出错
  113. /// </summary>
  114. private bool _isDiReplenInFault = false;
  115. /// <summary>
  116. /// Recipe
  117. /// </summary>
  118. private ResRecipe _resRecipe;
  119. /// <summary>
  120. /// 平均PH值
  121. /// </summary>
  122. private double _avaragePH;
  123. /// <summary>
  124. /// PH Routine
  125. /// </summary>
  126. private StandardHotPHRoutine _phRoutine;
  127. /// <summary>
  128. /// PH Routine状态
  129. /// </summary>
  130. private RState _phState = RState.Init;
  131. /// <summary>
  132. /// PH结束时间
  133. /// </summary>
  134. private DateTime _phRoutineEndTime = DateTime.Now;
  135. /// <summary>
  136. /// Direplen 逻辑对象
  137. /// </summary>
  138. private ReservoirDiReplenHelper _direplenHelper;
  139. /// <summary>
  140. /// Replen数量
  141. /// </summary>
  142. private int _replenNum = 0;
  143. /// <summary>
  144. /// Dose Replen数据
  145. /// </summary>
  146. private ReplenData[] _replenDatas;
  147. /// <summary>
  148. /// ReplenType
  149. /// </summary>
  150. private string _replenType;
  151. /// <summary>
  152. /// Replen Recipe集合
  153. /// </summary>
  154. private RdsRecipe[] _rdsRecipe;
  155. /// <summary>
  156. /// DosingSystemHelper对象列表
  157. /// </summary>
  158. private List<DosingSystemHelper> _dosingSystemHelperLst;
  159. /// <summary>
  160. /// ReplenLevel 列表
  161. /// </summary>
  162. private List<bool> _replenLevelLst;
  163. /// <summary>
  164. /// 当前操作
  165. /// </summary>
  166. private List<DosingOperation> _currentDosingOperation;
  167. /// <summary>
  168. /// 配置的metal device集合
  169. /// </summary>
  170. private ObservableCollection<StandardHotMetalDevice> _metalDevices = new ObservableCollection<StandardHotMetalDevice>();
  171. /// <summary>
  172. /// Replen Persistent Value
  173. /// </summary>
  174. private Dictionary<string, ReplenPersistentValue> _replenPersistentValue = new Dictionary<string, ReplenPersistentValue>();
  175. /// <summary>
  176. /// DosingCommonHelper
  177. /// </summary>
  178. private DosingCommonHelper _dosingCommonHelper;
  179. /// <summary>
  180. /// WarningFlag
  181. /// </summary>
  182. private List<bool> _isCAFlowRateWARN;
  183. /// <summary>
  184. /// CMM Flow High Error
  185. /// </summary>
  186. private double _reservoirCMMFlowHighError;
  187. /// <summary>
  188. /// CMM Flow Low Error
  189. /// </summary>
  190. private double _reservoirCMMFlowLowError;
  191. /// <summary>
  192. /// ErrorMessage
  193. /// </summary>
  194. private bool _isTCControlWARN = false;
  195. private bool _isCMMPowerCurrentWARN = false;
  196. private bool _isCMMPowerFlowWARN = false;
  197. private bool _isExportCMMUsage = false;
  198. private bool _isAutoDIReplenError = false;
  199. private bool _isSafetyHigh = false;
  200. private bool _isSystemAutoMode = false;
  201. /// <summary>
  202. /// 用于控制打印错误log
  203. /// </summary>
  204. private HashSet<string> errorLogSet = new HashSet<string>();
  205. /// <summary>
  206. /// 是否为调速类型的pump
  207. /// </summary>
  208. private bool _isRegulatePump = false;
  209. /// <summary>
  210. /// 调速泵Pump速度
  211. /// </summary>
  212. private double _regulatePumpSpeed;
  213. /// <summary>
  214. /// 泵速Helper
  215. /// </summary>
  216. private ReservoirPumpSpeedHelper _pumpSpeedHelper;
  217. /// <summary>
  218. /// 是否配备CMM
  219. /// </summary>
  220. private bool _isCMMConfig = false;
  221. /// <summary>
  222. /// holdofftime 配置项
  223. /// </summary>
  224. private double _cellFlowHoldoffTime;
  225. /// <summary>
  226. /// holdofftimeMonitor字典;key:Moudle_item,value :HoldoffTimeSignalMonitor对象
  227. /// </summary>
  228. private Dictionary<string, HoldoffTimeSignalMonitor> _holdoffTimeSignalDic = new Dictionary<string, HoldoffTimeSignalMonitor>();
  229. /// <summary>
  230. /// 累计补水超时
  231. /// </summary>
  232. private bool _diReplenMaxTimeOut;
  233. #endregion
  234. #region 属性
  235. /// <summary>
  236. /// 数据
  237. /// </summary>
  238. public StandardHotReservoirData ReservoirData { get { return _reservoirData; } }
  239. /// <summary>
  240. /// Replen数据
  241. /// </summary>
  242. public ReplenData[] ReplenDatas { get { return _replenDatas; } }
  243. /// <summary>
  244. /// DosingSystemHelper对象列表
  245. /// </summary>
  246. public List<DosingSystemHelper> DosingSystemHelpers { get { return _dosingSystemHelperLst; } }
  247. /// <summary>
  248. /// Replen数量
  249. /// </summary>
  250. public int ReplenNum { get { return _replenNum; } }
  251. /// <summary>
  252. /// 操作模式
  253. /// </summary>
  254. public string OperationMode { get { return _persistentValue.OperatingMode; } }
  255. /// <summary>
  256. /// 工程模式
  257. /// </summary>
  258. public string EngineerMode { get { return _persistentValue.RecipeOperatingMode; } }
  259. /// <summary>
  260. /// 是否自动
  261. /// </summary>
  262. public bool IsAuto { get { return _persistentValue.OperatingMode == AUTO; } }
  263. /// <summary>
  264. /// 是否需要补水
  265. /// </summary>
  266. public bool NeedAutoDireplen { get { return GetNeedAutoDireplen(); } }
  267. /// <summary>
  268. /// 正在补水
  269. /// </summary>
  270. public bool IsDireplenOn { get { return _reservoirData.DiReplen; } }
  271. /// <summary>
  272. /// 平均PH数值
  273. /// </summary>
  274. public double AveragePH { get { return _avaragePH; } set { _avaragePH = value; } }
  275. /// <summary>
  276. /// 当前Recipe
  277. /// </summary>
  278. public ResRecipe Recipe { get { return _resRecipe; } }
  279. /// <summary>
  280. /// 当前Rds Recipe
  281. /// </summary>
  282. public RdsRecipe[] RdsRecipe { get { return _rdsRecipe; } }
  283. /// <summary>
  284. /// 是否调速泵
  285. /// </summary>
  286. public bool IsRegulatePump { get { return _isRegulatePump; } }
  287. /// <summary>
  288. /// 补水累计超时
  289. /// </summary>
  290. public bool DiReplenMaxTimeOut
  291. {
  292. get { return _diReplenMaxTimeOut; }
  293. }
  294. /// <summary>
  295. /// 每隔30秒打印槽体相关的信息
  296. /// </summary>
  297. private DateTime _periodLogTime;
  298. #endregion
  299. /// <summary>
  300. /// 初始化成功清除对应的错误log
  301. /// </summary>
  302. /// <param name="module"></param>
  303. public void ClearErrorLogSet(string module)
  304. {
  305. // 使用构造函数复制 HashSet
  306. HashSet<string> newHashSet = new HashSet<string>(errorLogSet);
  307. foreach (var item in newHashSet)
  308. {
  309. if (item.Contains(module))
  310. {
  311. errorLogSet.Remove(item);
  312. }
  313. }
  314. }
  315. /// <summary>
  316. /// 构造函数
  317. /// </summary>
  318. /// <param name="moduleName"></param>
  319. /// <param name="name"></param>
  320. public StandardHotReservoirDevice(string moduleName) : base(moduleName, moduleName, moduleName, moduleName)
  321. {
  322. levelSampleCount = SC.GetValue<int>("Reservoir.LevelAvgSamples");
  323. levelSampleCount = levelSampleCount == 0 ? 20 : levelSampleCount;
  324. _LevelSamples = new Queue<double>(levelSampleCount);
  325. _cellFlowHoldoffTime = SC.GetValue<double>($"Metal.CellFlowAlarmHoldoffTime");
  326. _periodicJob = new PeriodicJob(100, OnTimer, $"{Module}.OnTimer", true);
  327. ResPowerOn();//保持继电器常开
  328. ClearErrorLogSet(Module.ToString());//软件启动的时候也清一下ErrorLogSet
  329. _periodLogTime = DateTime.Now;
  330. }
  331. /// <summary>
  332. /// 定时器
  333. /// </summary>
  334. /// <returns></returns>
  335. private bool OnTimer()
  336. {
  337. if ((DateTime.Now - _periodLogTime).TotalSeconds > 30)
  338. {
  339. _periodLogTime = DateTime.Now;
  340. double temp = 0;
  341. ReservoirItem reservoirItem = ReservoirItemManager.Instance.GetReservoirItem(Module.ToString());
  342. if (reservoirItem != null)
  343. {
  344. TemperatureController temperatureController = DEVICE.GetDevice<TemperatureController>(reservoirItem.TCID);
  345. if (temperatureController != null)
  346. {
  347. temp = temperatureController.TemperatureData.ReserviorTemperature;
  348. }
  349. }
  350. for (int i = 0; i < _metalDevices.Count; i++)
  351. {
  352. StandardHotMetalDevice hotMetalDevice = _metalDevices[i];
  353. if (hotMetalDevice != null)
  354. {
  355. LOG.WriteLog(eEvent.INFO_METAL, hotMetalDevice.Name, $"CA Flow:{hotMetalDevice.MetalDeviceData.CellFlow} L/min");
  356. }
  357. }
  358. LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, $"{Module} PH :{_reservoirData.PHValue}, " +
  359. $"Temp:{temp}C " +
  360. $"CALevel = {_reservoirData.Level}L ");
  361. }
  362. //计算AN/CA level的平均值
  363. if (ReservoirData != null)
  364. {
  365. //AN
  366. if (_LevelSamples.Count >= levelSampleCount)
  367. {
  368. _LevelSamples.Dequeue();
  369. _LevelSamples.Enqueue(ReservoirData.Level);
  370. }
  371. else
  372. {
  373. _LevelSamples.Enqueue(ReservoirData.Level);
  374. }
  375. _avgLevel = _LevelSamples.Count > 0 ? _LevelSamples.Average() : 0;
  376. }
  377. foreach (StandardHotMetalDevice device in _metalDevices)
  378. {
  379. device.OnTimer(_periodicJob.Interval);
  380. }
  381. /// <summary>
  382. /// WaterLevelMonitor
  383. /// </summary>
  384. WaterLevelMonitor();
  385. //TC SafeCheck
  386. TCSafeCheck();
  387. ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(Module);
  388. if (reservoirEntity == null || !reservoirEntity.IsInitialized)
  389. {
  390. if (IsDireplenOn) DIReplenOff("", null);
  391. return true;
  392. }
  393. //DIReplen
  394. if (_direplenHelper != null)
  395. {
  396. _direplenHelper.MonitorPeriodTime(DiReplenTimeOutOpeartion);
  397. if (!DiReplenMaxTimeOut)
  398. {
  399. if (_currentOperation == ReservoirOperation.ManualDiReplen && _reservoirData.DiReplen)
  400. {
  401. bool result = _direplenHelper.MonitorManualDiReplenComplete(_manualReplenSecond, DIReplenOff, DiReplenTimeOutOpeartion);
  402. if (result)
  403. {
  404. _currentOperation = ReservoirOperation.None;
  405. }
  406. }
  407. else if (_currentOperation == ReservoirOperation.AutoDiReplen && _reservoirData.DiReplen)
  408. {
  409. bool result = _direplenHelper.AutoDiReplenMonitorTimeOut(DIReplenOff, DiReplenTimeOutOpeartion);
  410. if (result)
  411. {
  412. _currentOperation = ReservoirOperation.None;
  413. //触发注水异常信号
  414. _isDiReplenInFault = true;
  415. }
  416. else
  417. {
  418. //按液位补水
  419. result = _direplenHelper.AutoDiReplenMonitorComplete(_reservoirData.Level, _resRecipe.ReservoirCALevel, _resRecipe.DIReplenEnable,
  420. _resRecipe.DIReplenTimeRate, _resRecipe.DIReplenCurrentRate, DIReplenOff);
  421. if (result)
  422. {
  423. //补水完成打印日志
  424. LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, $"{Module} CADIReplen State :False, " +
  425. $"SetPoint = {Recipe.CAFlowSetPoint} " +
  426. $"Level = {_reservoirData.Level} " +
  427. $"HighLimit = {Recipe.CALevelErrorHigh} " +
  428. $"LowLimit = {Recipe.CALevelErrorLow} ");
  429. _currentOperation = ReservoirOperation.None;
  430. }
  431. }
  432. }
  433. }
  434. }
  435. if (_persistentValue.OperatingMode == AUTO)
  436. {
  437. CAFlowRateCheck();
  438. TemperatureCheck();
  439. CMMPowerCheck();
  440. //CMM用电量记录
  441. if (_isExportCMMUsage && _persistentValue.CMMStartTime != DateTime.MinValue)
  442. {
  443. ReservoirItem reservoirItem = ReservoirItemManager.Instance.GetReservoirItem(Module);
  444. if (!string.IsNullOrEmpty(reservoirItem.CMMSupplyID) && _resRecipe != null && _resRecipe.CMMEnable)
  445. {
  446. CellPowerSupplier powerSupplier = DEVICE.GetDevice<CellPowerSupplier>(reservoirItem.CMMSupplyID);
  447. double cmmUsage = powerSupplier.PowerSupplierData.Current * DateTime.Now.Subtract(_persistentValue.CMMStartTime).TotalHours;
  448. ReservoirUsageManager.Instance.UpdateReservoirCMMUsage(Module, Math.Round(cmmUsage, 3));
  449. _persistentValue.CMMStartTime = DateTime.Now;
  450. ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
  451. _isExportCMMUsage = false;
  452. }
  453. }
  454. if (_isRegulatePump && _pumpSpeedHelper != null)
  455. {
  456. _pumpSpeedHelper.Monitor(_resRecipe);//泵调速
  457. }
  458. }
  459. if(ReservoirItemManager.Instance.GetReservoirItem(Module)!=null && !string.IsNullOrEmpty(ReservoirItemManager.Instance.GetReservoirItem(Module).PHProbeType))
  460. {
  461. if (_phState == RState.Running)
  462. {
  463. _phState = _phRoutine.Monitor();
  464. if (_phState == RState.End)
  465. {
  466. _phRoutineEndTime = DateTime.Now;
  467. }
  468. }
  469. else if (_phState != RState.Init)
  470. {
  471. double phUpdatePeriod = SC.GetValue<double>("Reservoir.PHUpdatePeriod");
  472. if (DateTime.Now.Subtract(_phRoutineEndTime).TotalMilliseconds >= phUpdatePeriod * 1000)
  473. {
  474. StartDetectPHValve();
  475. }
  476. }
  477. }
  478. return true;
  479. }
  480. /// <summary>
  481. /// DI Replen超时
  482. /// </summary>
  483. private void DiReplenTimeOutOpeartion(bool timeOutFlag)
  484. {
  485. _diReplenMaxTimeOut = timeOutFlag;
  486. }
  487. /// <summary>
  488. /// Low Level 触发操作
  489. /// </summary>
  490. private void LowLevelOperation()
  491. {
  492. if (ReservoirData.WaterLevel < SC.GetValue<double>($"Reservoir.{Module}.LowLevel"))
  493. {
  494. ReservoirItem reservoirItem = ReservoirItemManager.Instance.GetReservoirItem(Module);
  495. foreach (var metalDevice in _metalDevices)
  496. {
  497. if (metalDevice.MetalDeviceData.Circulation)
  498. {
  499. metalDevice.SwitchToBypass($"{metalDevice.Name}.SwitchToBypass", null);
  500. }
  501. if (metalDevice.MetalDeviceData.CellFlow > 0)
  502. {
  503. metalDevice.ClosePump("", null);
  504. }
  505. //水位过低时将起对应的metal也要切成error
  506. MetalEntity metalEntity = Singleton<RouteManager>.Instance.GetModule<MetalEntity>(metalDevice.DeviceID);
  507. if (metalEntity != null && !metalEntity.IsError)
  508. {
  509. metalEntity.PostMsg(MetalMsg.Error);
  510. }
  511. }
  512. //禁用TC
  513. if (!String.IsNullOrEmpty(reservoirItem.TCID))
  514. {
  515. TemperatureController temperatureController = DEVICE.GetDevice<TemperatureController>(reservoirItem.TCID);
  516. if (temperatureController != null && temperatureController.TemperatureData.ControlOperationModel == 5)
  517. {
  518. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Lowlevel was activate");
  519. temperatureController.DisableOperation("", null);
  520. }
  521. }
  522. }
  523. }
  524. /// <summary>
  525. /// 检验TC的运行状态是否满足
  526. /// </summary>
  527. private void TCSafeCheck()
  528. {
  529. bool result = false;
  530. double totalFlow = 0;
  531. //检验冷却水
  532. SystemFacilities systemFacilities = DEVICE.GetDevice<SystemFacilities>("System.Facilities");
  533. if ((systemFacilities != null && !systemFacilities.HouseChilledWaterEnable))
  534. {
  535. result = true;
  536. }
  537. //检验循环流量
  538. for (int i = 0; i < _metalDevices.Count; i++)
  539. {
  540. StandardHotMetalDevice hotMetalDevice = _metalDevices[i];
  541. if (hotMetalDevice != null)
  542. {
  543. if (hotMetalDevice.MetalDeviceData != null)
  544. {
  545. totalFlow += hotMetalDevice.MetalDeviceData.CellFlow;
  546. }
  547. }
  548. }
  549. if(totalFlow <= 0)
  550. {
  551. result = true ;
  552. }
  553. if (result)
  554. {
  555. ReservoirItem reservoirItem = ReservoirItemManager.Instance.GetReservoirItem(Module);
  556. //禁用TC
  557. if (!String.IsNullOrEmpty(reservoirItem.TCID))
  558. {
  559. TemperatureController temperatureController = DEVICE.GetDevice<TemperatureController>(reservoirItem.TCID);
  560. if (temperatureController != null && temperatureController.TemperatureData.ControlOperationModel == 5)
  561. {
  562. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"TC run status abnormal, Disable TC !");
  563. temperatureController.DisableOperation("", null);
  564. }
  565. }
  566. }
  567. }
  568. /// <summary>
  569. /// High Level 触发操作
  570. /// </summary>
  571. private void HighLevelOperation()
  572. {
  573. SystemFacilities systemFacilities = DEVICE.GetDevice<SystemFacilities>("System.Facilities");
  574. if (systemFacilities != null)
  575. {
  576. if (systemFacilities.DIFillEnable) systemFacilities.DiFillDisableOperation("DIFillDisableOpeartion", null);
  577. if (systemFacilities.DIReplenEnable) systemFacilities.DiReplenDisableOperation("DiReplenDisableOperation", null);
  578. if (ReservoirData.DiReplen)
  579. {
  580. _currentOperation = ReservoirOperation.None;
  581. DIReplenOff("", null);
  582. }
  583. }
  584. }
  585. /// <summary>
  586. /// WaterLevelMonitor
  587. /// </summary>
  588. private void WaterLevelMonitor()
  589. {
  590. ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(Module);
  591. _isSystemAutoMode = reservoirEntity.IsAuto;
  592. //触发水位过高或者过低将reservoir切成error
  593. if (ReservoirData.WaterLevel < SC.GetValue<double>($"Reservoir.{Module}.LowLevel"))
  594. {
  595. if (!errorLogSet.Contains($"{Module}.WaterLevel"))
  596. {
  597. errorLogSet.Add($"{Module}.WaterLevel");
  598. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"WaterLevel low is Activate");
  599. }
  600. LowLevelOperation();
  601. if (!reservoirEntity.IsError)
  602. {
  603. reservoirEntity.PostMsg(ReservoirMsg.Error);
  604. }
  605. if (_isSystemAutoMode && !AlarmListManager.Instance.IsContainDataError(Module, "WaterLevel"))
  606. {
  607. AlarmListManager.Instance.AddDataError(Module,
  608. $"WaterLevel", $"WaterLevel low is Activate");
  609. }
  610. }
  611. else if (ReservoirData.WaterLevel > SC.GetValue<double>($"Reservoir.{Module}.HighLevel"))
  612. {
  613. if (!errorLogSet.Contains($"{Module}.WaterLevel"))
  614. {
  615. errorLogSet.Add($"{Module}.WaterLevel");
  616. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"WaterLevel:{ReservoirData.WaterLevel} is larger than HighLevel Config:{SC.GetValue<double>($"Reservoir.{Module}.HighLevel")}");
  617. }
  618. HighLevelOperation();
  619. if (!reservoirEntity.IsError)
  620. {
  621. reservoirEntity.PostMsg(ReservoirMsg.Error);
  622. }
  623. if (_isSystemAutoMode && !AlarmListManager.Instance.IsContainDataError(Module, "WaterLevel"))
  624. {
  625. AlarmListManager.Instance.AddDataError(Module,
  626. $"WaterLevel", $"WaterLevel:{ReservoirData.WaterLevel} is larger than HighLevel Config:{SC.GetValue<double>($"Reservoir.{Module}.HighLevel")}");
  627. }
  628. }
  629. //High high监控
  630. if (ReservoirData.SafetyHighLevel)
  631. {
  632. if (!errorLogSet.Contains($"{Module}.SafetyHigh"))
  633. {
  634. errorLogSet.Add($"{Module}.SafetyHigh");
  635. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Safety High is activate");
  636. }
  637. HighLevelOperation();
  638. if (!reservoirEntity.IsError)
  639. {
  640. reservoirEntity.PostMsg(ReservoirMsg.Error);
  641. }
  642. if (_isSystemAutoMode && !AlarmListManager.Instance.IsContainDataError(Module, "SafetyHigh"))
  643. {
  644. AlarmListManager.Instance.AddDataError(Module,
  645. $"SafetyHigh", $"Safety High is activate");
  646. }
  647. }
  648. //水位触发reservoir里面的high/low将对应的reservoir切成error
  649. if (_resRecipe == null) return;
  650. if (ReservoirData.Level < _resRecipe.CALevelErrorLow)
  651. {
  652. if (!errorLogSet.Contains($"{Module}.Level"))
  653. {
  654. errorLogSet.Add($"{Module}.Level");
  655. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Current level:{ReservoirData.Level} is lower than recipe's CA Errorlow paramater:{_resRecipe.CALevelErrorLow}");
  656. }
  657. if (!reservoirEntity.IsError)
  658. {
  659. reservoirEntity.PostMsg(ReservoirMsg.Error);
  660. }
  661. if (_isSystemAutoMode && !AlarmListManager.Instance.IsContainDataError(Module, "Level"))
  662. {
  663. AlarmListManager.Instance.AddDataError(Module,
  664. $"Level", $"Current level:{ReservoirData.Level} is lower than recipe's CA Errorlow paramater:{_resRecipe.CALevelErrorLow}");
  665. }
  666. }
  667. else if (ReservoirData.Level > _resRecipe.CALevelErrorHigh)
  668. {
  669. if (!errorLogSet.Contains($"{Module}.Level"))
  670. {
  671. errorLogSet.Add($"{Module}.Level");
  672. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Current level:{ReservoirData.Level} is larger than recipe's CA ErrorHigh paramater:{_resRecipe.CALevelErrorHigh}");
  673. }
  674. if (!reservoirEntity.IsError)
  675. {
  676. reservoirEntity.PostMsg(ReservoirMsg.Error);
  677. }
  678. if (_isSystemAutoMode && !AlarmListManager.Instance.IsContainDataError(Module, "Level"))
  679. {
  680. AlarmListManager.Instance.AddDataError(Module,
  681. $"Level", $"Current level:{ReservoirData.Level} is larger than recipe CA ErrorHigh paramater:{_resRecipe.CALevelErrorHigh}");
  682. }
  683. }
  684. }
  685. /// <summary>
  686. /// 获取是否需要补水
  687. /// </summary>
  688. /// <returns></returns>
  689. private bool GetNeedAutoDireplen()
  690. {
  691. if (IsAuto && _resRecipe != null)
  692. {
  693. if (_resRecipe.DIReplenEnable && _resRecipe.DIReplenCurrentRate == 0 && _resRecipe.DIReplenTimeRate == 0)
  694. {
  695. double levelHysteresis = SC.GetValue<double>("Reservoir.LevelHysteresis");
  696. return ReservoirData.Level < _resRecipe.ReservoirCALevel - levelHysteresis;
  697. }
  698. return false;
  699. }
  700. else
  701. {
  702. return false;
  703. }
  704. }
  705. /// <summary>
  706. /// 初始化
  707. /// </summary>
  708. /// <returns></returns>
  709. public bool Initialize()
  710. {
  711. InitializeRoutine();
  712. InitializeParameter();
  713. SubscribeData();
  714. InitializeOperation();
  715. SubscribeValueAction();
  716. return true;
  717. }
  718. /// <summary>
  719. /// 初始化routine
  720. /// </summary>
  721. private void InitializeRoutine()
  722. {
  723. _phRoutine = new StandardHotPHRoutine(Module);
  724. }
  725. /// <summary>
  726. /// 初始化参数
  727. /// </summary>
  728. private void InitializeParameter()
  729. {
  730. _persistentValue = ReservoirsPersistentManager.Instance.GetReservoirsPersistentValue(Module.ToString());
  731. if (_persistentValue == null)
  732. {
  733. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module.ToString(), "Persistent Value Object is not exist");
  734. }
  735. else
  736. {
  737. if (!string.IsNullOrEmpty(_persistentValue.Recipe))
  738. {
  739. _resRecipe = RecipeFileManager.Instance.LoadGenericityRecipe<ResRecipe>(_persistentValue.Recipe);
  740. }
  741. _direplenHelper = new ReservoirDiReplenHelper(Module, _persistentValue);
  742. }
  743. ReservoirItem reservoirItem = ReservoirItemManager.Instance.GetReservoirItem(Module.ToString());
  744. if (reservoirItem != null)
  745. {
  746. foreach (var item in reservoirItem.MetalCells)
  747. {
  748. if (item.ModuleName != Module)
  749. {
  750. StandardHotMetalDevice metalDevice = DEVICE.GetDevice<StandardHotMetalDevice>(item.ModuleName);
  751. if (metalDevice != null)
  752. {
  753. _metalDevices.Add(metalDevice);
  754. _holdoffTimeSignalDic.Add($"{item.ModuleName}_CellFlow", new HoldoffTimeSignalMonitor(item.ModuleName, "CellFlow"));
  755. }
  756. }
  757. }
  758. _isRegulatePump = "Regulate" == reservoirItem.PumpType;
  759. _regulatePumpSpeed = SC.GetValue<double>("Reservoir.DefaultPumpSpeed");
  760. if (_isRegulatePump)
  761. {
  762. _pumpSpeedHelper = new ReservoirPumpSpeedHelper(Module, this);
  763. }
  764. _isCMMConfig = !string.IsNullOrEmpty(reservoirItem.CMMType);
  765. }
  766. _isCAFlowRateWARN = new List<bool>(new bool[_metalDevices.Count]);
  767. //DosingSystem数据初始化
  768. _replenType = reservoirItem.ChemReplenType;
  769. _replenNum = reservoirItem.ChemReplenPumps;
  770. if (_replenType != "" && _replenNum != 0)
  771. {
  772. _replenDatas = new ReplenData[_replenNum];
  773. _rdsRecipe = new RdsRecipe[_replenNum];
  774. _replenLevelLst = new List<bool>(new bool[_replenNum]);
  775. _currentDosingOperation = new List<DosingOperation>();
  776. for (int i = 0; i < _replenNum; i++)
  777. {
  778. string replenName = "Replen" + (i + 1).ToString();
  779. _replenDatas[i] = new ReplenData();
  780. _replenDatas[i].ReplenName = replenName;
  781. _replenDatas[i].RecipeName = "";
  782. _replenDatas[i].BottleLevel = DosingSystemHelper.BottleLevelState.Empty.ToString();
  783. _replenDatas[i].IsAutoDosingError = false;
  784. if (_dosingSystemHelperLst == null) _dosingSystemHelperLst = new List<DosingSystemHelper>();
  785. _dosingSystemHelperLst.Add(new DosingSystemHelper(Module, _replenDatas[i].ReplenName));
  786. _currentDosingOperation.Add(DosingOperation.None);
  787. _replenPersistentValue[replenName] = ReplenPersistentManager.Instance.GetReplenPersistentValue(Module, replenName);
  788. }
  789. _dosingCommonHelper = new DosingCommonHelper(Module, _replenNum);
  790. }
  791. }
  792. /// <summary>
  793. /// 订阅数据
  794. /// </summary>
  795. private void SubscribeData()
  796. {
  797. DATA.Subscribe($"{Module}.DIValveMaxOnTime", () => SC.GetValue<double>($"Reservoir.{Module}.DIValveMaxOnTime") * 60, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  798. DATA.Subscribe($"{Module}.IsManualReplen", () => { return _currentOperation == ReservoirOperation.ManualDiReplen; }, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  799. DATA.Subscribe($"{Module}.ReservoirData", () => _reservoirData, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  800. DATA.Subscribe($"{Module}.ReservoirAverageLevel", () => _avgLevel, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  801. DATA.Subscribe($"{Module}.{PERSISTENT_VALUE}", () => _persistentValue, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  802. DATA.Subscribe($"{Module}.ReplenPersistentValue", () => _replenPersistentValue, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  803. DATA.Subscribe($"{Module}.PHValue", () => _avaragePH, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  804. DATA.Subscribe($"{Module}.CurrentRecipe", () => _resRecipe, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  805. DATA.Subscribe($"{Module}.ReplenType", () => _replenType, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  806. DATA.Subscribe($"{Module}.ReplenNum", () => _replenNum, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  807. DATA.Subscribe($"{Module}.ReplenDatas", () => _replenDatas, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  808. DATA.Subscribe($"{Module}.DosingSystemState", () => _dosingCommonHelper != null ? _dosingCommonHelper.DosingSystemState : null, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  809. DATA.Subscribe($"{Module}.RecipeName", () => (_resRecipe != null ? _resRecipe.Ppid : ""), SubscriptionAttribute.FLAG.IgnoreSaveDB);
  810. DATA.Subscribe($"{Module}.HedFlow", () => _reservoirData.HedFlow, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  811. DATA.Subscribe($"{Module}.PHEnable", () => _reservoirData.PHFlowValve, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  812. DATA.Subscribe($"{Module}.IsDIReplenInFault", () => _isDiReplenInFault, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  813. DATA.Subscribe($"{Module}.ReservoirPowerOn", () => _reservoirData.ResPowerOn, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  814. DATA.Subscribe($"{Module}.HedPowerOn", () => _reservoirData.HedPowerOn, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  815. DATA.Subscribe($"{Module}.IsRegulatePump", () => _isRegulatePump, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  816. DATA.Subscribe($"{Module}.PumpSpeed", () => _regulatePumpSpeed, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  817. DATA.Subscribe($"{Module}.IsCMMConfig", () => _isCMMConfig, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  818. DATA.Subscribe($"{Module}.SubordinateReservoirPump", () => _reservoirData.RegulatePumpSignalIn, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  819. }
  820. /// <summary>
  821. /// 初始化操作
  822. /// </summary>
  823. private void InitializeOperation()
  824. {
  825. OP.Subscribe($"{Module}.DisabledAction", DisabledOperation);
  826. OP.Subscribe($"{Module}.ManualAction", ManualOperation);
  827. OP.Subscribe($"{Module}.AutoAction", AutoOperation);
  828. OP.Subscribe($"{Module}.EngineeringModeAction", EngineeringModeOperation);
  829. OP.Subscribe($"{Module}.ProductionModeAction", ProductionModeOperation);
  830. OP.Subscribe($"{Module}.DiReplenOn", DIReplenOnOperation);
  831. OP.Subscribe($"{Module}.DiReplenOff", DIReplenOff);
  832. OP.Subscribe($"{Module}.ManualDiReplen", ManualDiReplen);
  833. OP.Subscribe($"{Module}.ResetTotalTime", ResetTotalTime);
  834. OP.Subscribe($"{Module}.LoadRecipe", LoadRecipeOperation);
  835. OP.Subscribe($"{Module}.LoadDosingRecipe", LoadDosingRecipeOperation);
  836. OP.Subscribe($"{Module}.ReplenPumpOn", ReplenPumpOnOperation);
  837. OP.Subscribe($"{Module}.ReplenPumpOff", ReplenPumpOffOperation);
  838. OP.Subscribe($"{Module}.SetPumpFactor", SetPumpFactor);
  839. OP.Subscribe($"{Module}.ManualDosing", ManualDosing);
  840. OP.Subscribe($"{Module}.StopManualDosing", StopManualDosing);
  841. OP.Subscribe($"{Module}.ResetBottleVolume", ResetBottleVolume);
  842. OP.Subscribe($"{Module}.DosingInitialize", DosingInitialize);
  843. OP.Subscribe($"{Module}.HedPowerOn", HedPowerOnAction);
  844. OP.Subscribe($"{Module}.HedPowerOff", HedPowerOffAction);
  845. OP.Subscribe($"{Module}.ResPowerOn", ResPowerOnAction);
  846. OP.Subscribe($"{Module}.ResPowerOff", ResPowerOffAction);
  847. OP.Subscribe($"{Module}.RegulatPumpSpeed", RegulatePumpSpeedOperation);
  848. OP.Subscribe($"{Module}.RegulatPumpOn", RegulatePumpOn);
  849. OP.Subscribe($"{Module}.RegulatPumpOff", RegulatePumpOff);
  850. }
  851. #region Regulat Pump
  852. /// <summary>
  853. /// 调速pump
  854. /// </summary>
  855. /// <param name="cmd"></param>
  856. /// <param name="args"></param>
  857. /// <returns></returns>
  858. private bool RegulatePumpSpeedOperation(string cmd, object[] args)
  859. {
  860. double MaxPumpSpeed = 0;
  861. if (SC.ContainsItem("Reservoir.MaxPumpSpeed"))
  862. {
  863. MaxPumpSpeed = SC.GetValue<double>("Reservoir.MaxPumpSpeed");
  864. }
  865. if (double.TryParse(args[0].ToString(), out double speed))
  866. {
  867. _regulatePumpSpeed = speed;
  868. if (_regulatePumpSpeed > MaxPumpSpeed)
  869. {
  870. _regulatePumpSpeed = MaxPumpSpeed;//设置成最大泵速
  871. LOG.WriteLog(eEvent.WARN_METAL, Module, $"Pump speed:{_regulatePumpSpeed} is over max pump speed {MaxPumpSpeed}!");
  872. return false;
  873. }
  874. return RegulatePumpSpeed(_regulatePumpSpeed);
  875. }
  876. else
  877. {
  878. LOG.WriteLog(eEvent.ERR_METAL, Module, $"{args[0]} is nor invalid speed");
  879. return false;
  880. }
  881. }
  882. /// <summary>
  883. /// 设置泵速
  884. /// </summary>
  885. /// <param name="PumpSpeed"></param>
  886. /// <returns></returns>
  887. public bool RegulatePumpSpeed(double PumpSpeed)
  888. {
  889. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REGULATE_PUMP_SPEED}");
  890. return IOModuleManager.Instance.WriteIoValue(ioName, PumpSpeed);
  891. }
  892. /// <summary>
  893. /// Pump On
  894. /// </summary>
  895. /// <param name="cmd"></param>
  896. /// <param name="args"></param>
  897. /// <returns></returns>
  898. public bool RegulatePumpOn(string cmd, object[] args)
  899. {
  900. string enableIOName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REGULATE_PUMP}");
  901. return IOModuleManager.Instance.WriteIoValue(enableIOName, true);
  902. }
  903. /// <summary>
  904. /// Pump Off
  905. /// </summary>
  906. /// <param name="cmd"></param>
  907. /// <param name="args"></param>
  908. /// <returns></returns>
  909. public bool RegulatePumpOff(string cmd, object[] args)
  910. {
  911. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REGULATE_PUMP}");
  912. return IOModuleManager.Instance.WriteIoValue(ioName, false);
  913. }
  914. #endregion
  915. private bool HedPowerOnAction(string cmd, object[] args)
  916. {
  917. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{HEDPOWERON}");
  918. if (!string.IsNullOrEmpty(ioName))
  919. {
  920. bool result = IOModuleManager.Instance.WriteIoValue(ioName, true);
  921. if (!result)
  922. {
  923. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Open HED Power Relay failed");
  924. return false;
  925. }
  926. return true;
  927. }
  928. else
  929. {
  930. return true;
  931. }
  932. }
  933. private bool HedPowerOffAction(string cmd, object[] args)
  934. {
  935. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{HEDPOWERON}");
  936. if (!string.IsNullOrEmpty(ioName))
  937. {
  938. bool result = IOModuleManager.Instance.WriteIoValue(ioName, false);
  939. if (!result)
  940. {
  941. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Close HED Power Relay failed");
  942. return false;
  943. }
  944. return true;
  945. }
  946. else
  947. {
  948. return true;
  949. }
  950. }
  951. private bool ResPowerOnAction(string cmd, object[] args)
  952. {
  953. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{RESPOWERON}");
  954. if (!string.IsNullOrEmpty(ioName))
  955. {
  956. bool result = IOModuleManager.Instance.WriteIoValue(ioName, true);
  957. if (!result)
  958. {
  959. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Open Res Power Relay failed");
  960. return false;
  961. }
  962. return true;
  963. }
  964. else
  965. {
  966. return true;
  967. }
  968. }
  969. private bool ResPowerOffAction(string cmd, object[] args)
  970. {
  971. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{RESPOWERON}");
  972. if (!string.IsNullOrEmpty(ioName))
  973. {
  974. bool result = IOModuleManager.Instance.WriteIoValue(ioName, false);
  975. if (!result)
  976. {
  977. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Close Res Power Relay failed");
  978. return false;
  979. }
  980. return true;
  981. }
  982. else
  983. {
  984. return true;
  985. }
  986. }
  987. #region Operation
  988. /// <summary>
  989. /// 重置时长
  990. /// </summary>
  991. /// <param name="cmd"></param>
  992. /// <param name="objs"></param>
  993. /// <returns></returns>
  994. private bool ResetTotalTime(string cmd, object[] objs)
  995. {
  996. _isDiReplenInFault = false;
  997. _diReplenMaxTimeOut = false;
  998. _persistentValue.TotalReplen = 0;
  999. _persistentValue.LastTotalReplen = 0;
  1000. ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
  1001. return true;
  1002. }
  1003. /// <summary>
  1004. /// DisabledAction
  1005. /// </summary>
  1006. /// <param name="cmd"></param>
  1007. /// <param name="param"></param>
  1008. /// <returns></returns>
  1009. private bool DisabledOperation(string cmd, object[] args)
  1010. {
  1011. string currentOperation = "Disabled";
  1012. if (args.Length >= 1 && (bool)args[0])
  1013. {
  1014. foreach (var replenData in ReplenDatas)
  1015. {
  1016. if (_replenPersistentValue != null && _replenPersistentValue[replenData.ReplenName] != null)
  1017. {
  1018. _replenPersistentValue[replenData.ReplenName].OperatingMode = currentOperation;
  1019. ReplenPersistentManager.Instance.UpdatePersistentValue(Module, replenData.ReplenName);
  1020. }
  1021. }
  1022. for (int i = 0; i < _replenNum; i++)
  1023. {
  1024. string replenName = "Replen" + (i + 1).ToString();
  1025. if (_replenPersistentValue[replenName].IsDosingRunning)
  1026. {
  1027. _dosingSystemHelperLst[i].StopDosing();
  1028. _currentDosingOperation[i] = DosingOperation.None;
  1029. }
  1030. }
  1031. DosingEnterInit();
  1032. }
  1033. else
  1034. {
  1035. ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(Module);
  1036. if (_persistentValue != null && reservoirEntity != null && _persistentValue.OperatingMode != currentOperation)
  1037. {
  1038. string preOperation = _persistentValue.OperatingMode;
  1039. if (reservoirEntity.IsBusy)
  1040. {
  1041. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{Module} is Busy, can't switch to Disabled mode");
  1042. return false;
  1043. }
  1044. if (_persistentValue.OperatingMode == "Auto" && reservoirEntity.IsMetalBusy)
  1045. {
  1046. string busymodule = "";
  1047. if (_metalDevices != null)
  1048. {
  1049. foreach (var item in _metalDevices)
  1050. {
  1051. MetalEntity metalEntity = Singleton<RouteManager>.Instance.GetModule<MetalEntity>(item.Module.ToString());
  1052. if (metalEntity != null && metalEntity.IsBusy)
  1053. {
  1054. busymodule += metalEntity.Module.ToString() + "/";
  1055. }
  1056. }
  1057. }
  1058. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{busymodule} is Busy, can't switch to Disabled mode");
  1059. return false;
  1060. }
  1061. foreach (var metalDevice in _metalDevices)
  1062. {
  1063. metalDevice.DisabledOperation("", null);
  1064. MetalEntity metalEntity = Singleton<RouteManager>.Instance.GetModule<MetalEntity>(metalDevice.Module);
  1065. metalEntity.AbortRecipe(null);
  1066. metalDevice.EnterDisabledOperation();
  1067. }
  1068. EnterDisabledOperation();
  1069. reservoirEntity.EnterInit();
  1070. _persistentValue.OperatingMode = currentOperation;
  1071. LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
  1072. }
  1073. ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
  1074. _currentOperation = ReservoirOperation.None;
  1075. }
  1076. return true;
  1077. }
  1078. /// <summary>
  1079. /// ManualAction
  1080. /// </summary>
  1081. /// <param name="cmd"></param>
  1082. /// <param name="param"></param>
  1083. /// <returns></returns>
  1084. private bool ManualOperation(string cmd, object[] args)
  1085. {
  1086. string currentOperation = "Manual";
  1087. if (args.Length >= 1 && (bool)args[0])
  1088. {
  1089. foreach (var replenData in ReplenDatas)
  1090. {
  1091. if (_replenPersistentValue != null && _replenPersistentValue[replenData.ReplenName] != null)
  1092. {
  1093. _replenPersistentValue[replenData.ReplenName].OperatingMode = currentOperation;
  1094. ReplenPersistentManager.Instance.UpdatePersistentValue(Module, replenData.ReplenName);
  1095. }
  1096. }
  1097. DosingEnterInit();
  1098. }
  1099. else
  1100. {
  1101. ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(Module);
  1102. if (_persistentValue != null && reservoirEntity != null && _persistentValue.OperatingMode != currentOperation)
  1103. {
  1104. string preOperation = _persistentValue.OperatingMode;
  1105. if (reservoirEntity.IsBusy)
  1106. {
  1107. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{Module} is Busy, can't switch to Manual mode");
  1108. return false;
  1109. }
  1110. if (_persistentValue.OperatingMode == "Auto" && reservoirEntity.IsMetalBusy)
  1111. {
  1112. string busymodule = "";
  1113. if (_metalDevices != null)
  1114. {
  1115. foreach (var item in _metalDevices)
  1116. {
  1117. MetalEntity metalEntity = Singleton<RouteManager>.Instance.GetModule<MetalEntity>(item.Module.ToString());
  1118. if (metalEntity != null && metalEntity.IsBusy)
  1119. {
  1120. busymodule += metalEntity.Module.ToString() + "/";
  1121. }
  1122. }
  1123. }
  1124. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{busymodule} is Busy, can't switch to Manual mode");
  1125. return false;
  1126. }
  1127. foreach (var metalDevice in _metalDevices)
  1128. {
  1129. metalDevice.ManualOperation("", null);
  1130. }
  1131. reservoirEntity.EnterInit();
  1132. if (_reservoirData.DiReplen) DIReplenOff("", null);
  1133. _persistentValue.OperatingMode = currentOperation;
  1134. LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
  1135. }
  1136. ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
  1137. _currentOperation = ReservoirOperation.None;
  1138. }
  1139. return true;
  1140. }
  1141. /// <summary>
  1142. /// AutoAction
  1143. /// </summary>
  1144. /// <param name="cmd"></param>
  1145. /// <param name="param"></param>
  1146. /// <returns></returns>
  1147. private bool AutoOperation(string cmd, object[] args)
  1148. {
  1149. double lowLevel = SC.GetValue<double>($"Reservoir.{Module}.LowLevel");
  1150. if (ReservoirData.WaterLevel < lowLevel)
  1151. {
  1152. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Lowlevel was activated, can't switch to Auto mode");
  1153. return false;
  1154. }
  1155. string currentOperation = "Auto";
  1156. if (args.Length >= 1 && (bool)args[0])
  1157. {
  1158. foreach (var replenData in ReplenDatas)
  1159. {
  1160. if (_replenPersistentValue != null && _replenPersistentValue[replenData.ReplenName] != null)
  1161. {
  1162. _replenPersistentValue[replenData.ReplenName].OperatingMode = currentOperation;
  1163. ReplenPersistentManager.Instance.UpdatePersistentValue(Module, replenData.ReplenName);
  1164. }
  1165. }
  1166. DosingEnterInit();
  1167. }
  1168. else
  1169. {
  1170. ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(Module);
  1171. if (_persistentValue != null && reservoirEntity != null && _persistentValue.OperatingMode != currentOperation)
  1172. {
  1173. string preOperation = _persistentValue.OperatingMode;
  1174. if (reservoirEntity.IsBusy)
  1175. {
  1176. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{Module} is Busy, can't switch to Auto mode");
  1177. return false;
  1178. }
  1179. reservoirEntity.EnterInit();
  1180. _persistentValue.OperatingMode = currentOperation;
  1181. if (_reservoirData.DiReplen) DIReplenOff("", null);
  1182. _isDiReplenInFault = false;
  1183. LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
  1184. }
  1185. ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
  1186. }
  1187. return true;
  1188. }
  1189. /// <summary>
  1190. /// EngineeringModeAction
  1191. /// </summary>
  1192. /// <param name="cmd"></param>
  1193. /// <param name="param"></param>
  1194. /// <returns></returns>
  1195. private bool EngineeringModeOperation(string cmd, object[] args)
  1196. {
  1197. string currentRecipeOperation = "Engineering";
  1198. if (_persistentValue != null)
  1199. {
  1200. _persistentValue.RecipeOperatingMode = currentRecipeOperation;
  1201. }
  1202. ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
  1203. return true;
  1204. }
  1205. /// <summary>
  1206. /// ProductionAction
  1207. /// </summary>
  1208. /// <param name="cmd"></param>
  1209. /// <param name="param"></param>
  1210. /// <returns></returns>
  1211. private bool ProductionModeOperation(string cmd, object[] args)
  1212. {
  1213. string currentRecipeOperation = "Production";
  1214. if (_persistentValue != null)
  1215. {
  1216. _persistentValue.RecipeOperatingMode = currentRecipeOperation;
  1217. }
  1218. ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
  1219. return true;
  1220. }
  1221. /// <summary>
  1222. /// 加载Recipe
  1223. /// </summary>
  1224. /// <param name="cmd"></param>
  1225. /// <param name="args"></param>
  1226. /// <returns></returns>
  1227. private bool LoadRecipeOperation(string cmd, object[] args)
  1228. {
  1229. _persistentValue.Recipe = args[0].ToString();
  1230. string[] fileRoute = _persistentValue.Recipe.Split('\\');
  1231. string recipeRoute = "";
  1232. if (fileRoute.Length > 2)
  1233. {
  1234. recipeRoute = fileRoute[fileRoute.Length - 2];
  1235. }
  1236. try
  1237. {
  1238. _resRecipe = RecipeFileManager.Instance.LoadGenericityRecipe<ResRecipe>(_persistentValue.Recipe);
  1239. ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module.ToString());
  1240. LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, $"Load {recipeRoute} Recipe {_resRecipe.Ppid} Success");
  1241. }
  1242. catch
  1243. {
  1244. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Load {recipeRoute} Recipe {_persistentValue.Recipe} failed");
  1245. }
  1246. return true;
  1247. }
  1248. /// <summary>
  1249. /// DiReplen On
  1250. /// </summary>
  1251. /// <param name="cmd"></param>
  1252. /// <param name="args"></param>
  1253. /// <returns></returns>
  1254. public bool DIReplenOnOperation(string cmd, object[] args)
  1255. {
  1256. return DIReplenOn(true);
  1257. }
  1258. /// <summary>
  1259. /// 自动注水
  1260. /// </summary>
  1261. /// <returns></returns>
  1262. public bool DIReplenOn(bool showError)
  1263. {
  1264. ReservoirEntity entity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(Module);
  1265. if (ReservoirData.WaterLevel > SC.GetValue<double>($"Reservoir.{Module}.HighLevel"))
  1266. {
  1267. if(entity!=null && !entity.IsError)
  1268. {
  1269. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "Highlevel is activate");
  1270. }
  1271. return false;
  1272. }
  1273. if(ReservoirData.WaterLevel < SC.GetValue<double>($"Reservoir.{Module}.LowLevel"))
  1274. {
  1275. if (entity != null && !entity.IsError)
  1276. {
  1277. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"WaterLevel low is Activate");
  1278. }
  1279. return false;
  1280. }
  1281. bool preCondition = CheckPreDiReplenCondition(showError);
  1282. if (!preCondition)
  1283. {
  1284. return false;
  1285. }
  1286. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{DI_REPLEN}");
  1287. bool result = IOModuleManager.Instance.WriteIoValue(ioName, true);
  1288. if (result)
  1289. {
  1290. _persistentValue.IsDiReplenOn = true;
  1291. }
  1292. return result;
  1293. }
  1294. /// <summary>
  1295. /// 打开继电器
  1296. /// </summary>
  1297. /// <returns></returns>
  1298. public void ResPowerOn()
  1299. {
  1300. bool result = false;
  1301. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{RESPOWERON}");
  1302. if (!string.IsNullOrEmpty(ioName))
  1303. {
  1304. result = IOModuleManager.Instance.WriteIoValue(ioName, true);
  1305. if (!result)
  1306. {
  1307. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Open {Module} Power Relay failed");
  1308. }
  1309. }
  1310. ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{HEDPOWERON}");
  1311. if (!string.IsNullOrEmpty(ioName))
  1312. {
  1313. result = IOModuleManager.Instance.WriteIoValue(ioName, true);
  1314. if (!result)
  1315. {
  1316. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Open {Module} Hed Power Relay failed");
  1317. }
  1318. }
  1319. }
  1320. /// <summary>
  1321. /// 检验DiReplen前置条件
  1322. /// </summary>
  1323. /// <returns></returns>
  1324. public bool CheckPreDiReplenCondition(bool showError)
  1325. {
  1326. if (!CheckFacilitiesDiReplenStatus() && showError)
  1327. {
  1328. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "Facilities DiReplen is Off");
  1329. return false;
  1330. }
  1331. SafetyDevice safetyDevice = DEVICE.GetDevice<SafetyDevice>("Safety");
  1332. if (safetyDevice != null && safetyDevice.SafetyData.ReservoirHighLevel)
  1333. {
  1334. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Safety high is Activate");
  1335. return false;
  1336. }
  1337. if (CheckOtherReservoirDiReplenStatus(showError))
  1338. {
  1339. return false;
  1340. }
  1341. return true;
  1342. }
  1343. /// <summary>
  1344. /// 检验总Di有没有开
  1345. /// </summary>
  1346. /// <returns></returns>
  1347. private bool CheckFacilitiesDiReplenStatus()
  1348. {
  1349. SystemFacilities systemFacilities = DEVICE.GetDevice<SystemFacilities>("System.Facilities");
  1350. if (systemFacilities != null)
  1351. {
  1352. return systemFacilities.DIReplenEnable;
  1353. }
  1354. return false;
  1355. }
  1356. /// <summary>
  1357. /// 检验是否其他Reservoir Direplen已经
  1358. /// </summary>
  1359. /// <returns></returns>
  1360. private bool CheckOtherReservoirDiReplenStatus(bool showError)
  1361. {
  1362. List<string> reservoirs = ReservoirItemManager.Instance.InstalledModules;
  1363. foreach (string item in reservoirs)
  1364. {
  1365. if (item != Module)
  1366. {
  1367. ReservoirItem reservoirItem = ReservoirItemManager.Instance.GetReservoirItem(item);
  1368. if (reservoirItem.SubType == STRATUS)
  1369. {
  1370. StandardHotReservoirDevice tmpDevice = DEVICE.GetDevice<StandardHotReservoirDevice>(item);
  1371. if (tmpDevice.ReservoirData.DiReplen && showError)
  1372. {
  1373. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{item} direplen valve is on");
  1374. return true;
  1375. }
  1376. }
  1377. else
  1378. {
  1379. CompactMembranReservoirDevice tmpDevice = DEVICE.GetDevice<CompactMembranReservoirDevice>(item);
  1380. if (tmpDevice.ReservoirData.ANDiReplen && showError)
  1381. {
  1382. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{item} ANDireplen valve is on");
  1383. return true;
  1384. }
  1385. if (tmpDevice.ReservoirData.CADiReplen && showError)
  1386. {
  1387. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{item} CADireplen valve is on");
  1388. return true;
  1389. }
  1390. }
  1391. }
  1392. }
  1393. return false;
  1394. }
  1395. /// <summary>
  1396. /// DiReplen Off
  1397. /// </summary>
  1398. /// <param name="cmd"></param>
  1399. /// <param name="args"></param>
  1400. /// <returns></returns>
  1401. private bool DIReplenOff(string cmd, object[] args)
  1402. {
  1403. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{DI_REPLEN}");
  1404. bool result = IOModuleManager.Instance.WriteIoValue(ioName, false);
  1405. if (result)
  1406. {
  1407. _persistentValue.IsDiReplenOn = false;
  1408. if (_currentOperation == ReservoirOperation.ManualDiReplen || _currentOperation == ReservoirOperation.AutoDiReplen)
  1409. {
  1410. _currentOperation = ReservoirOperation.None;
  1411. _persistentValue.LastTotalReplen = _persistentValue.TotalReplen;
  1412. ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
  1413. }
  1414. }
  1415. return result;
  1416. }
  1417. /// <summary>
  1418. /// 手动注水
  1419. /// </summary>
  1420. /// <param name="cmd"></param>
  1421. /// <param name="args"></param>
  1422. /// <returns></returns>
  1423. private bool ManualDiReplen(string cmd, object[] args)
  1424. {
  1425. if (_currentOperation != ReservoirOperation.None)
  1426. {
  1427. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"current operation is {_currentOperation},cannot execute ManualDireplen operation");
  1428. return false;
  1429. }
  1430. ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(Module);
  1431. if (!reservoirEntity.IsInitialized)
  1432. {
  1433. LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"{Module} is not initialized. Can't start DiReplen");
  1434. return false;
  1435. }
  1436. if (DiReplenMaxTimeOut)
  1437. {
  1438. double diValveMaxOnTime = SC.GetValue<double>($"Reservoir.{Module}.DIValveMaxOnTime");
  1439. LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"Direplen time over conifg's DIValveMaxOnTime:{diValveMaxOnTime} min");
  1440. return false;
  1441. }
  1442. bool result = DIReplenOnOperation("", null);
  1443. if (result)
  1444. {
  1445. _currentOperation = ReservoirOperation.ManualDiReplen;
  1446. _persistentValue.DiReplenTime = DateTime.Now;
  1447. ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
  1448. int.TryParse(args[0].ToString(), out _manualReplenSecond);
  1449. }
  1450. return result;
  1451. }
  1452. /// <summary>
  1453. /// 自动注水
  1454. /// </summary>
  1455. /// <returns></returns>
  1456. public bool AutoDireplen()
  1457. {
  1458. if (ReservoirData.WaterLevel < SC.GetValue<double>($"Reservoir.{Module}.LowLevel") && !_isAutoDIReplenError)
  1459. {
  1460. _isAutoDIReplenError = true;
  1461. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"LowLevel is activate,Can't AutoDireplen");
  1462. return false;
  1463. }
  1464. else
  1465. {
  1466. _isAutoDIReplenError = false;
  1467. }
  1468. if (_currentOperation != ReservoirOperation.None)
  1469. {
  1470. return false;
  1471. }
  1472. if (_resRecipe == null)
  1473. {
  1474. return false;
  1475. }
  1476. bool result = DIReplenOn(false);
  1477. if (result)
  1478. {
  1479. LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, $"{Module} CADIReplen State :True, " +
  1480. $"SetPoint = {Recipe.CAFlowSetPoint} " +
  1481. $"Level = {_reservoirData.Level} " +
  1482. $"HighLimit = {Recipe.CALevelErrorHigh} " +
  1483. $"LowLimit = {Recipe.CALevelErrorLow} ");
  1484. _currentOperation = ReservoirOperation.AutoDiReplen;
  1485. _persistentValue.DiReplenTime = DateTime.Now;
  1486. }
  1487. return result;
  1488. }
  1489. /// <summary>
  1490. /// 启动PH检测
  1491. /// </summary>
  1492. public bool StartDetectPHValve()
  1493. {
  1494. string phProbeType = "";
  1495. ReservoirItem reservoirItem = ReservoirItemManager.Instance.GetReservoirItem(Module.ToString());
  1496. if (reservoirItem != null)
  1497. {
  1498. phProbeType = reservoirItem.PHProbeType;
  1499. }
  1500. if (_persistentValue.OperatingMode == MANUAL || string.IsNullOrEmpty(phProbeType))
  1501. {
  1502. return false;
  1503. }
  1504. _phState = _phRoutine.Start();
  1505. LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, "Start Detect PH");
  1506. return true;
  1507. }
  1508. /// <summary>
  1509. /// 打开PH Valve
  1510. /// </summary>
  1511. /// <returns></returns>
  1512. public bool PHValveOn()
  1513. {
  1514. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{PH_FLOW_VALVE}");
  1515. return IOModuleManager.Instance.WriteIoValue(ioName, true);
  1516. }
  1517. /// <summary>
  1518. /// 关闭PH Valve
  1519. /// </summary>
  1520. /// <returns></returns>
  1521. public bool PHValveOff()
  1522. {
  1523. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{PH_FLOW_VALVE}");
  1524. return IOModuleManager.Instance.WriteIoValue(ioName, false);
  1525. }
  1526. /// <summary>
  1527. /// CAFlowRateCheck
  1528. /// </summary>
  1529. private void CAFlowRateCheck()
  1530. {
  1531. if (_resRecipe == null) return;
  1532. for (int i = 0; i < _metalDevices.Count; i++)
  1533. {
  1534. StandardHotMetalDevice hotMetalDevice = _metalDevices[i];
  1535. if (hotMetalDevice != null && !hotMetalDevice.IsDisable && hotMetalDevice.IsAuto)
  1536. {
  1537. if (hotMetalDevice.MetalDeviceData == null || !hotMetalDevice.MetalDeviceData.Circulation) continue;
  1538. if (!hotMetalDevice.FlowValveStable) continue;
  1539. MetalEntity metalEntity = Singleton<RouteManager>.Instance.GetModule<MetalEntity>(hotMetalDevice.Name);
  1540. double cellFlow = hotMetalDevice.MetalDeviceData.CellFlow;
  1541. //if (cellFlow < _resRecipe.CAFlowRateErrorLow)
  1542. //{
  1543. // if (!metalEntity.IsError)
  1544. // {
  1545. // LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"cell {hotMetalDevice.Name} cellflow:{cellFlow} is less than recipe's CAFlowRateErrorLow parameter:{_resRecipe.CAFlowRateErrorLow}");
  1546. // metalEntity.PostMsg(MetalMsg.Error);
  1547. // }
  1548. //}
  1549. bool cellFlowSignalresulte = _holdoffTimeSignalDic[$"{hotMetalDevice.Name}_CellFlow"].IsSignalAbnormal(_cellFlowHoldoffTime, cellFlow, null, _resRecipe.CAFlowRateErrorLow);
  1550. if (cellFlowSignalresulte)
  1551. {
  1552. if (!metalEntity.IsError)
  1553. {
  1554. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{hotMetalDevice.Name} cellflow:{cellFlow} is less than recipe's CAFlowRateErrorLow parameter:{_resRecipe.CAFlowRateErrorLow}");
  1555. metalEntity.PostMsg(MetalMsg.Error);
  1556. }
  1557. }
  1558. else if (cellFlow < _resRecipe.CAFlowRateWarningLow)
  1559. {
  1560. if (!_isCAFlowRateWARN[i])
  1561. {
  1562. LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"cell {hotMetalDevice.Name} cellflow:{cellFlow} is less than recipe's CAFlowRateWarningLow parameter:{_resRecipe.CAFlowRateWarningLow}");
  1563. _isCAFlowRateWARN[i] = true;
  1564. }
  1565. }
  1566. else
  1567. {
  1568. _isCAFlowRateWARN[i] = false;
  1569. }
  1570. }
  1571. }
  1572. }
  1573. /// <summary>
  1574. /// Temperature Check
  1575. /// </summary>
  1576. private void TemperatureCheck()
  1577. {
  1578. ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(Module);
  1579. ReservoirItem reservoirItem = ReservoirItemManager.Instance.GetReservoirItem(Module);
  1580. TemperatureController temperatureController = DEVICE.GetDevice<TemperatureController>(reservoirItem.TCID);
  1581. if (temperatureController == null || temperatureController.TemperatureData == null || _resRecipe == null
  1582. || temperatureController.TemperatureData.ControlOperationModel != ENABLE) return;
  1583. double tempValue = temperatureController.TemperatureData.ReserviorTemperature;
  1584. if (tempValue > _resRecipe.TemperatureErrorHigh && !reservoirEntity.IsError)
  1585. {
  1586. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{temperatureController.Name} temperature:{tempValue} is over recipe's TemperatureErrorHigh parameter:{_resRecipe.TemperatureErrorHigh}");
  1587. reservoirEntity.PostMsg(ReservoirMsg.Error);
  1588. }
  1589. else if (tempValue < _resRecipe.TemperatureErrorLow && !reservoirEntity.IsError)
  1590. {
  1591. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{temperatureController.Name} temperature:{tempValue} is less than recipe's TemperatureErrorLow parameter:{_resRecipe.TemperatureErrorLow}");
  1592. reservoirEntity.PostMsg(ReservoirMsg.Error);
  1593. }
  1594. else if (tempValue > _resRecipe.TemperatureWarningHigh)
  1595. {
  1596. if (!_isTCControlWARN)
  1597. {
  1598. LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"{temperatureController.Name} temperature:{tempValue} is over recipe's TemperatureWarningHigh parameter:{_resRecipe.TemperatureWarningHigh}");
  1599. _isTCControlWARN = true;
  1600. }
  1601. }
  1602. else if (tempValue < _resRecipe.TemperatureWarningLow)
  1603. {
  1604. if (!_isTCControlWARN)
  1605. {
  1606. LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"{temperatureController.Name} temperature:{tempValue} is less than recipe's TemperatureWarningLow parameter:{_resRecipe.TemperatureWarningLow}");
  1607. _isTCControlWARN = true;
  1608. }
  1609. }
  1610. else
  1611. {
  1612. _isTCControlWARN = false;
  1613. }
  1614. }
  1615. /// <summary>
  1616. /// CMMPowerCheck
  1617. /// </summary>
  1618. private void CMMPowerCheck()
  1619. {
  1620. ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(Module);
  1621. ReservoirItem _reservoirItem = ReservoirItemManager.Instance.GetReservoirItem(Module.ToString());
  1622. if (!string.IsNullOrEmpty(_reservoirItem.CMMSupplyID))
  1623. {
  1624. CellPowerSupplier _powerSupplier = DEVICE.GetDevice<CellPowerSupplier>(_reservoirItem.CMMSupplyID);
  1625. if (_powerSupplier == null || _powerSupplier.PowerSupplierData == null || _resRecipe == null || !_resRecipe.CMMEnable || !_powerSupplier.PowerSupplierData.Enabled || _powerSupplier.PowerSupplierData.Current == 0) return;
  1626. //CMM Current Check
  1627. double current = _powerSupplier.PowerSupplierData.Current;
  1628. if (current > _resRecipe.CMMCurrentSetPoint * (1 + (double)_resRecipe.CMMCurrentFaultPercent / 100))
  1629. {
  1630. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{_powerSupplier.Name} current:{current} is over error upper limit:{_resRecipe.CMMCurrentSetPoint * (1 + (double)_resRecipe.CMMCurrentFaultPercent / 100)} based on recipe's CMMCurrentFaultPercent parameter:{_resRecipe.CMMCurrentFaultPercent} %");
  1631. reservoirEntity.PostMsg(ReservoirMsg.Error);
  1632. if (_powerSupplier.PowerSupplierData.Enabled)
  1633. {
  1634. _powerSupplier.DisableOperation("", null);
  1635. _persistentValue.CMMStartTime = DateTime.MinValue;
  1636. ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
  1637. }
  1638. }
  1639. else if (current < _resRecipe.CMMCurrentSetPoint * (1 - (double)_resRecipe.CMMCurrentFaultPercent / 100))
  1640. {
  1641. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{_powerSupplier.Name} current:{current} is less than error lower limit:{_resRecipe.CMMCurrentSetPoint * (1 - (double)_resRecipe.CMMCurrentFaultPercent / 100)} based on recipe's CMMCurrentFaultPercent parameter:{_resRecipe.CMMCurrentFaultPercent}%");
  1642. reservoirEntity.PostMsg(ReservoirMsg.Error);
  1643. if (_powerSupplier.PowerSupplierData.Enabled)
  1644. {
  1645. _powerSupplier.DisableOperation("", null);
  1646. _persistentValue.CMMStartTime = DateTime.MinValue;
  1647. ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
  1648. }
  1649. }
  1650. else if (current > _resRecipe.CMMCurrentSetPoint * (1 + (double)_resRecipe.CMMCurrentWarningPercent / 100))
  1651. {
  1652. if (!_isCMMPowerCurrentWARN)
  1653. {
  1654. LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"{_powerSupplier.Name} current:{current} is over warning upper limit:{_resRecipe.CMMCurrentSetPoint * (1 + (double)_resRecipe.CMMCurrentWarningPercent / 100)} based on recipe's CMMCurrentWarningPercent parameter:{_resRecipe.CMMCurrentWarningPercent}%");
  1655. _isCMMPowerCurrentWARN = true;
  1656. }
  1657. }
  1658. else if (current < _resRecipe.CMMCurrentSetPoint * (1 - (double)_resRecipe.CMMCurrentWarningPercent / 100))
  1659. {
  1660. if (!_isCMMPowerCurrentWARN)
  1661. {
  1662. LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"{_powerSupplier.Name} current:{current} is less than warning lower limit{_resRecipe.CMMCurrentSetPoint * (1 - (double)_resRecipe.CMMCurrentWarningPercent / 100)} based on recipe's CMMCurrentWarningPercent parameter:{_resRecipe.CMMCurrentWarningPercent}%");
  1663. _isCMMPowerCurrentWARN = true;
  1664. }
  1665. }
  1666. else
  1667. {
  1668. _isCMMPowerCurrentWARN = false;
  1669. }
  1670. //CMM Voltage Check
  1671. double voltage = _powerSupplier.PowerSupplierData.Voltage;
  1672. if (voltage < _resRecipe.CMMMinVoltage)
  1673. {
  1674. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{_powerSupplier.Name} voltage:{voltage} is less than recipe's CMMMinVoltage parameter:{_resRecipe.CMMMinVoltage}");
  1675. reservoirEntity.PostMsg(ReservoirMsg.Error);
  1676. if (_powerSupplier.PowerSupplierData.Enabled) _powerSupplier.DisableOperation("", null);
  1677. }
  1678. //CMM Flow Check
  1679. double flow = ReservoirData.Flow;
  1680. double cmmFlowHighFault = SC.GetValue<double>($"Reservoir.{Module}.CMMFlowHighFault");
  1681. double cmmFlowHighWarning = SC.GetValue<double>($"Reservoir.{Module}.CMMFlowHighWarning");
  1682. double cmmFlowLowFault = SC.GetValue<double>($"Reservoir.{Module}.CMMFlowLowFault");
  1683. double cmmFlowLowWarning = SC.GetValue<double>($"Reservoir.{Module}.CMMFlowLowWarning");
  1684. if (flow < cmmFlowLowFault)
  1685. {
  1686. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{Module} CMM flow:{flow} is less than config item CMMFlowLowFault:{cmmFlowLowFault}");
  1687. if (_powerSupplier.PowerSupplierData.Enabled) _powerSupplier.DisableOperation("", null);
  1688. reservoirEntity.PostMsg(ReservoirMsg.Error);
  1689. }
  1690. else if (flow < cmmFlowLowWarning)
  1691. {
  1692. if (!_isCMMPowerFlowWARN)
  1693. {
  1694. LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"{Module} CMM flow:{flow} is less than config item CMMFlowLowWarning:{cmmFlowLowWarning}");
  1695. _isCMMPowerFlowWARN = true;
  1696. }
  1697. }
  1698. else if (flow > cmmFlowHighFault)
  1699. {
  1700. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{Module} CMM flow:{flow} is over config item CMMFlowHighFault:{cmmFlowLowFault}");
  1701. if (_powerSupplier.PowerSupplierData.Enabled) _powerSupplier.DisableOperation("", null);
  1702. reservoirEntity.PostMsg(ReservoirMsg.Error);
  1703. }
  1704. else if (flow > cmmFlowHighWarning)
  1705. {
  1706. if (!_isCMMPowerFlowWARN)
  1707. {
  1708. LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"{Module} CMM flow:{flow} is over config item CMMFlowHighWarning:{cmmFlowLowWarning}");
  1709. _isCMMPowerFlowWARN = true;
  1710. }
  1711. }
  1712. else
  1713. {
  1714. _isCMMPowerFlowWARN = false;
  1715. }
  1716. }
  1717. }
  1718. #region DosingSystem
  1719. /// <summary>
  1720. /// 加载Replen Recipe
  1721. /// </summary>
  1722. /// <param name="cmd"></param>
  1723. /// <param name="args"></param>
  1724. /// <returns></returns>
  1725. private bool LoadDosingRecipeOperation(string cmd, object[] args)
  1726. {
  1727. string replenName = args[1].ToString();
  1728. int replenID = int.Parse(args[1].ToString().Substring(6, 1));
  1729. string replenRecipe = args[0].ToString();
  1730. _rdsRecipe[replenID - 1] = RecipeFileManager.Instance.LoadGenericityRecipe<RdsRecipe>(replenRecipe);
  1731. _replenDatas[replenID - 1].RecipeName = args[2].ToString();
  1732. LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, $"Load Replen Recipe {_rdsRecipe[replenID - 1].Ppid} Success");
  1733. return true;
  1734. }
  1735. #region Replen Pump
  1736. /// <summary>
  1737. /// Replen Pump On 操作(根据PumpFactor和InitialDosingSpeed调速)
  1738. /// </summary>
  1739. /// <param name="cmd"></param>
  1740. /// <param name="args"></param>
  1741. /// <returns></returns>
  1742. public bool ReplenPumpOnOperation(string cmd, object[] args)
  1743. {
  1744. string replenName = args[0].ToString();
  1745. int replenID = int.Parse(args[0].ToString().Substring(6, 1));
  1746. //加载InitialDosingSpeed
  1747. double InitialDosingSpeed = 0;
  1748. if (SC.ContainsItem($"Reservoir.{Module}.InitialDosingSpeed"))
  1749. {
  1750. InitialDosingSpeed = SC.GetValue<double>($"Reservoir.{Module}.InitialDosingSpeed");
  1751. if (InitialDosingSpeed == 0)
  1752. {
  1753. _replenDatas[replenID - 1].ReplenPumpEnable = false;
  1754. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "InitialDosingSpeed is zero. Can't open replen pump");
  1755. return false;
  1756. }
  1757. }
  1758. else
  1759. {
  1760. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "Configuration item of InitialDosingSpeed doesn't exist!");
  1761. return false;
  1762. }
  1763. //加载ReplenPumpFactor
  1764. double PumpFactor = 0;
  1765. PumpFactor = _replenPersistentValue[replenName].ReplenPumpFactor;
  1766. if (PumpFactor == 0)
  1767. {
  1768. _replenDatas[replenID - 1].ReplenPumpEnable = false;
  1769. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "PumpFactor is zero. Can't open replen pump");
  1770. return false;
  1771. }
  1772. //计算PumpSpeed(mL/min)
  1773. double replenPumpSpeed = InitialDosingSpeed * PumpFactor;
  1774. SCConfigItem item = SC.GetConfigItem($"Reservoir.{Module}.InitialDosingSpeed");
  1775. double speedMax = double.Parse(item.Max);
  1776. if (replenPumpSpeed > speedMax) replenPumpSpeed = speedMax;
  1777. bool result = ReplenPump(replenPumpSpeed / PUMP_SPEED_CONVERT, replenID);
  1778. if (!result)
  1779. {
  1780. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Opening replen{replenID} pump is failed");
  1781. _replenDatas[replenID - 1].ReplenPumpSpeed = 0;
  1782. _replenDatas[replenID - 1].ReplenPumpEnable = false;
  1783. return false;
  1784. }
  1785. _replenDatas[replenID - 1].ReplenPumpSpeed = replenPumpSpeed;
  1786. _replenDatas[replenID - 1].ReplenPumpEnable = true;
  1787. LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, $"Replen{replenID} pump is opened");
  1788. return true;
  1789. }
  1790. /// <summary>
  1791. /// Replen Pump Off操作
  1792. /// </summary>
  1793. /// <param name="cmd"></param>
  1794. /// <param name="args"></param>
  1795. /// <returns></returns>
  1796. public bool ReplenPumpOffOperation(string cmd, object[] args)
  1797. {
  1798. string replenName = args[0].ToString();
  1799. int replenID = int.Parse(args[0].ToString().Substring(6, 1));
  1800. bool result = ReplenPump(0, replenID);
  1801. if (!result)
  1802. {
  1803. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Closing replen{replenID} pump is failed");
  1804. return false;
  1805. }
  1806. _replenDatas[replenID - 1].ReplenPumpSpeed = 0;
  1807. _replenDatas[replenID - 1].ReplenPumpEnable = false;
  1808. LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, $"Replen{replenID} pump is closed");
  1809. return true;
  1810. }
  1811. /// <summary>
  1812. /// Replen Pump WriteIOValue
  1813. /// </summary>
  1814. /// <param name="speed"></param>
  1815. /// <returns></returns>
  1816. private bool ReplenPump(double speed, int replenNum)
  1817. {
  1818. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.Replen{replenNum}PumpSpeed");
  1819. return IOModuleManager.Instance.WriteIoValue(ioName, speed);
  1820. }
  1821. #endregion
  1822. /// <summary>
  1823. /// 设置PumpFactor
  1824. /// </summary>
  1825. /// <param name="cmd"></param>
  1826. /// <param name="args"></param>
  1827. /// <returns></returns>
  1828. public bool SetPumpFactor(string cmd, object[] args)
  1829. {
  1830. int replenID = int.Parse(args[0].ToString().Substring(6, 1));
  1831. double targetPumpFactor = (double)args[1];
  1832. _dosingSystemHelperLst[replenID - 1].SetPumpfactor(targetPumpFactor);
  1833. return true;
  1834. }
  1835. /// <summary>
  1836. /// 手动Dosing
  1837. /// </summary>
  1838. /// <param name="cmd"></param>
  1839. /// <param name="args"></param>
  1840. /// <returns></returns>
  1841. private bool ManualDosing(string cmd, object[] args)
  1842. {
  1843. ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(Module);
  1844. if (reservoirEntity == null || !_dosingCommonHelper.IsDosingSystemInitialized)
  1845. {
  1846. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "Dosing System is not initialized!");
  1847. return true;
  1848. }
  1849. string replenName = args[0].ToString();
  1850. int replenID = int.Parse(args[0].ToString().Substring(6, 1));
  1851. double manualDosingVolume = (double)args[1];
  1852. if (manualDosingVolume == 0)
  1853. {
  1854. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "Dosing Volume is zero, can't do manual dosing");
  1855. return false;
  1856. }
  1857. if (!CheckandUpdateBottleLevel(replenName, manualDosingVolume))
  1858. {
  1859. return false;
  1860. }
  1861. if (_replenPersistentValue[replenName].IsDosingRunning)
  1862. {
  1863. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "Dosing is runnning, can't do manual dosing");
  1864. return false;
  1865. }
  1866. LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, "ManualDosing starts now");
  1867. _currentDosingOperation[replenID - 1] = DosingOperation.ManualDosing;
  1868. bool result = _dosingSystemHelperLst[replenID - 1].StartDosing(manualDosingVolume, false);
  1869. return result;
  1870. }
  1871. /// <summary>
  1872. /// 停止手动Dosing
  1873. /// </summary>
  1874. /// <param name="cmd"></param>
  1875. /// <param name="args"></param>
  1876. /// <returns></returns>
  1877. private bool StopManualDosing(string cmd, object[] args)
  1878. {
  1879. string replenName = args[0].ToString();
  1880. int replenID = int.Parse(args[0].ToString().Substring(6, 1));
  1881. if (!_replenPersistentValue[replenName].IsDosingRunning)
  1882. {
  1883. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "ManualDosing is not running. Can't stop!");
  1884. }
  1885. _currentDosingOperation[replenID - 1] = DosingOperation.None;
  1886. bool result = _dosingSystemHelperLst[replenID - 1].StopDosing();
  1887. if (result)
  1888. {
  1889. LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, "ManualDosing has stopped now");
  1890. }
  1891. return result;
  1892. }
  1893. /// <summary>
  1894. /// 检查并更新BottleLevel状态
  1895. /// </summary>
  1896. /// <param name="replenName"></param>
  1897. /// <param name="targetVolume"></param>
  1898. public bool CheckandUpdateBottleLevel(string replenName, double targetVolume = -1, bool isError = true)
  1899. {
  1900. int replenId = int.Parse(replenName.Substring(6, 1));
  1901. double remainVolume = _replenPersistentValue[replenName].RemainDosingVolume;
  1902. bool result = true;
  1903. if (ReservoirData.ReplenLevel[replenId - 1])
  1904. {
  1905. ReplenDatas[replenId - 1].BottleLevel = DosingSystemHelper.BottleLevelState.Full.ToString();
  1906. if (targetVolume > remainVolume)
  1907. {
  1908. ReplenDatas[replenId - 1].BottleLevel = DosingSystemHelper.BottleLevelState.Warning.ToString();
  1909. if (isError)
  1910. {
  1911. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Current Bottle is in Warning Level!");
  1912. }
  1913. result = false;
  1914. }
  1915. }
  1916. else
  1917. {
  1918. ReplenDatas[replenId - 1].BottleLevel = DosingSystemHelper.BottleLevelState.Empty.ToString();
  1919. if (isError)
  1920. {
  1921. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Current Bottle is in Empty Level!");
  1922. }
  1923. result = false;
  1924. }
  1925. return result;
  1926. }
  1927. /// <summary>
  1928. /// Reset BottleVolume
  1929. /// </summary>
  1930. /// <param name="cmd"></param>
  1931. /// <param name="args"></param>
  1932. /// <returns></returns>
  1933. private bool ResetBottleVolume(string cmd, object[] args)
  1934. {
  1935. string replenName = args[0].ToString();
  1936. int replenID = int.Parse(args[0].ToString().Substring(6, 1));
  1937. if (SC.ContainsItem($"Reservoir.{Module}.BottleReserveVolume{replenID}"))
  1938. {
  1939. _replenPersistentValue[replenName].RemainDosingVolume = SC.GetValue<double>($"Reservoir.{Module}.BottleReserveVolume{replenID}");
  1940. }
  1941. ReplenPersistentManager.Instance.UpdatePersistentValue(Module, replenName);
  1942. LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, $"Bottle Reserve Volume of Replen{replenID} has been reset now");
  1943. return true;
  1944. }
  1945. /// <summary>
  1946. /// DosingSystem初始化
  1947. /// </summary>
  1948. /// <param name="cmd"></param>
  1949. /// <param name="args"></param>
  1950. /// <returns></returns>
  1951. private bool DosingInitialize(string cmd, object[] args)
  1952. {
  1953. ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(Module);
  1954. if (reservoirEntity == null || !reservoirEntity.IsInitialized)
  1955. {
  1956. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{Module} is not initialized");
  1957. return false;
  1958. }
  1959. return _dosingCommonHelper.DosingInitialize(); ;
  1960. }
  1961. /// <summary>
  1962. /// Enetr Init State
  1963. /// </summary>
  1964. /// <param name="cmd"></param>
  1965. /// <param name="args"></param>
  1966. /// <returns></returns>
  1967. private bool DosingEnterInit()
  1968. {
  1969. return _dosingCommonHelper.DosingEnterInit();
  1970. }
  1971. #endregion
  1972. /// <summary>
  1973. /// Enter Disabled Operation
  1974. /// </summary>
  1975. private void EnterDisabledOperation()
  1976. {
  1977. ReservoirItem _reservoirItem = ReservoirItemManager.Instance.GetReservoirItem(Module.ToString());
  1978. //关CMMPower
  1979. if (!string.IsNullOrEmpty(_reservoirItem.CMMSupplyID))
  1980. {
  1981. CellPowerSupplier powerSupplier = DEVICE.GetDevice<CellPowerSupplier>(_reservoirItem.CMMSupplyID);
  1982. if (powerSupplier != null && powerSupplier.PowerSupplierData.Enabled) powerSupplier.DisableOperation("", null);
  1983. }
  1984. //关TC
  1985. if (!string.IsNullOrEmpty(_reservoirItem.TCID))
  1986. {
  1987. TemperatureController temperatureController = DEVICE.GetDevice<TemperatureController>(_reservoirItem.TCID);
  1988. if (temperatureController != null) temperatureController.DisableOperation("", null);
  1989. }
  1990. _phRoutine.Abort();
  1991. if (_reservoirData.PHFlowValve)
  1992. {
  1993. PHValveOff();
  1994. }
  1995. if (_reservoirData.DiReplen)
  1996. {
  1997. DIReplenOff("", null);
  1998. }
  1999. }
  2000. /// <summary>
  2001. /// Set Export CMMUsage
  2002. /// </summary>
  2003. public void SetExportCMMUsage()
  2004. {
  2005. _isExportCMMUsage = true;
  2006. }
  2007. /// <summary>
  2008. /// ReservoirUsage监控
  2009. /// </summary>
  2010. public void ReservoirUsageMonitor()
  2011. {
  2012. ReservoirUsage reservoirUsage = ReservoirUsageManager.Instance.GetReservoirUsage(Module);
  2013. ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(Module);
  2014. if (reservoirUsage == null || reservoirEntity == null) return;
  2015. //reservoirTotalAmpHours Check
  2016. double reservoirTotalAmpHoursWarningLimit = 0;
  2017. if (SC.ContainsItem($"Reservoir.{Module}.ReservoirTotalAmpHoursWarningLimit"))
  2018. {
  2019. reservoirTotalAmpHoursWarningLimit = (double)SC.GetValue<double>($"Reservoir.{Module}.ReservoirTotalAmpHoursWarningLimit");
  2020. }
  2021. double reservoirTotalAmpHoursFaultLimit = 0;
  2022. if (SC.ContainsItem($"Reservoir.{Module}.ReservoirTotalAmpHoursFaultLimit"))
  2023. {
  2024. reservoirTotalAmpHoursFaultLimit = (double)SC.GetValue<double>($"Reservoir.{Module}.ReservoirTotalAmpHoursFaultLimit");
  2025. }
  2026. if (reservoirUsage.TotalUsage > reservoirTotalAmpHoursFaultLimit && reservoirTotalAmpHoursFaultLimit != 0)
  2027. {
  2028. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{Module} Total Usage(AHr):{reservoirUsage.TotalUsage} is over config item ReservoirTotalAmpHoursFaultLimit:{reservoirTotalAmpHoursFaultLimit}");
  2029. reservoirEntity.PostMsg(ReservoirMsg.Error);
  2030. AlarmListManager.Instance.AddDataError(Module,
  2031. $"TotalUsage", $"{Module} usage:{reservoirUsage.TotalUsage} is over ReservoirTotalAmpHoursFaultLimit:{reservoirTotalAmpHoursFaultLimit}");
  2032. }
  2033. else if (reservoirUsage.TotalUsage > reservoirTotalAmpHoursWarningLimit && reservoirTotalAmpHoursWarningLimit != 0)
  2034. {
  2035. LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"{Module} Total Usage(AHr):{reservoirUsage.TotalUsage} is over config item ReservoirTotalAmpHoursWarningLimit:{reservoirTotalAmpHoursWarningLimit}");
  2036. AlarmListManager.Instance.AddWarn(Module,
  2037. $"TotalUsage", $"{Module} usage:{reservoirUsage.TotalUsage} is over ReservoirTotalAmpHoursWarningLimit:{reservoirTotalAmpHoursWarningLimit}");
  2038. }
  2039. //MembraneTotalAmpHoursCheck
  2040. double membraneTotalAmpHoursWarningLimit = 0;
  2041. if (SC.ContainsItem($"Reservoir.{Module}.MembraneTotalAmpHoursWarningLimit"))
  2042. {
  2043. membraneTotalAmpHoursWarningLimit = (double)SC.GetValue<double>($"Reservoir.{Module}.MembraneTotalAmpHoursWarningLimit");
  2044. }
  2045. double membraneTotalAmpHoursFaultLimit = 0;
  2046. if (SC.ContainsItem($"Reservoir.{Module}.MembraneTotalAmpHoursFaultLimit"))
  2047. {
  2048. membraneTotalAmpHoursFaultLimit = (double)SC.GetValue<double>($"Reservoir.{Module}.MembraneTotalAmpHoursFaultLimit");
  2049. }
  2050. if (reservoirUsage.MembranceUsage > membraneTotalAmpHoursFaultLimit && membraneTotalAmpHoursFaultLimit != 0)
  2051. {
  2052. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{Module} Membrane Usage(AHr):{reservoirUsage.MembranceUsage} is over config item MembraneTotalAmpHoursFaultLimit:{membraneTotalAmpHoursFaultLimit}");
  2053. reservoirEntity.PostMsg(ReservoirMsg.Error);
  2054. AlarmListManager.Instance.AddDataError(Module,
  2055. $"MembraneUsage", $"{Module} usage:{reservoirUsage.MembranceUsage} is over MembraneTotalAmpHoursFaultLimit:{membraneTotalAmpHoursFaultLimit}");
  2056. }
  2057. else if (reservoirUsage.MembranceUsage > membraneTotalAmpHoursWarningLimit && membraneTotalAmpHoursWarningLimit != 0)
  2058. {
  2059. LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"{Module} Membrane Usage(AHr):{reservoirUsage.MembranceUsage} is over config item MembraneTotalAmpHoursWarningLimit:{membraneTotalAmpHoursWarningLimit}");
  2060. AlarmListManager.Instance.AddWarn(Module,
  2061. $"MembraneUsage", $"{Module} usage:{reservoirUsage.MembranceUsage} is over MembraneTotalAmpHoursWarningLimit:{membraneTotalAmpHoursWarningLimit}");
  2062. }
  2063. double bathTotalAmpHoursWarningLimit = 0;
  2064. if (SC.ContainsItem($"Reservoir.{Module}.BathTotalAmpHoursWarningLimit"))
  2065. {
  2066. bathTotalAmpHoursWarningLimit = (double)SC.GetValue<double>($"Reservoir.{Module}.BathTotalAmpHoursWarningLimit");
  2067. }
  2068. double bathTotalAmpHoursFaultLimit = 0;
  2069. if (SC.ContainsItem($"Reservoir.{Module}.BathTotalAmpHoursFaultLimit"))
  2070. {
  2071. bathTotalAmpHoursFaultLimit = (double)SC.GetValue<double>($"Reservoir.{Module}.BathTotalAmpHoursFaultLimit");
  2072. }
  2073. if (reservoirUsage.BathUsage > bathTotalAmpHoursFaultLimit && bathTotalAmpHoursFaultLimit != 0)
  2074. {
  2075. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{Module} Bath Usage(AHr):{reservoirUsage.BathUsage} is over config item BathTotalAmpHoursFaultLimit:{bathTotalAmpHoursFaultLimit}");
  2076. reservoirEntity.PostMsg(ReservoirMsg.Error);
  2077. AlarmListManager.Instance.AddDataError(Module,
  2078. $"BathUsage", $"{Module} usage:{reservoirUsage.BathUsage} is over BathTotalAmpHoursFaultLimit:{bathTotalAmpHoursFaultLimit}");
  2079. }
  2080. else if (reservoirUsage.BathUsage > bathTotalAmpHoursWarningLimit && bathTotalAmpHoursWarningLimit != 0)
  2081. {
  2082. LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"{Module} Bath Usage(AHr):{reservoirUsage.BathUsage} is over config item BathTotalAmpHoursWarningLimit:{bathTotalAmpHoursWarningLimit}");
  2083. AlarmListManager.Instance.AddWarn(Module,
  2084. $"BathUsage", $"{Module} usage:{reservoirUsage.BathUsage} is over BathTotalAmpHoursWarningLimit:{bathTotalAmpHoursWarningLimit}");
  2085. }
  2086. //BathTotalDaysCheck
  2087. int bathTotalDaysWarningLimit = 0;
  2088. if (SC.ContainsItem($"Reservoir.{Module}.BathTotalDaysWarningLimit"))
  2089. {
  2090. bathTotalDaysWarningLimit = SC.GetValue<int>($"Reservoir.{Module}.BathTotalDaysWarningLimit");
  2091. }
  2092. int bathTotalDaysFaultLimit = 0;
  2093. if (SC.ContainsItem($"Reservoir.{Module}.BathTotalDaysFaultLimit"))
  2094. {
  2095. bathTotalDaysFaultLimit = SC.GetValue<int>($"Reservoir.{Module}.BathTotalDaysFaultLimit");
  2096. }
  2097. if (reservoirUsage.BathUsageDays > bathTotalDaysFaultLimit && bathTotalDaysFaultLimit != 0)
  2098. {
  2099. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{Module} Bath Usage(Days):{reservoirUsage.BathUsageDays} is over config item BathTotalDaysFaultLimit:{bathTotalDaysFaultLimit}");
  2100. reservoirEntity.PostMsg(ReservoirMsg.Error);
  2101. AlarmListManager.Instance.AddDataError(Module,
  2102. $"BathUsageDays", $"{Module} usage:{reservoirUsage.BathUsageDays} is over BathTotalDaysFaultLimit:{bathTotalDaysFaultLimit}");
  2103. }
  2104. else if (reservoirUsage.BathUsageDays > bathTotalDaysWarningLimit && bathTotalDaysWarningLimit != 0)
  2105. {
  2106. LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"{Module} Bath Usage(Days):{reservoirUsage.BathUsageDays} is over config item BathTotalDaysWarningLimit:{bathTotalDaysWarningLimit}");
  2107. AlarmListManager.Instance.AddWarn(Module,
  2108. $"BathUsageDays", $"{Module} usage:{reservoirUsage.BathUsageDays} is over BathTotalDaysWarningLimit:{bathTotalDaysWarningLimit}");
  2109. }
  2110. //ReservoirTotalWafersCheck
  2111. int reservoirTotalWafersWarningLimit = 0;
  2112. if (SC.ContainsItem($"Reservoir.{Module}.ReservoirTotalWafersWarningLimit"))
  2113. {
  2114. reservoirTotalWafersWarningLimit = SC.GetValue<int>($"Reservoir.{Module}.ReservoirTotalWafersWarningLimit");
  2115. }
  2116. int reservoirTotalWafersFaultLimit = 0;
  2117. if (SC.ContainsItem($"Reservoir.{Module}.ReservoirTotalWafersFaultLimit"))
  2118. {
  2119. reservoirTotalWafersFaultLimit = SC.GetValue<int>($"Reservoir.{Module}.ReservoirTotalWafersFaultLimit");
  2120. }
  2121. if (reservoirUsage.TotalWafers > reservoirTotalWafersFaultLimit && reservoirTotalWafersFaultLimit != 0)
  2122. {
  2123. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{Module} Total Wafers:{reservoirUsage.TotalWafers} is over config item ReservoirTotalWafersFaultLimit:{reservoirTotalWafersFaultLimit}");
  2124. reservoirEntity.PostMsg(ReservoirMsg.Error);
  2125. AlarmListManager.Instance.AddDataError(Module,
  2126. $"TotalWafers", $"{Module} usage:{reservoirUsage.TotalWafers} is over ReservoirTotalWafersFaultLimit:{reservoirTotalWafersFaultLimit}");
  2127. }
  2128. else if (reservoirUsage.TotalWafers > reservoirTotalWafersWarningLimit && reservoirTotalWafersWarningLimit != 0)
  2129. {
  2130. LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"{Module} Total Wafers:{reservoirUsage.TotalWafers} is over config item ReservoirTotalWafersWarningLimit:{reservoirTotalWafersWarningLimit}");
  2131. AlarmListManager.Instance.AddWarn(Module,
  2132. $"TotalWafers", $"{Module} usage:{reservoirUsage.TotalWafers} is over ReservoirTotalWafersWarningLimit:{reservoirTotalWafersWarningLimit}");
  2133. }
  2134. //CMMAnodeTotalAmpHoursCheck
  2135. double cmmAnodeTotalAmpHoursWarningLimit = 0;
  2136. if (SC.ContainsItem($"Reservoir.{Module}.CMMAnodeTotalAmpHoursWarningLimit"))
  2137. {
  2138. cmmAnodeTotalAmpHoursWarningLimit = (double)SC.GetValue<double>($"Reservoir.{Module}.CMMAnodeTotalAmpHoursWarningLimit");
  2139. }
  2140. double cmmAnodeTotalAmpHoursFaultLimit = 0;
  2141. if (SC.ContainsItem($"Reservoir.{Module}.CMMAnodeTotalAmpHoursFaultLimit"))
  2142. {
  2143. cmmAnodeTotalAmpHoursFaultLimit = (double)SC.GetValue<double>($"Reservoir.{Module}.CMMAnodeTotalAmpHoursFaultLimit");
  2144. }
  2145. if (reservoirUsage.CMMAnodeUsage > cmmAnodeTotalAmpHoursFaultLimit && cmmAnodeTotalAmpHoursFaultLimit != 0)
  2146. {
  2147. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{Module} CMM Anode Usage(AHr):{reservoirUsage.CMMAnodeUsage} is over config item CMMAnodeTotalAmpHoursFaultLimit:{cmmAnodeTotalAmpHoursFaultLimit}");
  2148. reservoirEntity.PostMsg(ReservoirMsg.Error);
  2149. AlarmListManager.Instance.AddDataError(Module,
  2150. $"CMMAnodeUsage", $"{Module} CMM Anode Usage(AHr):{reservoirUsage.CMMAnodeUsage} is over CMMAnodeTotalAmpHoursFaultLimit:{cmmAnodeTotalAmpHoursFaultLimit}");
  2151. }
  2152. else if (reservoirUsage.CMMAnodeUsage > cmmAnodeTotalAmpHoursWarningLimit && cmmAnodeTotalAmpHoursWarningLimit != 0)
  2153. {
  2154. LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"{Module} CMM Anode Usage(AHr):{reservoirUsage.CMMAnodeUsage} is over config item CMMAnodeTotalAmpHoursWarningLimit:{cmmAnodeTotalAmpHoursWarningLimit}");
  2155. AlarmListManager.Instance.AddWarn(Module,
  2156. $"CMMAnodeUsage", $"{Module} CMM Anode Usage(AHr):{reservoirUsage.CMMAnodeUsage} is over CMMAnodeTotalAmpHoursWarningLimit:{cmmAnodeTotalAmpHoursWarningLimit}");
  2157. }
  2158. //CMMCathodeTotalAmpHoursCheck
  2159. double cmmCathodeTotalAmpHoursWarningLimit = 0;
  2160. if (SC.ContainsItem($"Reservoir.{Module}.CMMCathodeTotalAmpHoursWarningLimit"))
  2161. {
  2162. cmmCathodeTotalAmpHoursWarningLimit = (double)SC.GetValue<double>($"Reservoir.{Module}.CMMCathodeTotalAmpHoursWarningLimit");
  2163. }
  2164. double cmmCathodeTotalAmpHoursFaultLimit = 0;
  2165. if (SC.ContainsItem($"Reservoir.{Module}.CMMCathodeTotalAmpHoursFaultLimit"))
  2166. {
  2167. cmmCathodeTotalAmpHoursFaultLimit = (double)SC.GetValue<double>($"Reservoir.{Module}.CMMCathodeTotalAmpHoursFaultLimit");
  2168. }
  2169. if (reservoirUsage.CMMMembranceUsage > cmmCathodeTotalAmpHoursFaultLimit && cmmCathodeTotalAmpHoursFaultLimit != 0)
  2170. {
  2171. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{Module} CMM Cathode Usage(AHr):{reservoirUsage.CMMMembranceUsage} is over config item CMMCathodeTotalAmpHoursFaultLimit:{cmmCathodeTotalAmpHoursFaultLimit}");
  2172. reservoirEntity.PostMsg(ReservoirMsg.Error);
  2173. AlarmListManager.Instance.AddDataError(Module,
  2174. $"CMMCathodeUsage", $"{Module} CMM Cathode Usage(AHr):{reservoirUsage.CMMMembranceUsage} is over CMMCathodeTotalAmpHoursFaultLimit:{cmmCathodeTotalAmpHoursFaultLimit}");
  2175. }
  2176. else if (reservoirUsage.CMMMembranceUsage > cmmCathodeTotalAmpHoursWarningLimit && cmmCathodeTotalAmpHoursWarningLimit != 0)
  2177. {
  2178. LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"{Module} CMM Cathode Usage(AHr):{reservoirUsage.CMMMembranceUsage} is over config item CMMCathodeTotalAmpHoursWarningLimit:{cmmCathodeTotalAmpHoursWarningLimit}");
  2179. AlarmListManager.Instance.AddWarn(Module,
  2180. $"CMMCathodeUsage", $"{Module} CMM Cathode Usage(AHr):{reservoirUsage.CMMMembranceUsage} is over CMMCathodeTotalAmpHoursWarningLimit:{cmmCathodeTotalAmpHoursWarningLimit}");
  2181. }
  2182. }
  2183. #endregion
  2184. /// <summary>
  2185. /// 订阅变量数值发生变化
  2186. /// </summary>
  2187. private void SubscribeValueAction()
  2188. {
  2189. BeckhoffIoSubscribeUpdateVariable(FLOW);
  2190. BeckhoffIoSubscribeUpdateVariable(HED_FLOW);
  2191. BeckhoffIoSubscribeUpdateVariable(DI_REPLEN);
  2192. BeckhoffIoSubscribeUpdateVariable(PH_FLOW_VALVE);
  2193. BeckhoffIoSubscribeUpdateVariable(PH_VALUE);
  2194. BeckhoffIoSubscribeUpdateVariable(WATER_LEVEL);
  2195. BeckhoffIoSubscribeUpdateVariable(LOW_LEVEL);
  2196. BeckhoffIoSubscribeUpdateVariable(HIGH_LEVEL);
  2197. BeckhoffIoSubscribeUpdateVariable(SAFETY_HIGH_LEVEL);
  2198. BeckhoffIoSubscribeUpdateVariable(RESPOWERON);
  2199. BeckhoffIoSubscribeUpdateVariable(HEDPOWERON);
  2200. BeckhoffIoSubscribeUpdateVariable(REGULATE_PUMP_SIGNAL_IN);
  2201. BeckhoffIoSubscribeUpdateVariable(REGULATE_PUMP_SPEED);
  2202. for (int i = 0; i < _replenNum; i++)
  2203. {
  2204. BeckhoffIoSubscribeUpdateVariable($"Replen{i + 1}Level");
  2205. }
  2206. }
  2207. /// <summary>
  2208. /// 订阅IO变量
  2209. /// </summary>
  2210. /// <param name="variable"></param>
  2211. private void BeckhoffIoSubscribeUpdateVariable(string variable)
  2212. {
  2213. _variableInitializeDic[variable] = false;
  2214. IOModuleManager.Instance.SubscribeModuleVariable(Module, variable, UpdateVariableValue);
  2215. }
  2216. /// <summary>
  2217. /// 更新变量数值
  2218. /// </summary>
  2219. /// <param name="variable"></param>
  2220. /// <param name="value"></param>
  2221. private void UpdateVariableValue(string variable, object value)
  2222. {
  2223. if (!ReservoirData.IsDataInitialized)
  2224. {
  2225. ReservoirData.IsDataInitialized = true;
  2226. }
  2227. PropertyInfo property = ReservoirData.GetType().GetProperty(variable);
  2228. if (property != null)
  2229. {
  2230. property.SetValue(_reservoirData, value);
  2231. if (variable == WATER_LEVEL)
  2232. {
  2233. string levelCurve = SC.GetStringValue($"Reservoir.{Module}.LevelCurve");
  2234. ReservoirData.Level = LevelCurveManager.Instance.CalculateLevelByWaterLevel(ReservoirData.WaterLevel, levelCurve);
  2235. }
  2236. }
  2237. if (variable.Contains("Replen") && variable.Substring(0, 6) == "Replen")
  2238. {
  2239. property = ReservoirData.GetType().GetProperty(REPLEN_LEVEL);
  2240. _replenLevelLst[int.Parse(variable.Substring(6, 1)) - 1] = (bool)value;
  2241. property.SetValue(_reservoirData, _replenLevelLst);
  2242. }
  2243. if (_variableInitializeDic.ContainsKey(variable) && !_variableInitializeDic[variable])
  2244. {
  2245. _variableInitializeDic[variable] = true;
  2246. }
  2247. }
  2248. /// <summary>
  2249. /// 是否所有IO变量初始化完成
  2250. /// </summary>
  2251. /// <returns></returns>
  2252. private bool AllIoVariableInitialized()
  2253. {
  2254. foreach (string item in _variableInitializeDic.Keys)
  2255. {
  2256. if (!_variableInitializeDic[item])
  2257. {
  2258. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{item} is not initialized");
  2259. return false;
  2260. }
  2261. }
  2262. return true;
  2263. }
  2264. public void Monitor()
  2265. {
  2266. }
  2267. public void Reset()
  2268. {
  2269. }
  2270. public void Terminate()
  2271. {
  2272. }
  2273. }
  2274. }