12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723 |
- using Aitex.Core.RT.DataCenter;
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.OperationCenter;
- using Aitex.Core.RT.RecipeCenter;
- using Aitex.Core.RT.SCCore;
- using Aitex.Core.Util;
- using MECF.Framework.Common.Beckhoff.ModuleIO;
- using MECF.Framework.Common.CommonData.Reservoir;
- using MECF.Framework.Common.Persistent.Reservoirs;
- using MECF.Framework.Common.TwinCat;
- using System;
- using System.Collections.Generic;
- using System.Reflection;
- using MECF.Framework.Common.RecipeCenter;
- using MECF.Framework.Common.ToolLayout;
- using System.Collections.ObjectModel;
- using MECF.Framework.Common.CommonData;
- using MECF.Framework.Common.Beckhoff.IOAxis;
- using System.Linq;
- using MECF.Framework.Common.Alarm;
- using MECF.Framework.Common.ProcessCell;
- using MECF.Framework.Common.Persistent.Temperature;
- using CyberX8_Core;
- using CyberX8_RT.Devices.Facilities;
- using CyberX8_RT.Devices.Metal;
- using CyberX8_RT.Devices.Reservoir;
- using CyberX8_RT.Devices.Safety;
- using CyberX8_RT.Devices.Temperature;
- using CyberX8_RT.Modules.Metal;
- using CyberX8_RT.Modules.Reservoir;
- using CyberX8_RT.Modules;
- using MECF.Framework.Common.IOCore;
- namespace CyberX8_RT.Devices.Reservoir
- {
- public class CompactMembranReservoirDevice : BaseDevice, IDevice
- {
- private enum ReservoirOperation
- {
- None,
- ManualANDiReplen,
- ManualCADiReplen,
- AutoANDiReplen,
- AutoCADiReplen
- }
- #region 常量
- private const string PERSISTENT_VALUE = "PersistentValue";
- private const string CA_DI_REPLEN = "CADiReplen";
- private const string AN_DI_REPLEN = "ANDiReplen";
- private const string CA_WATER_LEVEL = "CAWaterLevel";
- private const string AN_WATER_LEVEL = "ANWaterLevel";
- private const string AN_PUMP = "ANPump";
- private const string CROSS_DOSE_ENABLE = "CrossDoseEnable";
- private const string TRANSFER_PUMP_STM_STATUS = "TransferPumpSTMStatus";
- private const string TRANSFER_PUMP_POS_STATUS = "TransferPumpPOSStatus";
- private const string TRANSFER_ACTUAL_POSITION = "TransferActualPosition";
- private const string TRANSFER_PUMP_ENABLE = "TransferPumpEnable";
- private const string TRANSFER_PUMP_RESET = "TransferPumpReset";
- private const string TRANSFER_PUMP_EXECUTE = "TransferPumpExecute";
- private const string TRANSFER_PUMP_TARGET_POSITION = "TransferPumpTargetPosition";
- private const string TRANSFER_PUMP_SPEED = "TransferPumpSpeed";
- private const string TRANSFER_PUMP_START_TYPE = "TransferPumpStartType";
- private const string TRANSFER_PUMP_ACCELERATION = "TransferPumpAcceleration";
- private const string TRANSFER_PUMP_DECELERATION = "TransferPumpDeceleration";
- private const string AN_BYPASS_FLOW = "ANBypassFlow";
- private const string AN_A_DRAIN_PUMP = "ANADrainPump";
- private const string AN_B_DRAIN_PUMP = "ANBDrainPump";
- private const string AN_BY_PASS = "ANByPass";
- //private const string AN_SLIP_STREAM_PUMP = "ANSlipStreamPump";
- private const string AN_TRANSFER_FLOW = "ANTransferFlow";
- //private const string CA_SLIP_STREAM_PUMP = "CASlipStreamPump";
- private const string CA_PUMP_SPEED = "CAPumpSpeed";
- private const string CA_PUMP_RUNNING = "CAPumpRunning";
- private const string CA_HED_FLOW = "CAHedFlow";
- private const string CDA_FLOW_VALVE = "CDAFlowValve";
- private const string CA_BY_PASS = "CAByPass";
- private const string CA_PUMP_ENABLE = "CAPumpEnable";
- private const string EVAPORATORLEVEL = "EvaporatorLevel";
- private const string AN_BYPASS_COUNTERFLOW = "ANBypassFlow";
- private const string AN_SAMPLE_FLOW = "ANSampleFlow";
- private const string CA_SAMPLE_FLOW = "CASampleFlow";
- private const string STRATUS = "Stratus";
- private const string AUTO = "Auto";
- private const string COUNTER_VALUE = "CounterValue";
- private const string COUNTER_START = "Start";
- private const string COUNTER_STOP = "Stop";
- private const string COUNTER_RESET = "Reset";
- private const int ENABLE = 5;
- #endregion
- #region 内部变量
- /// <summary>
- /// AN Level取样平均值
- /// </summary>
- private double _avgANLevel;
- /// <summary>
- /// AN Level取样队列
- /// </summary>
- private Queue<double> _ANLevelSamples;
- /// <summary>
- /// CA Level取样平均值
- /// </summary>
- private double _avgCALevel;
- /// <summary>
- /// CA Level取样队列
- /// </summary>
- private Queue<double> _CALevelSamples;
- /// <summary>
- /// AN/CA level计算平均值取样数
- /// </summary>
- private int levelSampleCount;
- /// <summary>
- /// Prewet 持久性数值对象
- /// </summary>
- private ReservoirsPersistentValue _persistentValue;
- /// <summary>
- /// 变量是否初始化字典
- /// </summary>
- private Dictionary<string, bool> _variableInitializeDic = new Dictionary<string, bool>();
- /// <summary>
- /// 数据
- /// </summary>
- private CompactMembranReservoirData _reservoirData = new CompactMembranReservoirData();
- /// <summary>
- /// Recipe
- /// </summary>
- private ResRecipe _resRecipe;
- /// <summary>
- /// 阳极Pump速度
- /// </summary>
- private double _anPumpSpeed = 0;
- /// <summary>
- /// 阴极Pump速度
- /// </summary>
- private double _caPumpSpeed = 0;
- /// <summary>
- /// 定时器
- /// </summary>
- private PeriodicJob _periodicJob;
- /// <summary>
- /// 注水Helper
- /// </summary>
- private ReservoirDiReplenHelper _direplenHelper;
- /// <summary>
- /// 泵速Helper
- /// </summary>
- private ReservoirPumpSpeedHelper _pumpSpeedHelper;
- /// <summary>
- /// 当前操作
- /// </summary>
- private ReservoirOperation _currentOperation;
- /// <summary>
- /// 手动注水时间(秒)
- /// </summary>
- private int _manualReplenSecond = 0;
- /// <summary>
- /// 注水是否出错
- /// </summary>
- private bool _isDiReplenInFault = false;
- /// <summary>
- /// Fast leak Test时间间隔
- /// </summary>
- private int _aNLeakOperatingUpdateTime;
- /// <summary>
- /// Fast leak Test Tolerance Value
- /// </summary>
- private double _aNFastLeakLevelTolerance;
- /// <summary>
- /// 计时器是否正在运行
- /// </summary>
- private bool _isTestRunning = false;
- /// <summary>
- /// 是否检测到漏液
- /// </summary>
- private bool _isLeakDetected = false;
- /// <summary>
- /// 漏液的体积
- /// </summary>
- private double _leakVolume;
- /// <summary>
- /// 开始检测slow leak test时的ANLevel
- /// </summary>
- private double _StartSlowLeakTestANLevel;
- /// <summary>
- /// 配置的metal device集合
- /// </summary>
- private ObservableCollection<CompactMembranMetalDevice> _metalDevices = new ObservableCollection<CompactMembranMetalDevice>();
- /// <summary>
- /// 是否存在anflow有流量
- /// </summary>
- private bool _isHasAnFlow;
- /// <summary>
- /// 是否存在metal 在auto模式
- /// </summary>
- private bool _isHasMetalInAuto;
- /// <summary>
- /// 设备是否进行过初始化
- /// </summary>
- private bool _isInitialized;
- /// <summary>
- /// 是否安装CrossDose
- /// </summary>
- private bool _isCrossDoseInstalled;
- /// <summary>
- /// fastleaktest的开始时间
- /// </summary>
- private DateTime _fastLeakStartTime;
- /// <summary>
- /// slowleaktest的开始时间
- /// </summary>
- private DateTime _slowLeakStartTime;
- /// <summary>
- /// fastleak 测试时间间隔
- /// </summary>
- private TimeSpan _fastLeakTestSpan;
- /// <summary>
- /// slowleak 测试时间间隔
- /// </summary>
- private TimeSpan _slowLeakTestSpan;
- /// <summary>
- /// clearLeakVolumeTime
- /// </summary>
- private double _clearLeakVolumeTime;
- /// <summary>
- /// ANTransferFlow(CrossDose Flow)
- /// </summary>
- private CounterFlowData _anTransferFlow = new CounterFlowData();
- /// <summary>
- /// ReservoirANByPassCounterFlow
- /// </summary>
- private CounterFlowData _reservoirCounterByPassFlow = new CounterFlowData();
- /// <summary>
- /// Counter字典
- /// </summary>
- private Dictionary<string, CounterFlowData> _nameCounterFlowData = new Dictionary<string, CounterFlowData>();
- /// <summary>
- /// CrossDoseHelper
- /// </summary>
- private CrossDoseHelper _crossDoseHelper;
- /// <summary>
- /// CrossDose是否初始化
- /// </summary>
- private bool _isCrossDoseInitialized;
- /// <summary>
- /// WarningFlag
- /// </summary>
- private List<bool> _isCAFlowRateWARN;
- private List<bool> _isANAFlowRateWARN;
- private List<bool> _isANBFlowRateWARN;
- private bool _isTCControlWARN = false;
- /// <summary>
- /// flow fault hold off时长
- /// </summary>
- private int _flowFaultHoldOffTime = 10;
- private DateTime _AnPumpSafeDetectTime;
- private double _metalTotalFlow;
- /// <summary>
- /// ErrorMessage
- /// </summary>
- private bool _isAnPumpSafeDetectedActivate = false;
- private bool _isANAutoDIReplenError = false;
- private bool _isCAAutoDIReplenError = false;
- private bool _isSystemAutoMode = false;
- /// <summary>
- /// 用于控制打印错误log
- /// </summary>
- private HashSet<string> errorLogSet = new HashSet<string>();
- #endregion
- #region 属性
- /// <summary>
- /// 数据
- /// </summary>
- public CompactMembranReservoirData ReservoirData { get { return _reservoirData; } }
- /// <summary>
- /// 操作模式
- /// </summary>
- public string OperationMode { get { return _persistentValue.OperatingMode; } }
- /// <summary>
- /// 工程模式
- /// </summary>
- public string EngineerMode { get { return _persistentValue.RecipeOperatingMode; } }
- /// <summary>
- /// 阳极是否需要补水
- /// </summary>
- public bool AnNeedDireplen { get { return CheckANNeedDiReplen(); } }
- /// <summary>
- /// 阴极是否需要补水
- /// </summary>
- public bool CANeedDiReplen { get { return CheckCANeedDiReplen(); } }
- /// <summary>
- /// 检验阴极是否highlevel
- /// </summary>
- public bool IsCAHighLevel { get { return CheckCAHighLevelStatus(); } }
- /// <summary>
- /// 检验阴极是否lowlevel
- /// </summary>
- public bool IsCALowLevel { get { return CheckCALowLevelStatus(); } }
- /// <summary>
- /// 检验阳极是否highlevel
- /// </summary>
- public bool IsANHighLevel { get { return CheckANHighLevelStatus(); } }
- /// <summary>
- /// 检验阳极是否lowlevel
- /// </summary>
- public bool IsANLowLevel { get { return CheckANLowLevelStatus(); } }
- /// <summary>
- /// 正在补水
- /// </summary>
- public bool IsDireplenOn { get { return _reservoirData.ANDiReplen || _reservoirData.CADiReplen; } }
- /// <summary>
- /// 当前Recipe
- /// </summary>
- public ResRecipe Recipe { get { return _resRecipe; } }
- /// <summary>
- /// 是否自动模式
- /// </summary>
- public bool IsAuto { get { return _persistentValue.OperatingMode == AUTO; } }
- /// <summary>
- /// ANTransferFlow
- /// </summary>
- public CounterFlowData ANTransferFlow { get { return _anTransferFlow; } }
- /// <summary>
- /// ReservoirCounterByPassFlow
- /// </summary>
- public CounterFlowData ReservoirCounterByPassFlow { get { return _reservoirCounterByPassFlow; } }
- #endregion
- /// <summary>
- /// 初始化成功清除对应的错误log
- /// </summary>
- /// <param name="module"></param>
- public void ClearErrorLogSet(string module)
- {
- // 使用构造函数复制 HashSet
- HashSet<string> newHashSet = new HashSet<string>(errorLogSet);
- foreach (var item in newHashSet)
- {
- if (item.Contains(module))
- {
- errorLogSet.Remove(item);
- }
- }
- }
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="moduleName"></param>
- /// <param name="name"></param>
- public CompactMembranReservoirDevice(string moduleName) : base(moduleName, moduleName, moduleName, moduleName)
- {
- _anPumpSpeed = SC.GetValue<double>($"Reservoir.ANDefaultPumpSpeed");
- _caPumpSpeed = SC.GetValue<double>("Reservoir.CADefaultPumpSpeed");
- _aNLeakOperatingUpdateTime = SC.GetValue<int>($"Reservoir.{Module}.ANLeakOperatingUpdateTime");
- _aNFastLeakLevelTolerance = SC.GetValue<double>($"Reservoir.{Module}.ANFastLeakLevelTolerance");
- _clearLeakVolumeTime = SC.GetValue<double>($"Reservoir.{Module}.CleraLeakVolumeTime");
- _flowFaultHoldOffTime = SC.GetValue<int>($"Reservoir.{Module}.FlowFaultHoldOffTime") / 1000;
- levelSampleCount = SC.GetValue<int>("Reservoir.LevelAvgSamples");
- levelSampleCount = levelSampleCount == 0 ? 20 : levelSampleCount;
- _ANLevelSamples = new Queue<double>(levelSampleCount);
- _CALevelSamples = new Queue<double>(levelSampleCount);
- _periodicJob = new PeriodicJob(200, OnTimer, $"{Module}.Timer", true, true);
- double updateTime = _aNLeakOperatingUpdateTime > 0 ? Convert.ToDouble(_aNLeakOperatingUpdateTime) : 3.00;//配置文件没有则默认3分钟
- _fastLeakTestSpan = TimeSpan.FromMinutes(updateTime);
- //slow leak test 时间间隔一个小时,因为leak test开始后要等待clearleakvolumeTime重新开始,因此时间间隔就等于两者相加,第一次执行减掉就行。
- _slowLeakTestSpan = TimeSpan.FromMinutes(60) + TimeSpan.FromMinutes(_clearLeakVolumeTime);
- }
- /// <summary>
- /// 初始化
- /// </summary>
- /// <returns></returns>
- public bool Initialize()
- {
- InitializeParameter();
- InitializeRoutine();
- SubscribeData();
- InitializeOperation();
- SubscribeValueAction();
- return true;
- }
- /// <summary>
- /// 初始化Routine
- /// </summary>
- private void InitializeRoutine()
- {
- }
- /// <summary>
- /// 初始化参数
- /// </summary>
- private void InitializeParameter()
- {
- _persistentValue = ReservoirsPersistentManager.Instance.GetReservoirsPersistentValue(Module);
- if (_persistentValue == null)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "Persistent Value Object is not exist");
- }
- if (!string.IsNullOrEmpty(_persistentValue.Recipe))
- {
- _resRecipe = RecipeFileManager.Instance.LoadGenericityRecipe<ResRecipe>(_persistentValue.Recipe);
- }
- _direplenHelper = new ReservoirDiReplenHelper(Module, _persistentValue);
- _pumpSpeedHelper = new ReservoirPumpSpeedHelper(Module, this);
- ReservoirItem reservoirItem = ReservoirItemManager.Instance.GetReservoirItem(Module);
- if (reservoirItem != null)
- {
- foreach (var item in reservoirItem.MetalCells)
- {
- if (item.ModuleName != Module)
- {
- CompactMembranMetalDevice metalDevice = DEVICE.GetDevice<CompactMembranMetalDevice>(item.ModuleName);
- if (metalDevice != null)
- {
- _metalDevices.Add(metalDevice);
- }
- }
- }
- if (reservoirItem.CrossDoseType != "" && reservoirItem.CrossDoseType != "None")
- {
- _isCrossDoseInstalled = true;
- _crossDoseHelper = new CrossDoseHelper(Module);
- _isCrossDoseInitialized = false;
- }
- _isCAFlowRateWARN = new List<bool>(new bool[_metalDevices.Count]);
- _isANAFlowRateWARN = new List<bool>(new bool[_metalDevices.Count]);
- _isANBFlowRateWARN = new List<bool>(new bool[_metalDevices.Count]);
- }
- }
- /// <summary>
- /// 订阅数据
- /// </summary>
- private void SubscribeData()
- {
- ReservoirItem reservoirItem = ReservoirItemManager.Instance.GetReservoirItem(Module);
- DATA.Subscribe($"{Module}.ReservoirData", () => _reservoirData, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.ReservoirAverageANLevel", () => _avgANLevel, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.ReservoirAverageCALevel", () => _avgCALevel, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.{PERSISTENT_VALUE}", () => _persistentValue, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.ANPumpSpeed", () => _anPumpSpeed, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.CAPumpSpeed", () => _caPumpSpeed, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.RecipeName", () => (_resRecipe != null ? _resRecipe.Ppid : ""), SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.ANLevel", () => _reservoirData.ANLevel, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.CALevel", () => _reservoirData.CALevel, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.ANBypassFlow", () => _reservoirData.ANBypassFlow, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.HedFlow", () => _reservoirData.CAHedFlow, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.CurrentRecipe", () => _resRecipe, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.DIValveMaxOnTime", () => SC.GetValue<double>($"Reservoir.{Module}.DIValveMaxOnTime") * 60, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.IsManualCAReplen", () => { return _currentOperation == ReservoirOperation.ManualCADiReplen; }, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.IsManualANReplen", () => { return _currentOperation == ReservoirOperation.ManualANDiReplen; }, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.IsCAHighLevel", () => IsCAHighLevel, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.IsCALowLevel", () => IsCALowLevel, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.IsANHighLevel", () => IsANHighLevel, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.IsANLowLevel", () => IsANLowLevel, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.IsDIReplenInFault", () => _isDiReplenInFault, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.EvaporatorType", () => reservoirItem.EvaporatorType, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.CroseDoseType", () => reservoirItem.CrossDoseType, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.IsLeakDetected", () => _isLeakDetected, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.IsCrossDoseInstalled", () => _isCrossDoseInstalled, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.ANBypassCounterFlow", () => ReservoirCounterByPassFlow.CounterValue, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- if (_isCrossDoseInstalled)
- {
- DATA.Subscribe($"{Module}.ANTransferFlow", () => ANTransferFlow != null ? ANTransferFlow.CounterValue : 0, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.IsCalibrateEnable", () => (_crossDoseHelper != null && _crossDoseHelper.CrossDoseState == RState.Running) ? false : true, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- }
- }
- /// <summary>
- /// 初始化操作
- /// </summary>
- private void InitializeOperation()
- {
- OP.Subscribe($"{Module}.DisabledAction", DisabledOperation);
- OP.Subscribe($"{Module}.ManualAction", ManualOperation);
- OP.Subscribe($"{Module}.AutoAction", AutoOperation);
- OP.Subscribe($"{Module}.EngineeringModeAction", EngineeringModeOperation);
- OP.Subscribe($"{Module}.ProductionModeAction", ProductionModeOperation);
- OP.Subscribe($"{Module}.LoadRecipe", LoadRecipeOperation);
- OP.Subscribe($"{Module}.AnPumpOn", AnPumpOnOperation);
- OP.Subscribe($"{Module}.ANPumpSpeed", ANPumpSpeed);
- OP.Subscribe($"{Module}.AnPumpOff", AnPumpOffOperation);
- OP.Subscribe($"{Module}.AnADrainPumpOn", AnADrainPumpOn);
- OP.Subscribe($"{Module}.AnADrainPumpOff", AnADrainPumpOff);
- OP.Subscribe($"{Module}.AnBDrainPumpOn", AnBDrainPumpOn);
- OP.Subscribe($"{Module}.AnBDrainPumpOff", AnBDrainPumpOff);
- OP.Subscribe($"{Module}.ANDiReplenOn", ANDiReplenOnOperation);
- OP.Subscribe($"{Module}.ANDiReplenOff", ANDiReplenOff);
- OP.Subscribe($"{Module}.ANByPassOn", ANByPassOn);
- OP.Subscribe($"{Module}.ANByPassOff", ANByPassOff);
- OP.Subscribe($"{Module}.CAPumpOn", CAPumpOn);
- OP.Subscribe($"{Module}.CAPumpSpeed", CAPumpSpeedOperation);
- OP.Subscribe($"{Module}.CAPumpOff", CAPumpOff);
- OP.Subscribe($"{Module}.CADiReplenOn", CADiReplenOnOperation);
- OP.Subscribe($"{Module}.CADiReplenOff", CADiReplenOff);
- OP.Subscribe($"{Module}.CDAFlowOn", CDAFlowOn);
- OP.Subscribe($"{Module}.CDAFlowOff", CDAFlowOff);
- OP.Subscribe($"{Module}.CAByPassOn", CAByPassOn);
- OP.Subscribe($"{Module}.CAByPassOff", CAByPassOff);
- OP.Subscribe($"{Module}.ANSampleOn", ANSampleOn);
- OP.Subscribe($"{Module}.ANSampleOff", ANSampleOff);
- OP.Subscribe($"{Module}.CASampleOn", CASampleOn);
- OP.Subscribe($"{Module}.CASampleOff", CASampleOff);
- OP.Subscribe($"{Module}.ManualANDiReplen", ManualANDiReplen);
- OP.Subscribe($"{Module}.ManualCADiReplen", ManualCADiReplen);
- OP.Subscribe($"{Module}.BaseLineKeyDown", BaseLineKeyDownAction);
- OP.Subscribe($"{Module}.StartLeakTest", StartLeakTestAction);
- OP.Subscribe($"{Module}.ResetTotalTime", ResetTotalTime);
- OP.Subscribe($"{Module}.ClearSlowLeak", ClearSlowLeak);
- if (_isCrossDoseInstalled)
- {
- OP.Subscribe($"{Module}.StartDosing", StartDosing);
- OP.Subscribe($"{Module}.HaltDosing", HaltDosing);
- OP.Subscribe($"{Module}.SetPumpFactor", SetPumpFactor);
- OP.Subscribe($"{Module}.CrossDoseOn", CrossDoseOn);
- OP.Subscribe($"{Module}.CrossDoseOff", CrossDoseOff);
- OP.Subscribe($"{Module}.ResetCrossDose", ResetCrossDose);
- }
- }
- #region Operation
- /// <summary>
- /// 重置时长
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="objs"></param>
- /// <returns></returns>
- private bool ResetTotalTime(string cmd, object[] objs)
- {
- _persistentValue.TotalReplen = 0;
- _persistentValue.LastTotalReplen = 0;
- ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
- return true;
- }
- /// <summary>
- /// DisabledAction
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool DisabledOperation(string cmd, object[] args)
- {
- string currentOperation = "Disabled";
- ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(Module);
- if (_persistentValue != null && reservoirEntity != null && _persistentValue.OperatingMode != currentOperation)
- {
- string preOperation = _persistentValue.OperatingMode;
- if (reservoirEntity.IsBusy)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{Module} is Busy, can't switch to Disabled mode");
- return false;
- }
- if (_persistentValue.OperatingMode == "Auto" && reservoirEntity.IsMetalBusy)
- {
- string busymodule = "";
- if (_metalDevices != null)
- {
- foreach (var item in _metalDevices)
- {
- MetalEntity metalEntity = Singleton<RouteManager>.Instance.GetModule<MetalEntity>(item.Module.ToString());
- if (metalEntity != null && metalEntity.IsBusy)
- {
- busymodule += metalEntity.Module.ToString() + "/";
- }
- }
- }
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{busymodule} is Busy, can't switch to Disabled mode");
- return false;
- }
- foreach (var metalDevice in _metalDevices)
- {
- metalDevice.DisabledOperation("", null);
- MetalEntity metalEntity = Singleton<RouteManager>.Instance.GetModule<MetalEntity>(metalDevice.Module);
- metalEntity.AbortRecipe(null);
- metalDevice.EnterDisabledOperation();
- }
- if (_isCrossDoseInstalled)
- {
- HaltDosing("", null);
- InitializeCrossDose(false);
- }
- EnterDisabledOperation();
- reservoirEntity.EnterInit();
- _persistentValue.OperatingMode = currentOperation;
- LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
- }
- ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
- _currentOperation = ReservoirOperation.None;
- return true;
- }
- /// <summary>
- /// ManualAction
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool ManualOperation(string cmd, object[] args)
- {
- string currentOperation = "Manual";
- ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(Module);
- if (_persistentValue != null && reservoirEntity != null && _persistentValue.OperatingMode != currentOperation)
- {
- string preOperation = _persistentValue.OperatingMode;
- if (reservoirEntity.IsBusy)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{Module} is Busy, can't switch to Manual mode");
- return false;
- }
- if (_persistentValue.OperatingMode == "Auto" && reservoirEntity.IsMetalBusy)
- {
- string busymodule = "";
- if (_metalDevices != null)
- {
- foreach (var item in _metalDevices)
- {
- MetalEntity metalEntity = Singleton<RouteManager>.Instance.GetModule<MetalEntity>(item.Module.ToString());
- if (metalEntity != null && metalEntity.IsBusy)
- {
- busymodule += metalEntity.Module.ToString() + "/";
- }
- }
- }
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{busymodule} is Busy, can't switch to Manual mode");
- return false;
- }
- foreach (var metalDevice in _metalDevices)
- {
- metalDevice.ManualOperation("", null);
- }
- if (_isCrossDoseInstalled) InitializeCrossDose(false);
- reservoirEntity.EnterInit();
- if (_reservoirData.ANDiReplen) ANDiReplenOff("", null);
- if (_reservoirData.CADiReplen) CADiReplenOff("", null);
- _persistentValue.OperatingMode = currentOperation;
- LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
- }
- ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
- _currentOperation = ReservoirOperation.None;
- return true;
- }
- /// <summary>
- /// AutoAction
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool AutoOperation(string cmd, object[] args)
- {
- if (IsANLowLevel || IsCALowLevel)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"LowLevel is activated, can't switch to Auto mode");
- return false;
- }
- string currentOperation = "Auto";
- ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(Module);
- if (_persistentValue != null && reservoirEntity != null && _persistentValue.OperatingMode != currentOperation)
- {
- string preOperation = _persistentValue.OperatingMode;
- if (reservoirEntity.IsBusy)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{Module} is Busy, can't switch to Auto mode");
- return false;
- }
- if (_isCrossDoseInstalled) InitializeCrossDose(false);
- reservoirEntity.EnterInit();
- if (_reservoirData.ANDiReplen) ANDiReplenOff("", null);
- if (_reservoirData.CADiReplen) CADiReplenOff("", null);
- _isDiReplenInFault = false;
- _persistentValue.OperatingMode = currentOperation;
- LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
- }
- ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
- return true;
- }
- /// <summary>
- /// EngineeringModeAction
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool EngineeringModeOperation(string cmd, object[] args)
- {
- string currentRecipeOperation = "Engineering";
- if (_persistentValue != null)
- {
- _persistentValue.RecipeOperatingMode = currentRecipeOperation;
- }
- ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
- return true;
- }
- /// <summary>
- /// ProductionAction
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="param"></param>
- /// <returns></returns>
- private bool ProductionModeOperation(string cmd, object[] args)
- {
- string currentRecipeOperation = "Production";
- if (_persistentValue != null)
- {
- _persistentValue.RecipeOperatingMode = currentRecipeOperation;
- }
- ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
- return true;
- }
- /// <summary>
- /// 加载Recipe
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- private bool LoadRecipeOperation(string cmd, object[] args)
- {
- _persistentValue.Recipe = args[0].ToString();
- string[] fileRoute = _persistentValue.Recipe.Split('\\');
- string recipeRoute = "";
- if (fileRoute.Length > 2)
- {
- recipeRoute = fileRoute[fileRoute.Length - 2];
- }
- _resRecipe = RecipeFileManager.Instance.LoadGenericityRecipe<ResRecipe>(_persistentValue.Recipe);
- ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module.ToString());
- LOG.WriteLog(eEvent.INFO_RESERVOIR, Module.ToString(), $"Load {recipeRoute} Recipe {_resRecipe.Ppid} Success");
- return true;
- }
- /// <summary>
- /// Enter Disabled Operation
- /// </summary>
- /// <returns></returns>
- private void EnterDisabledOperation()
- {
- if (_reservoirData.CAPumpEnable)
- {
- CAPumpOff("CAPumpOff", null);
- }
- if (_reservoirData.ANPump > 0)
- {
- AnPumpOffOperation("", null);
- }
- if (_reservoirData.ANADrainPump > 0)
- {
- AnADrainPumpOff("", null);
- }
- if (_reservoirData.ANBDrainPump > 0)
- {
- AnBDrainPumpOff("", null);
- }
- if (_reservoirData.ANByPass)
- {
- ANByPassOff("", null);
- }
- if (_reservoirData.ANDiReplen)
- {
- ANDiReplenOff("", null);
- }
- if (_reservoirData.CADiReplen)
- {
- CADiReplenOff("", null);
- }
- }
- #endregion
- #region AN DiReplen
- /// <summary>
- /// 阳极DI Replen On
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- private bool ANDiReplenOnOperation(string cmd, object[] args)
- {
- return ANDiReplenOn(true);
- }
- /// <summary>
- /// 阳极DI Replen On
- /// </summary>
- /// <param name="showError"></param>
- /// <returns></returns>
- public bool ANDiReplenOn(bool showError)
- {
- if (IsANHighLevel)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"ANHighLevel is activate,Can't do AN_DIReple");
- return false;
- }
- if (IsANLowLevel)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"ANLowLevel is activate,Can't do AN_DIReple");
- return false;
- }
- bool preCondition = CheckPreDiReplenCondition(showError);
- if (!preCondition)
- {
- return false;
- }
- if (ReservoirData.CADiReplen)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "CADiReplen is on");
- return false;
- }
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{AN_DI_REPLEN}");
- return BeckhoffIOManager.Instance.WriteIoValue(ioName, true);
- }
- /// <summary>
- /// 阳极DI Replen On
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- private bool ANDiReplenOff(string cmd, object[] args)
- {
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{AN_DI_REPLEN}");
- bool result = BeckhoffIOManager.Instance.WriteIoValue(ioName, false);
- if (result)
- {
- _persistentValue.IsDiReplenOn = false;
- if (_currentOperation == ReservoirOperation.ManualANDiReplen || _currentOperation == ReservoirOperation.AutoANDiReplen)
- {
- _currentOperation = ReservoirOperation.None;
- _persistentValue.LastTotalReplen = _persistentValue.TotalReplen;
- ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
- }
- }
- return result;
- }
- /// <summary>
- /// 检验DiReplen前置条件
- /// </summary>
- /// <returns></returns>
- public bool CheckPreDiReplenCondition(bool showError)
- {
- if (!CheckFacilitiesDiReplenStatus() && showError)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "Facilities DiReplen is Off");
- return false;
- }
- SafetyDevice safetyDevice = DEVICE.GetDevice<SafetyDevice>("Safety");
- if (safetyDevice != null && safetyDevice.SafetyData.ReservoirHighLevel)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Safety high is Activate");
- return false;
- }
- if (CheckOtherReservoirDiReplenStatus(showError))
- {
- return false;
- }
- return true;
- }
- /// <summary>
- /// 检验总Di有没有开
- /// </summary>
- /// <returns></returns>
- private bool CheckFacilitiesDiReplenStatus()
- {
- SystemFacilities systemFacilities = DEVICE.GetDevice<SystemFacilities>("System.Facilities");
- if (systemFacilities != null)
- {
- return systemFacilities.DIReplenEnable;
- }
- return false;
- }
- /// <summary>
- /// 检验是否其他Reservoir Direplen已经
- /// </summary>
- /// <returns></returns>
- private bool CheckOtherReservoirDiReplenStatus(bool showError)
- {
- List<string> reservoirs = ReservoirItemManager.Instance.InstalledModules;
- foreach (string item in reservoirs)
- {
- if (item != Module)
- {
- ReservoirItem reservoirItem = ReservoirItemManager.Instance.GetReservoirItem(item);
- if (reservoirItem.SubType == STRATUS)
- {
- StandardHotReservoirDevice tmpDevice = DEVICE.GetDevice<StandardHotReservoirDevice>(item);
- if (tmpDevice.ReservoirData.DiReplen && showError)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{item} direplen valve is on");
- return true;
- }
- }
- else
- {
- CompactMembranReservoirDevice tmpDevice = DEVICE.GetDevice<CompactMembranReservoirDevice>(item);
- if (tmpDevice.ReservoirData.ANDiReplen && showError)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{item} ANDireplen valve is on");
- return true;
- }
- if (tmpDevice.ReservoirData.CADiReplen && showError)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{item} CADireplen valve is on");
- return true;
- }
- }
- }
- }
- return false;
- }
- #endregion
- #region AnPump
- /// <summary>
- /// AN Pump On 操作
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- public bool AnPumpOnOperation(string cmd, object[] args)
- {
- double anPumpSpeed = SC.GetValue<double>($"Reservoir.ANDefaultPumpSpeed");
- return AnPump(anPumpSpeed);
- }
- /// <summary>
- /// AN Pump Off操作
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- private bool AnPumpOffOperation(string cmd, object[] args)
- {
- return AnPump(0);
- }
- /// <summary>
- /// AN Pump
- /// </summary>
- /// <param name="speed"></param>
- /// <returns></returns>
- public bool AnPump(double speed)
- {
- if (speed == 0) //关pump时关掉配置的metal的fill valve
- {
- ReservoirItem reservoirItem = ReservoirItemManager.Instance.GetReservoirItem(Module);
- if (reservoirItem != null)
- {
- List<MetalItem> metalItems = reservoirItem.MetalCells;
- if (metalItems != null && metalItems.Count > 0)
- {
- foreach (MetalItem metalItem in metalItems)
- {
- if (metalItem.Installed)
- {
- CompactMembranMetalDevice metalDevice = DEVICE.GetDevice<CompactMembranMetalDevice>(metalItem.ModuleName);
- if (metalDevice != null)
- {
- metalDevice.AnSideAFillOff("ANAFillOff", null);
- metalDevice.AnSideBFillOff("ANBFillOff", null);
- }
- }
- }
- }
- }
- }
- SafetyDevice safetyDevice = DEVICE.GetDevice<SafetyDevice>("Safety");
- if (safetyDevice != null && !safetyDevice.SafetyData.PumpEdm)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Safety PumpEdm is Activate");
- return false;
- }
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{AN_PUMP}");
- return BeckhoffIOManager.Instance.WriteIoValue(ioName, speed);
- }
- /// <summary>
- /// AN Pump调整速度
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- public bool ANPumpSpeed(string cmd, object[] args)
- {
- if (double.TryParse(args[0].ToString(), out double speed))
- {
- _anPumpSpeed = speed;
- if (_anPumpSpeed > 0)
- {
- _reservoirData.ANPump = _anPumpSpeed;
- }
- return AnPump(speed);
- }
- else
- {
- LOG.WriteLog(eEvent.ERR_METAL, Module, $"{args[0]} is nor invalid speed");
- return false;
- }
- }
- #endregion
- #region AN Drain Pump
- /// <summary>
- /// 阳极A面Drain Pump On
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- public bool AnADrainPumpOn(string cmd, object[] args)
- {
- double speed = SC.GetValue<double>($"Reservoir.DrainSpeed");
- return AnADrainPump(speed);
- }
- /// <summary>
- /// 阳极A面Drain Pump Off
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- private bool AnADrainPumpOff(string cmd, object[] args)
- {
- return AnADrainPump(0);
- }
- /// <summary>
- /// 阳极B面Drain Pump On
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- public bool AnBDrainPumpOn(string cmd, object[] args)
- {
- double speed = SC.GetValue<double>($"Reservoir.DrainSpeed");
- return AnBDrainPump(speed);
- }
- /// <summary>
- /// 阳极B面Drain Pump Off
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- private bool AnBDrainPumpOff(string cmd, object[] args)
- {
- return AnBDrainPump(0);
- }
- /// <summary>
- /// 阳极A Drain Pump
- /// </summary>
- /// <param name="speed"></param>
- /// <returns></returns>
- public bool AnADrainPump(double speed)
- {
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{AN_A_DRAIN_PUMP}");
- return BeckhoffIOManager.Instance.WriteIoValue(ioName, speed);
- }
- /// <summary>
- /// 阳极B Drain Pump
- /// </summary>
- /// <param name="speed"></param>
- /// <returns></returns>
- public bool AnBDrainPump(double speed)
- {
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{AN_B_DRAIN_PUMP}");
- return BeckhoffIOManager.Instance.WriteIoValue(ioName, speed);
- }
- #endregion
- #region AN ByPass
- /// <summary>
- /// 阳极ByPass On
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- private bool ANByPassOn(string cmd, object[] args)
- {
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{AN_BY_PASS}");
- return BeckhoffIOManager.Instance.WriteIoValue(ioName, true);
- }
- /// <summary>
- /// 阳极ByPass Off
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- private bool ANByPassOff(string cmd, object[] args)
- {
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{AN_BY_PASS}");
- return BeckhoffIOManager.Instance.WriteIoValue(ioName, false);
- }
- #endregion
- #region CA Pump
- /// <summary>
- /// CA Pump调速
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- private bool CAPumpSpeedOperation(string cmd, object[] args)
- {
- double caMaxPumpSpeed = 0;
- if (SC.ContainsItem("Reservoir.CAMaxPumpSpeed"))
- {
- caMaxPumpSpeed = SC.GetValue<double>("Reservoir.CAMaxPumpSpeed");
- }
- if (double.TryParse(args[0].ToString(), out double speed))
- {
- _caPumpSpeed = speed;
- if (_caPumpSpeed > caMaxPumpSpeed)
- {
- LOG.WriteLog(eEvent.WARN_METAL, Module, $"CA pump speed:{_caPumpSpeed} is over CA max pump speed {caMaxPumpSpeed}!");
- return false;
- }
- return CAPumpSpeed(_caPumpSpeed);
- }
- else
- {
- LOG.WriteLog(eEvent.ERR_METAL, Module, $"{args[0]} is nor invalid speed");
- return false;
- }
- }
- /// <summary>
- /// 设置阴极泵速
- /// </summary>
- /// <param name="caPumpSpeed"></param>
- /// <returns></returns>
- public bool CAPumpSpeed(double caPumpSpeed)
- {
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{CA_PUMP_SPEED}");
- return BeckhoffIOManager.Instance.WriteIoValue(ioName, caPumpSpeed);
- }
- /// <summary>
- /// 阴极Pump On
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- private bool CAPumpOn(string cmd, object[] args)
- {
- double caPumpSpeed = SC.GetValue<double>("Reservoir.CADefaultPumpSpeed");
- bool result = CAPumpSpeed(caPumpSpeed);
- if (result)
- {
- string enableIOName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{CA_PUMP_ENABLE}");
- return BeckhoffIOManager.Instance.WriteIoValue(enableIOName, true);
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 阴极Pump Off
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- private bool CAPumpOff(string cmd, object[] args)
- {
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{CA_PUMP_ENABLE}");
- return BeckhoffIOManager.Instance.WriteIoValue(ioName, false);
- }
- #endregion
- #region CA DiReplen
- /// <summary>
- /// 阴极DI Replen On
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- private bool CADiReplenOnOperation(string cmd, object[] args)
- {
- return CADiReplenOn(true);
- }
- /// <summary>
- /// 阴极DI Replen On
- /// </summary>
- /// <param name="showError"></param>
- /// <returns></returns>
- private bool CADiReplenOn(bool showError)
- {
- bool preCondition = CheckPreDiReplenCondition(showError);
- if (!preCondition)
- {
- return false;
- }
- if (IsCAHighLevel)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"CAHighLevel is activate,Can't do CA_DIReple");
- return false;
- }
- if (IsCALowLevel)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"CALowLevel is activate,Can't do CA_DIReple");
- return false;
- }
- if (ReservoirData.ANDiReplen)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "ANDiReplen is on");
- return false;
- }
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{CA_DI_REPLEN}");
- return BeckhoffIOManager.Instance.WriteIoValue(ioName, true);
- }
- /// <summary>
- /// 阴极DI Replen Off
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- private bool CADiReplenOff(string cmd, object[] args)
- {
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{CA_DI_REPLEN}");
- bool result = BeckhoffIOManager.Instance.WriteIoValue(ioName, false);
- if (result)
- {
- _persistentValue.IsDiReplenOn = false;
- if (_currentOperation == ReservoirOperation.ManualCADiReplen || _currentOperation == ReservoirOperation.AutoCADiReplen)
- {
- _currentOperation = ReservoirOperation.None;
- _persistentValue.LastTotalReplen = _persistentValue.TotalReplen;
- ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
- }
- }
- return result;
- }
- #endregion
- #region CDA Flow
- /// <summary>
- /// 阴极CDA Flow On
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- private bool CDAFlowOn(string cmd, object[] args)
- {
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{CDA_FLOW_VALVE}");
- return BeckhoffIOManager.Instance.WriteIoValue(ioName, true);
- }
- /// <summary>
- /// 阴极CDA Flow Off
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- private bool CDAFlowOff(string cmd, object[] args)
- {
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{CDA_FLOW_VALVE}");
- return BeckhoffIOManager.Instance.WriteIoValue(ioName, false);
- }
- #endregion
- #region CA ByPass
- /// <summary>
- /// 阴极ByPass On
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- public bool CAByPassOn(string cmd, object[] args)
- {
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{CA_BY_PASS}");
- return BeckhoffIOManager.Instance.WriteIoValue(ioName, true);
- }
- /// <summary>
- /// 阴极ByPass Off
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- public bool CAByPassOff(string cmd, object[] args)
- {
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{CA_BY_PASS}");
- return BeckhoffIOManager.Instance.WriteIoValue(ioName, false);
- }
- #endregion
- #region DiReplen Operation
- /// <summary>
- /// 手动阳极注水
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- private bool ManualANDiReplen(string cmd, object[] args)
- {
- return ManualDiReplen(ANDiReplenOnOperation, ReservoirOperation.ManualANDiReplen, args[0].ToString());
- }
- /// <summary>
- /// 手动阴极注水
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- private bool ManualCADiReplen(string cmd, object[] args)
- {
- return ManualDiReplen(CADiReplenOnOperation, ReservoirOperation.ManualCADiReplen, args[0].ToString());
- }
- /// <summary>
- /// 将前端输入的baseline更新到持久化文件
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- private bool BaseLineKeyDownAction(string cmd, object[] args)
- {
- string variableName = args[0].ToString();
- //baseline输入了一个不同的值的话,将新值写入持久化文件
- if (_persistentValue.ANBaseLineLevel.ToString() != args[1].ToString())
- {
- PropertyInfo property = _persistentValue.GetType().GetProperty(variableName);
- if (property != null)
- {
- property.SetValue(_persistentValue, args[1]);
- }
- ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
- LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, $" New ANBaseline {args[1]} was inputed");
- _isTestRunning = false;
- }
- return true;
- }
- private bool StartLeakTestAction(string cmd, object[] args)
- {
- //前端重复点击start直接返回true;
- if (_isTestRunning)
- {
- LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, $" Fast leak test has already started");
- return true;
- }
- //判断是否启动fast leak test 参数【0】表示是否初始化,参数【1】表示是否有metal有流量
- if ((bool)args[0] && (bool)args[1])
- {
- LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, $" Fast leak test is start");
- _isTestRunning = true;
- //记录fast leak test的开始时间
- _fastLeakStartTime = DateTime.Now;
- //记录slow leak test的开始时间,第一次的开始时间需要加上这个配置时间,正好使第一次执行slow leak test的时间间隔使为1小时。
- _slowLeakStartTime = DateTime.Now + TimeSpan.FromMinutes(_clearLeakVolumeTime);
- //记录slow leak test的开始液位
- _StartSlowLeakTestANLevel = ReservoirData.ANLevel;
- }
- else
- {
- LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, $" Leak test precondition not met, stoped");
- _isTestRunning = false;
- }
- return true;
- }
- /// Fast leak test
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private bool FastLeakTestAction()
- {
- bool isHasMetalFlow = false;
- foreach (var metalDevice in _metalDevices)
- {
- if (metalDevice.ANACellFlow.CounterValue > 0 || metalDevice.ANBCellFlow.CounterValue > 0)
- {
- isHasMetalFlow = true;
- }
- }
- if (!isHasMetalFlow)
- {
- LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, $" No ANFLow in {Module}, current fast leak test is skiped");
- //更新_faseLeak的启动时间,使其可以自动周期性检测
- _fastLeakStartTime = DateTime.Now;
- return true;
- }
- double aNBaseLineLevel = ReservoirsPersistentManager.Instance.GetReservoirsPersistentValue(Module).ANBaseLineLevel;
- if (_reservoirData.ANLevel < aNBaseLineLevel - _aNFastLeakLevelTolerance)
- {
- _isLeakDetected = true; //用于前端页面指示灯
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $" Fast Leak was Detected,Current ANLevel is{_reservoirData.ANLevel},baseline is{aNBaseLineLevel}. Related pump and valve was closed");
- AnPumpOffOperation($"{Module}.AnPumpOff", null);
- //关闭对应的anolyte flow valve
- foreach (var metalDevice in _metalDevices)
- {
- metalDevice.AnSideAFillOff($"{metalDevice.Name}.ANAFillOff", null);
- metalDevice.AnSideBFillOff($"{metalDevice.Name}.ANBFillOff", null);
- metalDevice.AnSideADrainOff($"{metalDevice.Name}.ANADrainOff", null);
- metalDevice.AnSideBDrainOff($"{metalDevice.Name}.ANBDrainOff", null);
- }
- }
- else
- {
- _isLeakDetected = false;
- string variableName = "ANBaseLineLevel";
- PropertyInfo property = _persistentValue.GetType().GetProperty(variableName);
- if (property != null)
- {
- property.SetValue(_persistentValue, _reservoirData.ANLevel);
- }
- ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
- LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, $"No fast leak test was Detected, leak test baseLine was updated");
- }
- //更新_faseLeak的启动时间,使其可以自动周期性检测
- _fastLeakStartTime = DateTime.Now;
- return true;
- }
- /// Slow leak test
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private bool SlowLeakTestAction()
- {
- ReservoirEntity _reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(Module);
- if (_reservoirEntity != null && _reservoirEntity.IsInitialized)
- {
- _isInitialized = true;
- }
- else
- {
- _isInitialized = false;
- }
- if (_persistentValue.OperatingMode == AUTO)
- {
- foreach (var metalDevice in _metalDevices)
- {
- if (metalDevice.ANACellFlow.CounterValue > 0 || metalDevice.ANBCellFlow.CounterValue > 0)
- {
- _isHasAnFlow = true;
- }
- if ("Auto".Equals(metalDevice.OperationMode))
- {
- _isHasMetalInAuto = true;
- }
- }
- if (_isHasAnFlow && _isHasMetalInAuto && _isInitialized)
- {
- LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, $" Slow leak test is start");
- _leakVolume = ReservoirData.ANLevel - _StartSlowLeakTestANLevel;
- if (_leakVolume > SC.GetValue<double>($"Reservoir.{Module}.MaxLeakVolume"))
- {
- LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, " Slow leak was detected");
- }
- }
- }
- //更新当前液位
- _StartSlowLeakTestANLevel = ReservoirData.ANLevel;
- //更新启动时间
- _slowLeakStartTime = DateTime.Now;
- return true;
- }
- /// <summary>
- /// 重新开始slow leak test
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="objs"></param>
- /// <returns></returns>
- private bool ClearSlowLeak(string cmd, object[] objs)
- {
- _StartSlowLeakTestANLevel = ReservoirData.ANLevel;
- _slowLeakStartTime = DateTime.Now;
- LOG.WriteLog(eEvent.INFO_RESERVOIR, Module, $" Slow leak test was reset");
- return true;
- }
- /// <summary>
- /// 手动注水
- /// </summary>
- /// <param name="direplenOn"></param>
- /// <param name="direplenOperation"></param>
- /// <returns></returns>
- private bool ManualDiReplen(Func<string, object[], bool> direplenOn, ReservoirOperation direplenOperation, string timeLength)
- {
- if (_currentOperation != ReservoirOperation.None)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"current operation is {_currentOperation},cannot execute {direplenOperation}");
- return false;
- }
- bool result = direplenOn("", null);
- if (result)
- {
- _currentOperation = direplenOperation;
- _persistentValue.DiReplenTime = DateTime.Now;
- ReservoirsPersistentManager.Instance.UpdatePersistentValue(Module);
- int.TryParse(timeLength, out _manualReplenSecond);
- }
- return result;
- }
- /// <summary>
- /// 阳极自动注水
- /// </summary>
- /// <returns></returns>
- public bool AutoANDiReplen()
- {
- if (IsANLowLevel)
- {
- if (!_isANAutoDIReplenError)
- {
- _isANAutoDIReplenError = true;
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"ANLowLevel is activate,Can't AutoANDireplen");
- }
- return false;
- }
- else
- {
- _isANAutoDIReplenError = false;
- }
- return AutoDireplen(ANDiReplenOn, ReservoirOperation.AutoANDiReplen);
- }
- /// <summary>
- /// 阴极自动流水
- /// </summary>
- /// <returns></returns>
- public bool AutoCADiReplen()
- {
- if (IsCALowLevel)
- {
- if (!_isCAAutoDIReplenError)
- {
- _isCAAutoDIReplenError = true;
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"CALowLevel is activate,Can't AutoANDireplen");
- }
- return false;
- }
- else
- {
- _isCAAutoDIReplenError = false;
- }
- return AutoDireplen(CADiReplenOn, ReservoirOperation.AutoCADiReplen);
- }
- /// <summary>
- /// 自动注水
- /// </summary>
- /// <returns></returns>
- private bool AutoDireplen(Func<bool, bool> direplenOn, ReservoirOperation reservoirOperation)
- {
- if (_currentOperation != ReservoirOperation.None)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"current operation is {_currentOperation},cannot execute {reservoirOperation}");
- return false;
- }
- if (_resRecipe == null)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"recipe is null");
- return false;
- }
- bool result = direplenOn(false);
- if (result)
- {
- _currentOperation = reservoirOperation;
- _persistentValue.DiReplenTime = DateTime.Now;
- }
- return result;
- }
- #endregion
- #region CrossDose
- /// <summary>
- /// CrossDose开阀
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- public bool CrossDoseOn(string cmd, object[] args)
- {
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{CROSS_DOSE_ENABLE}");
- return BeckhoffIOManager.Instance.WriteIoValue(ioName, true);
- }
- /// <summary>
- /// CrossDose关阀
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- public bool CrossDoseOff(string cmd, object[] args)
- {
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{CROSS_DOSE_ENABLE}");
- return BeckhoffIOManager.Instance.WriteIoValue(ioName, false);
- }
- /// <summary>
- /// 手动Dosing
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- private bool StartDosing(string cmd, object[] args)
- {
- ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(Module);
- if (!_isCrossDoseInitialized)
- {
- LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, "Please initialize Cross Dose");
- return false;
- }
- double crossDoseVolume = (double)args[0];
- _crossDoseHelper.SetManualDoseOperation();
- return _crossDoseHelper.StartDosing(crossDoseVolume);
- }
- /// <summary>
- /// 停止Dosing
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- private bool HaltDosing(string cmd, object[] args)
- {
- _crossDoseHelper.ResetDoseOperation();
- _crossDoseHelper.HaltDosing();
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{CROSS_DOSE_ENABLE}");
- return BeckhoffIOManager.Instance.WriteIoValue(ioName, false);
- }
- /// <summary>
- /// Set Pump Factor
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- private bool SetPumpFactor(string cmd, object[] args)
- {
- double targetPumpFactor = (double)args[0];
- _crossDoseHelper.SetPumpfactor(targetPumpFactor);
- return true;
- }
- /// <summary>
- /// CrossDose初始化
- /// </summary>
- /// <param name="isInitialized"></param>
- public void InitializeCrossDose(bool isInitialized)
- {
- _isCrossDoseInitialized = isInitialized;
- }
- /// <summary>
- /// Reset CrossDose
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- public bool ResetCrossDose(string cmd, object[] args)
- {
- return _crossDoseHelper.ResetCrossDose();
- }
- /// <summary>
- /// Reset Monitor
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- public bool ResetCrossDoseMonitor()
- {
- return _crossDoseHelper.ResetCrossDoseMonitor();
- }
- #endregion
- #region Sample
- /// <summary>
- /// ANSample开阀
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- public bool ANSampleOn(string cmd, object[] args)
- {
- SystemFacilities systemFacility = DEVICE.GetDevice<SystemFacilities>("System.Facilities");
- if (systemFacility != null && !systemFacility.SampleFluidDetect)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "SampleFluidDetect is Activate. Can't open ANSample");
- return false;
- }
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{AN_SAMPLE_FLOW}");
- return BeckhoffIOManager.Instance.WriteIoValue(ioName, true);
- }
- /// <summary>
- /// ANSample关阀
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- public bool ANSampleOff(string cmd, object[] args)
- {
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{AN_SAMPLE_FLOW}");
- return BeckhoffIOManager.Instance.WriteIoValue(ioName, false);
- }
- /// <summary>
- /// CASample开阀
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- public bool CASampleOn(string cmd, object[] args)
- {
- SystemFacilities systemFacility = DEVICE.GetDevice<SystemFacilities>("System.Facilities");
- if (systemFacility != null && !systemFacility.SampleFluidDetect)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "SampleFluidDetect is Activate. Can't open CASample");
- return false;
- }
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{CA_SAMPLE_FLOW}");
- return BeckhoffIOManager.Instance.WriteIoValue(ioName, true);
- }
- /// <summary>
- /// CASample关阀
- /// </summary>
- /// <param name="cmd"></param>
- /// <param name="args"></param>
- /// <returns></returns>
- public bool CASampleOff(string cmd, object[] args)
- {
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{CA_SAMPLE_FLOW}");
- return BeckhoffIOManager.Instance.WriteIoValue(ioName, false);
- }
- #endregion
- /// <summary>
- /// 订阅变量数值发生变化
- /// </summary>
- private void SubscribeValueAction()
- {
- BeckhoffIoSubscribeUpdateVariable(CA_DI_REPLEN);
- BeckhoffIoSubscribeUpdateVariable(AN_DI_REPLEN);
- BeckhoffIoSubscribeUpdateVariable(CA_WATER_LEVEL);
- BeckhoffIoSubscribeUpdateVariable(AN_WATER_LEVEL);
- BeckhoffIoSubscribeUpdateVariable(AN_PUMP);
- BeckhoffIoSubscribeUpdateVariable(CROSS_DOSE_ENABLE);
- BeckhoffIoSubscribeUpdateVariable(TRANSFER_PUMP_STM_STATUS);
- BeckhoffIoSubscribeUpdateVariable(TRANSFER_PUMP_POS_STATUS);
- BeckhoffIoSubscribeUpdateVariable(TRANSFER_PUMP_TARGET_POSITION);
- BeckhoffIoSubscribeUpdateVariable(TRANSFER_PUMP_ENABLE);
- BeckhoffIoSubscribeUpdateVariable(TRANSFER_PUMP_EXECUTE);
- BeckhoffIoSubscribeUpdateVariable(TRANSFER_PUMP_RESET);
- BeckhoffIoSubscribeUpdateVariable(TRANSFER_PUMP_SPEED);
- BeckhoffIoSubscribeUpdateVariable(TRANSFER_PUMP_START_TYPE);
- BeckhoffIoSubscribeUpdateVariable(TRANSFER_PUMP_ACCELERATION);
- BeckhoffIoSubscribeUpdateVariable(TRANSFER_PUMP_DECELERATION);
- BeckhoffIoSubscribeUpdateVariable(TRANSFER_ACTUAL_POSITION);
- BeckhoffIoSubscribeUpdateVariable(AN_BYPASS_FLOW);
- BeckhoffIoSubscribeUpdateVariable(AN_A_DRAIN_PUMP);
- BeckhoffIoSubscribeUpdateVariable(AN_B_DRAIN_PUMP);
- BeckhoffIoSubscribeUpdateVariable(AN_SAMPLE_FLOW);
- BeckhoffIoSubscribeUpdateVariable(CA_SAMPLE_FLOW);
- BeckhoffIoSubscribeUpdateVariable(CA_PUMP_SPEED);
- BeckhoffIoSubscribeUpdateVariable(CA_PUMP_RUNNING);
- BeckhoffIoSubscribeUpdateVariable(CA_HED_FLOW);
- BeckhoffIoSubscribeUpdateVariable(CDA_FLOW_VALVE);
- BeckhoffIoSubscribeUpdateVariable(AN_BY_PASS);
- BeckhoffIoSubscribeUpdateVariable(CA_BY_PASS);
- BeckhoffIoSubscribeUpdateVariable(CA_PUMP_ENABLE);
- BeckhoffIoSubscribeUpdateVariable(EVAPORATORLEVEL);
- BeckhoffCounterSubscribeUpdateVariable(AN_TRANSFER_FLOW, ANTransferFlow);
- BeckhoffCounter anTransferFlowCounter = BeckhoffCounterManager.Instance.GetBeckhoffCounter($"{Module}.{AN_TRANSFER_FLOW}");
- if (anTransferFlowCounter != null)
- {
- ANTransferFlow.Period = anTransferFlowCounter.Period;
- }
- BeckhoffCounterSubscribeUpdateVariable(AN_BYPASS_COUNTERFLOW, ReservoirCounterByPassFlow);
- BeckhoffCounter reservoirCounterByPassFlow = BeckhoffCounterManager.Instance.GetBeckhoffCounter($"{Module}.{AN_BYPASS_COUNTERFLOW}");
- if (reservoirCounterByPassFlow != null)
- {
- ReservoirCounterByPassFlow.Period = reservoirCounterByPassFlow.Period;
- }
- }
- /// <summary>
- /// 订阅IO变量
- /// </summary>
- /// <param name="variable"></param>
- private void BeckhoffIoSubscribeUpdateVariable(string variable)
- {
- _variableInitializeDic[variable] = false;
- IOModuleManager.Instance.SubscribeModuleVariable(Module, variable, UpdateVariableValue);
- }
- /// <summary>
- /// 订阅Counter变量
- /// </summary>
- /// <param name="variable"></param>
- private void BeckhoffCounterSubscribeUpdateVariable(string variable, CounterFlowData counterFlowData)
- {
- _nameCounterFlowData[$"{Module}.{variable}"] = counterFlowData;
- BeckhoffCounterManager.Instance.SubscribeModuleVariable($"{Module}.{variable}", COUNTER_VALUE, UpdateCounterVariableValue);
- BeckhoffCounterManager.Instance.SubscribeModuleVariable($"{Module}.{variable}", COUNTER_START, UpdateCounterVariableValue);
- BeckhoffCounterManager.Instance.SubscribeModuleVariable($"{Module}.{variable}", COUNTER_STOP, UpdateCounterVariableValue);
- BeckhoffCounterManager.Instance.SubscribeModuleVariable($"{Module}.{variable}", COUNTER_RESET, UpdateCounterVariableValue);
- }
- /// <summary>
- /// 更新变量数值
- /// </summary>
- /// <param name="variable"></param>
- /// <param name="value"></param>
- private void UpdateCounterVariableValue(string variable, object value)
- {
- string[] strAry = variable.Split('.');
- string lastVariable = strAry[strAry.Length - 1];
- PropertyInfo property = null;
- string key = variable.Replace($".{lastVariable}", "");
- if (_nameCounterFlowData.ContainsKey(key))
- {
- CounterFlowData counterFlowData = _nameCounterFlowData[key];
- if (counterFlowData != null)
- {
- property = counterFlowData.GetType().GetProperty(lastVariable);
- if (property != null)
- {
- property.SetValue(counterFlowData, value);
- }
- }
- }
- }
- /// <summary>
- /// 更新变量数值
- /// </summary>
- /// <param name="variable"></param>
- /// <param name="value"></param>
- private void UpdateVariableValue(string variable, object value)
- {
- if (!ReservoirData.IsDataInitialized)
- {
- ReservoirData.IsDataInitialized = true;
- }
- PropertyInfo property = ReservoirData.GetType().GetProperty(variable);
- if (property != null)
- {
- property.SetValue(ReservoirData, value);
- if (variable == AN_WATER_LEVEL)
- {
- string anLevelCurve = SC.GetStringValue($"Reservoir.{Module}.ANLevelCurve");
- ReservoirData.ANLevel = LevelCurveManager.Instance.CalculateLevelByWaterLevel(ReservoirData.ANWaterLevel, anLevelCurve);
- }
- else if (variable == CA_WATER_LEVEL)
- {
- string caLevelCurve = SC.GetStringValue($"Reservoir.{Module}.CALevelCurve");
- ReservoirData.CALevel = LevelCurveManager.Instance.CalculateLevelByWaterLevel(ReservoirData.CAWaterLevel, caLevelCurve);
- }
- }
- if (_variableInitializeDic.ContainsKey(variable) && !_variableInitializeDic[variable])
- {
- _variableInitializeDic[variable] = true;
- }
- }
- /// <summary>
- /// 是否所有IO变量初始化完成
- /// </summary>
- /// <returns></returns>
- private bool AllIoVariableInitialized()
- {
- foreach (string item in _variableInitializeDic.Keys)
- {
- if (!_variableInitializeDic[item])
- {
- LOG.WriteLog(eEvent.ERR_RINSE, Module, $"{item} is not initialized");
- return false;
- }
- }
- return true;
- }
- /// <summary>
- /// 检验阳极是否需要补水
- /// </summary>
- /// <returns></returns>
- private bool CheckANNeedDiReplen()
- {
- if (IsAuto && _resRecipe != null)
- {
- if (_resRecipe.ANDIReplenEnable && _resRecipe.ANDIReplenCurrentRate == 0 && _resRecipe.ANDIReplenTimeRate == 0)
- {
- double levelHysteresis = SC.GetValue<double>("Reservoir.LevelHysteresis");
- return _reservoirData.ANLevel < _resRecipe.ReservoirANLevel - levelHysteresis;
- }
- return false;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 检验CA是否需要注水
- /// </summary>
- /// <returns></returns>
- public bool CheckCANeedDiReplen()
- {
- if (IsAuto && _resRecipe != null)
- {
- if (_resRecipe.DIReplenEnable && _resRecipe.DIReplenTimeRate == 0 && _resRecipe.DIReplenCurrentRate == 0)
- {
- double levelHysteresis = SC.GetValue<double>("Reservoir.LevelHysteresis");
- return _reservoirData.CALevel < _resRecipe.ReservoirCALevel - levelHysteresis;
- }
- return false;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 检验阴极是否highlevel
- /// </summary>
- public bool CheckCAHighLevelStatus()
- {
- return ReservoirData.CAWaterLevel > SC.GetValue<double>($"Reservoir.{Module}.CAHighLevel") ? true : false;
- }
- /// <summary>
- /// 检验阴极是否lowlevel
- /// </summary>
- public bool CheckCALowLevelStatus()
- {
- return ReservoirData.CAWaterLevel < SC.GetValue<double>($"Reservoir.{Module}.CALowLevel") ? true : false;
- }
- /// <summary>
- /// 检验阳极是否highlevel
- /// </summary>
- public bool CheckANHighLevelStatus()
- {
- return ReservoirData.ANWaterLevel > SC.GetValue<double>($"Reservoir.{Module}.ANHighLevel") ? true : false;
- }
- /// <summary>
- /// 检验阳极是否lowlevel
- /// </summary>
- public bool CheckANLowLevelStatus()
- {
- return ReservoirData.ANWaterLevel < SC.GetValue<double>($"Reservoir.{Module}.ANLowLevel") ? true : false;
- }
- /// <summary>
- /// CAFlowRate Check
- /// </summary>
- private void CAFlowRateCheck()
- {
- if (_resRecipe == null) return;
- for (int i = 0; i < _metalDevices.Count; i++)
- {
- CompactMembranMetalDevice hotMetalDevice = _metalDevices[i];
- if (hotMetalDevice != null && !hotMetalDevice.IsDisable && hotMetalDevice.IsAuto)
- {
- if (hotMetalDevice.MetalDeviceData == null) continue;
- if (!hotMetalDevice.FlowValveStable) continue;
- MetalEntity metalEntity = Singleton<RouteManager>.Instance.GetModule<MetalEntity>(hotMetalDevice.Name);
- double cellFlow = hotMetalDevice.MetalDeviceData.CellFlow;
- if (cellFlow < _resRecipe.CAFlowRateErrorLow)
- {
- if (!metalEntity.IsError)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{hotMetalDevice.Name} cellflow:{cellFlow} is less than recipe's CAFlowRateErrorLow parameter:{_resRecipe.CAFlowRateErrorLow}");
- metalEntity.PostMsg(MetalMsg.Error);
- }
- }
- else if (cellFlow < _resRecipe.CAFlowRateWarningLow)
- {
- if (!_isCAFlowRateWARN[i])
- {
- LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"{hotMetalDevice.Name} cellflow:{cellFlow} is less than recipe's CAFlowRateWarningLow parameter:{_resRecipe.CAFlowRateWarningLow}");
- _isCAFlowRateWARN[i] = true;
- }
- }
- else
- {
- _isCAFlowRateWARN[i] = false;
- }
- }
- }
- }
- /// <summary>
- /// ANFlowRate Check
- /// </summary>
- private void ANFlowRateCheck()
- {
- if (_resRecipe == null) return;
- for (int i = 0; i < _metalDevices.Count; i++)
- {
- CompactMembranMetalDevice hotMetalDevice = _metalDevices[i];
- if (hotMetalDevice != null && !hotMetalDevice.IsDisable && hotMetalDevice.IsAuto)
- {
- if (hotMetalDevice.MetalDeviceData == null) continue;
- //ANACellFlow
- MetalEntity metalEntity = Singleton<RouteManager>.Instance.GetModule<MetalEntity>(hotMetalDevice.Name);
- if (hotMetalDevice.MetalDeviceData.ANAPinEnable && hotMetalDevice.ANAFlowValveStable)
- {
- double ANAcellFlow = hotMetalDevice.ANACellFlow.CounterValue;
- if (ANAcellFlow < _resRecipe.ANFlowRateErrorLow)
- {
- if (!metalEntity.IsError)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{hotMetalDevice.Name} ANASideflow:{ANAcellFlow} is less than recipe's ANFlowRateErrorLow parameter:{_resRecipe.ANFlowRateErrorLow}");
- metalEntity.PostMsg(MetalMsg.Error);
- }
- }
- else if (ANAcellFlow < _resRecipe.ANFlowRateWarningLow)
- {
- if (!_isANAFlowRateWARN[i])
- {
- LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"{hotMetalDevice.Name} ANASideflow:{ANAcellFlow} is less than recipe's ANFlowRateWarningLow parameter:{_resRecipe.ANFlowRateWarningLow}");
- _isANAFlowRateWARN[i] = true;
- }
- }
- else
- {
- _isANAFlowRateWARN[i] = false;
- }
- }
- //ANBCellFlow
- if (hotMetalDevice.MetalDeviceData.ANBPinEnable && hotMetalDevice.ANBFlowValveStable)
- {
- double ANBcellFlow = hotMetalDevice.ANBCellFlow.CounterValue;
- if (ANBcellFlow < _resRecipe.ANFlowRateErrorLow)
- {
- if (!metalEntity.IsError)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{hotMetalDevice.Name} ANBSideflow:{ANBcellFlow} is less than recipe's ANFlowRateErrorLow parameter:{_resRecipe.ANFlowRateErrorLow}");
- metalEntity.PostMsg(MetalMsg.Error);
- }
- }
- else if (ANBcellFlow < _resRecipe.ANFlowRateWarningLow)
- {
- if (!_isANBFlowRateWARN[i])
- {
- LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"{hotMetalDevice.Name} ANBSideflow:{ANBcellFlow} is less than recipe's ANFlowRateWarningLow parameter:{_resRecipe.ANFlowRateWarningLow}");
- _isANBFlowRateWARN[i] = true;
- }
- }
- else
- {
- _isANBFlowRateWARN[i] = false;
- }
- }
- }
- }
- }
- /// <summary>
- /// Temperature Check
- /// </summary>
- private void TemperatureCheck()
- {
- ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(Module);
- ReservoirItem reservoirItem = ReservoirItemManager.Instance.GetReservoirItem(Module);
- TemperatureController temperatureController = DEVICE.GetDevice<TemperatureController>(reservoirItem.TCID);
- if (temperatureController == null || temperatureController.TemperatureData == null || _resRecipe == null
- || temperatureController.TemperatureData.ControlOperationModel != ENABLE) return;
- double tempValue = temperatureController.TemperatureData.ReserviorTemperature;
- if (tempValue > _resRecipe.TemperatureErrorHigh && !reservoirEntity.IsError)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{temperatureController.Name} temperature:{tempValue} is over recipe's TemperatureErrorHigh parameter:{_resRecipe.TemperatureErrorHigh}");
- reservoirEntity.PostMsg(ReservoirMsg.Error);
- }
- else if (tempValue < _resRecipe.TemperatureErrorLow && !reservoirEntity.IsError)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{temperatureController.Name} temperature:{tempValue} is less than recipe's TemperatureErrorLow parameter:{_resRecipe.TemperatureErrorLow}");
- reservoirEntity.PostMsg(ReservoirMsg.Error);
- }
- else if (tempValue > _resRecipe.TemperatureWarningHigh)
- {
- if (!_isTCControlWARN)
- {
- LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"{temperatureController.Name} temperature:{tempValue} is over recipe's TemperatureWarningHigh parameter:{_resRecipe.TemperatureWarningHigh}");
- _isTCControlWARN = true;
- }
- }
- else if (tempValue < _resRecipe.TemperatureWarningLow)
- {
- if (!_isTCControlWARN)
- {
- LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"{temperatureController.Name} temperature;{tempValue} is less than recipe's TemperatureWarningLow parameter:{_resRecipe.TemperatureWarningLow}");
- _isTCControlWARN = true;
- }
- }
- else
- {
- _isTCControlWARN = false;
- }
- }
- /// <summary>
- /// AN LowLevel触发对应操作
- /// </summary>
- private void ANLowLevelOperation()
- {
- if (IsANLowLevel)
- {
- if (_reservoirData.ANPump > 0)
- {
- AnPumpOffOperation("ANPumpOff", null);
- }
- foreach (var metalDevice in _metalDevices)
- {
- if (metalDevice.MetalDeviceData.ANAPinEnable)
- {
- metalDevice.AnSideAFillOff($"{metalDevice.Name}.ANAFillOff", null);
- }
- if (metalDevice.MetalDeviceData.ANBPinEnable)
- {
- metalDevice.AnSideBFillOff($"{metalDevice.Name}.ANBFillOff", null);
- }
- }
- }
- }
- /// <summary>
- /// CA Low Level触发对应操作
- /// </summary>
- private void CALowLevelOperation()
- {
- ReservoirItem reservoirItem = ReservoirItemManager.Instance.GetReservoirItem(Module);
- if (IsCALowLevel)
- {
- if (_reservoirData.CAPumpEnable)
- {
- CAPumpOff("CAPumpOff", null);
- }
- foreach (var metalDevice in _metalDevices)
- {
- if (metalDevice.MetalDeviceData.CellFlowValve)
- {
- metalDevice.CellFlowValveOff($"{metalDevice.Name}.FlowOff", null);
- }
- }
- //禁用TC
- if (!String.IsNullOrEmpty(reservoirItem.TCID))
- {
- TemperatureController temperatureController = DEVICE.GetDevice<TemperatureController>(reservoirItem.TCID);
- if (temperatureController != null && temperatureController.TemperatureData.ControlOperationModel == 5)
- {
- temperatureController.DisableOperation("", null);
- }
- }
- }
- }
- /// <summary>
- /// High Level Common Operation
- /// </summary>
- private void HighLevelOperation()
- {
- ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(Module);
- SystemFacilities systemFacilities = DEVICE.GetDevice<SystemFacilities>("System.Facilities");
- if (systemFacilities != null)
- {
- if (systemFacilities.DIFillEnable) systemFacilities.DiFillDisableOperation("DIFillDisableOpeartion", null);
- if (systemFacilities.DIReplenEnable) systemFacilities.DiReplenDisableOperation("DiReplenDisableOperation", null);
- if (_reservoirData.ANDiReplen)
- {
- _currentOperation = ReservoirOperation.None;
- ANDiReplenOff("", null);
- }
- if (_reservoirData.CADiReplen)
- {
- _currentOperation = ReservoirOperation.None;
- CADiReplenOff("", null);
- }
- }
- if (!reservoirEntity.IsError) reservoirEntity.PostMsg(ReservoirMsg.Error);
- }
- /// <summary>
- /// Low Level common Operation
- /// </summary>
- private void LowLevelOperation()
- {
- ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(Module);
- foreach (var metalDevice in _metalDevices)
- {
- MetalEntity metalEntity = Singleton<RouteManager>.Instance.GetModule<MetalEntity>(metalDevice.DeviceID);
- if (metalEntity != null && !metalEntity.IsError)
- {
- metalEntity.PostMsg(MetalMsg.Error);
- }
- }
- if (!reservoirEntity.IsError) reservoirEntity.PostMsg(ReservoirMsg.Error);
- }
- /// <summary>
- /// WaterLevelMonitor
- /// </summary>
- private void WaterLevelMonitor()
- {
- ReservoirItem reservoirItem = ReservoirItemManager.Instance.GetReservoirItem(Module);
- ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(Module);
- _isSystemAutoMode = reservoirEntity.IsAuto; ;
- //触发low将对应的reservoir和对应metal切成error
- if (IsANLowLevel)
- {
- if (!errorLogSet.Contains($"{Module}.IsANLowLevel"))
- {
- errorLogSet.Add($"{Module}.IsANLowLevel");
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Current ANWaterlevel:{ReservoirData.ANWaterLevel} is lower than ANLowLevel Config:{SC.GetValue<double>($"Reservoir.{Module}.ANLowLevel")}");
- }
- ANLowLevelOperation();
- LowLevelOperation();
- if (_isSystemAutoMode && !AlarmListManager.Instance.IsContainDataError(Module, "ANWaterLevel"))//模块处于Auto模式使将报错信息加入到Alarm
- {
- AlarmListManager.Instance.AddDataError(Module,
- $"ANWaterLevel", $"Current ANWaterlevel:{ReservoirData.ANWaterLevel} is lower than ANLowLevel Config:{SC.GetValue<double>($"Reservoir.{Module}.ANLowLevel")}");
- }
- }
- else if (IsANHighLevel)
- {
- if (!errorLogSet.Contains($"{Module}.IsANHighLevel"))
- {
- errorLogSet.Add($"{Module}.IsANHighLevel");
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Current ANWaterlevel:{ReservoirData.ANWaterLevel} is larger than ANHighLevel Config:{SC.GetValue<double>($"Reservoir.{Module}.ANHighLevel")}");
- }
- HighLevelOperation();
- if (_isSystemAutoMode && !AlarmListManager.Instance.IsContainDataError(Module, "ANWaterLevel"))
- {
- AlarmListManager.Instance.AddDataError(Module,
- $"ANWaterLevel", $"Current ANWaterlevel:{ReservoirData.ANWaterLevel} is larger than ANHighLevel Config:{SC.GetValue<double>($"Reservoir.{Module}.ANHighLevel")}");
- }
- }
- if (IsCALowLevel)
- {
- if (!errorLogSet.Contains($"{Module}.IsCALowLevel"))
- {
- errorLogSet.Add($"{Module}.IsCALowLevel");
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Current CAWaterlevel:{ReservoirData.CAWaterLevel} is lower than CALowLevel Config:{SC.GetValue<double>($"Reservoir.{Module}.CALowLevel")}");
- }
- CALowLevelOperation();
- LowLevelOperation();
- if (_isSystemAutoMode && !AlarmListManager.Instance.IsContainDataError(Module, "CAWaterLevel"))
- {
- AlarmListManager.Instance.AddDataError(Module,
- $"CAWaterLevel", $"Current CAWaterlevel:{ReservoirData.CAWaterLevel} is lower than CALowLevel Config:{SC.GetValue<double>($"Reservoir.{Module}.CALowLevel")}");
- }
- }
- else if (IsCAHighLevel)
- {
- if (!errorLogSet.Contains($"{Module}.IsCAHighLevel"))
- {
- errorLogSet.Add($"{Module}.IsCAHighLevel");
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Current CAWaterlevel:{ReservoirData.CAWaterLevel} is large than CAHighLevel Config:{SC.GetValue<double>($"Reservoir.{Module}.CAHighLevel")}");
- }
- HighLevelOperation();
- if (_isSystemAutoMode && !AlarmListManager.Instance.IsContainDataError(Module, "CAWaterLevel"))
- {
- AlarmListManager.Instance.AddDataError(Module,
- $"CAWaterLevel", $"Current CAWaterlevel:{ReservoirData.CAWaterLevel} is large than CAHighLevel Config:{SC.GetValue<double>($"Reservoir.{Module}.CAHighLevel")}");
- }
- }
- //水位触发recipe里面的high/low参数将对应的reservoir切成error
- if (_resRecipe == null) return;
- //ANLevel监控
- if (ReservoirData.ANLevel < _resRecipe.ANLevelErrorLow)
- {
- if (!errorLogSet.Contains($"{Module}.ANLevel"))
- {
- errorLogSet.Add($"{Module}.ANLevel");
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Current ANlevel:{ReservoirData.ANLevel} is lower than ResRecipe.ANLevelErrorLow:{_resRecipe.ANLevelErrorLow}");
- }
- if (!reservoirEntity.IsError)
- {
- reservoirEntity.PostMsg(ReservoirMsg.Error);
- }
- if (_isSystemAutoMode && !AlarmListManager.Instance.IsContainDataError(Module, "ANLevel"))
- {
- AlarmListManager.Instance.AddDataError(Module,
- $"ANLevel", $"Current ANlevel:{ReservoirData.ANLevel} is lower than ResRecipe.ANLevelErrorLow:{_resRecipe.ANLevelErrorLow}");
- }
- }
- else if (ReservoirData.ANLevel > _resRecipe.ANLevelErrorHigh)
- {
- if (!errorLogSet.Contains($"{Module}.ANLevel"))
- {
- errorLogSet.Add($"{Module}.ANLevel");
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Current ANlevel:{ReservoirData.ANLevel} is larger than ResRecipe.ANLevelErrorHigh:{_resRecipe.ANLevelErrorHigh}");
- }
- if (!reservoirEntity.IsError)
- {
- reservoirEntity.PostMsg(ReservoirMsg.Error);
- }
- if (_isSystemAutoMode && !AlarmListManager.Instance.IsContainDataError(Module, "ANLevel"))
- {
- AlarmListManager.Instance.AddDataError(Module,
- $"ANLevel", $"Current ANlevel:{ReservoirData.ANLevel} is larger than ResRecipe.ANLevelErrorHigh:{_resRecipe.ANLevelErrorHigh}");
- }
- }
- //CALevel监控
- if (ReservoirData.CALevel < _resRecipe.CALevelErrorLow)
- {
- if (!errorLogSet.Contains($"{Module}.CALevel"))
- {
- errorLogSet.Add($"{Module}.CALevel");
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Current CAlevel:{ReservoirData.CALevel} is lower than ResRecipe.CALevelErrorLow:{_resRecipe.CALevelErrorLow}");
- }
- if (!reservoirEntity.IsError)
- {
- reservoirEntity.PostMsg(ReservoirMsg.Error);
- }
- if (_isSystemAutoMode && !AlarmListManager.Instance.IsContainDataError(Module, "CALevel"))
- {
- AlarmListManager.Instance.AddDataError(Module,
- $"CALevel", $"Current CAlevel:{ReservoirData.CALevel} is lower than ResRecipe.CALevelErrorLow:{_resRecipe.CALevelErrorLow}");
- }
- }
- else if (ReservoirData.CALevel > _resRecipe.CALevelErrorHigh)
- {
- if (!errorLogSet.Contains($"{Module}.CALevel"))
- {
- errorLogSet.Add($"{Module}.CALevel");
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Current CAlevel:{ReservoirData.CALevel} is larger than ResRecipe.CALevelErrorHigh:{_resRecipe.CALevelErrorHigh}");
- }
- if (!reservoirEntity.IsError)
- {
- reservoirEntity.PostMsg(ReservoirMsg.Error);
- }
- if (_isSystemAutoMode && !AlarmListManager.Instance.IsContainDataError(Module, "CALevel"))
- {
- AlarmListManager.Instance.AddDataError(Module,
- $"CALevel", $"Current CAlevel:{ReservoirData.CALevel} is larger than ResRecipe.CALevelErrorHigh:{_resRecipe.CALevelErrorHigh}");
- }
- }
- }
- /// <summary>
- /// 定时器
- /// </summary>
- /// <returns></returns>
- private bool OnTimer()
- {
- //补水监控
- if (_direplenHelper != null)
- {
- _direplenHelper.MonitorPeriodTime();
- if (_currentOperation == ReservoirOperation.ManualANDiReplen)
- {
- bool result = _direplenHelper.MonitorManualDiReplenComplete(_manualReplenSecond, ANDiReplenOff);
- if (result)
- {
- _currentOperation = ReservoirOperation.None;
- }
- }
- if (_currentOperation == ReservoirOperation.ManualCADiReplen)
- {
- bool result = _direplenHelper.MonitorManualDiReplenComplete(_manualReplenSecond, CADiReplenOff);
- if (result)
- {
- _currentOperation = ReservoirOperation.None;
- }
- }
- if (_currentOperation == ReservoirOperation.AutoANDiReplen)
- {
- AutoDiReplenMonitor(ANDiReplenOff, _reservoirData.ANLevel, _resRecipe.ReservoirANLevel, _resRecipe.ANDIReplenEnable,
- _resRecipe.ANDIReplenTimeRate, _resRecipe.ANDIReplenCurrentRate);
- }
- if (_currentOperation == ReservoirOperation.AutoCADiReplen)
- {
- AutoDiReplenMonitor(CADiReplenOff, _reservoirData.CALevel, _resRecipe.ReservoirCALevel, _resRecipe.DIReplenEnable,
- _resRecipe.DIReplenTimeRate, _resRecipe.DIReplenCurrentRate);
- }
- }
- //计算AN/CA level的平均值
- if (ReservoirData != null)
- {
- //AN
- if (_ANLevelSamples.Count >= levelSampleCount)
- {
- _ANLevelSamples.Dequeue();
- _ANLevelSamples.Enqueue(ReservoirData.ANLevel);
- }
- else
- {
- _ANLevelSamples.Enqueue(ReservoirData.ANLevel);
- }
- //CA
- if (_CALevelSamples.Count >= levelSampleCount)
- {
- _CALevelSamples.Dequeue();
- _CALevelSamples.Enqueue(ReservoirData.CALevel);
- }
- else
- {
- _CALevelSamples.Enqueue(ReservoirData.CALevel);
- }
- _avgANLevel = _ANLevelSamples.Count > 0 ? _ANLevelSamples.Average() : 0;
- _avgCALevel = _CALevelSamples.Count > 0 ? _CALevelSamples.Average() : 0;
- }
- _metalTotalFlow = 0;
- ReservoirItem reservoirItem = ReservoirItemManager.Instance.GetReservoirItem(Module);
- if (reservoirItem != null)
- {
- List<MetalItem> metalItems = reservoirItem.MetalCells;
- if (metalItems != null && metalItems.Count > 0)
- {
- foreach (MetalItem metalItem in metalItems)
- {
- if (metalItem.Installed)
- {
- CompactMembranMetalDevice metalDevice = DEVICE.GetDevice<CompactMembranMetalDevice>(metalItem.ModuleName);
- if (metalDevice != null)
- {
- _metalTotalFlow += metalDevice.ANACellFlow.CounterValue;
- _metalTotalFlow += metalDevice.ANBCellFlow.CounterValue;
- }
- }
- }
- }
- }
- ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(Module);
- //pump安全性检验
- if (_reservoirData.ANPump > 0 && (_reservoirData.ANBypassFlow + ReservoirCounterByPassFlow.CounterValue + _metalTotalFlow) < SC.GetValue<double>($"Reservoir.{Module}.ByPassMetalTotalFlowMinLimit"))
- {
- if (!_isAnPumpSafeDetectedActivate)
- {
- _isAnPumpSafeDetectedActivate = true;
- _AnPumpSafeDetectTime = DateTime.Now;
- }
- if ((DateTime.Now - _AnPumpSafeDetectTime).TotalSeconds > _flowFaultHoldOffTime && _isAnPumpSafeDetectedActivate)
- {
- if (reservoirEntity.IsAuto && !reservoirEntity.IsError)
- {
- reservoirEntity.PostMsg(ReservoirMsg.Error);
- }
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Total flow is less than configuration item ByPassMetalTotalFlowMinLimit :{SC.GetValue<double>($"Reservoir.{Module}.ByPassMetalTotalFlowMinLimit")}, AN Pump off");
- _isAnPumpSafeDetectedActivate = false;
- AnPump(0);
- }
- }
- else
- {
- _isAnPumpSafeDetectedActivate = false;
- }
- foreach (CompactMembranMetalDevice device in _metalDevices)
- {
- device.OnTimer(_periodicJob.Interval);
- }
- if (reservoirEntity != null && reservoirEntity.IsError && _isCrossDoseInstalled && _reservoirData.TransferPumpEnable && _reservoirData.TransferPumpExecute)
- {
- _crossDoseHelper.HaltDosing();
- }
- // 判断排气是否触发漏液警报
- if (_reservoirData != null && _reservoirData.EvaporatorLevel && "STD".Equals(reservoirItem.EvaporatorType)) //_reservoirData.EvaporatorLevel true表示触发漏液
- {
- if (_reservoirData.CDAFlowValve)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"EvaporatorLevel is Activate");
- CDAFlowOff("CDAFlowOff", null);
- }
- if (_reservoirData.CAPumpEnable)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"EvaporatorLevel is Activate");
- CAPumpOff("CAPumpOff", null);
- }
- }
- //WaterLevel Monitor
- WaterLevelMonitor();
- //触发Safetyhigh将reservoir切成error
- SafetyDevice safetyDevice = DEVICE.GetDevice<SafetyDevice>("Safety");
- if (safetyDevice != null && safetyDevice.SafetyData.ReservoirHighLevel && !reservoirEntity.IsError)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Safety high is Activate");
- reservoirEntity.PostMsg(ReservoirMsg.Error);
- }
- //Sample检测
- SystemFacilities systemFacility = DEVICE.GetDevice<SystemFacilities>("System.Facilities");
- if (systemFacility != null && !systemFacility.SampleFluidDetect)
- {
- if (ReservoirData.ANSampleFlow) ANSampleOff("", null);
- if (ReservoirData.CASampleFlow) CASampleOff("", null);
- }
- if (reservoirEntity == null || !reservoirEntity.IsInitialized)
- {
- return true;
- }
- if (_isCrossDoseInstalled)
- {
- if (_crossDoseHelper.CrossDoseState == RState.Running)
- {
- _crossDoseHelper.CrossDoseStatusMonitor();
- }
- if (_crossDoseHelper.ResetState == RState.Running)
- {
- _crossDoseHelper.ResetCrossDoseMonitor();
- }
- if (_persistentValue.OperatingMode == "Auto")
- {
- _crossDoseHelper.AutoCrossDoseMonitor(_isCrossDoseInitialized);
- }
- else
- {
- _crossDoseHelper.CrossDoseOperationMonitor();
- }
- }
- if (_persistentValue.OperatingMode == AUTO)
- {
- _pumpSpeedHelper.Monitor(_resRecipe);
- //CAFlowRate判断
- CAFlowRateCheck();
- //ANFlowRate判断
- ANFlowRateCheck();
- //Temperature判断
- TemperatureCheck();
- }
- //判断是否到启动fast leak test的时间
- if (DateTime.Now - _fastLeakStartTime >= _fastLeakTestSpan - TimeSpan.FromMilliseconds(200) && DateTime.Now - _fastLeakStartTime <= _fastLeakTestSpan + TimeSpan.FromMilliseconds(200))
- {
- FastLeakTestAction();
- }
- //判断是否到启动slow leak test的时间
- if (DateTime.Now - _slowLeakStartTime >= _slowLeakTestSpan - TimeSpan.FromMilliseconds(200) && DateTime.Now - _slowLeakStartTime <= _slowLeakTestSpan + TimeSpan.FromMilliseconds(200))
- {
- SlowLeakTestAction();
- }
- return true;
- }
- /// <summary>
- /// 自动注水监控
- /// </summary>
- /// <param name="direplenOff"></param>
- /// <param name="level"></param>
- /// <param name="recipeLevel"></param>
- private void AutoDiReplenMonitor(Func<string, object[], bool> direplenOff, double level, double recipeLevel, bool replenEnable,
- int direplenTimeRate, int direplenCurrentRate)
- {
- bool result = _direplenHelper.AutoDiReplenMonitorTimeOut(direplenOff);
- if (result)
- {
- _currentOperation = ReservoirOperation.None;
- //触发注水异常信号
- _isDiReplenInFault = true;
- }
- else
- {
- //按液位补水
- result = _direplenHelper.AutoDiReplenMonitorComplete(level, recipeLevel, replenEnable, direplenTimeRate, direplenCurrentRate, direplenOff);
- if (result)
- {
- _currentOperation = ReservoirOperation.None;
- }
- }
- }
- /// <summary>
- /// ReservoirUsage监控
- /// </summary>
- public void ReservoirUsageMonitor()
- {
- ReservoirUsage reservoirUsage = ReservoirUsageManager.Instance.GetReservoirUsage(Module);
- ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(Module);
- if (reservoirUsage == null || reservoirEntity == null) return;
- //reservoirTotalAmpHours Check
- double reservoirTotalAmpHoursWarningLimit = 0;
- if (SC.ContainsItem($"Reservoir.{Module}.ReservoirTotalAmpHoursWarningLimit"))
- {
- reservoirTotalAmpHoursWarningLimit = (double)SC.GetValue<double>($"Reservoir.{Module}.ReservoirTotalAmpHoursWarningLimit");
- }
- double reservoirTotalAmpHoursFaultLimit = 0;
- if (SC.ContainsItem($"Reservoir.{Module}.ReservoirTotalAmpHoursFaultLimit"))
- {
- reservoirTotalAmpHoursFaultLimit = (double)SC.GetValue<double>($"Reservoir.{Module}.ReservoirTotalAmpHoursFaultLimit");
- }
- if (reservoirUsage.TotalUsage > reservoirTotalAmpHoursFaultLimit && reservoirTotalAmpHoursFaultLimit != 0)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{Module} Total Usage(AHr):{reservoirUsage.TotalUsage} is over config item ReservoirTotalAmpHoursFaultLimit:{reservoirTotalAmpHoursFaultLimit}");
- reservoirEntity.PostMsg(ReservoirMsg.Error);
- AlarmListManager.Instance.AddDataError(Module,
- $"TotalUsage", $"{Module} Total Usage(AHr):{reservoirUsage.TotalUsage} is over ReservoirTotalAmpHoursFaultLimit:{reservoirTotalAmpHoursFaultLimit}");
- }
- else if (reservoirUsage.TotalUsage > reservoirTotalAmpHoursWarningLimit && reservoirTotalAmpHoursWarningLimit != 0)
- {
- LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"{Module} Total Usage(AHr):{reservoirUsage.TotalUsage} is over config item ReservoirTotalAmpHoursWarningLimit:{reservoirTotalAmpHoursWarningLimit}");
- AlarmListManager.Instance.AddWarn(Module,
- $"TotalUsage", $"{Module} Total Usage(AHr):{reservoirUsage.TotalUsage} is over ReservoirTotalAmpHoursWarningLimit:{reservoirTotalAmpHoursWarningLimit}");
- }
- //MembraneTotalAmpHoursCheck
- double membraneTotalAmpHoursWarningLimit = 0;
- if (SC.ContainsItem($"Reservoir.{Module}.MembraneTotalAmpHoursWarningLimit"))
- {
- membraneTotalAmpHoursWarningLimit = (double)SC.GetValue<double>($"Reservoir.{Module}.MembraneTotalAmpHoursWarningLimit");
- }
- double membraneTotalAmpHoursFaultLimit = 0;
- if (SC.ContainsItem($"Reservoir.{Module}.MembraneTotalAmpHoursFaultLimit"))
- {
- membraneTotalAmpHoursFaultLimit = (double)SC.GetValue<double>($"Reservoir.{Module}.MembraneTotalAmpHoursFaultLimit");
- }
- if (reservoirUsage.MembranceUsage > membraneTotalAmpHoursFaultLimit && membraneTotalAmpHoursFaultLimit != 0)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{Module} Membrane Usage(AHr):{reservoirUsage.MembranceUsage} is over config item MembraneTotalAmpHoursFaultLimit:{membraneTotalAmpHoursFaultLimit}");
- reservoirEntity.PostMsg(ReservoirMsg.Error);
- AlarmListManager.Instance.AddDataError(Module,
- $"MembraneUsage", $"{Module} Membrane Usage(AHr):{reservoirUsage.MembranceUsage} is over MembraneTotalAmpHoursFaultLimit:{membraneTotalAmpHoursFaultLimit}");
- }
- else if (reservoirUsage.MembranceUsage > membraneTotalAmpHoursWarningLimit && membraneTotalAmpHoursWarningLimit != 0)
- {
- LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"{Module} Membrane Usage(AHr):{reservoirUsage.MembranceUsage} is over config item MembraneTotalAmpHoursWarningLimit:{membraneTotalAmpHoursWarningLimit}");
- AlarmListManager.Instance.AddWarn(Module,
- $"MembraneUsage", $"{Module} Membrane Usage(AHr):{reservoirUsage.MembranceUsage} is over MembraneTotalAmpHoursWarningLimit:{membraneTotalAmpHoursWarningLimit}");
- }
- //ANBathTotalAmpHoursCheck
- double anBathTotalAmpHoursWarningLimit = 0;
- if (SC.ContainsItem($"Reservoir.{Module}.ANBathTotalAmpHoursWarningLimit"))
- {
- anBathTotalAmpHoursWarningLimit = (double)SC.GetValue<double>($"Reservoir.{Module}.ANBathTotalAmpHoursWarningLimit");
- }
- double anBathTotalAmpHoursFaultLimit = 0;
- if (SC.ContainsItem($"Reservoir.{Module}.ANBathTotalAmpHoursFaultLimit"))
- {
- anBathTotalAmpHoursFaultLimit = (double)SC.GetValue<double>($"Reservoir.{Module}.ANBathTotalAmpHoursFaultLimit");
- }
- if (reservoirUsage.AnodeUsage > anBathTotalAmpHoursFaultLimit && anBathTotalAmpHoursFaultLimit != 0)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{Module} Anolyte Bath Usage(AHr):{reservoirUsage.AnodeUsage} is over config item ANBathTotalAmpHoursFaultLimit:{anBathTotalAmpHoursFaultLimit}");
- reservoirEntity.PostMsg(ReservoirMsg.Error);
- AlarmListManager.Instance.AddDataError(Module,
- $"AnodeUsage", $"{Module} Anolyte Bath Usage(AHr):{reservoirUsage.AnodeUsage} is over ANBathTotalAmpHoursFaultLimit:{anBathTotalAmpHoursFaultLimit}");
- }
- else if (reservoirUsage.AnodeUsage > anBathTotalAmpHoursWarningLimit && anBathTotalAmpHoursWarningLimit != 0)
- {
- LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"{Module} Anolyte Bath Usage(AHr):{reservoirUsage.AnodeUsage} is over config item ANBathTotalAmpHoursWarningLimit:{anBathTotalAmpHoursWarningLimit}");
- AlarmListManager.Instance.AddWarn(Module,
- $"AnodeUsage", $"{Module} Anolyte Bath Usage(AHr):{reservoirUsage.AnodeUsage} is over ANBathTotalAmpHoursWarningLimit:{anBathTotalAmpHoursWarningLimit}");
- }
- //BathTotalAmpHoursCheck
- double bathTotalAmpHoursWarningLimit = 0;
- if (SC.ContainsItem($"Reservoir.{Module}.BathTotalAmpHoursWarningLimit"))
- {
- bathTotalAmpHoursWarningLimit = (double)SC.GetValue<double>($"Reservoir.{Module}.BathTotalAmpHoursWarningLimit");
- }
- double bathTotalAmpHoursFaultLimit = 0;
- if (SC.ContainsItem($"Reservoir.{Module}.BathTotalAmpHoursFaultLimit"))
- {
- bathTotalAmpHoursFaultLimit = (double)SC.GetValue<double>($"Reservoir.{Module}.BathTotalAmpHoursFaultLimit");
- }
- if (reservoirUsage.BathUsage > bathTotalAmpHoursFaultLimit && bathTotalAmpHoursFaultLimit != 0)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{Module} Bath Usage(AHr):{reservoirUsage.BathUsage} is over config item BathTotalAmpHoursFaultLimit:{bathTotalAmpHoursFaultLimit}");
- reservoirEntity.PostMsg(ReservoirMsg.Error);
- AlarmListManager.Instance.AddDataError(Module,
- $"BathUsage", $"{Module} Bath Usage(AHr):{reservoirUsage.BathUsage} is over BathTotalAmpHoursFaultLimit:{bathTotalAmpHoursFaultLimit}");
- }
- else if (reservoirUsage.BathUsage > bathTotalAmpHoursWarningLimit && bathTotalAmpHoursWarningLimit != 0)
- {
- LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"{Module} Bath Usage(AHr):{reservoirUsage.BathUsage} is over config item BathTotalAmpHoursWarningLimit:{bathTotalAmpHoursWarningLimit}");
- AlarmListManager.Instance.AddWarn(Module,
- $"BathUsage", $"{Module} Bath Usage(AHr):{reservoirUsage.BathUsage} is over BathTotalAmpHoursWarningLimit:{bathTotalAmpHoursWarningLimit}");
- }
- //BathTotalDaysCheck
- int bathTotalDaysWarningLimit = 0;
- if (SC.ContainsItem($"Reservoir.{Module}.BathTotalDaysWarningLimit"))
- {
- bathTotalDaysWarningLimit = SC.GetValue<int>($"Reservoir.{Module}.BathTotalDaysWarningLimit");
- }
- int bathTotalDaysFaultLimit = 0;
- if (SC.ContainsItem($"Reservoir.{Module}.BathTotalDaysFaultLimit"))
- {
- bathTotalDaysFaultLimit = SC.GetValue<int>($"Reservoir.{Module}.BathTotalDaysFaultLimit");
- }
- if (reservoirUsage.BathUsageDays > bathTotalDaysFaultLimit && bathTotalDaysFaultLimit != 0)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{Module} Bath Usage(Days):{reservoirUsage.BathUsageDays} is over config item BathTotalDaysFaultLimit:{bathTotalDaysFaultLimit}");
- reservoirEntity.PostMsg(ReservoirMsg.Error);
- AlarmListManager.Instance.AddDataError(Module,
- $"BathUsageDays", $"{Module} Bath Usage(Days):{reservoirUsage.BathUsageDays} is over BathTotalDaysFaultLimit:{bathTotalDaysFaultLimit}");
- }
- else if (reservoirUsage.BathUsageDays > bathTotalDaysWarningLimit && bathTotalDaysWarningLimit != 0)
- {
- LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"{Module} Bath Usage(Days):{reservoirUsage.BathUsage} is over config item BathTotalDaysWarningLimit:{bathTotalDaysWarningLimit}");
- AlarmListManager.Instance.AddWarn(Module,
- $"BathUsageDays", $"{Module} Bath Usage(Days):{reservoirUsage.BathUsageDays} is over BathTotalDaysWarningLimit:{bathTotalDaysWarningLimit}");
- }
- //ReservoirTotalWafersCheck
- int reservoirTotalWafersWarningLimit = 0;
- if (SC.ContainsItem($"Reservoir.{Module}.ReservoirTotalWafersWarningLimit"))
- {
- reservoirTotalWafersWarningLimit = SC.GetValue<int>($"Reservoir.{Module}.ReservoirTotalWafersWarningLimit");
- }
- int reservoirTotalWafersFaultLimit = 0;
- if (SC.ContainsItem($"Reservoir.{Module}.ReservoirTotalWafersFaultLimit"))
- {
- reservoirTotalWafersFaultLimit = SC.GetValue<int>($"Reservoir.{Module}.ReservoirTotalWafersFaultLimit");
- }
- if (reservoirUsage.TotalWafers > reservoirTotalWafersFaultLimit && reservoirTotalWafersFaultLimit != 0)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"{Module} Total Wafers:{reservoirUsage.TotalWafers} is over config item ReservoirTotalWafersFaultLimit:{reservoirTotalWafersFaultLimit}");
- reservoirEntity.PostMsg(ReservoirMsg.Error);
- AlarmListManager.Instance.AddDataError(Module,
- $"TotalWafers", $"{Module} Total Wafers:{reservoirUsage.TotalWafers} is over ReservoirTotalWafersFaultLimit:{reservoirTotalWafersFaultLimit}");
- }
- else if (reservoirUsage.TotalWafers > reservoirTotalWafersWarningLimit && reservoirTotalWafersWarningLimit != 0)
- {
- LOG.WriteLog(eEvent.WARN_RESERVOIR, Module, $"{Module} Total Wafers:{reservoirUsage.TotalWafers} is over config item ReservoirTotalWafersWarningLimit:{reservoirTotalWafersWarningLimit}");
- AlarmListManager.Instance.AddWarn(Module,
- $"TotalWafers", $"{Module} Total Wafers:{reservoirUsage.TotalWafers} is over ReservoirTotalWafersWarningLimit:{reservoirTotalWafersWarningLimit}");
- }
- }
- public void Monitor()
- {
- }
- public void Reset()
- {
- }
- public void Terminate()
- {
- }
- }
- }
|