(1) Diverter start/stop transition graph plotted, (2) Diverter ToTank / ToSink buttons, ver. 3.1.1616
This commit is contained in:
@@ -11,22 +11,21 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
public enum ActionID
|
||||
{
|
||||
/// Basic
|
||||
RequestDataOnly = 0,
|
||||
ChangeRoute = 1, /// Change digital outputs (route)
|
||||
MeasureFlow = 2, /// Activate a flow meter to measure the flow
|
||||
SetFlow = 4, /// Set flow
|
||||
StartTest = 8, /// Start a test
|
||||
Stop = 0x10, /// Stop a test or a flow regulation
|
||||
RegVlvIncrMove = 0x20,
|
||||
RegVlvMoveToPos = 0x40,
|
||||
RegVlvStop = 0x80,
|
||||
SwitchDiverter = 0x100, /// Switch diverter to tank/sink
|
||||
|
||||
/// Advanced
|
||||
GetDiverterTransitionData,
|
||||
GetScopeAnalyzerData,
|
||||
ResetScopeAnalyzer,
|
||||
GetSwitchCounterData,
|
||||
RequestDataOnly = 0,
|
||||
ChangeRoute = 1, /// Change digital outputs (route)
|
||||
MeasureFlow = 2, /// Activate a flow meter to measure the flow
|
||||
SetFlow = 4, /// Set flow
|
||||
StartTest = 8, /// Start a test
|
||||
Stop = 0x10, /// Stop a test or a flow regulation
|
||||
RegVlvIncrMove = 0x20,
|
||||
RegVlvMoveToPos = 0x40,
|
||||
RegVlvStop = 0x80,
|
||||
SwitchDiverter = 0x100, /// Switch diverter to tank/sink
|
||||
DelayStartOrStop = 0x200,
|
||||
GetDiverterTransitionData = 0x400,
|
||||
GetScopeAnalyzerData = 0x800,
|
||||
ResetScopeAnalyzer = 0x1000,
|
||||
GetSwitchCounterData = 0x2000,
|
||||
}
|
||||
|
||||
public class Action
|
||||
@@ -387,6 +386,111 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
(StartStop == Command.None || StartStop == Command.Start);
|
||||
}
|
||||
|
||||
///----------------------------------------------------------------------------------------------
|
||||
public static Action DelayStartOrStop(bool isFromUI)
|
||||
{
|
||||
return new Action
|
||||
{
|
||||
ActionId = ActionID.DelayStartOrStop,
|
||||
IsFromUI = isFromUI,
|
||||
///
|
||||
StartStop = Command.DelayStartOrStop,
|
||||
};
|
||||
}
|
||||
void SetDelayStartOrStopArgs(Action action)
|
||||
{
|
||||
StartStop = Command.DelayStartOrStop;
|
||||
}
|
||||
/// Check whether new action arguments are compatible with alredy collected arguments (true = yes)
|
||||
bool CheckDelayStartOrStopArgs(Action action)
|
||||
{
|
||||
return (StartStop == Command.None || StartStop == Command.DelayStartOrStop);
|
||||
}
|
||||
|
||||
///----------------------------------------------------------------------------------------------
|
||||
public static Action GetDiverterTransitionData(bool isFromUI)
|
||||
{
|
||||
return new Action
|
||||
{
|
||||
ActionId = ActionID.GetDiverterTransitionData,
|
||||
IsFromUI = isFromUI,
|
||||
///
|
||||
StartStop = Command.GetDiverterTransitionData,
|
||||
};
|
||||
}
|
||||
void SetGetDiverterTransitionDataArgs(Action action)
|
||||
{
|
||||
StartStop = Command.GetDiverterTransitionData;
|
||||
}
|
||||
/// Check whether new action arguments are compatible with alredy collected arguments (true = yes)
|
||||
bool CheckGetDiverterTransitionDataArgs(Action action)
|
||||
{
|
||||
return (StartStop == Command.None || StartStop == Command.GetDiverterTransitionData);
|
||||
}
|
||||
|
||||
///----------------------------------------------------------------------------------------------
|
||||
public static Action GetScopeAnalyzerData(bool isFromUI)
|
||||
{
|
||||
return new Action
|
||||
{
|
||||
ActionId = ActionID.GetScopeAnalyzerData,
|
||||
IsFromUI = isFromUI,
|
||||
///
|
||||
StartStop = Command.GetScopeAnalyzerData,
|
||||
};
|
||||
}
|
||||
void SetGetScopeAnalyzerDataArgs(Action action)
|
||||
{
|
||||
StartStop = Command.GetScopeAnalyzerData;
|
||||
}
|
||||
/// Check whether new action arguments are compatible with alredy collected arguments (true = yes)
|
||||
bool CheckGetScopeAnalyzerDataArgs(Action action)
|
||||
{
|
||||
return (StartStop == Command.None || StartStop == Command.GetScopeAnalyzerData);
|
||||
}
|
||||
|
||||
///----------------------------------------------------------------------------------------------
|
||||
public static Action ResetScopeAnalyzer(bool isFromUI)
|
||||
{
|
||||
return new Action
|
||||
{
|
||||
ActionId = ActionID.ResetScopeAnalyzer,
|
||||
IsFromUI = isFromUI,
|
||||
///
|
||||
StartStop = Command.ResetScopeAnalyzer,
|
||||
};
|
||||
}
|
||||
void SetResetScopeAnalyzerArgs(Action action)
|
||||
{
|
||||
StartStop = Command.GetScopeAnalyzerData;
|
||||
}
|
||||
/// Check whether new action arguments are compatible with alredy collected arguments (true = yes)
|
||||
bool CheckResetScopeAnalyzerArgs(Action action)
|
||||
{
|
||||
return (StartStop == Command.None || StartStop == Command.ResetScopeAnalyzer);
|
||||
}
|
||||
|
||||
///----------------------------------------------------------------------------------------------
|
||||
public static Action GetSwitchCounterData(bool isFromUI)
|
||||
{
|
||||
return new Action
|
||||
{
|
||||
ActionId = ActionID.GetSwitchCounterData,
|
||||
IsFromUI = isFromUI,
|
||||
///
|
||||
StartStop = Command.GetSwitchCounterData,
|
||||
};
|
||||
}
|
||||
void SetGetSwitchCounterDataArgs(Action action)
|
||||
{
|
||||
StartStop = Command.GetSwitchCounterData;
|
||||
}
|
||||
/// Check whether new action arguments are compatible with alredy collected arguments (true = yes)
|
||||
bool CheckGetSwitchCounterDataArgs(Action action)
|
||||
{
|
||||
return (StartStop == Command.None || StartStop == Command.GetSwitchCounterData);
|
||||
}
|
||||
|
||||
///----------------------------------------------------------------------------------------------
|
||||
void SetArgs(Action action)
|
||||
{
|
||||
@@ -394,15 +498,20 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
|
||||
switch (action.ActionId)
|
||||
{
|
||||
case ActionID.ChangeRoute: SetChangeRouteArgs(action); return;
|
||||
case ActionID.MeasureFlow: SetMeasureFlowArgs(action); return;
|
||||
case ActionID.SetFlow: SetSetFlowArgs(action); return;
|
||||
case ActionID.StartTest: SetStartTestArgs(action); return;
|
||||
case ActionID.Stop: SetStopArgs(action); return;
|
||||
case ActionID.RegVlvIncrMove: SetRegVlvIncrMoveArgs(action); return;
|
||||
case ActionID.RegVlvMoveToPos: SetRegVlvMoveToPosArgs(action); return;
|
||||
case ActionID.RegVlvStop: SetRegVlvStopArgs(action); return;
|
||||
case ActionID.SwitchDiverter: SetSwitchDiverterArgs(action); return;
|
||||
case ActionID.ChangeRoute: SetChangeRouteArgs(action); return;
|
||||
case ActionID.MeasureFlow: SetMeasureFlowArgs(action); return;
|
||||
case ActionID.SetFlow: SetSetFlowArgs(action); return;
|
||||
case ActionID.StartTest: SetStartTestArgs(action); return;
|
||||
case ActionID.Stop: SetStopArgs(action); return;
|
||||
case ActionID.RegVlvIncrMove: SetRegVlvIncrMoveArgs(action); return;
|
||||
case ActionID.RegVlvMoveToPos: SetRegVlvMoveToPosArgs(action); return;
|
||||
case ActionID.RegVlvStop: SetRegVlvStopArgs(action); return;
|
||||
case ActionID.SwitchDiverter: SetSwitchDiverterArgs(action); return;
|
||||
case ActionID.DelayStartOrStop: SetDelayStartOrStopArgs(action); return;
|
||||
case ActionID.GetDiverterTransitionData: SetGetDiverterTransitionDataArgs(action); return;
|
||||
case ActionID.GetScopeAnalyzerData: SetGetScopeAnalyzerDataArgs(action); return;
|
||||
case ActionID.ResetScopeAnalyzer: SetResetScopeAnalyzerArgs(action); return;
|
||||
case ActionID.GetSwitchCounterData: SetGetSwitchCounterDataArgs(action); return;
|
||||
default: return;
|
||||
}
|
||||
}
|
||||
@@ -416,16 +525,21 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
{
|
||||
switch (action.ActionId)
|
||||
{
|
||||
case ActionID.RequestDataOnly: return true;
|
||||
case ActionID.ChangeRoute: return CheckSharedChangeRouteArgs(action);
|
||||
case ActionID.MeasureFlow: return CheckSharedMeasureFlowArgs(action);
|
||||
case ActionID.SetFlow: return CheckSharedSetFlowArgs(action);
|
||||
case ActionID.StartTest: return CheckSharedStartTestArgs(action);
|
||||
case ActionID.Stop: return CheckSharedStopArgs(action);
|
||||
case ActionID.RegVlvIncrMove: return CheckSharedRegVlvIncrMoveArgs(action);
|
||||
case ActionID.RegVlvMoveToPos: return CheckSharedRegVlvMoveToPosArgs(action);
|
||||
case ActionID.RegVlvStop: return CheckSharedRegVlvStopArgs(action);
|
||||
case ActionID.SwitchDiverter: return CheckSharedSwitchDiverterArgs(action);
|
||||
case ActionID.RequestDataOnly: return true;
|
||||
case ActionID.ChangeRoute: return CheckSharedChangeRouteArgs(action);
|
||||
case ActionID.MeasureFlow: return CheckSharedMeasureFlowArgs(action);
|
||||
case ActionID.SetFlow: return CheckSharedSetFlowArgs(action);
|
||||
case ActionID.StartTest: return CheckSharedStartTestArgs(action);
|
||||
case ActionID.Stop: return CheckSharedStopArgs(action);
|
||||
case ActionID.RegVlvIncrMove: return CheckSharedRegVlvIncrMoveArgs(action);
|
||||
case ActionID.RegVlvMoveToPos: return CheckSharedRegVlvMoveToPosArgs(action);
|
||||
case ActionID.RegVlvStop: return CheckSharedRegVlvStopArgs(action);
|
||||
case ActionID.SwitchDiverter: return CheckSharedSwitchDiverterArgs(action);
|
||||
case ActionID.DelayStartOrStop: return CheckDelayStartOrStopArgs(action);
|
||||
case ActionID.GetDiverterTransitionData: return CheckGetDiverterTransitionDataArgs(action);
|
||||
case ActionID.GetScopeAnalyzerData: return CheckGetScopeAnalyzerDataArgs(action);
|
||||
case ActionID.ResetScopeAnalyzer: return CheckResetScopeAnalyzerArgs(action);
|
||||
case ActionID.GetSwitchCounterData: return CheckGetSwitchCounterDataArgs(action);
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,38 @@
|
||||
///
|
||||
/// Copyright (c) 2021 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using log4net;
|
||||
using TBF.Rig.Sequences;
|
||||
using TBF.Rig.Uni.Diverter;
|
||||
|
||||
namespace TBF.Rig.ControlBoard.Uni
|
||||
{
|
||||
public class DivTransitionData
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(DivTransitionData));
|
||||
|
||||
/// Used in FrameFitsData(), etc.
|
||||
public const int MessageLen = 255;
|
||||
public const byte MessageCode = (byte)'K';
|
||||
|
||||
/// Associated diverter and plotter
|
||||
public static Diverter Diverter;
|
||||
public static bool ToTank;
|
||||
public static Statistics Plotter;
|
||||
public static int DiverterAssociationValidUntil;
|
||||
|
||||
/// Diverter transition data
|
||||
const int samplesCount = 245;
|
||||
int DiverterTime_ms;
|
||||
byte[] CurveRaw;
|
||||
public byte[] Samples;
|
||||
public int Resolution_ms;
|
||||
public int TransitionTime_ms;
|
||||
|
||||
const int SamplesCount = 247;
|
||||
|
||||
DivTransitionData()
|
||||
{
|
||||
CurveRaw = new byte[samplesCount];
|
||||
Samples = new byte[SamplesCount];
|
||||
Resolution_ms = Const.DivTimeResolution;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -47,13 +64,88 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
/// <param name="offset">Offset of the message</param>
|
||||
public static DivTransitionData GetData(byte[] rcvdData, int offset)
|
||||
{
|
||||
log.DebugFormat("DivTransitionDataGetData() ... Diverter = {0}, DiverterAssociationValidUntil-StateMachine.Time = {1}s left",
|
||||
(Diverter != null) ? Diverter.Name : "none", DiverterAssociationValidUntil - StateMachine.Time);
|
||||
|
||||
var data = new DivTransitionData();
|
||||
data.DiverterTime_ms = Const.DivTimeResolution * rcvdData[offset + 4];
|
||||
for (int i = 0; i < samplesCount; i++)
|
||||
for (int i = 0; i < SamplesCount; i++)
|
||||
{
|
||||
data.CurveRaw[i] = rcvdData[offset + 6 + i];
|
||||
data.Samples[i] = rcvdData[offset + 6 + i];
|
||||
}
|
||||
|
||||
if (Diverter != null && StateMachine.Time <= DiverterAssociationValidUntil)
|
||||
{
|
||||
data.TransitionTime_ms = Const.DivTimeResolution * CalculateDivTransitionTime(data.Samples, Diverter.ThresholdLo, Diverter.ThresholdHi);
|
||||
|
||||
log.DebugFormat("{0} transition time = {1} ms", Diverter.Name, data.TransitionTime_ms);
|
||||
|
||||
if (Plotter != null)
|
||||
{
|
||||
int rangeLo = Math.Min(Diverter.AdcValueToSink, Diverter.AdcValueToTank);
|
||||
int rangeHi = Math.Max(Diverter.AdcValueToSink, Diverter.AdcValueToTank);
|
||||
if (rangeLo != rangeHi)
|
||||
{
|
||||
float denominator = Convert.ToSingle(rangeHi - rangeLo);
|
||||
for (int i = 0; i < SamplesCount; i++)
|
||||
{
|
||||
float y = Convert.ToSingle(data.Samples[i] - rangeLo) / denominator;
|
||||
Plotter.Update(y);
|
||||
}
|
||||
}
|
||||
Plotter.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Analyze diverter transition data and calculate transition time
|
||||
/// </summary>
|
||||
/// <param name="samples">Raw data samples</param>
|
||||
/// <param name="thresholdLo">Threshod level Low</param>
|
||||
/// <param name="thresholdHi">Threshold level High</param>
|
||||
/// <returns>Transition time in sasmple periods</returns>
|
||||
static int CalculateDivTransitionTime(byte[] samples, int thresholdLo, int thresholdHi)
|
||||
{
|
||||
bool startedRising = false;
|
||||
bool startedFalling = false;
|
||||
bool stopped = false;
|
||||
|
||||
int transitionStartIdx = 0;
|
||||
int transitionEndIdx = 0;
|
||||
|
||||
int level = samples[0];
|
||||
for (int i = 1; i < SamplesCount; i++)
|
||||
{
|
||||
if (!startedRising && !startedFalling)
|
||||
{
|
||||
if (level <= thresholdLo && samples[i] > thresholdLo)
|
||||
{
|
||||
transitionStartIdx = i;
|
||||
startedRising = true;
|
||||
}
|
||||
else if (level >= thresholdHi && samples[i] < thresholdHi)
|
||||
{
|
||||
transitionStartIdx = i;
|
||||
startedFalling = true;
|
||||
}
|
||||
}
|
||||
else if (startedRising && !stopped && level < thresholdHi && samples[i] >= thresholdHi)
|
||||
{
|
||||
transitionEndIdx = i;
|
||||
stopped = true;
|
||||
break;
|
||||
}
|
||||
else if (startedFalling && !stopped && level > thresholdLo && samples[i] <= thresholdLo)
|
||||
{
|
||||
transitionEndIdx = i;
|
||||
stopped = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return transitionEndIdx - transitionStartIdx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -94,7 +94,11 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
|
||||
static byte GetCommand(Action action)
|
||||
{
|
||||
if (action.StartStop == Command.Start && action.IsProlonged)
|
||||
if (action.StartStop == Command.DelayStartOrStop)
|
||||
{
|
||||
return (byte)Command.None;
|
||||
}
|
||||
else if (action.StartStop == Command.Start && action.IsProlonged)
|
||||
{
|
||||
return (byte)(Command.Start | Command.ProlongedFlag);
|
||||
}
|
||||
@@ -140,6 +144,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
GetSwitchCounterData = 9,
|
||||
///
|
||||
ProlongedFlag = 0x10, /// Not a command of its own, a valid command is (byte)(Command.Start | Command.ProlongedFlag)
|
||||
DelayStartOrStop = 255, /// Prevents other start or stop command, results in Command.None when creating a message
|
||||
}
|
||||
|
||||
public enum StartParam : byte
|
||||
|
||||
@@ -331,12 +331,12 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
route = (route & ~bitsChangedByUI) | (displayedRoutePlusUI & bitsChangedByUI);
|
||||
bitsChangedByUI = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ((StateMachine.Time - lastReceivedTime) >= 5)
|
||||
{
|
||||
/// No connection to control board ... set indicator bit
|
||||
route |= ((UInt128)1) << cbCfg.BitNr;
|
||||
}
|
||||
if (cbCfg.DebugLevel == DebugMode.Normal && (StateMachine.Time - lastReceivedTime) >= 5)
|
||||
{
|
||||
/// No connection to control board ... set indicator bit
|
||||
route |= ((UInt128)1) << cbCfg.BitNr;
|
||||
}
|
||||
|
||||
///
|
||||
@@ -451,6 +451,9 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
Debug.WriteLine(s);
|
||||
log.Debug(s);
|
||||
}
|
||||
|
||||
log.DebugFormat(" Queue content:");
|
||||
foreach (var a in actionQueue) log.DebugFormat(" {0}", a);
|
||||
}
|
||||
|
||||
public void StopDevice()
|
||||
@@ -547,14 +550,11 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
/// </summary>
|
||||
/// <returns>Operation running a test</returns>
|
||||
public IOperation FlyingStartStopTestOp(Test test, double qFrom, double qTo, int pulsesCount, bool withDiverter = false,
|
||||
bool isProlonged = false, int massPulsesCount = 0, bool readDivTransition = true)
|
||||
bool isProlonged = false, int massPulsesCount = 0, bool readDivTransition = false,
|
||||
TBF.Rig.Sequences.Statistics plotterStart = null, TBF.Rig.Sequences.Statistics plotterEnd = null)
|
||||
{
|
||||
return new FlyingStartStopTestOp(this, devices, qFrom, qTo, pulsesCount, withDiverter, isProlonged, massPulsesCount, readDivTransition);
|
||||
}
|
||||
|
||||
public IOperation ReadDiverterTransitionOp(bool isStart, Sequences.Statistics plotter, int batchNr, string testName, int repetition)
|
||||
{
|
||||
return null;
|
||||
return new FlyingStartStopTestOp(this, devices, qFrom, qTo, pulsesCount, withDiverter, isProlonged, massPulsesCount,
|
||||
readDivTransition, plotterStart, plotterEnd);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -720,16 +720,66 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
{
|
||||
if (IsUIBlocked && isFromUI) return;
|
||||
|
||||
actionQueue.Enqueue(Action.SwitchDiverter(isFromUI, divNr1, toTank));
|
||||
log.InfoFormat("Enqueue( SwitchDiverter(div={0}, toTank={1}) )", divNr1, toTank);
|
||||
if (toTank)
|
||||
{
|
||||
actionQueue.Enqueue(Action.StartTest(isFromUI, 0, divNr1, 127, true, true, false, false, int.MaxValue, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
actionQueue.Enqueue(Action.Stop(isFromUI));
|
||||
}
|
||||
log.InfoFormat("Enqueue( SwitchDiverter(div#={0}, toTank={1}) )", divNr1, toTank);
|
||||
foreach (var a in actionQueue) log.DebugFormat(" {0}", a);
|
||||
}
|
||||
|
||||
public void ReadDiverterTransition(bool isFromUI, int divNr1)
|
||||
public void DelayStartOrStop(bool isFromUI)
|
||||
{
|
||||
if (IsUIBlocked && isFromUI) return;
|
||||
|
||||
/// TODO
|
||||
actionQueue.Enqueue(Action.DelayStartOrStop(isFromUI));
|
||||
log.InfoFormat("Enqueue( DelayStartOrStop() )");
|
||||
foreach (var a in actionQueue) log.DebugFormat(" {0}", a);
|
||||
}
|
||||
|
||||
public void GetDiverterTransitionData(bool isFromUI, TBF.Rig.Uni.Diverter.Diverter diverter, bool toTank,
|
||||
Statistics plotter = null)
|
||||
{
|
||||
if (IsUIBlocked && isFromUI) return;
|
||||
|
||||
DivTransitionData.Diverter = diverter;
|
||||
DivTransitionData.ToTank = toTank;
|
||||
DivTransitionData.Plotter = plotter;
|
||||
DivTransitionData.DiverterAssociationValidUntil = StateMachine.Time + 5;
|
||||
actionQueue.Enqueue(Action.GetDiverterTransitionData(isFromUI));
|
||||
log.InfoFormat("Enqueue( GetDiverterTransitionData(div#={0}, toTank={1}) )", diverter.DiverterNr, toTank);
|
||||
foreach (var a in actionQueue) log.DebugFormat(" {0}", a);
|
||||
}
|
||||
|
||||
public void GetScopeAnalyzerData(bool isFromUI)
|
||||
{
|
||||
if (IsUIBlocked && isFromUI) return;
|
||||
|
||||
actionQueue.Enqueue(Action.GetScopeAnalyzerData(isFromUI));
|
||||
log.InfoFormat("Enqueue( GetScopeAnalyzerData() )");
|
||||
foreach (var a in actionQueue) log.DebugFormat(" {0}", a);
|
||||
}
|
||||
|
||||
public void ResetScopeAnalyzer(bool isFromUI)
|
||||
{
|
||||
if (IsUIBlocked && isFromUI) return;
|
||||
|
||||
actionQueue.Enqueue(Action.ResetScopeAnalyzer(isFromUI));
|
||||
log.InfoFormat("Enqueue( ResetScopeAnalyzer() )");
|
||||
foreach (var a in actionQueue) log.DebugFormat(" {0}", a);
|
||||
}
|
||||
|
||||
public void GetSwitchCounterData(bool isFromUI)
|
||||
{
|
||||
if (IsUIBlocked && isFromUI) return;
|
||||
|
||||
actionQueue.Enqueue(Action.GetSwitchCounterData(isFromUI));
|
||||
log.InfoFormat("Enqueue( GetSwitchCounterData() )");
|
||||
foreach (var a in actionQueue) log.DebugFormat(" {0}", a);
|
||||
}
|
||||
|
||||
public void SetFiltersPidShortPulses(int[] filters, float pidCoef, int shortPulses)
|
||||
|
||||
Reference in New Issue
Block a user