From 3e6f08c0f89f81236e4e9aaddc7caf392e8555b3 Mon Sep 17 00:00:00 2001 From: SL <123@123.com> Date: Tue, 8 Aug 2023 16:24:34 +0800 Subject: [PATCH] =?UTF-8?q?[RT.Equipment]=20=E4=BF=AE=E6=AD=A3GasFlowUnit?= =?UTF-8?q?=E4=B8=AD=E5=A6=82=E6=9E=9C=E6=9C=AA=E8=83=BD=E8=AF=BB=E5=8F=96?= =?UTF-8?q?Ratio=E8=AE=BE=E7=BD=AE=EF=BC=8C=E5=88=99=E6=B5=81=E9=87=8F?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E7=BB=93=E6=9E=9C=E6=80=BB=E6=98=AF=E4=B8=BA?= =?UTF-8?q?0=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82=20=E4=BF=AE=E6=AD=A3Proce?= =?UTF-8?q?ssDataStatCounter=E5=AF=B9=E8=B1=A1=E4=B8=ADPoll=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=BF=94=E5=9B=9Enull=E5=AF=BC=E8=87=B4=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Managers/PDS/ProcessDataStatCounter.cs | 11 ++++++++++- .../HardwareUnits/GasFlow/GasFlowUnit.cs | 11 +++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/MECF.Framework.RT.Core/Managers/PDS/ProcessDataStatCounter.cs b/MECF.Framework.RT.Core/Managers/PDS/ProcessDataStatCounter.cs index 18ac62c..55e5c9e 100644 --- a/MECF.Framework.RT.Core/Managers/PDS/ProcessDataStatCounter.cs +++ b/MECF.Framework.RT.Core/Managers/PDS/ProcessDataStatCounter.cs @@ -17,6 +17,7 @@ namespace MECF.Framework.RT.Core.Managers.PDS private DateTime _lastPollingTime = DateTime.MinValue; private readonly R_TRIG _trigDataPollingError = new(); private FunFilter _dataFilter; + private readonly R_TRIG _rTrigPollDataFailed = new(); #endregion @@ -94,7 +95,15 @@ namespace MECF.Framework.RT.Core.Managers.PDS var sum = 0.0d; foreach (var pdata in DataPath) { - var sFlow = DATA.Poll(pdata).ToString(); + var polled = DATA.Poll(pdata); + _rTrigPollDataFailed.CLK = polled == null; + if(_trigDataPollingError.Q) + LOG.Error($"Failed to count {pdata}, unable to poll data from RT"); + + if (polled == null) + continue; + + var sFlow = polled.ToString(); if (double.TryParse(sFlow, out var dFlow)) { sum += dFlow * ts.TotalSeconds; diff --git a/MECF.Framework.RT.EquipmentLibrary/HardwareUnits/GasFlow/GasFlowUnit.cs b/MECF.Framework.RT.EquipmentLibrary/HardwareUnits/GasFlow/GasFlowUnit.cs index c1d7a6e..8ceaf9a 100644 --- a/MECF.Framework.RT.EquipmentLibrary/HardwareUnits/GasFlow/GasFlowUnit.cs +++ b/MECF.Framework.RT.EquipmentLibrary/HardwareUnits/GasFlow/GasFlowUnit.cs @@ -55,8 +55,8 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.GasFlow public void Initialize(string moduleName) { ModuleName = moduleName; - SC.RegisterValueChangedCallback($"PM.{ModuleName}.Efficiency.{GasFlowRatioName}", (o) => { Set_Callback(o.ToString()); }); - GasFlowRatioValue = SC.GetValue($"PM.{ModuleName}.Efficiency.{GasFlowRatioName}"); + SC.RegisterValueChangedCallback($"PM.{ModuleName}.Efficiency.{GasFlowRatioName}", OnGasFlowRatioSCChanged); + GasFlowRatioValue = SC.SafeGetValue($"PM.{ModuleName}.Efficiency.{GasFlowRatioName}", 1d); if (GasName == "PN2_Vent") DATA.Subscribe($"{ModuleName}.GasRealTimeFlow.{GasName}.FeedBackSpecial", () => PN2_VentSpecial, SubscriptionAttribute.FLAG.IgnoreSaveDB);//仅作为显示用,不存储数据库 @@ -67,9 +67,12 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.GasFlow row.Initialize(moduleName, GasName); } - public void Set_Callback(string str = "") + private void OnGasFlowRatioSCChanged(object value) { - GasFlowRatioValue = SC.GetValue($"PM.{ModuleName}.Efficiency.{GasFlowRatioName}"); + if (value is double ratio) + GasFlowRatioValue = ratio; + else + GasFlowRatioValue = 1d; } public double GetGasFlowFeedBack()