diff --git a/TestBenchFramework/BenchControl/GenericDevices/IErrorFlags.cs b/TestBenchFramework/BenchControl/GenericDevices/IErrorFlags.cs index a1b526c0f..859f10ce4 100644 --- a/TestBenchFramework/BenchControl/GenericDevices/IErrorFlags.cs +++ b/TestBenchFramework/BenchControl/GenericDevices/IErrorFlags.cs @@ -9,6 +9,6 @@ namespace TBF.BenchControl.GenericDevices { Config.Entities.ErrorFlagsMode Mode { get; } - int GetErrorFlags(); + int GetErrorFlags(Config.Entities.Test test, double testTime); } } diff --git a/TestBenchFramework/BenchControl/Sequences/ProcessData.cs b/TestBenchFramework/BenchControl/Sequences/ProcessData.cs index 024c89754..bcdf4d067 100644 --- a/TestBenchFramework/BenchControl/Sequences/ProcessData.cs +++ b/TestBenchFramework/BenchControl/Sequences/ProcessData.cs @@ -80,9 +80,11 @@ namespace TBF.BenchControl.Sequences public static Statistics AmbTempStat = new Statistics(); public static Statistics AmbPressStat = new Statistics(); public static Statistics AmbHumiStat = new Statistics(); - public static Statistics TempUpStat = new Statistics(5, 5, true); - public static Statistics TempDownStat = new Statistics(5, 5, true); - public static Statistics TempDivStat = new Statistics(5, 5, true); + + public static Statistics TempUpStat = new Statistics(0, 5, true); + public static Statistics TempDownStat = new Statistics(0, 5, true); + public static Statistics TempDiffStat = new Statistics(0, 5, true); + public static Statistics TempDivStat = new Statistics(0, 5, true); public static Statistics PressUpStat = new Statistics(5, 5, true); public static Statistics PressDownStat = new Statistics(5, 5, true); public static Statistics PressDeltaStat = new Statistics(5, 5, true); @@ -104,8 +106,10 @@ namespace TBF.BenchControl.Sequences AmbTempStat.Clear(); AmbPressStat.Clear(); AmbHumiStat.Clear(); + TempUpStat.Clear(); TempDownStat.Clear(); + TempDiffStat.Clear(); TempDivStat.Clear(); PressUpStat.Clear(); PressDownStat.Clear(); @@ -126,17 +130,15 @@ namespace TBF.BenchControl.Sequences AmbTempStat.Update(AmbTemp); AmbPressStat.Update(AmbPress); AmbHumiStat.Update(AmbHumi); - TempUpStat.Update(TempUp); + + TempUpStat.Update(TempUp); TempDownStat.Update(TempDown); + TempDiffStat.Update(Math.Abs(TempUp.Val - TempDown.Val)); TempDivStat.Update(TempDiv); PressUpStat.Update(PressUp); PressDownStat.Update(PressDown); PressDeltaStat.Update(PressDelta); - - if (machineTime - machineTimeStart <= 5) /// Wait until flow is steady - { - RefFlowStat.Update(RefFlow); - } + RefFlowStat.Update(RefFlow); if (BatchRslts.Batch.HeatMeter) { diff --git a/TestBenchFramework/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs b/TestBenchFramework/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs index 3cd5c135f..54112e984 100644 --- a/TestBenchFramework/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs @@ -341,7 +341,8 @@ namespace TBF.BenchControl.TestMethods.Adjustment tstRslt.FlowMin = (float)RefFlowStat.Min; tstRslt.FlowMax = (float)RefFlowStat.Max; - if (ErrorFlagsComp != null) tstRslt.ErrorFlags = ErrorFlagsComp.GetErrorFlags(); + tstRslt.ErrorFlagsMd = (ErrorFlagsComp != null) ? (sbyte)ErrorFlagsComp.Mode : (sbyte)0; + tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(test, tstRslt.TestTime) : 0; for (int i = 0; i < BatchRslts.WMPositionsCount; i++) { diff --git a/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs index c7795b3d5..639755339 100644 --- a/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs @@ -627,7 +627,8 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection tstRslt.FlowMin = (float)RefFlowStat.Min; tstRslt.FlowMax = (float)RefFlowStat.Max; - if (ErrorFlagsComp != null) tstRslt.ErrorFlags = ErrorFlagsComp.GetErrorFlags(); + tstRslt.ErrorFlagsMd = (ErrorFlagsComp != null) ? (sbyte)ErrorFlagsComp.Mode : (sbyte)0; + tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(test, tstRslt.TestTime) : 0; for (int i = 0; i < BatchRslts.WMPositionsCount; i++) { diff --git a/TestBenchFramework/BenchControl/TestMethods/Endurance/EnduranceSeq.cs b/TestBenchFramework/BenchControl/TestMethods/Endurance/EnduranceSeq.cs index 1aba3b304..f4a507c55 100644 --- a/TestBenchFramework/BenchControl/TestMethods/Endurance/EnduranceSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/Endurance/EnduranceSeq.cs @@ -359,7 +359,8 @@ namespace TBF.BenchControl.TestMethods.Endurance tstRslt.FlowMin = (float)RefFlowStat.Min; tstRslt.FlowMax = (float)RefFlowStat.Max; - if (ErrorFlagsComp != null) tstRslt.ErrorFlags = ErrorFlagsComp.GetErrorFlags(); + tstRslt.ErrorFlagsMd = (ErrorFlagsComp != null) ? (sbyte)ErrorFlagsComp.Mode : (sbyte)0; + tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(test, tstRslt.TestTime) : 0; /// /// Single meters diff --git a/TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs index cf0d329de..8678887a3 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs @@ -528,7 +528,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced tstRslt.FlowMin = (float)RefFlowStat.Min; tstRslt.FlowMax = (float)RefFlowStat.Max; - if (ErrorFlagsComp != null) tstRslt.ErrorFlags = ErrorFlagsComp.GetErrorFlags(); + tstRslt.ErrorFlagsMd = (ErrorFlagsComp != null) ? (sbyte)ErrorFlagsComp.Mode : (sbyte)0; + tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(test, tstRslt.TestTime) : 0; for (int i = 0; i < BatchRslts.WMPositionsCount; i++) { diff --git a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs index 983edc7cb..2f96b3c8b 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs @@ -881,7 +881,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection tstRslt.FlowMin = (float)RefFlowStat.Min; tstRslt.FlowMax = (float)RefFlowStat.Max; - if (ErrorFlagsComp != null) tstRslt.ErrorFlags = ErrorFlagsComp.GetErrorFlags(); + tstRslt.ErrorFlagsMd = (ErrorFlagsComp != null) ? (sbyte)ErrorFlagsComp.Mode : (sbyte)0; + tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(test, tstRslt.TestTime) : 0; if (compound) { diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs index 40f3ced02..6b1b70a8f 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs @@ -466,7 +466,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStart tstRslt.FlowMin = (float)RefFlowStat.Min; tstRslt.FlowMax = (float)RefFlowStat.Max; - if (ErrorFlagsComp != null) tstRslt.ErrorFlags = ErrorFlagsComp.GetErrorFlags(); + tstRslt.ErrorFlagsMd = (ErrorFlagsComp != null) ? (sbyte)ErrorFlagsComp.Mode : (sbyte)0; + tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(test, tstRslt.TestTime) : 0; if (compoundTestParams != null) { diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs index e601c7a64..8baecb393 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs @@ -786,7 +786,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection tstRslt.FlowMin = (float)RefFlowStat.Min; tstRslt.FlowMax = (float)RefFlowStat.Max; - if (ErrorFlagsComp != null) tstRslt.ErrorFlags = ErrorFlagsComp.GetErrorFlags(); + tstRslt.ErrorFlagsMd = (ErrorFlagsComp != null) ? (sbyte)ErrorFlagsComp.Mode : (sbyte)0; + tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(test, tstRslt.TestTime) : 0; if (compoundTestParams != null) { diff --git a/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs b/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs index 5389e9e7f..a86c0d481 100644 --- a/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs @@ -329,7 +329,8 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration tstRslt.FlowMin = (float)RefFlowStat.Min; tstRslt.FlowMax = (float)RefFlowStat.Max; - if (ErrorFlagsComp != null) tstRslt.ErrorFlags = ErrorFlagsComp.GetErrorFlags(); + tstRslt.ErrorFlagsMd = (ErrorFlagsComp != null) ? (sbyte)ErrorFlagsComp.Mode : (sbyte)0; + tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(test, tstRslt.TestTime) : 0; /// Update flowmeter constant with the measured one if (outPath.FlowMeter.Idx1 > 0 && outPath.FlowMeter.Idx1 <= ReferenceFlowmetersCount) diff --git a/TestBenchFramework/BenchControl/Various/ErrorFlags/Errors.cs b/TestBenchFramework/BenchControl/Various/ErrorFlags/Errors.cs index 808c3f78b..f60b3fa35 100644 --- a/TestBenchFramework/BenchControl/Various/ErrorFlags/Errors.cs +++ b/TestBenchFramework/BenchControl/Various/ErrorFlags/Errors.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Text; using log4net; using Config.Entities; +using TBF.BenchControl.Sequences; namespace TBF.BenchControl.Various.ErrorFlags { @@ -23,15 +24,78 @@ namespace TBF.BenchControl.Various.ErrorFlags /// Cfg /// readonly ErrorsCfg errorsCfg; - public ErrorFlagsMode Mode { get { return errorsCfg.TestParams.Mode; } } - public int GetErrorFlags() - { - if (Mode != ErrorFlagsMode.Info && Mode != ErrorFlagsMode.On) return 0; /// return 0 when Mode == ErrorFlagsMode.Off - /// TODO : Return real error conditions - return 0; + public int GetErrorFlags(Test test, double testTime) + { + if (Mode != ErrorFlagsMode.Info && Mode != ErrorFlagsMode.On) return 0; /// return 0 when Mode == ErrorFlagsMode.Off + + /// Max. and min. flow + bool E1 = ProcessData.RefFlowStat.Min >= test.Qfrom + && ProcessData.RefFlowStat.Max <= test.Qto; + + /// Max. and min. up and down water temperature + bool E2 = ProcessData.TempUpStat.Min >= test.TempLimLo + && ProcessData.TempUpStat.Min <= test.TempLimHi + && ProcessData.TempDownStat.Min >= test.TempLimLo + && ProcessData.TempDownStat.Min <= test.TempLimHi; + + /// Max. flow deviation + bool E3 = ProcessData.RefFlowStat.Min >= ProcessData.RefFlowStat.Average * (1.0f - errorsCfg.TestParams.Delta_Q_pct / 100.0f) + && ProcessData.RefFlowStat.Max <= ProcessData.RefFlowStat.Average * (1.0f + errorsCfg.TestParams.Delta_Q_pct / 100.0f); + + /// Max. up and down water temperature deviation + bool E4 = ProcessData.TempUpStat.Min >= ProcessData.TempUpStat.Average - errorsCfg.TestParams.Delta_T + && ProcessData.TempUpStat.Min <= ProcessData.TempUpStat.Average + errorsCfg.TestParams.Delta_T + && ProcessData.TempDownStat.Min >= ProcessData.TempDownStat.Average - errorsCfg.TestParams.Delta_T + && ProcessData.TempDownStat.Min <= ProcessData.TempDownStat.Average + errorsCfg.TestParams.Delta_T; + + /// Max. absolute value of up and down water temperature difference + bool E5 = ProcessData.TempDiffStat.Max <= errorsCfg.TestParams.Delta_Tup_Tdn; + + bool E6 = false; + + /// Test time (min) + bool E7 = testTime >= errorsCfg.TestParams.TestTime_min; + + /// Test time (max) + bool E8 = testTime <= errorsCfg.TestParams.TestTime_max; + + bool E9 = false; + bool E10 = false; + bool E11 = false; + bool E12 = false; + + /// Ambient temperature + bool E13 = ProcessData.AmbTempStat.Min >= errorsCfg.TestParams.AmbTemp_min + && ProcessData.AmbTempStat.Max <= errorsCfg.TestParams.AmbTemp_max; + + /// Water pressure + bool E14 = ProcessData.PressUpStat.Min >= errorsCfg.TestParams.Pressure_min + && ProcessData.PressUpStat.Max <= errorsCfg.TestParams.Pressure_max; + + bool E15 = false; + bool E16 = false; + + int ErrorFlags = 0; + if (errorsCfg.TestParams.E1 && E1) ErrorFlags |= 0x0001; + if (errorsCfg.TestParams.E2 && E2) ErrorFlags |= 0x0002; + if (errorsCfg.TestParams.E3 && E3) ErrorFlags |= 0x0004; + if (errorsCfg.TestParams.E4 && E4) ErrorFlags |= 0x0008; + if (errorsCfg.TestParams.E5 && E5) ErrorFlags |= 0x0010; + if (errorsCfg.TestParams.E6 && E6) ErrorFlags |= 0x0020; + if (errorsCfg.TestParams.E7 && E7) ErrorFlags |= 0x0040; + if (errorsCfg.TestParams.E8 && E8) ErrorFlags |= 0x0080; + if (errorsCfg.TestParams.E9 && E9) ErrorFlags |= 0x0100; + if (errorsCfg.TestParams.E10 && E10) ErrorFlags |= 0x0200; + if (errorsCfg.TestParams.E11 && E11) ErrorFlags |= 0x0400; + if (errorsCfg.TestParams.E12 && E12) ErrorFlags |= 0x0800; + if (errorsCfg.TestParams.E13 && E13) ErrorFlags |= 0x1000; + if (errorsCfg.TestParams.E14 && E14) ErrorFlags |= 0x2000; + if (errorsCfg.TestParams.E15 && E15) ErrorFlags |= 0x4000; + if (errorsCfg.TestParams.E16 && E16) ErrorFlags |= 0x8000; + return ErrorFlags; } diff --git a/TestBenchFramework/BenchControl/Various/ErrorFlags/TestParams.cs b/TestBenchFramework/BenchControl/Various/ErrorFlags/TestParams.cs index a3b810283..52ba25b31 100644 --- a/TestBenchFramework/BenchControl/Various/ErrorFlags/TestParams.cs +++ b/TestBenchFramework/BenchControl/Various/ErrorFlags/TestParams.cs @@ -37,6 +37,10 @@ namespace TBF.BenchControl.Various.ErrorFlags public float Delta_Tup_Tdn; /// [°C] max. difference abs(T_up - T_down) public float TestTime_min; /// [s] public float TestTime_max; /// [s] + public float AmbTemp_min; /// [°C] min. ambient temperature + public float AmbTemp_max; /// [°C] max. ambient temperature + public float Pressure_min; /// [bar] min. water pressure + public float Pressure_max; /// [bar] max. water pressure public float Coef_E9; /// Coefficient used in E9, default 0.025 public float Coef_E10; /// Coefficient used in E10, default 0.04 @@ -68,7 +72,11 @@ namespace TBF.BenchControl.Various.ErrorFlags Delta_Tup_Tdn = 10.0f; /// [°C] TestTime_min = 0; /// [s] TestTime_max = 99999; /// [s] - /// + AmbTemp_min = 5.0f; /// [°C] + AmbTemp_max = 95.0f; /// [°C] + Pressure_min = 0; /// [bar] + Pressure_max = 16.0f; /// [bar] + Coef_E9 = 0.025f; Coef_E10 = 0.04f; Coef_E11 = 0.1f; @@ -95,11 +103,15 @@ namespace TBF.BenchControl.Various.ErrorFlags "E15", "E16", - "Delta Q", - "Delta T", - "max. Abs(Tup - Tdn)", - string.Format("min. {0}", Strings.Test_time_s_chdr), - string.Format("max. {0}", Strings.Test_time_s_chdr), + "Delta Q [%]", + "Delta T [°C]", + "max. Abs(Tup - Tdn) [°C]", + string.Format("min. {0} [s]", Strings.Test_time_s_chdr), + string.Format("max. {0} [s]", Strings.Test_time_s_chdr), + string.Format("min. {0}", Strings.Ambient_temp_C_), + string.Format("max. {0}", Strings.Ambient_temp_C_), + string.Format("min. {0}", Strings.Pressure_bar), + string.Format("max. {0}", Strings.Pressure_bar), "Coef.E9", "Coef.E10", @@ -136,10 +148,14 @@ namespace TBF.BenchControl.Various.ErrorFlags case 19: return Delta_Tup_Tdn.ToString(); case 20: return TestTime_min.ToString(); case 21: return TestTime_max.ToString(); - case 22: return Coef_E9.ToString(); - case 23: return Coef_E10.ToString(); - case 24: return Coef_E11.ToString(); - case 25: return Coef_E12.ToString(); + case 22: return AmbTemp_min.ToString(); + case 23: return AmbTemp_max.ToString(); + case 24: return Pressure_min.ToString(); + case 25: return Pressure_max.ToString(); + case 26: return Coef_E9.ToString(); + case 27: return Coef_E10.ToString(); + case 28: return Coef_E11.ToString(); + case 29: return Coef_E12.ToString(); default: return string.Empty; } @@ -182,10 +198,14 @@ namespace TBF.BenchControl.Various.ErrorFlags case 19: Delta_Tup_Tdn = Utils.ParseUFloat(strValue); return; case 20: TestTime_min = Utils.ParseUFloat(strValue); return; case 21: TestTime_max = Utils.ParseUFloat(strValue); return; - case 22: Coef_E9 = Utils.ParseUFloat(strValue); return; - case 23: Coef_E10 = Utils.ParseUFloat(strValue); return; - case 24: Coef_E11 = Utils.ParseUFloat(strValue); return; - case 25: Coef_E12 = Utils.ParseUFloat(strValue); return; + case 22: AmbTemp_min = Utils.ParseUFloat(strValue); return; + case 23: AmbTemp_max = Utils.ParseUFloat(strValue); return; + case 24: Pressure_min = Utils.ParseUFloat(strValue); return; + case 25: Pressure_max = Utils.ParseUFloat(strValue); return; + case 26: Coef_E9 = Utils.ParseUFloat(strValue); return; + case 27: Coef_E10 = Utils.ParseUFloat(strValue); return; + case 28: Coef_E11 = Utils.ParseUFloat(strValue); return; + case 29: Coef_E12 = Utils.ParseUFloat(strValue); return; default: return; } @@ -234,7 +254,11 @@ namespace TBF.BenchControl.Various.ErrorFlags case 23: case 24: case 25: - if (Utils.TryParseUFloat(strValue, out fdummy)) return true; + case 26: + case 27: + case 28: + case 29: + if (Utils.TryParseUFloat(strValue, out fdummy)) return true; break; default: @@ -271,6 +295,10 @@ namespace TBF.BenchControl.Various.ErrorFlags prms.Delta_Tup_Tdn = this.Delta_Tup_Tdn; prms.TestTime_min = this.TestTime_min; prms.TestTime_max = this.TestTime_max; + prms.AmbTemp_min = this.AmbTemp_min; + prms.AmbTemp_max = this.AmbTemp_max; + prms.Pressure_min = this.Pressure_min; + prms.Pressure_max = this.Pressure_max; prms.Coef_E9 = this.Coef_E9; prms.Coef_E10 = this.Coef_E10; prms.Coef_E11 = this.Coef_E11; diff --git a/TestBenchFramework/Properties/AssemblyInfo.cs b/TestBenchFramework/Properties/AssemblyInfo.cs index 1203afca6..0c5c5d65c 100644 --- a/TestBenchFramework/Properties/AssemblyInfo.cs +++ b/TestBenchFramework/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("2.16.642.1")] -[assembly: AssemblyFileVersion("2.16.642.1")] +[assembly: AssemblyVersion("2.16.643.1")] +[assembly: AssemblyFileVersion("2.16.643.1")]