diff --git a/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs b/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs
index 6790fa377..4808abe51 100644
--- a/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs
+++ b/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs
@@ -464,9 +464,12 @@ namespace TBF.BenchControl.Elde
/// An array of register readers
/// Number of reference pulses to complete the test
/// Created operation
- public IOperation StartMeasurementOp(OutputPath outputPath, TestMethods method, int refPulses, float filterConstant)
+ public IOperation StartMeasurementOp(OutputPath outputPath, TestMethods method,
+ float requiredFlowLo, float requiredFlowHi,
+ int refPulses, float filterConstant)
{
- return new StartMeasurementOp(this, outputPath, method, refPulses, filterConstant);
+ return new StartMeasurementOp(this, outputPath, method,
+ requiredFlowLo, requiredFlowHi, refPulses, filterConstant);
}
///
diff --git a/TestBenchFramework/BenchControl/Elde/RegulValve/SetFlowOp.cs b/TestBenchFramework/BenchControl/Elde/RegulValve/SetFlowOp.cs
index 44249f7f4..f51fa8b00 100644
--- a/TestBenchFramework/BenchControl/Elde/RegulValve/SetFlowOp.cs
+++ b/TestBenchFramework/BenchControl/Elde/RegulValve/SetFlowOp.cs
@@ -31,7 +31,9 @@ namespace TBF.BenchControl.Elde.RegulValve
readonly float nominalFlow;
- /// Process values
+ ///
+ /// Internal states of this operation
+ ///
enum OpState
{
Idle = 0,
diff --git a/TestBenchFramework/BenchControl/Elde/StartMeasurementOp.cs b/TestBenchFramework/BenchControl/Elde/StartMeasurementOp.cs
index 44a3b7c4b..f56eb6f22 100644
--- a/TestBenchFramework/BenchControl/Elde/StartMeasurementOp.cs
+++ b/TestBenchFramework/BenchControl/Elde/StartMeasurementOp.cs
@@ -9,18 +9,38 @@ namespace TBF.BenchControl.Elde
public class StartMeasurementOp : IOperation
{
private static readonly ILog log = LogManager.GetLogger(typeof(StartMeasurementOp));
- public override string ToString() { return string.Format("StartMeasurementOp(ref={0},pulses={1})", flowMeterIdx, refPulses); }
+ public override string ToString() { return string.Format("StartMeasurementOp(ref={0},pulses={1})", flowMeterNr, refPulses); }
/// Set by the constructor
readonly ControlBoardDev controlBoard;
- readonly int flowMeterIdx;
- readonly int refPulses; /// Number of reference pulses for a complete test
+ readonly Elde.RegulValve.RegulValve regulValve;
+ readonly int regulValveNr;
+ readonly int flowMeterNr;
+ readonly float nominalFlow;
+ readonly float reqFlowLo;
+ readonly float reqFlowHi;
+ readonly float reqFlowAve;
+ readonly float pidCoef;
+ readonly int refPulses; /// Number of reference pulses for a complete test
readonly TestMethods testMethod;
readonly float filterConstant;
- readonly int diverterIdx;
+ readonly int diverterNr;
bool started = false;
+ ///
+ /// Internal states of this operation
+ ///
+ enum OpState
+ {
+ StartingTest,
+ TestStarted,
+ ValveMoveToFlow,
+ OpCompleted,
+ }
+ OpState opState;
+
+
///
/// Starts the measurement.
/// Events: MeasurementStarted
@@ -30,30 +50,42 @@ namespace TBF.BenchControl.Elde
/// Test method
/// Test duration in number of reference flowmeter pulses
/// Specifies filter for watermeter pulses
- public StartMeasurementOp(ControlBoardDev controlBoard, OutputPath outputPath,
- TestMethods method, int refPulses, float filterConstant)
+ public StartMeasurementOp(ControlBoardDev controlBoard, OutputPath outputPath, TestMethods method,
+ float requiredFlowLo, float requiredFlowHi,
+ int refPulses, float filterConstant)
{
if (controlBoard == null) throw new ArgumentNullException("controlBoardDev");
this.controlBoard = controlBoard;
if (outputPath.FlowMeter is Elde.FlowMeter.FlowMeter)
{
- flowMeterIdx = (outputPath.FlowMeter as Elde.FlowMeter.FlowMeter).Idx1;
+ flowMeterNr = (outputPath.FlowMeter as Elde.FlowMeter.FlowMeter).Idx1;
}
else if (outputPath.FlowMeter is Elde.FlowMeterTwins.FlowMeter)
{
- flowMeterIdx = 0;
+ flowMeterNr = 0;
}
else
{
throw new ArgumentException("flowMeter is null or is not Elde");
}
+ regulValve = outputPath.RegulValve as Elde.RegulValve.RegulValve;
+ if (regulValve == null) throw new ArgumentNullException("regValve is null or not Elde");
+ regulValveNr = this.regulValve.Idx1;
+
if (outputPath.Diverter is Elde.Diverter.Diverter)
{
- diverterIdx = (outputPath.Diverter as Elde.Diverter.Diverter).AdcNr - 4;
+ diverterNr = (outputPath.Diverter as Elde.Diverter.Diverter).AdcNr - 4;
}
+ nominalFlow = outputPath.FlowMeter.NominalFlow;
+
+ this.reqFlowLo = requiredFlowLo;
+ this.reqFlowHi = requiredFlowHi;
+ this.reqFlowAve = (reqFlowLo + reqFlowHi) / 2.0f;
+ this.pidCoef = outputPath.PidCoef;
+
this.refPulses = refPulses;
this.testMethod = method;
this.filterConstant = filterConstant;
@@ -66,13 +98,15 @@ namespace TBF.BenchControl.Elde
{
controlBoard.SyncRoute();
#if IPERLST
- int flowMeterIdxAndDiv = flowMeterIdx + 16 * diverterIdx;
+ int flowMeterIdxAndDiv = flowMeterNr + 16 * diverterNr;
#else
- int flowMeterIdxAndDiv = flowMeterIdx;
+ int flowMeterIdxAndDiv = flowMeterNr;
#endif
controlBoard.SendCommand(Command.Start, flowMeterIdxAndDiv, controlBoard.Route, refPulses, testMethod,
filterConstant, 20, 0, StopDevs.None);
+
+ opState = OpState.StartingTest;
}
/// Run this operation
@@ -81,19 +115,50 @@ namespace TBF.BenchControl.Elde
///
public Event Run()
{
- if (started) return Event.MeasurementStarted;
- 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"));
- if (0 != (statusP & StatusP.TestInProgress))
- {
- log.Info("Test started");
- started = true;
- return Event.MeasurementStarted;
- }
+ if (opState == OpState.StartingTest)
+ {
+ 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"));
+
+ if (0 != (statusP & StatusP.TestInProgress))
+ {
+ log.Info("Test started");
+ opState = OpState.TestStarted;
+ }
+
+ return Event.None;
+ }
+ else if (opState == OpState.TestStarted)
+ {
+ ///
+ /// Done once, issues an appropriate ValveMove(...) command
+ ///
+ if (reqFlowLo >= reqFlowHi || reqFlowLo > nominalFlow || reqFlowHi <= 0)
+ {
+ return Event.OpArgumentError;
+ }
+
+ log.InfoFormat("Run(): rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3}",
+ regulValveNr, flowMeterNr, reqFlowLo, reqFlowHi);
+
+ float freqLo = 2000.0f * reqFlowLo / nominalFlow;
+ float freqHi = 2000.0f * reqFlowHi / nominalFlow;
+ controlBoard.ValveMove(regulValveNr, RegulValveMode.TargetFrequency,
+ new float[2] { freqLo, freqHi },
+ regulValve.StableTime);
+
+ opState = OpState.OpCompleted;
+ return Event.None;
+ }
+ else if (opState == OpState.OpCompleted)
+ {
+ return Event.MeasurementStarted;
+ }
+
return Event.None;
}
diff --git a/TestBenchFramework/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs b/TestBenchFramework/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs
index 6b8674a3b..c325c993b 100644
--- a/TestBenchFramework/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs
+++ b/TestBenchFramework/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs
@@ -176,7 +176,8 @@ namespace TBF.BenchControl.TestMethods.Adjustment
State.Create("Adjustment : Starting the test")
.AddOperation(checkUiOp)
.AddOperations(measureOperations)
- .AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Synchro, totalPulses, (float)test.TolerRed))
+ .AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Synchro,
+ test.Qfrom, test.Qto, totalPulses, (float)test.TolerRed))
.EnterState();
do
{
diff --git a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs b/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs
index 33e65cd6a..edaf61c1e 100644
--- a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs
+++ b/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs
@@ -232,7 +232,7 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
.AddOperation(checkUiOp)
.AddOperations(measureOperations)
.AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Diverter | Elde.TestMethods.Synchro,
- totalPulses, (float)test.TolerRed))
+ test.Qfrom, test.Qto, totalPulses, (float)test.TolerRed))
.EnterState();
do
{
diff --git a/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs
index 02f4e5dfa..55fbe3ba8 100644
--- a/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs
+++ b/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs
@@ -410,7 +410,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
.AddOperation(checkUiOp)
.AddOperations(measureOperations)
.AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Diverter | Elde.TestMethods.Synchro,
- totalPulses, (float)test.TolerRed))
+ test.Qfrom, test.Qto, totalPulses, (float)test.TolerRed))
.EnterState();
do
{
diff --git a/TestBenchFramework/BenchControl/TestMethods/FixedStartCombinedMeters/FixedStartCombinedMetersSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartCombinedMeters/FixedStartCombinedMetersSeq.cs
index 657d51d3a..22ccfc867 100644
--- a/TestBenchFramework/BenchControl/TestMethods/FixedStartCombinedMeters/FixedStartCombinedMetersSeq.cs
+++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartCombinedMeters/FixedStartCombinedMetersSeq.cs
@@ -286,7 +286,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartCombinedMeters
.AddOperation(checkUiOp)
.AddOperations(measureOperations)
.AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Diverter | Elde.TestMethods.Synchro,
- 2 * totalPulses, (float)test.TolerRed))
+ test.Qfrom, test.Qto, 2 * totalPulses, (float)test.TolerRed))
.EnterState();
do
{
diff --git a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs
index 9b4e98c38..1e1d19263 100644
--- a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs
+++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs
@@ -286,7 +286,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
.AddOperation(checkUiOp)
.AddOperations(measureOperations)
.AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Diverter | Elde.TestMethods.Synchro,
- 2 * totalPulses, (float)test.TolerRed))
+ test.Qfrom, test.Qto, 2 * totalPulses, (float)test.TolerRed))
.EnterState();
do
{
diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs
index 0326a40af..8f4de4638 100644
--- a/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs
+++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs
@@ -130,7 +130,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
.AddOperation(checkUiOp)
.AddOperations(measureOperations)
.AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Synchro,
- totalPulses, (float)test.TolerRed))
+ test.Qfrom, test.Qto, totalPulses, (float)test.TolerRed))
.EnterState();
do
{
diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs
index 8d3598b67..ca91bd1fd 100644
--- a/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs
+++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs
@@ -243,10 +243,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
State.Create("FlyingStartCollectionMethod : Starting the test")
.AddOperation(checkUiOp)
.AddOperations(measureOperations)
- .AddOperation(cBrd.StartMeasurementOp(outPath,
- Elde.TestMethods.Diverter | Elde.TestMethods.Synchro,
- totalPulses,
- (float)test.TolerRed))
+ .AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Diverter | Elde.TestMethods.Synchro,
+ test.Qfrom, test.Qto, totalPulses, (float)test.TolerRed))
.EnterState();
do
{
diff --git a/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs b/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs
index b186b118b..aaa02b51b 100644
--- a/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs
+++ b/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs
@@ -202,7 +202,7 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
State.Create("ReferenceFlowmeterCalibration : Starting the test")
.AddOperation(checkUiOp)
.AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Diverter | Elde.TestMethods.Synchro,
- totalPulses, (float)test.TolerRed))
+ test.Qfrom, test.Qto, totalPulses, (float)test.TolerRed))
.EnterState();
do
{
diff --git a/TestBenchFramework/Properties/AssemblyInfo.cs b/TestBenchFramework/Properties/AssemblyInfo.cs
index 73a02ca08..2cf2f5fbb 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.5.120.1")]
-[assembly: AssemblyFileVersion("1.5.120.1")]
+[assembly: AssemblyVersion("1.5.121.1")]
+[assembly: AssemblyFileVersion("1.5.121.1")]