(1) Diverter start/stop transition graph plotted, (2) Diverter ToTank / ToSink buttons, ver. 3.1.1616

This commit is contained in:
Milan Hanajik
2021-03-28 08:38:30 +02:00
parent 0fc8bb4ea0
commit baf7f84343
14 changed files with 414 additions and 112 deletions
@@ -3,14 +3,14 @@
///
using System;
using log4net;
using TBF.Rig.GenericDevices;
using TBF.Rig.Sequences;
namespace TBF.Rig.ControlBoard.Uni
{
public class FlyingStartStopTestOp : IOperation
{
private static readonly ILog log = LogManager.GetLogger(typeof(FlyingStartStopTestOp));
public override string ToString() { return string.Format("FlyingStartStopTestWithDivOp()"); }
public override string ToString() { return string.Format("FlyingStartStopTestOp()"); }
/// Arguments of the constructor
readonly UniCB uniCB;
@@ -21,10 +21,11 @@ namespace TBF.Rig.ControlBoard.Uni
readonly bool isProlonged;
readonly int massPulsesCount; /// Number of reference pulses for mass collection
readonly bool readDivTransition;
readonly Statistics divStartPlotter;
readonly Statistics divStopPlotter;
readonly TBF.Rig.Uni.RegValve.RegValve regV;
readonly TBF.Rig.Uni.FlowMeter.FlowMeter flowMeter;
readonly int diverterNr;
readonly int divThreshold;
readonly TBF.Rig.Uni.Diverter.Diverter diverter;
/// <summary>
/// Operation for a Flying start-stop test with a diverter (constructor)
@@ -47,8 +48,9 @@ namespace TBF.Rig.ControlBoard.Uni
/// <param name="isProlonged">true = Prolonged test with diverter</param>
/// <param name="massPulsesCount">Test part 1 duration - number of reference flow meter pulses<</param>
/// <param name="readDivTransition">true = Read diverter transition</param>
public FlyingStartStopTestOp(UniCB cb, OutputPath devices, double qFrom, double qTo, int pulsesCount,
bool withDiverter, bool isProlonged, int massPulsesCount, bool readDivTransition)
public FlyingStartStopTestOp(UniCB cb, OutputPath devices, double qFrom, double qTo, int pulsesCount, bool withDiverter,
bool isProlonged, int massPulsesCount,
bool readDivTransition, Statistics divStartPlotter, Statistics divStopPlotter)
{
this.uniCB = cb;
this.qFrom = qFrom;
@@ -58,6 +60,8 @@ namespace TBF.Rig.ControlBoard.Uni
this.isProlonged = withDiverter && isProlonged;
this.massPulsesCount = massPulsesCount;
this.readDivTransition = withDiverter && readDivTransition;
this.divStartPlotter = divStartPlotter;
this.divStopPlotter = divStopPlotter;
flowMeter = devices.FlowMeter as TBF.Rig.Uni.FlowMeter.FlowMeter;
if (flowMeter == null) throw new ArgumentNullException("Invalid flow meter");
@@ -65,11 +69,8 @@ namespace TBF.Rig.ControlBoard.Uni
regV = devices.RegValve as TBF.Rig.Uni.RegValve.RegValve;
if (regV == null) throw new ArgumentNullException("Invalid regulation valve");
diverterNr = (withDiverter && devices.Diverter is TBF.Rig.Uni.Diverter.Diverter)
? (devices.Diverter as TBF.Rig.Uni.Diverter.Diverter).DiverterNr : 0;
divThreshold = (withDiverter && devices.Diverter is TBF.Rig.Uni.Diverter.Diverter)
? (devices.Diverter as TBF.Rig.Uni.Diverter.Diverter).StartThreshold : 0;
diverter = (withDiverter && devices.Diverter is TBF.Rig.Uni.Diverter.Diverter)
? devices.Diverter as TBF.Rig.Uni.Diverter.Diverter : null;
log.Debug(this.ToString());
}
@@ -78,7 +79,6 @@ namespace TBF.Rig.ControlBoard.Uni
enum OpState
{
StartingTest,
ReadingDivTransition,
TestInProgress,
TestPart1InProgress, /// prolonged test only
TestPart2InProgress, /// prolonged test only
@@ -92,10 +92,12 @@ namespace TBF.Rig.ControlBoard.Uni
/// </summary>
public void Start()
{
log.InfoFormat("Op.Start() RV#={0} Et#={1} Div#={2} Qfrom={3} Qto={4}", regV.Idx1, flowMeter.Idx1, diverterNr, qFrom, qTo);
log.InfoFormat("Op.Start() RV#={0} Et#={1} Div#={2} Qfrom={3} Qto={4}",
regV.Idx1, flowMeter.Idx1, (diverter != null) ? diverter.DiverterNr : 0, qFrom, qTo);
/// Start the test (and the flow measurement)
uniCB.StartTest(false, flowMeter.Idx1, diverterNr, divThreshold, true, withDiverter, false, isProlonged, pulsesCount, massPulsesCount);
uniCB.StartTest(false, flowMeter.Idx1, (diverter != null) ? diverter.DiverterNr : 0, (diverter != null) ? diverter.StartThreshold : 0,
true, withDiverter, false, isProlonged, pulsesCount, massPulsesCount);
opState = OpState.StartingTest;
}
@@ -130,12 +132,12 @@ namespace TBF.Rig.ControlBoard.Uni
return Event.OpArgumentError; /// Invalid qFrom, qTo
}
if (!flowMeter.MsrmntAvailable || /// Flow measurement not started yet
(uniCB.State & (ulong)StatusP.ReadingCounters) == 0 || /// Test was not started yet
uniCB.RefFrequency == 0) /// Measured flow is 0
{
return Event.StartingTest; /// Flow regulation cannot be started
}
//if (!flowMeter.MsrmntAvailable || /// Flow measurement not started yet
// (uniCB.State & (ulong)StatusP.ReadingCounters) == 0 || /// Test was not started yet
// uniCB.RefFrequency == 0) /// Measured flow is 0
//{
// return Event.StartingTest; /// Flow regulation cannot be started
//}
/// Start flow regulation
double reqFlowAve = (qFrom + qTo) / 2;
@@ -144,16 +146,13 @@ namespace TBF.Rig.ControlBoard.Uni
///
uniCB.SetFlow(false, regV.Idx1, 2000 * reqFlowLo / flowMeter.NominalFlow,
2000 * reqFlowHi / flowMeter.NominalFlow);
if (readDivTransition)
{
/// Schedule reading diverter transition data
uniCB.DelayStartOrStop(false);
uniCB.GetDiverterTransitionData(false, diverter, true, divStartPlotter);
}
opState = readDivTransition ? OpState.ReadingDivTransition
: (isProlonged ? OpState.TestPart1InProgress : OpState.TestInProgress);
return isProlonged ? Event.TestPart1InProgress : Event.TestInProgress;
case OpState.ReadingDivTransition:
/// Read diverter transition data
uniCB.ReadDiverterTransition(false, diverterNr);
opState = isProlonged ? OpState.TestPart1InProgress : OpState.TestInProgress;
return isProlonged ? Event.TestPart1InProgress : Event.TestInProgress;
@@ -161,7 +160,15 @@ namespace TBF.Rig.ControlBoard.Uni
if ((uniCB.State & (ulong)StatusP.TestCompleted) == 0)
{
return Event.TestInProgress; /// Test was not completed yet
/// Test is running
return Event.TestInProgress;
}
/// Test was completed now
if (readDivTransition)
{
uniCB.DelayStartOrStop(false);
uniCB.GetDiverterTransitionData(false, diverter, false, divStopPlotter);
}
opState = OpState.TestCompleted;
return Event.TestCompleted;
@@ -172,6 +179,7 @@ namespace TBF.Rig.ControlBoard.Uni
{
return Event.TestPart1InProgress; /// Test was not completed yet
}
opState = OpState.TestPart2InProgress;
return Event.TestPart2InProgress;
@@ -179,9 +187,16 @@ namespace TBF.Rig.ControlBoard.Uni
if ((uniCB.State & (ulong)StatusP.TestCompleted) == 0)
{
/// Test was not completed yet
/// 2nd part of test with diverter is running
return Event.TestPart2InProgress;
}
/// 2nd part of test with diverter was completed now
if (readDivTransition)
{
uniCB.DelayStartOrStop(false);
uniCB.GetDiverterTransitionData(false, diverter, false, divStopPlotter);
}
opState = OpState.TestCompleted;
return Event.TestCompleted;