diff --git a/Config/Entities/Enums.cs b/Config/Entities/Enums.cs index 9eac6b22a..83a7dcadc 100644 --- a/Config/Entities/Enums.cs +++ b/Config/Entities/Enums.cs @@ -379,4 +379,26 @@ namespace Config.Entities [Description("270 deg")] Deg270, Count } + + public enum ErrorFlagsMode : sbyte + { +#if LANG_DE + [Description("aus")] Off, + [Description("info")] Info, + [Description("ein")] On, +#elif LANG_CS + [Description("vypnuto")] off, + [Description("info")] Info, + [Description("zapnuto")] On, +#elif LANG_PL + [Description("nie")] Off, + [Description("info")] Info, + [Description("tak")] On, +#else // LANG_EN + [Description("off")] Off, + [Description("info")] Info, + [Description("on")] On, +#endif + Count + } } diff --git a/Config/Properties/AssemblyInfo.cs b/Config/Properties/AssemblyInfo.cs index e9ea189d1..0eadeb5a0 100644 --- a/Config/Properties/AssemblyInfo.cs +++ b/Config/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.15.619.0")] -[assembly: AssemblyFileVersion("2.15.619.0")] +[assembly: AssemblyVersion("2.16.642.0")] +[assembly: AssemblyFileVersion("2.16.642.0")] diff --git a/Results/Entities/TestRslt.cs b/Results/Entities/TestRslt.cs index 2d897c65f..cf54811d8 100644 --- a/Results/Entities/TestRslt.cs +++ b/Results/Entities/TestRslt.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2015-2016 Sensus Metering Systems +/// Copyright (c) 2015-2017 Sensus Metering Systems /// using System; using System.Collections.Generic; @@ -38,6 +38,8 @@ namespace Results.Entities public virtual double VolumeCTV { get; set; } /// [l] Volume conventional true value public virtual double VolumeMaster { get; set; } /// [l] Volume from the master flow meter public virtual double ErrorMaster { get; set; } /// [%] + public virtual int ErrorFlags { get; set; } /// bitfield : bit0=E1, bit1=E2, bit2=E3, etc. + public virtual sbyte ErrorFlagsMd { get; set; } /// 0=off, 1=info, 2=on (evaluated in MeterTestRslt.Passed) /// Main results of heat meters public virtual double RefEnergy { get; set; } /// [J] Joul @@ -161,6 +163,8 @@ namespace Results.Entities VolumeCTV = src.VolumeCTV; VolumeMaster = src.VolumeMaster; ErrorMaster = src.ErrorMaster; + ErrorFlags = src.ErrorFlags; + ErrorFlagsMd = src.ErrorFlagsMd; RefEnergy = src.RefEnergy; AmbTempMean = src.AmbTempMean; AmbTempStart = src.AmbTempStart; @@ -224,6 +228,12 @@ namespace Results.Entities Custom10 = src.Custom10; } + /// Wrapper + public virtual Config.Entities.ErrorFlagsMode ErrorFlagsMode() + { + return (Config.Entities.ErrorFlagsMode)ErrorFlagsMd; + } + public override string ToString() { return string.Format("batch={0}, procedure={1}, test={2}, {3} {4}", Batch.BatchNr, Batch.ProcedureName, Name(), StartTime.ToShortDateString(), StartTime.ToShortTimeString()); diff --git a/Results/ItemID.cs b/Results/ItemID.cs index 8825403f4..f3c745eb2 100644 --- a/Results/ItemID.cs +++ b/Results/ItemID.cs @@ -149,6 +149,24 @@ namespace Results Buoyancy, /// 132 Density_correction, /// 133 + ErrorFlags, /// 134 + E1, /// 135 + E2, /// 136 + E3, /// 137 + E4, /// 138 + E5, /// 139 + E6, /// 140 + E7, /// 141 + E8, /// 142 + E9, /// 143 + E10, /// 144 + E11, /// 145 + E12, /// 146 + E13, /// 147 + E14, /// 148 + E15, /// 149 + E16, /// 150 + Count, } } diff --git a/Results/Mappings/TestRsltMap.cs b/Results/Mappings/TestRsltMap.cs index 99f531127..af765ff7b 100644 --- a/Results/Mappings/TestRsltMap.cs +++ b/Results/Mappings/TestRsltMap.cs @@ -40,6 +40,8 @@ namespace Results.Mappings Map(x => x.VolumeCTV); Map(x => x.VolumeMaster); Map(x => x.ErrorMaster); + Map(x => x.ErrorFlags); + Map(x => x.ErrorFlagsMd); #if HEAT_METERS Map(x => x.RefEnergy); #endif diff --git a/Results/Properties/AssemblyInfo.cs b/Results/Properties/AssemblyInfo.cs index 47d6a0e99..00c8ddd2f 100644 --- a/Results/Properties/AssemblyInfo.cs +++ b/Results/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.15.619.0")] -[assembly: AssemblyFileVersion("2.15.619.0")] +[assembly: AssemblyVersion("2.16.642.0")] +[assembly: AssemblyFileVersion("2.16.642.0")] diff --git a/Results/Resources/Strings.Designer.cs b/Results/Resources/Strings.Designer.cs index f6fd4414d..e4de6e3eb 100644 --- a/Results/Resources/Strings.Designer.cs +++ b/Results/Resources/Strings.Designer.cs @@ -330,6 +330,15 @@ namespace Results.Resources { } } + /// + /// Looks up a localized string similar to Error flags. + /// + internal static string Error_flags { + get { + return ResourceManager.GetString("Error_flags", resourceCulture); + } + } + /// /// Looks up a localized string similar to E rel. ref.. /// diff --git a/Results/Resources/Strings.resx b/Results/Resources/Strings.resx index 5191cebbe..22c92cb60 100644 --- a/Results/Resources/Strings.resx +++ b/Results/Resources/Strings.resx @@ -627,4 +627,7 @@ Density correction + + Error flags + \ No newline at end of file diff --git a/Results/WMeterRsltItemSpec.cs b/Results/WMeterRsltItemSpec.cs index 2871b0d9c..18bbc34d0 100644 --- a/Results/WMeterRsltItemSpec.cs +++ b/Results/WMeterRsltItemSpec.cs @@ -346,6 +346,23 @@ namespace Results #endif AllItems.Add(new WMeterRsltItemSpec(ItemID.TestDone, Strings.Test_done + "()", Quantity.Boolean, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetMeterTestRslt(t) != null && w.GetMeterTestRslt(t).TestDone) ? Strings.Yes : Strings.No)); AllItems.Add(new WMeterRsltItemSpec(ItemID.TestPassed, Strings.Test_passed + "()", Quantity.Boolean, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetMeterTestRslt(t) != null && w.GetMeterTestRslt(t).Passed) ? Strings.Yes : Strings.No)); + AllItems.Add(new WMeterRsltItemSpec(ItemID.ErrorFlags, Strings.Error_flags + "()", Quantity.String, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null) ? w.GetTestRslt(t).ErrorFlags.ToString("X4") : string.Empty)); + AllItems.Add(new WMeterRsltItemSpec(ItemID.E1, "E1 ()", Quantity.Boolean, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null && (w.GetTestRslt(t).ErrorFlags & 0x0001) != 0) ? Strings.Yes : Strings.No)); + AllItems.Add(new WMeterRsltItemSpec(ItemID.E2, "E2 ()", Quantity.Boolean, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null && (w.GetTestRslt(t).ErrorFlags & 0x0002) != 0) ? Strings.Yes : Strings.No)); + AllItems.Add(new WMeterRsltItemSpec(ItemID.E3, "E3 ()", Quantity.Boolean, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null && (w.GetTestRslt(t).ErrorFlags & 0x0004) != 0) ? Strings.Yes : Strings.No)); + AllItems.Add(new WMeterRsltItemSpec(ItemID.E4, "E4 ()", Quantity.Boolean, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null && (w.GetTestRslt(t).ErrorFlags & 0x0008) != 0) ? Strings.Yes : Strings.No)); + AllItems.Add(new WMeterRsltItemSpec(ItemID.E5, "E5 ()", Quantity.Boolean, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null && (w.GetTestRslt(t).ErrorFlags & 0x0010) != 0) ? Strings.Yes : Strings.No)); + AllItems.Add(new WMeterRsltItemSpec(ItemID.E6, "E6 ()", Quantity.Boolean, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null && (w.GetTestRslt(t).ErrorFlags & 0x0020) != 0) ? Strings.Yes : Strings.No)); + AllItems.Add(new WMeterRsltItemSpec(ItemID.E7, "E7 ()", Quantity.Boolean, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null && (w.GetTestRslt(t).ErrorFlags & 0x0040) != 0) ? Strings.Yes : Strings.No)); + AllItems.Add(new WMeterRsltItemSpec(ItemID.E8, "E8 ()", Quantity.Boolean, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null && (w.GetTestRslt(t).ErrorFlags & 0x0080) != 0) ? Strings.Yes : Strings.No)); + AllItems.Add(new WMeterRsltItemSpec(ItemID.E9, "E9 ()", Quantity.Boolean, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null && (w.GetTestRslt(t).ErrorFlags & 0x0100) != 0) ? Strings.Yes : Strings.No)); + AllItems.Add(new WMeterRsltItemSpec(ItemID.E10, "E10 ()", Quantity.Boolean, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null && (w.GetTestRslt(t).ErrorFlags & 0x0200) != 0) ? Strings.Yes : Strings.No)); + AllItems.Add(new WMeterRsltItemSpec(ItemID.E11, "E11 ()", Quantity.Boolean, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null && (w.GetTestRslt(t).ErrorFlags & 0x0400) != 0) ? Strings.Yes : Strings.No)); + AllItems.Add(new WMeterRsltItemSpec(ItemID.E12, "E12 ()", Quantity.Boolean, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null && (w.GetTestRslt(t).ErrorFlags & 0x0800) != 0) ? Strings.Yes : Strings.No)); + AllItems.Add(new WMeterRsltItemSpec(ItemID.E13, "E13 ()", Quantity.Boolean, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null && (w.GetTestRslt(t).ErrorFlags & 0x1000) != 0) ? Strings.Yes : Strings.No)); + AllItems.Add(new WMeterRsltItemSpec(ItemID.E14, "E14 ()", Quantity.Boolean, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null && (w.GetTestRslt(t).ErrorFlags & 0x2000) != 0) ? Strings.Yes : Strings.No)); + AllItems.Add(new WMeterRsltItemSpec(ItemID.E15, "E15 ()", Quantity.Boolean, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null && (w.GetTestRslt(t).ErrorFlags & 0x4000) != 0) ? Strings.Yes : Strings.No)); + AllItems.Add(new WMeterRsltItemSpec(ItemID.E16, "E16 ()", Quantity.Boolean, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null && (w.GetTestRslt(t).ErrorFlags & 0x8000) != 0) ? Strings.Yes : Strings.No)); } /// diff --git a/TestBenchFramework/BenchControl/Events.cs b/TestBenchFramework/BenchControl/Events.cs index 048d2373f..00fe1ec64 100644 --- a/TestBenchFramework/BenchControl/Events.cs +++ b/TestBenchFramework/BenchControl/Events.cs @@ -187,5 +187,6 @@ namespace TBF.BenchControl OuterLoopStart, OuterLoopNext, OuterLoopEnd, + ErrorConditionsDone, } } diff --git a/TestBenchFramework/BenchControl/GenericDevices/IErrorFlags.cs b/TestBenchFramework/BenchControl/GenericDevices/IErrorFlags.cs new file mode 100644 index 000000000..a1b526c0f --- /dev/null +++ b/TestBenchFramework/BenchControl/GenericDevices/IErrorFlags.cs @@ -0,0 +1,14 @@ +/// +/// Copyright (c) 2017 Sensus Metering Systems +/// +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.GenericDevices +{ + public interface IErrorFlags : IComponent + { + Config.Entities.ErrorFlagsMode Mode { get; } + + int GetErrorFlags(); + } +} diff --git a/TestBenchFramework/BenchControl/Sequences/ProcessData.cs b/TestBenchFramework/BenchControl/Sequences/ProcessData.cs index 1bd9e0ba5..024c89754 100644 --- a/TestBenchFramework/BenchControl/Sequences/ProcessData.cs +++ b/TestBenchFramework/BenchControl/Sequences/ProcessData.cs @@ -7,6 +7,7 @@ namespace TBF.BenchControl.Sequences public class ProcessData { public static IBenchInfo BenchInfo; + public static IErrorFlags ErrorFlagsComp; public static FloatBox AmbTemp = new FloatBox() { Name = "Ambient Temperature", Format = "F1" }; /// [Celsius] public static FloatBox AmbPress = new FloatBox() { Name = "Ambient Pressure", Format = "F0", Factor = 1000 }; /// [bar], printed by ToString() in [mbar] diff --git a/TestBenchFramework/BenchControl/StateMachine.cs b/TestBenchFramework/BenchControl/StateMachine.cs index c2a393bc0..02404a506 100644 --- a/TestBenchFramework/BenchControl/StateMachine.cs +++ b/TestBenchFramework/BenchControl/StateMachine.cs @@ -222,6 +222,7 @@ namespace TBF.BenchControl { if (cmpnt is Elde.ControlBoardDev) ControlBoard = cmpnt as Elde.ControlBoardDev; if (cmpnt is IBenchInfo) ProcessData.BenchInfo = cmpnt as IBenchInfo; + if (cmpnt is IErrorFlags) ProcessData.ErrorFlagsComp = cmpnt as IErrorFlags; if (cmpnt is IFlowMeter) SequenceBase.FlowMeters.Add(cmpnt as IFlowMeter); if ((cmpnt is IRegulValve) && !(cmpnt is BenchControl.Elde.RegulValveTandem.RegulValveTandem)) { diff --git a/TestBenchFramework/BenchControl/TbfComponents.cs b/TestBenchFramework/BenchControl/TbfComponents.cs index fbbb951dc..2048ee64e 100644 --- a/TestBenchFramework/BenchControl/TbfComponents.cs +++ b/TestBenchFramework/BenchControl/TbfComponents.cs @@ -122,6 +122,7 @@ namespace TBF.BenchControl Factories.Add(new Elde.TempMeterInternal.TempMeterFactory()); Factories.Add(new Elde.Valve.ValveFactory()); Factories.Add(new Elde.ValveEx.ValveFactory()); + Factories.Add(new Various.ErrorFlags.Factory()); Factories.Add(new WaterMeters.Munich.WaterMeterFactory()); /// 'WaterMeters.Munich' Factories.Add(new WaterMeters.WaterMeter.WaterMeterFactory()); /// 'WaterMeter' } diff --git a/TestBenchFramework/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs b/TestBenchFramework/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs index dce2a5bbb..3cd5c135f 100644 --- a/TestBenchFramework/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs @@ -341,6 +341,8 @@ namespace TBF.BenchControl.TestMethods.Adjustment tstRslt.FlowMin = (float)RefFlowStat.Min; tstRslt.FlowMax = (float)RefFlowStat.Max; + if (ErrorFlagsComp != null) tstRslt.ErrorFlags = ErrorFlagsComp.GetErrorFlags(); + for (int i = 0; i < BatchRslts.WMPositionsCount; i++) { if (test.Part != 0 && test.Part != Utils.PartNr(i + 1, BatchRslts.Batch.Compound)) continue; diff --git a/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs index 0aa0afb00..c7795b3d5 100644 --- a/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs @@ -627,6 +627,8 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection tstRslt.FlowMin = (float)RefFlowStat.Min; tstRslt.FlowMax = (float)RefFlowStat.Max; + if (ErrorFlagsComp != null) tstRslt.ErrorFlags = ErrorFlagsComp.GetErrorFlags(); + for (int i = 0; i < BatchRslts.WMPositionsCount; i++) { if (test.Part != 0 && test.Part != Utils.PartNr(i + 1, BatchRslts.Batch.Compound)) continue; @@ -672,7 +674,8 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection compoundMeterRslt.TestTime = tstRslt.TestTime; compoundMeterRslt.Error = Formulas.ErrorFromVolumes(compoundMeterRslt.VolumeMeter, compoundMeterRslt.VolumeRef); compoundMeterRslt.Passed = (compoundMeterRslt.Error >= test.ErrLimLo + test.Uncertainty) - && (compoundMeterRslt.Error <= test.ErrLimHi - test.Uncertainty); + && (compoundMeterRslt.Error <= test.ErrLimHi - test.Uncertainty) + && (tstRslt.ErrorFlags == 0 || tstRslt.ErrorFlagsMode() != Config.Entities.ErrorFlagsMode.On); mainMeterRslt.Passed = auxMeterRslt.Passed = compoundMeterRslt.Passed; mainMeterRslt.TestDone = auxMeterRslt.TestDone = compoundMeterRslt.TestDone = true; tstRslt.TestDone = true; diff --git a/TestBenchFramework/BenchControl/TestMethods/Endurance/EnduranceSeq.cs b/TestBenchFramework/BenchControl/TestMethods/Endurance/EnduranceSeq.cs index 99a4ba139..1aba3b304 100644 --- a/TestBenchFramework/BenchControl/TestMethods/Endurance/EnduranceSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/Endurance/EnduranceSeq.cs @@ -359,6 +359,8 @@ namespace TBF.BenchControl.TestMethods.Endurance tstRslt.FlowMin = (float)RefFlowStat.Min; tstRslt.FlowMax = (float)RefFlowStat.Max; + if (ErrorFlagsComp != null) tstRslt.ErrorFlags = ErrorFlagsComp.GetErrorFlags(); + /// /// Single meters /// @@ -398,8 +400,9 @@ namespace TBF.BenchControl.TestMethods.Endurance meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef); meterRslt.Passed = (meterRslt.Error >= test.ErrLimLo + test.Uncertainty) - && (meterRslt.Error <= test.ErrLimHi - test.Uncertainty); - meterRslt.TestDone = true; + && (meterRslt.Error <= test.ErrLimHi - test.Uncertainty) + && (tstRslt.ErrorFlags == 0 || tstRslt.ErrorFlagsMode() != Config.Entities.ErrorFlagsMode.On); + meterRslt.TestDone = true; tstRslt.TestDone = true; if (iPerl != null) diff --git a/TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs index dcca870e8..cf0d329de 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs @@ -528,6 +528,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced tstRslt.FlowMin = (float)RefFlowStat.Min; tstRslt.FlowMax = (float)RefFlowStat.Max; + if (ErrorFlagsComp != null) tstRslt.ErrorFlags = ErrorFlagsComp.GetErrorFlags(); + for (int i = 0; i < BatchRslts.WMPositionsCount; i++) { if (test.Part != 0 && test.Part != Utils.PartNr(i + 1, BatchRslts.Batch.Compound)) continue; @@ -547,7 +549,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced meterRslt.TestTime = tstRslt.TestTime; meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef); meterRslt.Passed = (meterRslt.Error >= test.ErrLimLo + test.Uncertainty) - && (meterRslt.Error <= test.ErrLimHi - test.Uncertainty); + && (meterRslt.Error <= test.ErrLimHi - test.Uncertainty) + && (tstRslt.ErrorFlags == 0 || tstRslt.ErrorFlagsMode() != Config.Entities.ErrorFlagsMode.On); meterRslt.TestDone = true; tstRslt.TestDone = true; } diff --git a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs index 39d68b40b..983edc7cb 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs @@ -881,6 +881,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection tstRslt.FlowMin = (float)RefFlowStat.Min; tstRslt.FlowMax = (float)RefFlowStat.Max; + if (ErrorFlagsComp != null) tstRslt.ErrorFlags = ErrorFlagsComp.GetErrorFlags(); + if (compound) { /// @@ -922,8 +924,9 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection compoundMeterRslt.TestTime = tstRslt.TestTime; compoundMeterRslt.Error = Formulas.ErrorFromVolumes(compoundMeterRslt.VolumeMeter, compoundMeterRslt.VolumeRef); compoundMeterRslt.Passed = (compoundMeterRslt.Error >= test.ErrLimLo + test.Uncertainty) - && (compoundMeterRslt.Error <= test.ErrLimHi - test.Uncertainty); - mainMeterRslt.Passed = auxMeterRslt.Passed = compoundMeterRslt.Passed; + && (compoundMeterRslt.Error <= test.ErrLimHi - test.Uncertainty) + && (tstRslt.ErrorFlags == 0 || tstRslt.ErrorFlagsMode() != Config.Entities.ErrorFlagsMode.On); + mainMeterRslt.Passed = auxMeterRslt.Passed = compoundMeterRslt.Passed; mainMeterRslt.TestDone = auxMeterRslt.TestDone = compoundMeterRslt.TestDone = true; tstRslt.TestDone = true; } @@ -974,7 +977,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection volumeRslt.Error = Formulas.ErrorFromVolumes(volumeRslt.VolumeMeter, volumeRslt.VolumeRef); volumeRslt.Passed = !heatMetersTestParams.EvaluateVolume || ((volumeRslt.Error >= test.ErrLimLo + test.Uncertainty) && - (volumeRslt.Error <= test.ErrLimHi - test.Uncertainty)); + (volumeRslt.Error <= test.ErrLimHi - test.Uncertainty) && + (tstRslt.ErrorFlags == 0 || tstRslt.ErrorFlagsMode() != Config.Entities.ErrorFlagsMode.On)); volumeRslt.TestDone = true; tstRslt.TestDone = true; } @@ -991,7 +995,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection energyRslt.Error = Formulas.ErrorFromVolumes(energyRslt.VolumeMeter, energyRslt.VolumeRef); energyRslt.Passed = (energyRslt.Error >= heatMetersTestParams.ErrorLimitLo) - && (energyRslt.Error <= heatMetersTestParams.ErrorLimitHi); + && (energyRslt.Error <= heatMetersTestParams.ErrorLimitHi) + && (tstRslt.ErrorFlags == 0 || tstRslt.ErrorFlagsMode() != Config.Entities.ErrorFlagsMode.On); energyRslt.TestDone = true; tstRslt.TestDone = true; } @@ -1021,8 +1026,9 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection meterRslt.TestTime = tstRslt.TestTime; meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef); meterRslt.Passed = (meterRslt.Error >= test.ErrLimLo + test.Uncertainty) - && (meterRslt.Error <= test.ErrLimHi - test.Uncertainty); - meterRslt.TestDone = true; + && (meterRslt.Error <= test.ErrLimHi - test.Uncertainty) + && (tstRslt.ErrorFlags == 0 || tstRslt.ErrorFlagsMode() != Config.Entities.ErrorFlagsMode.On); + meterRslt.TestDone = true; tstRslt.TestDone = true; } } diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs index 4ffd50482..40f3ced02 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs @@ -466,6 +466,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStart tstRslt.FlowMin = (float)RefFlowStat.Min; tstRslt.FlowMax = (float)RefFlowStat.Max; + if (ErrorFlagsComp != null) tstRslt.ErrorFlags = ErrorFlagsComp.GetErrorFlags(); + if (compoundTestParams != null) { /// @@ -518,7 +520,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStart volumeRslt.Error = Formulas.ErrorFromVolumes(volumeRslt.VolumeMeter, volumeRslt.VolumeRef); volumeRslt.Passed = !heatMetersTestParams.EvaluateVolume || ((volumeRslt.Error >= test.ErrLimLo + test.Uncertainty) && - (volumeRslt.Error <= test.ErrLimHi - test.Uncertainty)); + (volumeRslt.Error <= test.ErrLimHi - test.Uncertainty) && + (tstRslt.ErrorFlags == 0 || tstRslt.ErrorFlagsMode() != Config.Entities.ErrorFlagsMode.On)); volumeRslt.TestDone = true; tstRslt.TestDone = true; } @@ -536,7 +539,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStart energyRslt.Error = Formulas.ErrorFromVolumes(energyRslt.VolumeMeter, energyRslt.VolumeRef); energyRslt.Passed = (energyRslt.Error >= heatMetersTestParams.ErrorLimitLo) - && (energyRslt.Error <= heatMetersTestParams.ErrorLimitHi); + && (energyRslt.Error <= heatMetersTestParams.ErrorLimitHi) + && (tstRslt.ErrorFlags == 0 || tstRslt.ErrorFlagsMode() != Config.Entities.ErrorFlagsMode.On); energyRslt.TestDone = true; tstRslt.TestDone = true; } @@ -605,7 +609,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStart meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef); meterRslt.Passed = (meterRslt.Error >= test.ErrLimLo + test.Uncertainty) - && (meterRslt.Error <= test.ErrLimHi - test.Uncertainty); + && (meterRslt.Error <= test.ErrLimHi - test.Uncertainty) + && (tstRslt.ErrorFlags == 0 || tstRslt.ErrorFlagsMode() != Config.Entities.ErrorFlagsMode.On); meterRslt.TestDone = true; tstRslt.TestDone = true; } diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs index 5d16d85ba..e601c7a64 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs @@ -786,6 +786,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection tstRslt.FlowMin = (float)RefFlowStat.Min; tstRslt.FlowMax = (float)RefFlowStat.Max; + if (ErrorFlagsComp != null) tstRslt.ErrorFlags = ErrorFlagsComp.GetErrorFlags(); + if (compoundTestParams != null) { /// @@ -836,7 +838,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection compoundMeterRslt.TestTime = tstRslt.TestTime; compoundMeterRslt.Error = Formulas.ErrorFromVolumes(compoundMeterRslt.VolumeMeter, compoundMeterRslt.VolumeRef); compoundMeterRslt.Passed = (compoundMeterRslt.Error >= test.ErrLimLo + test.Uncertainty) - && (compoundMeterRslt.Error <= test.ErrLimHi - test.Uncertainty); + && (compoundMeterRslt.Error <= test.ErrLimHi - test.Uncertainty) + && (tstRslt.ErrorFlags == 0 || tstRslt.ErrorFlagsMode() != Config.Entities.ErrorFlagsMode.On); mainMeterRslt.Passed = auxMeterRslt.Passed = compoundMeterRslt.Passed; mainMeterRslt.TestDone = auxMeterRslt.TestDone = compoundMeterRslt.TestDone = true; tstRslt.TestDone = true; @@ -888,7 +891,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection volumeRslt.Error = Formulas.ErrorFromVolumes(volumeRslt.VolumeMeter, volumeRslt.VolumeRef); volumeRslt.Passed = !heatMetersTestParams.EvaluateVolume || ((volumeRslt.Error >= test.ErrLimLo + test.Uncertainty) && - (volumeRslt.Error <= test.ErrLimHi - test.Uncertainty)); + (volumeRslt.Error <= test.ErrLimHi - test.Uncertainty) && + (tstRslt.ErrorFlags == 0 || tstRslt.ErrorFlagsMode() != Config.Entities.ErrorFlagsMode.On)); volumeRslt.TestDone = true; tstRslt.TestDone = true; } @@ -906,7 +910,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection energyRslt.Error = Formulas.ErrorFromVolumes(energyRslt.VolumeMeter, energyRslt.VolumeRef); energyRslt.Passed = (energyRslt.Error >= heatMetersTestParams.ErrorLimitLo) - && (energyRslt.Error <= heatMetersTestParams.ErrorLimitHi); + && (energyRslt.Error <= heatMetersTestParams.ErrorLimitHi) + && (tstRslt.ErrorFlags == 0 || tstRslt.ErrorFlagsMode() != Config.Entities.ErrorFlagsMode.On); energyRslt.TestDone = true; tstRslt.TestDone = true; } @@ -976,7 +981,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef); meterRslt.Passed = (meterRslt.Error >= test.ErrLimLo + test.Uncertainty) - && (meterRslt.Error <= test.ErrLimHi - test.Uncertainty); + && (meterRslt.Error <= test.ErrLimHi - test.Uncertainty) + && (tstRslt.ErrorFlags == 0 || tstRslt.ErrorFlagsMode() != Config.Entities.ErrorFlagsMode.On); meterRslt.TestDone = true; tstRslt.TestDone = true; } diff --git a/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs b/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs index ff79f1b3b..5389e9e7f 100644 --- a/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs @@ -329,6 +329,8 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration tstRslt.FlowMin = (float)RefFlowStat.Min; tstRslt.FlowMax = (float)RefFlowStat.Max; + if (ErrorFlagsComp != null) tstRslt.ErrorFlags = ErrorFlagsComp.GetErrorFlags(); + /// 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 new file mode 100644 index 000000000..808c3f78b --- /dev/null +++ b/TestBenchFramework/BenchControl/Various/ErrorFlags/Errors.cs @@ -0,0 +1,82 @@ +/// +/// Copyright (c) 2017 Sensus Metering Systems +/// +using System; +using System.Collections.Generic; +using System.Text; +using log4net; +using Config.Entities; + +namespace TBF.BenchControl.Various.ErrorFlags +{ + public class Errors : ComponentBase, GenericDevices.IErrorFlags + { + /// TODO: Implement support for sharing one camera by multiple ROI-s + + private static readonly ILog log = LogManager.GetLogger(typeof(Errors)); + public override string ToString() + { + return string.Format("{0}({1})", this.GetType().Namespace.Substring(17), Cfg.ToString(1)); + } + + /// + /// 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 Errors() + { + } + + public Errors(Generic.IComponentCfg cfg, IList components) + : base(cfg) + { + errorsCfg = cfg as ErrorsCfg; + + StartChangeHandler(); + + log.Debug(this.ToString()); + } + + #region Configuration Change Handling + + public static void OnCfgChange(object sender, CfgChangeArgs args) + { + if (CfgChangeHandler == null) return; + try { CfgChangeHandler(sender, args); } + catch (Exception e) { log.Error("CfgChangeHandler(...) failed", e); } + } + + public static event EventHandler CfgChangeHandler; + + public override void StartChangeHandler() + { + CfgChangeHandler += delegate(object sender, CfgChangeArgs args) + { + ErrorsCfg tmpcfg = args.Cfg as ErrorsCfg; + if (tmpcfg != null && tmpcfg.Name.Equals(Name)) + { + if (args.Command == CfgChangeCmd.CfgChange) + { + //errorsCfg.BlackAndWhite = tmpcfg.BlackAndWhite; + //errorsCfg.LowResolution = tmpcfg.LowResolution; + //errorsCfg.ImageRotation = tmpcfg.ImageRotation; + } + } + }; + } + + #endregion Configuration Change Handling + } +} diff --git a/TestBenchFramework/BenchControl/Various/ErrorFlags/ErrorsCfg.cs b/TestBenchFramework/BenchControl/Various/ErrorFlags/ErrorsCfg.cs new file mode 100644 index 000000000..627f021ac --- /dev/null +++ b/TestBenchFramework/BenchControl/Various/ErrorFlags/ErrorsCfg.cs @@ -0,0 +1,50 @@ +/// +/// Copyright (c) 2017 Sensus Metering Systems +/// +using System.Xml.Serialization; +using Config.Entities; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.Various.ErrorFlags +{ + public class ErrorsCfg : ComponentCfgBase, IComponentCfg + { + public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(ErrorsCfg) })[0]; + protected override XmlSerializer GetSerializer() { return Serializer; } + + public IComponentCfgCtrl GetControl() { return new ErrorsCfgCtrl(); } + + /// + /// Serialized parameters + /// + + /// Test parameters + [XmlIgnore] + public TestParams TestParams; + public override IParamsProvider GetTestParams() { return TestParams; } + public override IParamsProvider CreateTestParams(Test test) + { + TestParams procParams = new TestParams(true); + procParams.UpdateTestParams(Name, test); + return procParams; + } + + /// Private parameterless constructor invoked by all other (public) constructors + ErrorsCfg() + { + TestParams = new TestParams(true); + } + + public ErrorsCfg(string name, IComponentFactory factory) + : this() + { + Name = name; + Factory = factory; + } + + public string ToString(int i) + { + return string.Format("{0}", Name); + } + } +} diff --git a/TestBenchFramework/BenchControl/Various/ErrorFlags/ErrorsCfgCtrl.cs b/TestBenchFramework/BenchControl/Various/ErrorFlags/ErrorsCfgCtrl.cs new file mode 100644 index 000000000..27e21d27d --- /dev/null +++ b/TestBenchFramework/BenchControl/Various/ErrorFlags/ErrorsCfgCtrl.cs @@ -0,0 +1,105 @@ +/// +/// Copyright (c) 2017 Sensus Metering Systems +/// +using System; +using System.Windows.Forms; +using log4net; +using Config.Entities; +using TBF.BenchControl.Generic; +using TBF.Resources; + +namespace TBF.BenchControl.Various.ErrorFlags +{ + public partial class ErrorsCfgCtrl : UserControl, IComponentCfgCtrl + { + static readonly ILog log = LogManager.GetLogger(typeof(ErrorsCfgCtrl)); + + ComponentParametersDlg parent; + + public bool ShowMore { get { return false; } } + + ErrorsCfg config; + public IComponentCfg Config + { + get { return config as IComponentCfg; } + set + { + config = value as ErrorsCfg; + Redraw(); + } + } + + public ErrorsCfgCtrl() + { + InitializeComponent(); + } + + private void PumpCfgCtrl_Load(object sender, EventArgs e) + { + parent = ParentForm as ComponentParametersDlg; + if (parent == null) return; + + Redraw(); + } + + public void Closing() + { + } + + void Redraw() + { + if (config == null) return; /// Control was not loaded, settings were not changed + + classNameLabel.Text = config.Factory.ClassName; + nameTextBox.Text = config.Name; + } + + public void Unlock() + { + nameTextBox.Enabled = true; + } + + public CfgUpdateFlags VerifyCfg(ref string message) + { + CfgUpdateFlags flags = CfgUpdateFlags.None; + + return flags; + } + + public CfgUpdateFlags UpdateCfg() + { + CfgUpdateFlags flags = CfgUpdateFlags.None; + + if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed + + if (config.Name != nameTextBox.Text) + { + config.Name = nameTextBox.Text; + flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange); + } + + if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0) + { + Errors.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, Config)); + } + + return flags; + } + + #region Configuration Change Handling + + public static void OnCmdResponse(object sender, CmdResponseArgs args) + { + if (CmdResponseHandler == null) return; + try { CmdResponseHandler(sender, args); } + catch (Exception e) { log.Error("CmdResponseHandler(...) failed", e); } + } + + public static event EventHandler CmdResponseHandler; + + public void StartResponseHandler() { } + public void StopResponseHandler() { } + + #endregion Configuration Change Handling + } +} diff --git a/TestBenchFramework/BenchControl/Various/ErrorFlags/ErrorsCfgCtrl.designer.cs b/TestBenchFramework/BenchControl/Various/ErrorFlags/ErrorsCfgCtrl.designer.cs new file mode 100644 index 000000000..588bba6ee --- /dev/null +++ b/TestBenchFramework/BenchControl/Various/ErrorFlags/ErrorsCfgCtrl.designer.cs @@ -0,0 +1,109 @@ +/// +/// Copyright (c) 2017 Sensus Metering Systems +/// +namespace TBF.BenchControl.Various.ErrorFlags +{ + partial class ErrorsCfgCtrl + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.nameTextBox = new System.Windows.Forms.TextBox(); + this.nameLabel = new System.Windows.Forms.Label(); + this.classNameLabel = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // nameTextBox + // + this.nameTextBox.Enabled = false; + this.nameTextBox.Location = new System.Drawing.Point(115, 49); + this.nameTextBox.Name = "nameTextBox"; + this.nameTextBox.Size = new System.Drawing.Size(174, 20); + this.nameTextBox.TabIndex = 2; + // + // nameLabel + // + this.nameLabel.AutoSize = true; + this.nameLabel.Location = new System.Drawing.Point(20, 52); + this.nameLabel.Name = "nameLabel"; + this.nameLabel.Size = new System.Drawing.Size(35, 13); + this.nameLabel.TabIndex = 1; + this.nameLabel.Text = "Name"; + // + // classNameLabel + // + this.classNameLabel.AutoSize = true; + this.classNameLabel.Location = new System.Drawing.Point(112, 26); + this.classNameLabel.Name = "classNameLabel"; + this.classNameLabel.Size = new System.Drawing.Size(114, 13); + this.classNameLabel.TabIndex = 0; + this.classNameLabel.Text = "ComponentClassName"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(-211, -147); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(57, 13); + this.label1.TabIndex = 5; + this.label1.Text = "Arguments"; + // + // textBox1 + // + this.textBox1.Enabled = false; + this.textBox1.Location = new System.Drawing.Point(-125, -150); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(372, 20); + this.textBox1.TabIndex = 6; + // + // ErrorsCfgCtrl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.textBox1); + this.Controls.Add(this.label1); + this.Controls.Add(this.nameTextBox); + this.Controls.Add(this.nameLabel); + this.Controls.Add(this.classNameLabel); + this.Name = "ErrorsCfgCtrl"; + this.Size = new System.Drawing.Size(500, 300); + this.Load += new System.EventHandler(this.PumpCfgCtrl_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox nameTextBox; + private System.Windows.Forms.Label nameLabel; + private System.Windows.Forms.Label classNameLabel; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox textBox1; + } +} diff --git a/TestBenchFramework/BenchControl/Various/ErrorFlags/ErrorsCfgCtrl.resx b/TestBenchFramework/BenchControl/Various/ErrorFlags/ErrorsCfgCtrl.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/TestBenchFramework/BenchControl/Various/ErrorFlags/ErrorsCfgCtrl.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TestBenchFramework/BenchControl/Various/ErrorFlags/Factory.cs b/TestBenchFramework/BenchControl/Various/ErrorFlags/Factory.cs new file mode 100644 index 000000000..823733c08 --- /dev/null +++ b/TestBenchFramework/BenchControl/Various/ErrorFlags/Factory.cs @@ -0,0 +1,26 @@ +/// +/// Copyright (c) 2017 Sensus Metering Systems +/// +using System.Collections.Generic; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.Various.ErrorFlags +{ + public class Factory : IComponentFactory + { + public string ClassName { get { return this.GetType().Namespace.Substring(17); } } + + public void ResetStaticProperties() { Errors.ResetStaticProperties(); } + + public IComponent DummyComponent() { return new Errors(); } + + public IComponent GetComponent(IComponentCfg cfg, IList components) { return new Errors(cfg, components); } + + public IComponentCfg DefaultConfig() { return new ErrorsCfg(this.GetType().Namespace.Substring(25), this); } + + public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) + { + return ComponentCfgBase.CreateFromDbEntity(ErrorsCfg.Serializer, component, this); + } + } +} diff --git a/TestBenchFramework/BenchControl/Various/ErrorFlags/TestParams.cs b/TestBenchFramework/BenchControl/Various/ErrorFlags/TestParams.cs new file mode 100644 index 000000000..a3b810283 --- /dev/null +++ b/TestBenchFramework/BenchControl/Various/ErrorFlags/TestParams.cs @@ -0,0 +1,319 @@ +/// +/// Copyright (c) 2017 Sensus Metering Systems +/// +using System.IO; +using System.Xml.Serialization; +using Config.Entities; +using TBF.BenchControl.Generic; +using TBF.Resources; + +namespace TBF.BenchControl.Various.ErrorFlags +{ + public class TestParams : TestParamsBase, IParamsProvider, ITestParams + { + public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TestParams) })[0]; + protected override XmlSerializer GetSerializer() { return Serializer; } + + public ErrorFlagsMode Mode; /// 0 = Off, 1 = Info (show only), 2 = On (show and evaluate) + public bool E1; + public bool E2; + public bool E3; + public bool E4; + public bool E5; + public bool E6; + public bool E7; + public bool E8; + public bool E9; + public bool E10; + public bool E11; + public bool E12; + public bool E13; + public bool E14; + public bool E15; + public bool E16; + + public float Delta_Q_pct; /// [%] max deviation from the mean flow + public float Delta_T; /// [°C] max. T_up or T_down deviation from the mean temperature + 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 Coef_E9; /// Coefficient used in E9, default 0.025 + public float Coef_E10; /// Coefficient used in E10, default 0.04 + public float Coef_E11; /// Coefficient used in E11, default 0.1 + public float Coef_E12; /// Coefficient used in E12, default 1 + + public override void InitializeAll() + { + Mode = ErrorFlagsMode.On; + E1 = true; + E2 = true; + E3 = true; + E4 = true; + E5 = true; + E6 = true; + E7 = true; + E8 = true; + E9 = true; + E10 = true; + E11 = true; + E12 = true; + E13 = true; + E14 = true; + E15 = true; + E16 = true; + + Delta_Q_pct = 2.5f; /// [%] + Delta_T = 10.0f; /// [°C] + Delta_Tup_Tdn = 10.0f; /// [°C] + TestTime_min = 0; /// [s] + TestTime_max = 99999; /// [s] + /// + Coef_E9 = 0.025f; + Coef_E10 = 0.04f; + Coef_E11 = 0.1f; + Coef_E12 = 1.0f; + } + + string[] paramNames = new string[] + { + Strings.Mode, + "E1", + "E2", + "E3", + "E4", + "E5", + "E6", + "E7", + "E8", + "E9", + "E10", + "E11", + "E12", + "E13", + "E14", + "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), + + "Coef.E9", + "Coef.E10", + "Coef.E11", + "Coef.E12" + }; + public override string ParamName(int i) { return paramNames[i]; } + public override int ParamsCount() { return paramNames.Length; } + + public override string ToString(int i) + { + switch (i) + { + case 0: return Mode.ToDescription(); + case 1: return (E1 ? Strings.yes : Strings.no); + case 2: return (E2 ? Strings.yes : Strings.no); + case 3: return (E3 ? Strings.yes : Strings.no); + case 4: return (E4 ? Strings.yes : Strings.no); + case 5: return (E5 ? Strings.yes : Strings.no); + case 6: return (E6 ? Strings.yes : Strings.no); + case 7: return (E7 ? Strings.yes : Strings.no); + case 8: return (E8 ? Strings.yes : Strings.no); + case 9: return (E9 ? Strings.yes : Strings.no); + case 10: return (E10 ? Strings.yes : Strings.no); + case 11: return (E11 ? Strings.yes : Strings.no); + case 12: return (E12 ? Strings.yes : Strings.no); + case 13: return (E13 ? Strings.yes : Strings.no); + case 14: return (E14 ? Strings.yes : Strings.no); + case 15: return (E15 ? Strings.yes : Strings.no); + case 16: return (E16 ? Strings.yes : Strings.no); + + case 17: return Delta_Q_pct.ToString(); + case 18: return Delta_T.ToString(); + 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(); + + default: return string.Empty; + } + } + + /// Retrieves parameters from UI controls + public void UpdateParam(int i, string strValue) + { + switch (i) + { + case 0: + for (ErrorFlagsMode m = 0; m < ErrorFlagsMode.Count; m++) + { + if (m.ToDescription() == strValue) + { + Mode = m; + return; + } + } + return; + case 1: E1 = (strValue == Strings.yes); return; + case 2: E2 = (strValue == Strings.yes); return; + case 3: E3 = (strValue == Strings.yes); return; + case 4: E4 = (strValue == Strings.yes); return; + case 5: E5 = (strValue == Strings.yes); return; + case 6: E6 = (strValue == Strings.yes); return; + case 7: E7 = (strValue == Strings.yes); return; + case 8: E8 = (strValue == Strings.yes); return; + case 9: E9 = (strValue == Strings.yes); return; + case 10: E10 = (strValue == Strings.yes); return; + case 11: E11 = (strValue == Strings.yes); return; + case 12: E12 = (strValue == Strings.yes); return; + case 13: E13 = (strValue == Strings.yes); return; + case 14: E14 = (strValue == Strings.yes); return; + case 15: E15 = (strValue == Strings.yes); return; + case 16: E16 = (strValue == Strings.yes); return; + + case 17: Delta_Q_pct = Utils.ParseUFloat(strValue); return; + case 18: Delta_T = Utils.ParseUFloat(strValue); return; + 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; + + default: return; + } + } + + /// Verifies whether strings in UI controls represent valid parameters + public bool ValidateParam(int i, string strValue, out string message) + { + message = string.Empty; + + float fdummy; + switch (i) + { + case 0: + for (ErrorFlagsMode m = 0; m < ErrorFlagsMode.Count; m++) + { + if (m.ToDescription() == strValue) return true; + } + break; + + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + if (strValue == Strings.yes || strValue == Strings.no) return true; + break; + + case 17: + case 18: + case 19: + case 20: + case 21: + case 22: + case 23: + case 24: + case 25: + if (Utils.TryParseUFloat(strValue, out fdummy)) return true; + break; + + default: + message = "Invalid index"; + return false; + } + + message = ParamName(i) + " is invalid"; + return false; + } + + void CopyContentTo(TestParams prms) + { + prms.Mode = this.Mode; + prms.E1 = this.E1; + prms.E2 = this.E2; + prms.E3 = this.E3; + prms.E4 = this.E4; + prms.E5 = this.E5; + prms.E6 = this.E6; + prms.E7 = this.E7; + prms.E8 = this.E8; + prms.E9 = this.E9; + prms.E10 = this.E10; + prms.E11 = this.E11; + prms.E12 = this.E12; + prms.E13 = this.E13; + prms.E14 = this.E14; + prms.E15 = this.E15; + prms.E16 = this.E16; + + prms.Delta_Q_pct = this.Delta_Q_pct; + prms.Delta_T = this.Delta_T; + prms.Delta_Tup_Tdn = this.Delta_Tup_Tdn; + prms.TestTime_min = this.TestTime_min; + prms.TestTime_max = this.TestTime_max; + prms.Coef_E9 = this.Coef_E9; + prms.Coef_E10 = this.Coef_E10; + prms.Coef_E11 = this.Coef_E11; + prms.Coef_E12 = this.Coef_E12; + } + + public IParamsProvider Clone() + { + TestParams pars = new TestParams(); + CopyContentTo(pars); + return pars; + } + + public override void UpdateTestParams(ComponentTest dbEntity) + { + if (dbEntity == null) return; + try + { + TestParams tmp = Serializer.Deserialize(new StringReader(dbEntity.Parameters)) as TestParams; + + testParamsEntity = dbEntity; + componentName = dbEntity.CmpntName; + test = dbEntity.Test; + + if (tmp != null) tmp.CopyContentTo(this); + } + catch + { + } + } + + public TestParams() { } + + public TestParams(bool initialize) + { + if (initialize) InitializeAll(); + } + + public TestParams(ComponentProcedure procedureParamsEntity, string componentName, Test test) + { + this.testParamsEntity = testParamsEntity; + this.componentName = componentName; + this.test = test; + } + } +} diff --git a/TestBenchFramework/Properties/AssemblyInfo.cs b/TestBenchFramework/Properties/AssemblyInfo.cs index 4c542fea7..1203afca6 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.15.642.1")] -[assembly: AssemblyFileVersion("2.15.642.1")] +[assembly: AssemblyVersion("2.16.642.1")] +[assembly: AssemblyFileVersion("2.16.642.1")] diff --git a/TestBenchFramework/TBF.csproj b/TestBenchFramework/TBF.csproj index c29527f4d..3fa2a0ce2 100644 --- a/TestBenchFramework/TBF.csproj +++ b/TestBenchFramework/TBF.csproj @@ -501,6 +501,7 @@ + @@ -954,6 +955,16 @@ + + + + + + UserControl + + + ErrorsCfgCtrl.cs + @@ -2197,6 +2208,9 @@ TestMethodCfgCtrl.cs + + ErrorsCfgCtrl.cs + WaterMeterCfgCtrl.cs