diff --git a/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs b/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs
index 1832823c4..e26c1cbd3 100644
--- a/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs
+++ b/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs
@@ -547,6 +547,19 @@ namespace TBF.BenchControl.Elde
return new StopPreviousOp(this);
}
+ ///
+ /// Sends commands to the control board.
+ /// Events: Event.None, Event.CommandCompleted
+ ///
+ /// Command sent to CB when this operation starts
+ /// Command sent to CB when this operation stops
+ /// Test method parameter
+ /// Created operation
+ public IOperation ExecuteCommandOp(Command commandOnStartOp, Command commandOnStopOp, TestMethods testMethod)
+ {
+ return new ExecuteCommandOp(this, commandOnStartOp, commandOnStopOp, testMethod);
+ }
+
///
/// Updates the tank drawing and weight value in Elde software component.
///
diff --git a/TestBenchFramework/BenchControl/Elde/ExecuteCommandOp.cs b/TestBenchFramework/BenchControl/Elde/ExecuteCommandOp.cs
new file mode 100644
index 000000000..7cb4b7bac
--- /dev/null
+++ b/TestBenchFramework/BenchControl/Elde/ExecuteCommandOp.cs
@@ -0,0 +1,106 @@
+///
+/// Copyright (c) 2016 Sensus Metering Systems
+///
+using System;
+using log4net;
+
+namespace TBF.BenchControl.Elde
+{
+ public class ExecuteCommandOp : IOperation
+ {
+ private static readonly ILog log = LogManager.GetLogger(typeof(ExecuteCommandOp));
+ public override string ToString() { return string.Format("ExecuteCommandOp( command={0}, testMethod={1} )", commandOnStartOp, testMethod); }
+
+ /// Set by the constructor
+ readonly ControlBoardDev controlBoard;
+ readonly Command commandOnStartOp;
+ readonly Command commandOnStopOp;
+ readonly TestMethods testMethod;
+
+ bool started = false;
+
+ ///
+ /// Internal states of this operation
+ ///
+ enum OpState
+ {
+ StartingCommand,
+ CommandStarted,
+ OpCompleted,
+ }
+ OpState opState;
+
+
+ ///
+ /// Starts the measurement.
+ /// Events: MeasurementStarted
+ ///
+ /// Control board component reference
+ /// Specifies used components
+ /// Test method
+ /// Test duration in number of reference flowmeter pulses
+ /// Specifies filter for watermeter pulses
+ public ExecuteCommandOp(ControlBoardDev controlBoard, Command commandOnStartOp, Command commandOnStopOp, TestMethods testMethod)
+ {
+ if (controlBoard == null) throw new ArgumentNullException("controlBoardDev");
+
+ this.controlBoard = controlBoard;
+ this.commandOnStartOp = commandOnStartOp;
+ this.commandOnStopOp = commandOnStopOp;
+ this.testMethod = testMethod;
+
+ log.Debug(this.ToString());
+ }
+
+ /// Start this operation
+ public void Start()
+ {
+ controlBoard.SyncRoute();
+ controlBoard.SendCommand(commandOnStartOp, 0, controlBoard.Route, 0, 0, testMethod, 0, 20, 0, StopDevs.None);
+ opState = OpState.StartingCommand;
+ }
+
+ /// Run this operation
+ ///
+ /// Event.FlowInDone or Event.FlowOutDone
+ ///
+ public Event Run()
+ {
+ if (opState == OpState.StartingCommand)
+ {
+ StatusP statusP = controlBoard.StatusP;
+ log.DebugFormat("statusP = {0} {1} {2} {3}",
+ (((ulong)statusP >> 48) & 0xFFFF).ToString("X4"),
+ (((ulong)statusP >> 32) & 0xFFFF).ToString("X4"),
+ (((ulong)statusP >> 16) & 0xFFFF).ToString("X4"),
+ ((ulong)statusP & 0xFFFF).ToString("X4"));
+
+ log.Info("Run() - StartingCommand");
+ opState = OpState.CommandStarted;
+ return Event.None;
+ }
+ else if (opState == OpState.CommandStarted)
+ {
+ log.InfoFormat("Run() - CommandStarted");
+ opState = OpState.OpCompleted;
+ return Event.None;
+ }
+ else if (opState == OpState.OpCompleted)
+ {
+ return Event.CommandCompleted;
+ }
+
+ return Event.None;
+ }
+
+ /// Stop this operation
+ public void Stop()
+ {
+ if (commandOnStopOp != Command.None)
+ {
+ controlBoard.SyncRoute();
+ controlBoard.SendCommand(commandOnStopOp, 0, controlBoard.Route, 0, 0, testMethod, 0, 20, 0, StopDevs.None);
+ }
+ }
+ }
+}
diff --git a/TestBenchFramework/BenchControl/Events.cs b/TestBenchFramework/BenchControl/Events.cs
index 25b30ba00..219fe73ed 100644
--- a/TestBenchFramework/BenchControl/Events.cs
+++ b/TestBenchFramework/BenchControl/Events.cs
@@ -142,6 +142,7 @@ namespace TBF.BenchControl
MeasurementStarted,
ReadAllRegistersDone,
MeasurementCompleted,
+ CommandCompleted,
/// At the end of cycle when saving /printing resultss
ResultsPrinted,
diff --git a/TestBenchFramework/BenchControl/TestMethods/Endurance/EnduranceSeq.cs b/TestBenchFramework/BenchControl/TestMethods/Endurance/EnduranceSeq.cs
index 648379787..154b189f8 100644
--- a/TestBenchFramework/BenchControl/TestMethods/Endurance/EnduranceSeq.cs
+++ b/TestBenchFramework/BenchControl/TestMethods/Endurance/EnduranceSeq.cs
@@ -398,10 +398,12 @@ namespace TBF.BenchControl.TestMethods.Endurance
/// Endurance test : switching mode
///
+ ///
+ /// Update CyclePar[] array
+ ///
IList enduranceCycle = CycleStep.StringToCycle(enduranceCycleStr);
int stepsCount = Math.Min(enduranceCycle.Count, 80);
-
- /// Fill in CyclePar[] array
+ ///
uint[] cyclePar = new uint[2 * stepsCount + 3];
uint duration = 0;
uint state = 0;
@@ -420,6 +422,50 @@ namespace TBF.BenchControl.TestMethods.Endurance
cBrd.SetCyclePar(0, duration / 10);
+ //------------------------------------------------
+ Bridge.OnActivity(this, Strings.Endurance_cycle_execution);
+ //------------------------------------------------
+ State.Create("Endurance : Cycle parameters upload")
+ .AddOperation(checkUiOp)
+ .AddOperation(benchPath.TempMtrUp.ReadTempOp(ref TempUp))
+ .AddOperation(benchPath.TempMtrDown.ReadTempOp(ref TempDown))
+ .AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv))
+ .AddOperation(benchPath.PressMtrUp.ReadPressureOp(ref PressUp))
+ .AddOperation(benchPath.PressMtrDown.ReadPressureOp(ref PressDown))
+ .AddOperation(benchPath.PressMtrDelta == null ? null : benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta))
+ .AddOperation((StateMachine.Ambient != null) ? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null)
+ .AddOperation(processDataLoggingOp)
+ .AddOperation(cBrd.ExecuteCommandOp(Elde.Command.EnduranceCycleParamsUpload, Elde.Command.None, 0))
+ .EnterState();
+ do
+ {
+ e = StateMachine.WaitRunDevsRunOps();
+ if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
+ if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
+ }
+ while (!e.Contains(Event.CommandCompleted));
+
+
+ State.Create("Endurance : Cycle execution")
+ .AddOperation(checkUiOp)
+ .AddOperation(new Operations.TimerOp(1000, Event.TimerExpired))
+ .AddOperation(benchPath.TempMtrUp.ReadTempOp(ref TempUp))
+ .AddOperation(benchPath.TempMtrDown.ReadTempOp(ref TempDown))
+ .AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv))
+ .AddOperation(benchPath.PressMtrUp.ReadPressureOp(ref PressUp))
+ .AddOperation(benchPath.PressMtrDown.ReadPressureOp(ref PressDown))
+ .AddOperation(benchPath.PressMtrDelta == null ? null : benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta))
+ .AddOperation((StateMachine.Ambient != null) ? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null)
+ .AddOperation(processDataLoggingOp)
+ .AddOperation(cBrd.ExecuteCommandOp(Elde.Command.EnduranceCycleStart, Elde.Command.EnduranceCycleStop, 0))
+ .EnterState();
+ do
+ {
+ e = StateMachine.WaitRunDevsRunOps();
+ if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
+ if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
+ }
+ while (!e.Contains(Event.TimerExpired) && !e.Contains(Event.Next));
}
diff --git a/TestBenchFramework/Resources/Strings.Designer.cs b/TestBenchFramework/Resources/Strings.Designer.cs
index fab147427..d6f0821f1 100644
--- a/TestBenchFramework/Resources/Strings.Designer.cs
+++ b/TestBenchFramework/Resources/Strings.Designer.cs
@@ -1194,6 +1194,15 @@ namespace TBF.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Endurance cycle execution.
+ ///
+ internal static string Endurance_cycle_execution {
+ get {
+ return ResourceManager.GetString("Endurance_cycle_execution", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Endurance cycle steps.
///
diff --git a/TestBenchFramework/Resources/Strings.resx b/TestBenchFramework/Resources/Strings.resx
index 776a6e6e9..e8194be86 100644
--- a/TestBenchFramework/Resources/Strings.resx
+++ b/TestBenchFramework/Resources/Strings.resx
@@ -1603,4 +1603,7 @@
Duration [ms]
+
+ Endurance cycle execution
+
\ No newline at end of file
diff --git a/TestBenchFramework/TBF.csproj b/TestBenchFramework/TBF.csproj
index 54b377e6f..a5ecfd53b 100644
--- a/TestBenchFramework/TBF.csproj
+++ b/TestBenchFramework/TBF.csproj
@@ -377,6 +377,7 @@
+