From edb6d5e8b6c675217adc50267bbdca87a84bc78b Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Fri, 22 May 2015 10:29:56 +0200 Subject: [PATCH] 'EndCondiiton' and 'Communication' added to TransitionStep (transition sequence). TODO: EndConditions functionality, version 1.5.44 --- .../BenchControl/Sequences/MainSeq.cs | 6 +- .../BenchControl/Sequences/SequenceBase.cs | 18 ++-- .../BenchControl/StateMachine.cs | 14 +-- .../TestMethods/Adjustment/AdjustmentSeq.cs | 4 +- .../CameraRoiDetection/RoiDetectionSeq.cs | 4 +- .../CombinedMeters/CombinedMetersSeq.cs | 4 +- .../CombinedWithDetectionSeq.cs | 4 +- .../FixedStartMassCollectionSeq.cs | 4 +- .../TestMethods/FlyingStart/FlyingStartSeq.cs | 4 +- .../FlyingStartCollectionMethodSeq.cs | 4 +- .../TestMethods/LeakTest/LeakTestSeq.cs | 4 +- .../TestMethods/PMaxTest/PMaxTestSeq.cs | 4 +- .../ReferenceFlowmeterCalibrationSeq.cs | 4 +- TestBenchFramework/Entities/Enums.cs | 21 ++-- TestBenchFramework/Entities/Test.cs | 9 +- TestBenchFramework/Entities/TransitionStep.cs | 21 ++-- TestBenchFramework/Entities/User.cs | 6 ++ TestBenchFramework/Mappings/TestMap.cs | 7 +- .../Mappings/TransitionStepMap.cs | 2 + TestBenchFramework/ProcedureDlg.cs | 8 +- TestBenchFramework/Properties/AssemblyInfo.cs | 4 +- .../Resources/Strings.Designer.cs | 18 ++++ TestBenchFramework/Resources/Strings.resx | 6 ++ TestBenchFramework/TransitionsDlg.cs | 17 +++- .../UiControls/TransitionStepsCtrl.cs | 99 +++++++++++++++---- 25 files changed, 202 insertions(+), 94 deletions(-) diff --git a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs index b02b452a0..26a8a0fdc 100644 --- a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs +++ b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs @@ -255,7 +255,7 @@ namespace TBF.BenchControl.Sequences string errorMsg; if (!StateMachine.GetPaths(test, out inPath, out benchPath, out outPath, out sensPath, - out transitionStart, out transitionStop, + out transitionBefore, out transitionAfter, out errorMsg)) { UiBridge.Bridge.OnError(this, errorMsg); @@ -270,7 +270,7 @@ namespace TBF.BenchControl.Sequences string errorMsg; if (!StateMachine.GetPaths(test, out inPath, out benchPath, out outPath, out sensPath, - out transitionStart, out transitionStop, + out transitionBefore, out transitionAfter, out errorMsg)) { UiBridge.Bridge.OnError(this, errorMsg); @@ -318,7 +318,7 @@ namespace TBF.BenchControl.Sequences string errorMsg; if (!StateMachine.GetPaths(test, out inPath, out benchPath, out outPath, out sensPath, - out transitionStart, out transitionStop, + out transitionBefore, out transitionAfter, out errorMsg)) { UiBridge.Bridge.OnError(this, errorMsg); diff --git a/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs b/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs index 4c73630a4..49bc0b48e 100644 --- a/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs +++ b/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs @@ -125,8 +125,8 @@ namespace TBF.BenchControl.Sequences protected static BenchControl.BenchPath benchPath; protected static BenchControl.OutputPath outPath; protected static BenchControl.MetersPath sensPath; - protected static Entities.TransitionSequence transitionStart; - protected static Entities.TransitionSequence transitionStop; + protected static Entities.TransitionSequence transitionBefore; + protected static Entities.TransitionSequence transitionAfter; #region Temperature_Pressure_Humidity @@ -364,8 +364,8 @@ namespace TBF.BenchControl.Sequences { PurgeBegin, PurgeEnd, - TestStart, - TestEnd, + BeforeTest, + AfterTest, } /// @@ -387,8 +387,8 @@ namespace TBF.BenchControl.Sequences { case TransitionContext.PurgeBegin: message = Strings.Purging_i_n; break; case TransitionContext.PurgeEnd: message = Strings.Emptying_i_n; break; - case TransitionContext.TestStart: message = Strings.Test_start_sequence_i_n; break; - case TransitionContext.TestEnd: message = Strings.Test_stop_sequence_i_n; break; + case TransitionContext.BeforeTest: message = Strings.Test_start_sequence_i_n; break; + case TransitionContext.AfterTest: message = Strings.Test_stop_sequence_i_n; break; default: message = "Transition"; break; } @@ -397,7 +397,7 @@ namespace TBF.BenchControl.Sequences /// /// No transition sequence defined --> Default action /// - if (context == TransitionContext.TestStart) + if (context == TransitionContext.BeforeTest) { State.Create("SequenceBase : Transition : TestStart - Default action") .AddOperation(checkUiOp).AddOperation(StateMachine.ControlBoard @@ -411,7 +411,7 @@ namespace TBF.BenchControl.Sequences } while (e.Contains(Event.ValvesBusy)); } - else if (context == TransitionContext.TestEnd) + else if (context == TransitionContext.AfterTest) { State.Create("SequenceBase : Transition : TestEnd - Default action") .AddOperation(checkUiOp).AddOperation(StateMachine.ControlBoard @@ -548,7 +548,7 @@ namespace TBF.BenchControl.Sequences } } - if (context == TransitionContext.TestEnd) + if (context == TransitionContext.AfterTest) { /// /// Stop the pump at the end of test diff --git a/TestBenchFramework/BenchControl/StateMachine.cs b/TestBenchFramework/BenchControl/StateMachine.cs index 06cf73313..4cffcddaf 100644 --- a/TestBenchFramework/BenchControl/StateMachine.cs +++ b/TestBenchFramework/BenchControl/StateMachine.cs @@ -390,16 +390,16 @@ namespace TBF.BenchControl out BenchPath pben, out OutputPath pout, out MetersPath pmtrs, - out Entities.TransitionSequence transitionStart, - out Entities.TransitionSequence transitionEnd, + out Entities.TransitionSequence transitionBefore, + out Entities.TransitionSequence transitionAfter, out string errorMsg) { pfeed = null; pben = null; pout = null; pmtrs = null; - transitionStart = null; - transitionEnd = null; + transitionBefore = null; + transitionAfter = null; foreach (var path in feedingPaths) { @@ -433,10 +433,10 @@ namespace TBF.BenchControl } } - foreach (var transition in TransitionSequences) + foreach (var tr in TransitionSequences) { - if (transition.Name == test.TransitionStart) transitionStart = transition; - if (transition.Name == test.TransitionEnd) transitionEnd = transition; + if (tr.Name == test.RelTransBefore) transitionBefore = tr; + if (tr.Name == test.TransitionAfter) transitionAfter = tr; } if ((pfeed == null) || (pben == null) || (pout == null) || (pmtrs == null)) diff --git a/TestBenchFramework/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs b/TestBenchFramework/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs index 9c2bf770f..a68f72db5 100644 --- a/TestBenchFramework/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs @@ -60,7 +60,7 @@ namespace TBF.BenchControl.TestMethods.Adjustment //==================================== // Transition or SetRoute - Start //==================================== - switch (Transition(transitionStart, TransitionContext.TestStart)) + switch (Transition(transitionBefore, TransitionContext.BeforeTest)) { case Event.Error: { retVal = Event.Error; goto stopTest; } case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } @@ -351,7 +351,7 @@ namespace TBF.BenchControl.TestMethods.Adjustment /// Transition sequence at the end of test /// Prevent overwriting 'retVal' in case it was set to non-default value earlier - switch (Transition(transitionStop, TransitionContext.TestEnd)) + switch (Transition(transitionAfter, TransitionContext.AfterTest)) { case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; } case Event.UiCmdStop: { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; } diff --git a/TestBenchFramework/BenchControl/TestMethods/CameraRoiDetection/RoiDetectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/CameraRoiDetection/RoiDetectionSeq.cs index af095555d..f67592638 100644 --- a/TestBenchFramework/BenchControl/TestMethods/CameraRoiDetection/RoiDetectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/CameraRoiDetection/RoiDetectionSeq.cs @@ -37,7 +37,7 @@ namespace TBF.BenchControl.TestMethods.CameraRoiDetection //==================================== // Transition or SetRoute - Start //==================================== - switch (Transition(transitionStart, TransitionContext.TestStart)) + switch (Transition(transitionBefore, TransitionContext.BeforeTest)) { case Event.Error: { retVal = Event.Error; goto stopTest; } case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } @@ -146,7 +146,7 @@ namespace TBF.BenchControl.TestMethods.CameraRoiDetection /// Transition sequence at the end of test /// Prevent overwriting 'retVal' in case it was set to non-default value earlier - switch (Transition(transitionStop, TransitionContext.TestEnd)) + switch (Transition(transitionAfter, TransitionContext.AfterTest)) { case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; } case Event.UiCmdStop: { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; } diff --git a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs b/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs index 0c4b6142f..dc30c1ce7 100644 --- a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs @@ -54,7 +54,7 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters //==================================== // Transition or SetRoute - Start //==================================== - switch (Transition(transitionStart, TransitionContext.TestStart)) + switch (Transition(transitionBefore, TransitionContext.BeforeTest)) { case Event.Error: { retVal = Event.Error; goto stopTest; } case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } @@ -466,7 +466,7 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters /// Transition sequence at the end of test /// Prevent overwriting 'retVal' in case it was set to non-default value earlier - switch (Transition(transitionStop, TransitionContext.TestEnd)) + switch (Transition(transitionAfter, TransitionContext.AfterTest)) { case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; } case Event.UiCmdStop: { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; } diff --git a/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs index 05adb6b94..c4138b773 100644 --- a/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs @@ -69,7 +69,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection //==================================== // Transition or SetRoute - Start //==================================== - switch (Transition(transitionStart, TransitionContext.TestStart)) + switch (Transition(transitionBefore, TransitionContext.BeforeTest)) { case Event.Error: goto error; case Event.UiCmdStop: goto stopTest; @@ -665,7 +665,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection while (!e.Contains(Event.ValvesSet) || ((inPath.Pump is GenericDevices.IPumpFM) && !e.Contains(Event.TurnPumpOnOffDone))); /// Transition or SetRoute - End - switch (Transition(transitionStop, TransitionContext.TestEnd)) + switch (Transition(transitionAfter, TransitionContext.AfterTest)) { case Event.Error: goto error; case Event.UiCmdStop: goto stopTest; diff --git a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs index 2dac386a9..372a1325c 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs @@ -52,7 +52,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection //==================================== // Transition or SetRoute - Start //==================================== - switch (Transition(transitionStart, TransitionContext.TestStart)) + switch (Transition(transitionBefore, TransitionContext.BeforeTest)) { case Event.Error: { retVal = Event.Error; goto stopTest; } case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } @@ -597,7 +597,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection /// Transition sequence at the end of test /// Prevent overwriting 'retVal' in case it was set to non-default value earlier - switch (Transition(transitionStop, TransitionContext.TestEnd)) + switch (Transition(transitionAfter, TransitionContext.AfterTest)) { case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; } case Event.UiCmdStop: { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; } diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs index c16dcb5f9..4a3ad208c 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs @@ -49,7 +49,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStart //==================================== // Transition or SetRoute - Start //==================================== - switch (Transition(transitionStart, TransitionContext.TestStart)) + switch (Transition(transitionBefore, TransitionContext.BeforeTest)) { case Event.Error: { retVal = Event.Error; goto stopTest; } case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } @@ -314,7 +314,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStart /// Transition sequence at the end of test /// Prevent overwriting 'retVal' in case it was set to non-default value earlier - switch (Transition(transitionStop, TransitionContext.TestEnd)) + switch (Transition(transitionAfter, TransitionContext.AfterTest)) { case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; } case Event.UiCmdStop: { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; } diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs index 34e717b34..639287a43 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs @@ -49,7 +49,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod //==================================== // Transition or SetRoute - Start //==================================== - switch (Transition(transitionStart, TransitionContext.TestStart)) + switch (Transition(transitionBefore, TransitionContext.BeforeTest)) { case Event.Error: { retVal = Event.Error; goto stopTest; } case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } @@ -485,7 +485,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod /// Transition sequence at the end of test /// Prevent overwriting 'retVal' in case it was set to non-default value earlier - switch (Transition(transitionStop, TransitionContext.TestEnd)) + switch (Transition(transitionAfter, TransitionContext.AfterTest)) { case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; } case Event.UiCmdStop: { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; } diff --git a/TestBenchFramework/BenchControl/TestMethods/LeakTest/LeakTestSeq.cs b/TestBenchFramework/BenchControl/TestMethods/LeakTest/LeakTestSeq.cs index b4027b497..733a245a2 100644 --- a/TestBenchFramework/BenchControl/TestMethods/LeakTest/LeakTestSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/LeakTest/LeakTestSeq.cs @@ -38,7 +38,7 @@ namespace TBF.BenchControl.TestMethods.LeakTest // Transition or SetRoute - Start - switch (Transition(transitionStart, TransitionContext.TestStart)) + switch (Transition(transitionBefore, TransitionContext.BeforeTest)) { case Event.Error: { retVal = Event.Error; goto stopTest; } case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } @@ -333,7 +333,7 @@ namespace TBF.BenchControl.TestMethods.LeakTest /// Transition sequence at the end of test /// Prevent overwriting 'retVal' in case it was set to non-default value earlier - switch (Transition(transitionStop, TransitionContext.TestEnd)) + switch (Transition(transitionAfter, TransitionContext.AfterTest)) { case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; } case Event.UiCmdStop: { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; } diff --git a/TestBenchFramework/BenchControl/TestMethods/PMaxTest/PMaxTestSeq.cs b/TestBenchFramework/BenchControl/TestMethods/PMaxTest/PMaxTestSeq.cs index 5d9b5dd6e..50bb5d05e 100644 --- a/TestBenchFramework/BenchControl/TestMethods/PMaxTest/PMaxTestSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/PMaxTest/PMaxTestSeq.cs @@ -38,7 +38,7 @@ namespace TBF.BenchControl.TestMethods.PMaxTest // Transition or SetRoute - Start - switch (Transition(transitionStart, TransitionContext.TestStart)) + switch (Transition(transitionBefore, TransitionContext.BeforeTest)) { case Event.Error: { retVal = Event.Error; goto stopTest; } case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } @@ -252,7 +252,7 @@ namespace TBF.BenchControl.TestMethods.PMaxTest /// Transition sequence at the end of test /// Prevent overwriting 'retVal' in case it was set to non-default value earlier - switch (Transition(transitionStop, TransitionContext.TestEnd)) + switch (Transition(transitionAfter, TransitionContext.AfterTest)) { case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; } case Event.UiCmdStop: { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; } diff --git a/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs b/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs index 9485cc10d..8f4dfcb9f 100644 --- a/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs @@ -49,7 +49,7 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration //==================================== // Transition or SetRoute - Start //==================================== - switch (Transition(transitionStart, TransitionContext.TestStart)) + switch (Transition(transitionBefore, TransitionContext.BeforeTest)) { case Event.Error: { retVal = Event.Error; goto stopTest; } case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } @@ -436,7 +436,7 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration /// Transition sequence at the end of test /// Prevent overwriting 'retVal' in case it was set to non-default value earlier - switch (Transition(transitionStop, TransitionContext.TestEnd)) + switch (Transition(transitionAfter, TransitionContext.AfterTest)) { case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; } case Event.UiCmdStop: { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; } diff --git a/TestBenchFramework/Entities/Enums.cs b/TestBenchFramework/Entities/Enums.cs index a4076ffee..7871cded1 100644 --- a/TestBenchFramework/Entities/Enums.cs +++ b/TestBenchFramework/Entities/Enums.cs @@ -16,22 +16,15 @@ namespace TBF.Entities } /// - /// Flow set method Std/ComposedMeter + /// Transition step is finished when this condition is fulfilled /// - public enum QSetMethod + public enum StepCondition { - Standard, - CombinedMeter, - Count, - } - - /// - /// Procedure method FSS/SSS - /// - public enum TestMethod2 - { - FSS, - SSS, + None, + Scale1Empty, + Scale2Empty, + Scale3Empty, + AllScalesEmpty, Count, } diff --git a/TestBenchFramework/Entities/Test.cs b/TestBenchFramework/Entities/Test.cs index 82e2d7b3e..2b60668bd 100644 --- a/TestBenchFramework/Entities/Test.cs +++ b/TestBenchFramework/Entities/Test.cs @@ -1,5 +1,6 @@ /// /// Copyright (c) 2013-2015 Sensus Metering Systems +/// Author: Milan Hanajik /// using System; using System.Collections.Generic; @@ -37,8 +38,10 @@ namespace TBF.Entities public virtual string BenchPath { get; set; } public virtual string OutputPath { get; set; } public virtual string MetersPath { get; set; } - public virtual string TransitionStart { get; set; } - public virtual string TransitionEnd { get; set; } + public virtual string RelTransBefore { get; set; } + public virtual string RelTransBetween { get; set; } + public virtual string RelTransAfter { get; set; } + public virtual string TransitionAfter { get; set; } public virtual IList MoreParams { get; set; } @@ -63,7 +66,7 @@ namespace TBF.Entities TimeStop2Mass = 5; /// [s] between the test end and the final mass measurement ErrLimLo = -2.0f; /// [%] lower error limit ErrLimHi = 2.0f; /// [%] upper error limit - TolerRed = 5.0; /// = Filter parameter + TolerRed = 0.0; /// = Filter parameter } public Test(string name, int itemNr, Procedure procedure) diff --git a/TestBenchFramework/Entities/TransitionStep.cs b/TestBenchFramework/Entities/TransitionStep.cs index 310ec312c..8761bb8b2 100644 --- a/TestBenchFramework/Entities/TransitionStep.cs +++ b/TestBenchFramework/Entities/TransitionStep.cs @@ -9,13 +9,15 @@ namespace TBF.Entities public class TransitionStep : IHasItemNr, IHasValves { public virtual int Id { get; protected set; } - public virtual int ItemNr { get; set; } /// Order of the preparation step - public virtual int Duration { get; set; } /// Duration in seconds - public virtual string Message { get; set; } /// Message - public virtual string ValvesOpen { get; set; } /// List of valves to be opened - public virtual string ValvesClose { get; set; } /// List of valves to be closed - public virtual string RegulValvesPct { get; set; } /// Positions of regulation valves in % separated by ';' - public virtual string PumpWithFMPcts { get; set; } /// Power of FM controlled pumps in % separated by ';' + public virtual int ItemNr { get; set; } /// Order of the preparation step + public virtual int Duration { get; set; } /// Duration in seconds + public virtual string Message { get; set; } /// Message + public virtual StepCondition EndCondition { get; set; } /// Condition when transition step is finished (next to the duration) + public virtual string Communication { get; set; } /// String specifying type of communication with water meters + public virtual string ValvesOpen { get; set; } /// List of valves to be opened + public virtual string ValvesClose { get; set; } /// List of valves to be closed + public virtual string RegulValvesPct { get; set; } /// Positions of regulation valves in % separated by ';' + public virtual string PumpWithFMPcts { get; set; } /// Power of FM controlled pumps in % separated by ';' public virtual TransitionSequence TransitionSequence { get; set; } @@ -24,6 +26,7 @@ namespace TBF.Entities public TransitionStep() { Duration = 5; /// sec. + EndCondition = (int)StepCondition.None; } public TransitionStep(int itemNr, TransitionSequence sequence) @@ -38,6 +41,8 @@ namespace TBF.Entities TransitionStep result = new TransitionStep(ItemNr, TransitionSequence); result.Duration = Duration; result.Message = Message; + result.EndCondition = EndCondition; + result.Communication = Communication; result.ValvesOpen = ValvesOpen; result.ValvesClose = ValvesClose; result.RegulValvesPct = RegulValvesPct; @@ -51,6 +56,8 @@ namespace TBF.Entities result += indent + "ItemNr = " + ItemNr.ToString() + ", "; result += indent + "Duration = " + Duration.ToString() + ", "; result += indent + "Message = " + Message + ", "; + result += indent + "EndCondition = " + EndCondition.ToString() + ", "; + result += indent + "Communication = " + Communication + ", "; result += indent + "ValvesOpen = " + ValvesOpen.ToString() + ", "; result += indent + "ValvesClose = " + ValvesClose.ToString() + ", "; result += indent + "RegulValvesPct = " + RegulValvesPct.ToString() + ", "; diff --git a/TestBenchFramework/Entities/User.cs b/TestBenchFramework/Entities/User.cs index 3cbe0b4b7..251d59dab 100644 --- a/TestBenchFramework/Entities/User.cs +++ b/TestBenchFramework/Entities/User.cs @@ -246,6 +246,12 @@ namespace TBF.Entities return hashString; } + /// + /// Returns 'true' when authentication data are valid for a power user. + /// + /// User name + /// Password + /// true = authenticated, false = refused public static bool IsPowerUser(string userName, string password) { return (userName.Equals("milan") && password.Equals("napajedla")) || diff --git a/TestBenchFramework/Mappings/TestMap.cs b/TestBenchFramework/Mappings/TestMap.cs index c1b1b4ab5..9631dea95 100644 --- a/TestBenchFramework/Mappings/TestMap.cs +++ b/TestBenchFramework/Mappings/TestMap.cs @@ -1,5 +1,6 @@ /// /// Copyright (c) 2013-2015 Sensus Metering Systems +/// Author: Milan Hanajik /// using FluentNHibernate.Mapping; using TBF.Entities; @@ -35,8 +36,10 @@ namespace TBF.Mappings Map(x => x.BenchPath); Map(x => x.OutputPath); Map(x => x.MetersPath); - Map(x => x.TransitionStart); - Map(x => x.TransitionEnd); + Map(x => x.RelTransBefore); + Map(x => x.RelTransBetween); + Map(x => x.RelTransAfter); + Map(x => x.TransitionAfter); HasMany(x => x.MoreParams) .Cascade.All(); References(x => x.Procedure); diff --git a/TestBenchFramework/Mappings/TransitionStepMap.cs b/TestBenchFramework/Mappings/TransitionStepMap.cs index 9b3a03b5c..0bd289005 100644 --- a/TestBenchFramework/Mappings/TransitionStepMap.cs +++ b/TestBenchFramework/Mappings/TransitionStepMap.cs @@ -14,6 +14,8 @@ namespace TBF.Mappings Map(x => x.ItemNr); Map(x => x.Duration); Map(x => x.Message); + Map(x => x.EndCondition); + Map(x => x.Communication); Map(x => x.ValvesOpen) .CustomType("StringClob") .CustomSqlType("varchar(8000)"); diff --git a/TestBenchFramework/ProcedureDlg.cs b/TestBenchFramework/ProcedureDlg.cs index b6ceb05ef..441492ccd 100644 --- a/TestBenchFramework/ProcedureDlg.cs +++ b/TestBenchFramework/ProcedureDlg.cs @@ -640,8 +640,8 @@ namespace TBF lviProcess.SubItems.Add(test.BenchPath); lviProcess.SubItems.Add(test.OutputPath); lviProcess.SubItems.Add(test.MetersPath); - lviProcess.SubItems.Add(string.IsNullOrEmpty(test.TransitionStart) ? "---" : test.TransitionStart); - lviProcess.SubItems.Add(string.IsNullOrEmpty(test.TransitionEnd) ? "---" : test.TransitionEnd); + lviProcess.SubItems.Add(string.IsNullOrEmpty(test.RelTransBefore) ? "---" : test.RelTransBefore); + lviProcess.SubItems.Add(string.IsNullOrEmpty(test.TransitionAfter) ? "---" : test.TransitionAfter); processListViewEx.Items.Add(lviProcess); @@ -757,11 +757,11 @@ namespace TBF } if ((processEditors[(int)ProcessClmn.TrnStart] as ComboBox).Items.Contains(lvi.SubItems[(int)ProcessClmn.TrnStart].Text)) { - entity.TransitionStart = lvi.SubItems[(int)ProcessClmn.TrnStart].Text.Equals("---") ? string.Empty : lvi.SubItems[(int)ProcessClmn.TrnStart].Text; + entity.RelTransBefore = lvi.SubItems[(int)ProcessClmn.TrnStart].Text.Equals("---") ? string.Empty : lvi.SubItems[(int)ProcessClmn.TrnStart].Text; } if ((processEditors[(int)ProcessClmn.TrnStop] as ComboBox).Items.Contains(lvi.SubItems[(int)ProcessClmn.TrnStop].Text)) { - entity.TransitionEnd = lvi.SubItems[(int)ProcessClmn.TrnStop].Text.Equals("---") ? string.Empty : lvi.SubItems[(int)ProcessClmn.TrnStop].Text; + entity.TransitionAfter = lvi.SubItems[(int)ProcessClmn.TrnStop].Text.Equals("---") ? string.Empty : lvi.SubItems[(int)ProcessClmn.TrnStop].Text; } } } diff --git a/TestBenchFramework/Properties/AssemblyInfo.cs b/TestBenchFramework/Properties/AssemblyInfo.cs index cf81756e3..96580cd25 100644 --- a/TestBenchFramework/Properties/AssemblyInfo.cs +++ b/TestBenchFramework/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("1.4.43.1")] -[assembly: AssemblyFileVersion("1.4.43.1")] +[assembly: AssemblyVersion("1.5.44.1")] +[assembly: AssemblyFileVersion("1.5.44.1")] diff --git a/TestBenchFramework/Resources/Strings.Designer.cs b/TestBenchFramework/Resources/Strings.Designer.cs index da3850879..60b504094 100644 --- a/TestBenchFramework/Resources/Strings.Designer.cs +++ b/TestBenchFramework/Resources/Strings.Designer.cs @@ -393,6 +393,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Communication. + /// + internal static string Communication { + get { + return ResourceManager.GetString("Communication", resourceCulture); + } + } + /// /// Looks up a localized string similar to Component. /// @@ -744,6 +753,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to End condition. + /// + internal static string End_Condition { + get { + return ResourceManager.GetString("End_Condition", resourceCulture); + } + } + /// /// Looks up a localized string similar to End State. /// diff --git a/TestBenchFramework/Resources/Strings.resx b/TestBenchFramework/Resources/Strings.resx index dfd0c707d..b8326a371 100644 --- a/TestBenchFramework/Resources/Strings.resx +++ b/TestBenchFramework/Resources/Strings.resx @@ -1048,4 +1048,10 @@ Show cycle end form + + End condition + + + Communication + \ No newline at end of file diff --git a/TestBenchFramework/TransitionsDlg.cs b/TestBenchFramework/TransitionsDlg.cs index 5a919c621..90cc711f7 100644 --- a/TestBenchFramework/TransitionsDlg.cs +++ b/TestBenchFramework/TransitionsDlg.cs @@ -215,11 +215,20 @@ namespace TBF using (var transaction = Session.BeginTransaction()) { - foreach (var transSeq in TransitionSequences) Session.SaveOrUpdate(transSeq); - foreach (var vBnchSeq in VirtualBenchSequences) Session.SaveOrUpdate(vBnchSeq); + try + { + foreach (var transSeq in TransitionSequences) + Session.SaveOrUpdate(transSeq); + foreach (var vBnchSeq in VirtualBenchSequences) + Session.SaveOrUpdate(vBnchSeq); - try { transaction.Commit(); } - catch { log.Error("Update of sequences in the database failed"); } + transaction.Commit(); + } + catch (Exception e2) + { + MessageBox.Show("Cannot save changes", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + log.ErrorFormat("Update of sequences in the database failed: {0}", e2.Message); + } } Program.LocalSettings.TransitionsDlgLeft = Location.X; diff --git a/TestBenchFramework/UiControls/TransitionStepsCtrl.cs b/TestBenchFramework/UiControls/TransitionStepsCtrl.cs index 52f940f7d..fd8926c9d 100644 --- a/TestBenchFramework/UiControls/TransitionStepsCtrl.cs +++ b/TestBenchFramework/UiControls/TransitionStepsCtrl.cs @@ -21,6 +21,8 @@ namespace TBF.UiControls { Duration, Message, + Condition, + Communication, FixedColumnsCount, } readonly int fixedCount = (int)Column.FixedColumnsCount; @@ -60,6 +62,8 @@ namespace TBF.UiControls /// Columns.Add(Strings.Duration_s, 70 * parent.Dpi / PathsDlg.Dpi100pct); Columns.Add(Strings.Message, 100 * parent.Dpi / PathsDlg.Dpi100pct); + Columns.Add(Strings.End_Condition, 80 * parent.Dpi / PathsDlg.Dpi100pct); + Columns.Add(Strings.Communication, 85 * parent.Dpi / PathsDlg.Dpi100pct); foreach (var vlv in parent.Valves) { if (vlv is BenchControl.GenericDevices.IPumpFM) @@ -84,15 +88,29 @@ namespace TBF.UiControls /// /// Prepare valve combo-boxes /// - editors = new Control[fixedCount + vCount + fmPumpCount + regvCount]; + editors = new Control[fixedCount + fmPumpCount + regvCount + vCount]; /// Duration - editors[0] = new TextBox(); - parent.Controls.Add(editors[0]); + editors[(int)Column.Duration] = new TextBox(); + parent.Controls.Add(editors[(int)Column.Duration]); /// Message - editors[1] = new TextBox(); - parent.Controls.Add(editors[1]); + editors[(int)Column.Message] = new TextBox(); + parent.Controls.Add(editors[(int)Column.Message]); + + /// End condition + ComboBox condCombo = new ComboBox(); + condCombo.Items.Add("---"); + for (int i = 1; i < (int)Entities.StepCondition.Count; i++) + { + condCombo.Items.Add(((Entities.StepCondition)i).ToString()); + } + editors[(int)Column.Condition] = condCombo; + parent.Controls.Add(editors[(int)Column.Condition]); + + /// Communication + editors[(int)Column.Communication] = new TextBox(); + parent.Controls.Add(editors[(int)Column.Communication]); /// FM controlled pumps for (int i = fixedCount; i < fixedCount + fmPumpCount; i++) @@ -169,7 +187,24 @@ namespace TBF.UiControls if (e.DisplayText.Length >= 255) { // Message too long - e.DisplayText = e.Item.Text; + e.DisplayText = e.Item.SubItems[e.SubItem].Text; + e.Cancel = true; + } + } + else if (e.SubItem == (int)Column.Condition) + { + if (!((ComboBox)editors[(int)Column.Condition]).Items.Contains(e.DisplayText)) + { + e.DisplayText = e.Item.SubItems[e.SubItem].Text; + e.Cancel = true; + } + } + else if (e.SubItem == (int)Column.Communication) + { + if (e.DisplayText.Length >= 255) + { + // Communication string too long + e.DisplayText = e.Item.SubItems[e.SubItem].Text; e.Cancel = true; } } @@ -224,6 +259,8 @@ namespace TBF.UiControls ListViewItem lvi = new ListViewItem(step.Duration.ToString()); lvi.SubItems.Add(string.IsNullOrEmpty(step.Message) ? string.Empty : step.Message); + lvi.SubItems.Add((step.EndCondition == Entities.StepCondition.None) ? "---" : step.EndCondition.ToString()); + lvi.SubItems.Add(string.IsNullOrEmpty(step.Communication) ? string.Empty : step.Communication); string[] fmPumpsStr = (step.PumpWithFMPcts != null) ? step.PumpWithFMPcts.Split(new char[] { ';' }) : new string[0]; @@ -267,33 +304,53 @@ namespace TBF.UiControls { Entities.TransitionStep step = (Entities.TransitionStep)myItem; + /// /// Duration + /// int duration; if (int.TryParse(lvi.Text, out duration) && duration > 0) - { step.Duration = duration; - } else - { lvi.Text = step.Duration.ToString(); - } + /// /// Message + /// if (lvi.SubItems[(int)Column.Message].Text.Length == 0) - { - step.Message = null; - } + step.Message = string.Empty; else - { step.Message = lvi.SubItems[(int)Column.Message].Text; + + /// + /// Condition + /// + step.EndCondition = Entities.StepCondition.None; /// When item text is "---" or a wrong value + for (int cond = 1; cond < (int)Entities.StepCondition.Count; cond++) + { + if (lvi.SubItems[(int)Column.Condition].Text.Equals(((Entities.StepCondition)cond).ToString())) + { + step.EndCondition = (Entities.StepCondition)cond; + break; + } } + /// + /// Communication string + /// + if (lvi.SubItems[(int)Column.Communication].Text.Length == 0) + step.Communication = string.Empty; + else + step.Communication = lvi.SubItems[(int)Column.Communication].Text; + + + /// Required for pumps with FM and valves string valvesOpen = string.Empty; string valvesClose = string.Empty; - string regulValvesPct = string.Empty; - string fmPumpsPcts = string.Empty; + /// /// Pumps with FM control + /// + string fmPumpsPcts = string.Empty; int i = 0; foreach (var valve in parent.Valves) { @@ -328,8 +385,12 @@ namespace TBF.UiControls } } } + step.PumpWithFMPcts = fmPumpsPcts; + /// /// Regulation valves + /// + string regulValvesPct = string.Empty; for (int k = fixedCount + fmPumpCount; k < fixedCount + fmPumpCount + regvCount; k++) { if (regulValvesPct.Length > 0) regulValvesPct += ";"; @@ -340,8 +401,11 @@ namespace TBF.UiControls regulValvesPct += lvi.SubItems[k].Text; } } + step.RegulValvesPct = regulValvesPct; + /// /// Valves + /// for (int j = 0, k = 0; j < vCount; j++) { if (!(parent.Valves[j] is BenchControl.GenericDevices.IPumpFM)) @@ -359,9 +423,6 @@ namespace TBF.UiControls } } } - - step.PumpWithFMPcts = fmPumpsPcts; - step.RegulValvesPct = regulValvesPct; step.ValvesOpen = valvesOpen; step.ValvesClose = valvesClose; }