TransitionContext.AfterTestWithOverlap, PID coef. set earlier as well, nextHydroTest in MainSeq.
This commit is contained in:
parent
f1147031a1
commit
dbe87a375d
@ -234,6 +234,42 @@ namespace Config.Entities
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Processes the selection done by the bench control panel in the main sequence.
|
||||
/// </summary>
|
||||
/// <param name="selection">Selection.Q1, .Q2, .Q3 or .Test</param>
|
||||
/// <returns>The selected test or null</returns>
|
||||
public virtual Test GetTest(string expandedTestName, out int testIx, out int repetNr)
|
||||
{
|
||||
for (int ix = 0; ix < Tests.Count; ix++)
|
||||
{
|
||||
Test test = Tests[ix];
|
||||
if (test.Name.Equals(expandedTestName))
|
||||
{
|
||||
/// Name is not expanded => Repeats==1
|
||||
testIx = ix;
|
||||
repetNr = 1;
|
||||
return test;
|
||||
}
|
||||
|
||||
for (int r = 1; r <= test.Repeats; r++)
|
||||
{
|
||||
if (test.GetExpandedTestName(r).Equals(expandedTestName))
|
||||
{
|
||||
testIx = ix;
|
||||
repetNr = r;
|
||||
return test;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
testIx = 0;
|
||||
repetNr = 1;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0}, rev.{1}", Name, Revision);
|
||||
|
||||
@ -313,6 +313,33 @@ namespace Config.Entities
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return test title for a this test and a given repetition number
|
||||
/// </summary>
|
||||
/// <param name="repetitonNr">1 .. Nr. repetitions</param>
|
||||
/// <returns>Test title (string)</returns>
|
||||
public virtual string GetExpandedTestName(int repetitionNr)
|
||||
{
|
||||
if (Repeats == 1)
|
||||
{
|
||||
if (Part == 0)
|
||||
{
|
||||
/// Single test
|
||||
return Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
/// A part of a single test
|
||||
return string.Format("{0} ({1})", Name, Part);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/// More test repetitions
|
||||
return string.Format("{0} ({1}/{2})", Name, repetitionNr, Repeats);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual double GetErrLimLo(double volumeCTV, double testTime)
|
||||
{
|
||||
if (ErrLimLo <= ErrLimHi)
|
||||
|
||||
@ -207,7 +207,11 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
|
||||
/// <summary>Run this operation</summary>
|
||||
/// <returns>
|
||||
/// Event.None, Event.FlowReached, Event.RegulValveTimeOut, Event.OpArgumentError
|
||||
/// Event.OpArgumentError
|
||||
/// Event.Starting
|
||||
/// Event.Busy
|
||||
/// Event.FlowReached
|
||||
/// Event.RegulValveTimeOut
|
||||
/// </returns>
|
||||
public Event Run()
|
||||
{
|
||||
@ -251,12 +255,12 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
// '_regulValve.RegulValveCfg.PidCoef' replaced by a casted operation parameter 'pidCoef'
|
||||
controlBoard.SendCommand(Command.Start, flowMeter.Idx1, controlBoard.Route,
|
||||
int.MaxValue, int.MaxValue, tm, sd);
|
||||
return Event.None;
|
||||
return Event.Starting;
|
||||
}
|
||||
else if (opState == OpState.ValveMoveToPosition1)
|
||||
{
|
||||
opState = OpState.ValveMoveToPosition2;
|
||||
return Event.None;
|
||||
return Event.Starting;
|
||||
}
|
||||
else if (opState == OpState.ValveMoveToPosition2) /// Move to position
|
||||
{
|
||||
@ -266,7 +270,7 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
regulValve.StableTime);
|
||||
|
||||
opState = OpState.SettingPosition;
|
||||
return Event.None;
|
||||
return Event.Starting;
|
||||
}
|
||||
else if (opState == OpState.ValveMoveToPosition3)
|
||||
{
|
||||
@ -278,14 +282,14 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
{
|
||||
opState = OpState.SettingPosition;
|
||||
}
|
||||
return Event.None;
|
||||
return Event.Starting;
|
||||
}
|
||||
else if (opState == OpState.CheckStatePosition) /// Verify
|
||||
{
|
||||
if (((ulong)controlBoard.StatusP & (ulong)StatusP.RefPulsesMsrmnt) == 0)
|
||||
{
|
||||
opState = OpState.SendCommandAgain;
|
||||
return Event.None;
|
||||
return Event.Starting;
|
||||
}
|
||||
else if (controlBoard.RegulValveState(regulValveNr) != RegulValveState.DacValueRegul)
|
||||
{
|
||||
@ -298,12 +302,12 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
regulValveNr, targetPositionLo, targetPositionHi, regulValve.StableTime);
|
||||
|
||||
opState = OpState.ValveMoveToPosition3;
|
||||
return Event.None;
|
||||
return Event.Starting;
|
||||
}
|
||||
else
|
||||
{
|
||||
opState = OpState.SettingPosition;
|
||||
return Event.None;
|
||||
return Event.Starting;
|
||||
}
|
||||
}
|
||||
else if (opState == OpState.SettingPosition)
|
||||
@ -313,12 +317,12 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
{
|
||||
opState = OpState.ValveMoveToFlow1;
|
||||
}
|
||||
return Event.None;
|
||||
return Event.Starting;
|
||||
}
|
||||
else if (opState == OpState.ValveMoveToFlow1)
|
||||
{
|
||||
opState = OpState.ValveMoveToFlow2;
|
||||
return Event.None;
|
||||
return Event.Starting;
|
||||
}
|
||||
else if (opState == OpState.ValveMoveToFlow2) /// Move to flow
|
||||
{
|
||||
@ -340,7 +344,7 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
regulValve.StableTime);
|
||||
|
||||
opState = OpState.ValveMoveToFlow3;
|
||||
return Event.None;
|
||||
return Event.Starting;
|
||||
}
|
||||
else if (opState == OpState.ValveMoveToFlow3)
|
||||
{
|
||||
@ -352,7 +356,7 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
{
|
||||
opState = OpState.SettingFlow;
|
||||
}
|
||||
return Event.None;
|
||||
return Event.Starting;
|
||||
}
|
||||
else if (opState == OpState.CheckStateFlow) /// Verify the flow setting
|
||||
{
|
||||
@ -360,7 +364,7 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
(controlBoard.RegulValveState(regulValveNr) & RegulValveState.PwOrFreqRegul) != RegulValveState.PwOrFreqRegul)
|
||||
{
|
||||
opState = OpState.SendCommandAgain;
|
||||
return Event.None;
|
||||
return Event.Starting;
|
||||
}
|
||||
else if (controlBoard.RegulValveState(regulValveNr) != RegulValveState.PwOrFreqRegul)
|
||||
{
|
||||
@ -375,12 +379,12 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
regulValveNr, freqLo, freqHi, regulValve.StableTime);
|
||||
|
||||
opState = OpState.ValveMoveToFlow3;
|
||||
return Event.None;
|
||||
return Event.Starting;
|
||||
}
|
||||
else
|
||||
{
|
||||
opState = OpState.SettingFlow;
|
||||
return Event.None;
|
||||
return Event.Busy;
|
||||
}
|
||||
}
|
||||
else if (opState == OpState.SettingFlow)
|
||||
@ -423,7 +427,7 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
else
|
||||
{
|
||||
log.InfoFormat("flow = {0} m3/h (lo={1}, hi={2}, FLOW_OK_TIMER={3}s)", flow, currentReqFlowLo, currentReqFlowHi, flowWithinBoundsTime);
|
||||
return Event.None;
|
||||
return Event.Busy;
|
||||
}
|
||||
}
|
||||
else if (StateMachine.Time > expireTime)
|
||||
@ -434,7 +438,7 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
{
|
||||
log.InfoFormat("flow = {0} m3/h (lo={1}, hi={2})", flow, currentReqFlowLo, currentReqFlowHi);
|
||||
flowWithinBoundsTime = 0;
|
||||
return Event.None;
|
||||
return Event.Busy;
|
||||
}
|
||||
}
|
||||
else /// opState == OpState.FlowReached
|
||||
|
||||
@ -73,6 +73,7 @@ namespace TBF.BenchControl
|
||||
public enum Event
|
||||
{
|
||||
None = 0,
|
||||
Starting, /// During initial phase of some process, sending a command to a device, etc.
|
||||
Busy, /// Useful when waiting in state until at least one is busy (all are done)
|
||||
Done, /// Useful when waiting in state until the first is done, the rest miht still be busy
|
||||
MakeSecondPass, /// Test completed OK but 2nd pass (evaluation) is required
|
||||
|
||||
@ -819,9 +819,9 @@ namespace TBF.BenchControl.Sequences
|
||||
{
|
||||
//--------------------------------
|
||||
State.Create("MainSeq : Continue in the cycle?")
|
||||
.AddOperation(new Operations.AskYesNoOp(Strings.Continue_in_the_cycle))
|
||||
.AddOperation(checkUiOp)
|
||||
.EnterState();
|
||||
.AddOperation(new Operations.AskYesNoOp(Strings.Continue_in_the_cycle))
|
||||
.AddOperation(checkUiOp)
|
||||
.EnterState();
|
||||
while (true)
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
@ -848,23 +848,14 @@ namespace TBF.BenchControl.Sequences
|
||||
///
|
||||
if (selection == Selection.RestOfCycle) /// ... otherwise
|
||||
{
|
||||
Test slctdTest = TBF.BenchControl.StateMachine.GetTest(selectedTestName, out repetNr);
|
||||
if (slctdTest == null)
|
||||
Test slctdTest = TBF.BenchControl.StateMachine.Procedure.GetTest(selectedTestName, out selsctedTestIx, out repetNr);
|
||||
if (slctdTest == null || (selsctedTestIx < simultWithPurgingCount)
|
||||
|| (selsctedTestIx >= StateMachine.Tests.Count - simultWithEvacuationCount))
|
||||
{
|
||||
/// Invalid test selection
|
||||
UiBridge.Bridge.OnError(this, string.Format("No test specified"));
|
||||
goto select_cycle_or_test;
|
||||
}
|
||||
|
||||
selsctedTestIx = -1;
|
||||
for (int i = simultWithPurgingCount; i < StateMachine.Tests.Count - simultWithEvacuationCount; i++)
|
||||
{
|
||||
if (slctdTest == StateMachine.Tests[i])
|
||||
{
|
||||
selsctedTestIx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (selsctedTestIx == -1) goto select_cycle_or_test; /// goto ... when selection is not valid
|
||||
}
|
||||
|
||||
|
||||
@ -878,8 +869,8 @@ namespace TBF.BenchControl.Sequences
|
||||
|
||||
/// Try to fetch all test paths and transitions
|
||||
/// to detect configuration errors as early as possible.
|
||||
string errorMsg;
|
||||
TBF.BenchControl.Generic.IComponent testMethodComp = TbfComponents.FindComponent(test.Method);
|
||||
TBF.BenchControl.Generic.IComponent testMethodComp = TbfComponents.FindComponent(test.Method);
|
||||
string errorMsg;
|
||||
if (!(testMethodComp is TBF.BenchControl.TestMethods.OuterLoop.Start.Component) &&
|
||||
!(testMethodComp is TBF.BenchControl.TestMethods.OuterLoop.End.Component) &&
|
||||
!StateMachine.GetPaths(test, (StateMachine.Procedure.MetersKind == MetersKind.HeatMeter),
|
||||
@ -899,15 +890,65 @@ namespace TBF.BenchControl.Sequences
|
||||
int outerLoopRepeats = 0;
|
||||
while (currentTestIx < StateMachine.Tests.Count - simultWithEvacuationCount)
|
||||
{
|
||||
Test test = StateMachine.Tests[currentTestIx];
|
||||
Test nextTest = (currentTestIx + 1 < StateMachine.Tests.Count - simultWithEvacuationCount)
|
||||
? StateMachine.Tests[currentTestIx + 1]
|
||||
: null;
|
||||
|
||||
/// Fetch the test paths and transitions
|
||||
string errorMsg;
|
||||
TBF.BenchControl.Generic.IComponent testMethodComp = TbfComponents.FindComponent(test.Method);
|
||||
if (!(testMethodComp is TBF.BenchControl.TestMethods.OuterLoop.Start.Component) &&
|
||||
Test nextHydroTest = null;
|
||||
for (int i = currentTestIx + 1; i < StateMachine.Tests.Count - simultWithEvacuationCount; i++)
|
||||
{
|
||||
Test tst = StateMachine.Tests[i];
|
||||
if (tst != null)
|
||||
{
|
||||
ITestMethod tm = TbfComponents.FindComponent(tst.Method) as ITestMethod;
|
||||
if (tm != null && tm.DoTransitions())
|
||||
{
|
||||
nextHydroTest = tst;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nextHydroTest != null)
|
||||
{
|
||||
/// Fetch paths and 'transition before' of the next test
|
||||
TBF.BenchControl.Generic.IComponent nextTestMethodComp = TbfComponents.FindComponent(nextHydroTest.Method);
|
||||
TransitionSequence dummy2, dummy3;
|
||||
string errorMsg2;
|
||||
if (!(nextTestMethodComp is TBF.BenchControl.TestMethods.OuterLoop.Start.Component) &&
|
||||
!(nextTestMethodComp is TBF.BenchControl.TestMethods.OuterLoop.End.Component) &&
|
||||
!StateMachine.GetPaths(nextHydroTest, (StateMachine.Procedure.MetersKind == MetersKind.HeatMeter),
|
||||
out nextInPath, out nextBenchPath, out nextOutPath, out nextSensPath,
|
||||
out nextHeatMetersPath,
|
||||
out nextTransitionBefore, out dummy2, out dummy3,
|
||||
out errorMsg2))
|
||||
{
|
||||
UiBridge.Bridge.OnError(this, errorMsg2);
|
||||
goto select_cycle_or_test;
|
||||
}
|
||||
|
||||
nextQfrom = nextHydroTest.Qfrom;
|
||||
nextQto = nextHydroTest.Qto;
|
||||
nextPumpPower = nextHydroTest.PumpPower;
|
||||
nextTolerRed = nextHydroTest.TolerRed;
|
||||
nextPidCoef = (nextOutPath != null) ? nextOutPath.PidCoef : 1.0F;
|
||||
}
|
||||
else
|
||||
{
|
||||
/// Clear paths and 'transition before' of the next test it does not exist
|
||||
nextInPath = null;
|
||||
nextBenchPath = null;
|
||||
nextOutPath = null;
|
||||
nextSensPath = null;
|
||||
nextHeatMetersPath = null;
|
||||
nextTransitionBefore = null;
|
||||
}
|
||||
|
||||
/// Fetch paths and transitions of this test
|
||||
Test test = StateMachine.Tests[currentTestIx];
|
||||
TBF.BenchControl.Generic.IComponent testMethodComp = TbfComponents.FindComponent(test.Method);
|
||||
string errorMsg;
|
||||
if (!(testMethodComp is TBF.BenchControl.TestMethods.OuterLoop.Start.Component) &&
|
||||
!(testMethodComp is TBF.BenchControl.TestMethods.OuterLoop.End.Component) &&
|
||||
!StateMachine.GetPaths(test, (StateMachine.Procedure.MetersKind == MetersKind.HeatMeter),
|
||||
out inPath, out benchPath, out outPath, out sensPath,
|
||||
@ -920,9 +961,12 @@ namespace TBF.BenchControl.Sequences
|
||||
}
|
||||
|
||||
/// Update format for the water mass
|
||||
Mass.Format = outPath.Scale.Format;
|
||||
StartMass.Format = outPath.Scale.Format;
|
||||
EndMass.Format = outPath.Scale.Format;
|
||||
if (outPath != null && outPath.Scale != null && !string.IsNullOrEmpty(outPath.Scale.Format))
|
||||
{
|
||||
Mass.Format = outPath.Scale.Format;
|
||||
StartMass.Format = outPath.Scale.Format;
|
||||
EndMass.Format = outPath.Scale.Format;
|
||||
}
|
||||
|
||||
|
||||
ITestMethod testMethod = testMethodComp as ITestMethod;
|
||||
@ -1008,7 +1052,10 @@ namespace TBF.BenchControl.Sequences
|
||||
if (testMethod.DoTransitions() && !e.Contains(Event.RecoverableError))
|
||||
{
|
||||
/// Make a transition after the last test repetition
|
||||
TransitionContext endContext = currentTestFinished ? TransitionContext.AfterTest : TransitionContext.Stop;
|
||||
TransitionContext endContext =
|
||||
!currentTestFinished ? TransitionContext.Stop
|
||||
: ((nextTransitionBefore != null) && (nextTransitionBefore.Name.ToLower().Contains("fastflow"))) ? TransitionContext.AfterTestWithOverlap
|
||||
: TransitionContext.AfterTest;
|
||||
rsltTransAfter = Transition(transitionAfter, endContext); /// Transition or SetRoute - end of test
|
||||
log.InfoFormat("Test {0}: Transition({1}, {2}) returned {3}", test.Name, (transitionAfter == null ? "null" : transitionAfter.Name), endContext, rsltTransAfter);
|
||||
}
|
||||
@ -1116,7 +1163,8 @@ namespace TBF.BenchControl.Sequences
|
||||
/// Single test will be executed
|
||||
|
||||
int repetNr;
|
||||
Test test = TBF.BenchControl.StateMachine.GetTest(selectedTestName, out repetNr);
|
||||
int testIx;
|
||||
Test test = TBF.BenchControl.StateMachine.Procedure.GetTest(selectedTestName, out testIx, out repetNr);
|
||||
if (test == null)
|
||||
{
|
||||
UiBridge.Bridge.OnError(this, string.Format("No test specified"));
|
||||
|
||||
@ -68,6 +68,21 @@ namespace TBF.BenchControl.Sequences
|
||||
protected static TransitionSequence transitionBetween;
|
||||
protected static TransitionSequence transitionAfter;
|
||||
|
||||
/// <summary>
|
||||
/// Advanced information about the next test
|
||||
/// </summary>
|
||||
protected static BenchControl.FeedingPath nextInPath;
|
||||
protected static BenchControl.BenchPath nextBenchPath;
|
||||
protected static BenchControl.OutputPath nextOutPath;
|
||||
protected static BenchControl.MetersPath nextSensPath;
|
||||
protected static BenchControl.HeatMetersPath nextHeatMetersPath;
|
||||
protected static TransitionSequence nextTransitionBefore;
|
||||
protected static float nextQfrom;
|
||||
protected static float nextQto;
|
||||
protected static float nextPumpPower;
|
||||
protected static float nextPidCoef;
|
||||
protected static double nextTolerRed;
|
||||
|
||||
|
||||
protected IOperation readRegistersOp;
|
||||
protected IOperation queryEnd1;
|
||||
@ -439,10 +454,11 @@ namespace TBF.BenchControl.Sequences
|
||||
public enum TransitionContext
|
||||
{
|
||||
PurgeBegin,
|
||||
BeforeTest,
|
||||
BetweenTests,
|
||||
AfterTest,
|
||||
PurgeEnd,
|
||||
BeforeTest, /// Before starting a test, paths are always applied aftr this sequence
|
||||
BetweenTests, /// Between two repetitions of the same test
|
||||
AfterTest, /// After completing a test
|
||||
AfterTestWithOverlap, /// After completing transition sequence paths of the next test are selected and flow setting starts
|
||||
PurgeEnd,
|
||||
Stop,
|
||||
}
|
||||
|
||||
@ -482,7 +498,12 @@ namespace TBF.BenchControl.Sequences
|
||||
case TransitionContext.PurgeBegin: message = Strings.Purging_i_n; break;
|
||||
case TransitionContext.BeforeTest: message = Strings.Test_start_sequence_i_n; break;
|
||||
case TransitionContext.BetweenTests: message = Strings.Between_tests_sequence_i_n; break;
|
||||
case TransitionContext.AfterTest: message = Strings.Test_stop_sequence_i_n; break;
|
||||
|
||||
case TransitionContext.AfterTestWithOverlap:
|
||||
case TransitionContext.AfterTest:
|
||||
message = Strings.Test_stop_sequence_i_n;
|
||||
break;
|
||||
|
||||
case TransitionContext.PurgeEnd: message = Strings.Emptying_i_n; break;
|
||||
case TransitionContext.Stop: message = Strings.Test_stop_sequence_i_n; break;
|
||||
default: message = "Transition"; break;
|
||||
@ -495,7 +516,7 @@ namespace TBF.BenchControl.Sequences
|
||||
///
|
||||
/// No transition sequence defined --> Default action
|
||||
///
|
||||
if (context == TransitionContext.AfterTest)
|
||||
if ((context == TransitionContext.AfterTest) || (context == TransitionContext.AfterTestWithOverlap))
|
||||
{
|
||||
if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOff();
|
||||
|
||||
@ -680,7 +701,8 @@ namespace TBF.BenchControl.Sequences
|
||||
for (int first = 1; first <= lastStartedRV; first++)
|
||||
{
|
||||
log.DebugFormat("SequenceBase.Transition() : Step {0} stop, opening={1}, closing={2}", step.ItemNr + 1, step.ValvesOpen, step.ValvesClose);
|
||||
State stepStop = State.Create(string.Format("SequenceBase.Transition() : Step {0} stop, opening={1}, closing={2}", step.ItemNr + 1, step.ValvesOpen, step.ValvesClose))
|
||||
State stepStop = State
|
||||
.Create(string.Format("SequenceBase.Transition() : Step {0} stop, opening={1}, closing={2}", step.ItemNr + 1, step.ValvesOpen, step.ValvesClose))
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(conditionOperation)
|
||||
.AddOperation(new MettlerToledo.KeepReadingMassesOp())
|
||||
@ -717,11 +739,10 @@ namespace TBF.BenchControl.Sequences
|
||||
/// Stop the pump
|
||||
///
|
||||
State.Create("SequenceBase.Transition() : Test stopped -> Stopping the pump")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, inPath.Pump))
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, inPath.Pump))
|
||||
.EnterState();
|
||||
do {
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) return Event.Error;
|
||||
}
|
||||
@ -730,17 +751,19 @@ namespace TBF.BenchControl.Sequences
|
||||
}
|
||||
else if (context == TransitionContext.BeforeTest)
|
||||
{
|
||||
if (inPath != null && benchPath != null && outPath != null)
|
||||
///
|
||||
/// Always set route at the beginning of this test
|
||||
///
|
||||
if (inPath != null && benchPath != null && outPath != null)
|
||||
{
|
||||
State.Create("SequenceBase : Transition : TestStart - Default action")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(new MettlerToledo.KeepReadingMassesOp())
|
||||
.AddOperation(StateMachine.ControlBoard
|
||||
.SetValvesOp(GenericDevices.ValveBase.Merge(inPath.ValvesOpen, benchPath.ValvesOpen, outPath.ValvesOpen),
|
||||
GenericDevices.ValveBase.Merge(inPath.ValvesClose, benchPath.ValvesClose, outPath.ValvesClose)))
|
||||
.SetValvesOp(GenericDevices.ValveBase.Merge(inPath.ValvesOpen, benchPath.ValvesOpen, outPath.ValvesOpen),
|
||||
GenericDevices.ValveBase.Merge(inPath.ValvesClose, benchPath.ValvesClose, outPath.ValvesClose)))
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
do {
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) return Event.Error;
|
||||
if (TestAndLogUiCmdStop(e)) return Event.UiCmdStop;
|
||||
@ -748,8 +771,54 @@ namespace TBF.BenchControl.Sequences
|
||||
while (e.Contains(Event.ValvesBusy));
|
||||
}
|
||||
}
|
||||
else if ((context == TransitionContext.AfterTestWithOverlap) && (nextInPath != null) && (nextBenchPath != null) && (nextOutPath != null))
|
||||
{
|
||||
/// Set route for the next test
|
||||
State.Create("SequenceBase : AfterTestWithOverlap : Default action")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(new MettlerToledo.KeepReadingMassesOp())
|
||||
.AddOperation(StateMachine.ControlBoard
|
||||
.SetValvesOp(GenericDevices.ValveBase.Merge(nextInPath.ValvesOpen, nextBenchPath.ValvesOpen, nextOutPath.ValvesOpen),
|
||||
GenericDevices.ValveBase.Merge(nextInPath.ValvesClose, nextBenchPath.ValvesClose, nextOutPath.ValvesClose)))
|
||||
.EnterState();
|
||||
do {
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) return Event.Error;
|
||||
if (TestAndLogUiCmdStop(e)) return Event.UiCmdStop;
|
||||
}
|
||||
while (e.Contains(Event.ValvesBusy));
|
||||
|
||||
|
||||
/// Set PID coefficient, etc.
|
||||
int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
StateMachine.ControlBoard.SetFiltersPidShortPulses(filters, nextPidCoef, (nextTolerRed == 0) ? 0 : 1);
|
||||
|
||||
/// Set pump power
|
||||
if (nextInPath.Pump is GenericDevices.IPumpFM) (nextInPath.Pump as GenericDevices.IPumpFM).TurnOn(nextPumpPower);
|
||||
|
||||
//------------------------------------------------
|
||||
Bridge.OnActivity(this, Strings.Setting_the_flow);
|
||||
//------------------------------------------------
|
||||
/// Set flow for the next test
|
||||
State.Create(string.Format("SequenceBase : AfterTestWithOverlap - Setting the flow to {0} - {1} m3/h", nextQfrom, nextQto))
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(new MettlerToledo.KeepReadingMassesOp())
|
||||
.AddOperation(nextOutPath.RegulValve.SetFlowAndMeasureOp(nextOutPath.FlowMeter, nextQfrom, nextQto, RefFlow, FlowSettingTimeoutSec, 0))
|
||||
.EnterState();
|
||||
do {
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
|
||||
if (e.Contains(Event.OpArgumentError)) return Event.Error;
|
||||
if (TestAndLogUiCmdStop(e)) return Event.UiCmdStop;
|
||||
if (e.Contains(Event.RegulValveTimeOut))
|
||||
{
|
||||
Bridge.OnError(this, Strings.Flow_adjustment_failed);
|
||||
return Event.UiCmdStop;
|
||||
}
|
||||
}
|
||||
while (!e.Contains(Event.Busy) && !e.Contains(Event.FlowReached));
|
||||
}
|
||||
|
||||
if (errorFlag)
|
||||
return Event.Error;
|
||||
else if (stopFlag)
|
||||
@ -866,6 +935,114 @@ namespace TBF.BenchControl.Sequences
|
||||
}
|
||||
|
||||
|
||||
protected Event SetFlowEtc(Test test, IFlowMeter flowMeter, IRegulValve regulValve, IValve pump, IValve stopBFValve, IList<IOperation> extraOperations, bool doNotWait)
|
||||
{
|
||||
IList<Event> e;
|
||||
Event retVal = Event.Done;
|
||||
|
||||
if (pump is GenericDevices.IPumpFM) (pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower);
|
||||
///
|
||||
State.Create(string.Format("{0}({1}) : Starting the pump", test.Method, test.Name))
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperations(extraOperations)
|
||||
.AddOperation(pump != null ? StateMachine.ControlBoard.SetValvesOp(pump, null) : null)
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
//Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
|
||||
//Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
|
||||
|
||||
if (TestAndLogUiCmdStop(e)) return Event.UiCmdStop;
|
||||
if (e.Contains(Event.Error)) return Event.Error;
|
||||
}
|
||||
while (e.Contains(Event.ValvesBusy) /* || !e.Contains(Event.AllPositionsReached)*/);
|
||||
|
||||
|
||||
if (test.TimePump2StartV > 0)
|
||||
{
|
||||
State.Create(string.Format("{0}({1}) : Waiting after the pump started", test.Method, test.Name))
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(new Operations.TimerOp(test.TimePump2StartV))
|
||||
.AddOperations(extraOperations)
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
//Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
|
||||
//Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
|
||||
|
||||
if (TestAndLogUiCmdStop(e)) return Event.UiCmdStop;
|
||||
}
|
||||
while (!e.Contains(Event.TimerExpired));
|
||||
}
|
||||
|
||||
|
||||
if (stopBFValve != null)
|
||||
{
|
||||
State.Create(string.Format("{0}({1}) : Opening the stop backflow valve", test.Method, test.Name))
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(stopBFValve, null))
|
||||
.AddOperations(extraOperations)
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (TestAndLogUiCmdStop(e)) return Event.UiCmdStop;
|
||||
if (e.Contains(Event.Error)) return Event.Error;
|
||||
}
|
||||
while (!e.Contains(Event.ValvesSet));
|
||||
}
|
||||
|
||||
|
||||
if (test.TimeBeforeFlow > 0)
|
||||
{
|
||||
State.Create(string.Format("{0}({1}) : Waiting before flow setting process starts", test.Method, test.Name))
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(new Operations.TimerOp(test.TimeBeforeFlow))
|
||||
.AddOperations(extraOperations)
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
//Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
|
||||
//Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
|
||||
|
||||
if (TestAndLogUiCmdStop(e)) return Event.UiCmdStop;
|
||||
}
|
||||
while (!e.Contains(Event.TimerExpired));
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
Bridge.OnActivity(this, Strings.Setting_the_flow);
|
||||
//------------------------------------------------
|
||||
State.Create(string.Format("{0}({1}) : Setting the flow", test.Method, test.Name))
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(doNotWait ? regulValve.SetFlowAndMeasureOp(flowMeter, test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec, 0)
|
||||
: regulValve.SetFlowOp(flowMeter, test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec))
|
||||
.AddOperations(extraOperations)
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
//Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
|
||||
//Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
|
||||
|
||||
if (e.Contains(Event.OpArgumentError)) return Event.OpArgumentError;
|
||||
if (TestAndLogUiCmdStop(e)) return Event.UiCmdStop;
|
||||
if (e.Contains(Event.RegulValveTimeOut))
|
||||
{
|
||||
Bridge.OnError(this, Strings.Flow_adjustment_failed);
|
||||
return Event.RecoverableError;
|
||||
}
|
||||
if (e.Contains(Event.Next)) return Event.Done;
|
||||
}
|
||||
while (!(e.Contains(Event.FlowReached) || (doNotWait && e.Contains(Event.Busy)))); /// Stay in the loop while e.Contains(Event.Starting)
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Main loop where measurements are collected.
|
||||
/// </summary>
|
||||
@ -1631,7 +1808,7 @@ namespace TBF.BenchControl.Sequences
|
||||
/// <summary>
|
||||
/// Returns true and makes a log when 'e' contains Event.UiCmdStop
|
||||
/// </summary>
|
||||
/// <param name="test"></param>
|
||||
/// <param name="test">test or null (only for logs)</param>
|
||||
/// <param name="e"></param>
|
||||
/// <returns></returns>
|
||||
protected bool TestAndLogUiCmdStop(Test test, IList<Event> e)
|
||||
|
||||
@ -574,31 +574,6 @@ namespace TBF.BenchControl
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes the selection done by the bench control panel in the main sequence.
|
||||
/// </summary>
|
||||
/// <param name="selection">Selection.Q1, .Q2, .Q3 or .Test</param>
|
||||
/// <returns>The selected test or null</returns>
|
||||
public static Config.Entities.Test GetTest(string selectedTestName, out int repetNr)
|
||||
{
|
||||
repetNr = 1;
|
||||
foreach (var test in Tests)
|
||||
{
|
||||
if (test.Name.Equals(selectedTestName)) return test; /// Test name specified, keep repetNr = 1
|
||||
|
||||
for (int i = 1; i <= test.Repeats; i++)
|
||||
{
|
||||
if (Utils.TestTitle(test, i).Equals(selectedTestName))
|
||||
{
|
||||
repetNr = i;
|
||||
return test;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called from the sequence to update paths based on the selected test
|
||||
/// </summary>
|
||||
@ -623,6 +598,9 @@ namespace TBF.BenchControl
|
||||
out TransitionSequence transitionAfter,
|
||||
out string errorMsg)
|
||||
{
|
||||
ITestMethod tm = TbfComponents.FindComponent(test.Method) as ITestMethod;
|
||||
bool isHydroTest = (tm != null) ? tm.DoTransitions() : false;
|
||||
|
||||
pfeed = null;
|
||||
pben = null;
|
||||
pout = null;
|
||||
@ -648,12 +626,12 @@ namespace TBF.BenchControl
|
||||
|
||||
pmtrs = GetMetersPath(test);
|
||||
|
||||
if (pfeed == null) errorMsg = Strings.Cannot_load_feeding_path;
|
||||
else if (pben == null) errorMsg = Strings.Cannot_load_bench_path;
|
||||
else if (pout == null) errorMsg = Strings.Cannot_load_output_path;
|
||||
if (isHydroTest && (pfeed == null)) errorMsg = Strings.Cannot_load_feeding_path;
|
||||
else if (isHydroTest && (pben == null)) errorMsg = Strings.Cannot_load_bench_path;
|
||||
else if (isHydroTest && (pout == null)) errorMsg = Strings.Cannot_load_output_path;
|
||||
else if (pmtrs == null) errorMsg = Strings.Cannot_load_sensor_path;
|
||||
else errorMsg = string.Empty;
|
||||
if ((pfeed == null) || (pben == null) || (pout == null) || (pmtrs == null))
|
||||
if ((isHydroTest && (pfeed == null || pben == null || pout == null)) || (pmtrs == null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -677,7 +655,7 @@ namespace TBF.BenchControl
|
||||
if (tr.Name == test.TransitionAfter) transitionAfter = tr;
|
||||
}
|
||||
|
||||
if (pout.Scale == null)
|
||||
if (isHydroTest && pout.Scale == null)
|
||||
{
|
||||
errorMsg = string.Format("No balance specified in path {0}", test.OutputPath);
|
||||
return false;
|
||||
|
||||
@ -693,11 +693,19 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
UpdateRfidCommResult(tests); /// TODO: Pass the test info in a correct way
|
||||
}
|
||||
|
||||
long checkboxStates = GetCheckBoxStates();
|
||||
if (Program.LocalSettings.iPerlCommunicationsFormLeft != Location.X ||
|
||||
Program.LocalSettings.iPerlCommunicationsFormTop != Location.Y ||
|
||||
Program.LocalSettings.iPerlCommunicationsFormCheckboxes != checkboxStates)
|
||||
{
|
||||
/// Update local settings
|
||||
Program.LocalSettings.iPerlCommunicationsFormLeft = Location.X;
|
||||
Program.LocalSettings.iPerlCommunicationsFormTop = Location.Y;
|
||||
Program.LocalSettings.iPerlCommunicationsFormCheckboxes = checkboxStates;
|
||||
Program.LocalSettings.Save();
|
||||
}
|
||||
|
||||
formCompleted = true;
|
||||
Program.LocalSettings.iPerlCommunicationsFormLeft = Location.X;
|
||||
Program.LocalSettings.iPerlCommunicationsFormTop = Location.Y;
|
||||
Program.LocalSettings.iPerlCommunicationsFormCheckboxes = GetCheckBoxStates();
|
||||
Program.LocalSettings.Save();
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
|
||||
@ -186,7 +186,7 @@ namespace TBF.UI.Shared
|
||||
{
|
||||
for (int i = 1; i <= test.Repeats; i++)
|
||||
{
|
||||
testComboBox.Items.Add(Utils.TestTitle(test, i));
|
||||
testComboBox.Items.Add(test.GetExpandedTestName(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -121,7 +121,7 @@ namespace TBF.UI
|
||||
|
||||
string test2Name = global::Results.Utils.GetTestName(test2.Name, test2.Repeats, r);
|
||||
TestProgressCtrl progress =
|
||||
new TestProgressCtrl(test2.Id, test2Name, test2.Part, Utils.TestTitle(test2, r), r, test2.Repeats);
|
||||
new TestProgressCtrl(test2.Id, test2Name, test2.Part, test2.GetExpandedTestName(r), r, test2.Repeats);
|
||||
progresses.Add(progress);
|
||||
parent.Controls.Add(progress);
|
||||
Console.WriteLine(test2Name);
|
||||
@ -131,7 +131,7 @@ namespace TBF.UI
|
||||
{
|
||||
string testName = global::Results.Utils.GetTestName(test.Name, test.Repeats, r);
|
||||
TestProgressCtrl progress =
|
||||
new TestProgressCtrl(test.Id, testName, test.Part, Utils.TestTitle(test, r), r, test.Repeats);
|
||||
new TestProgressCtrl(test.Id, testName, test.Part, test.GetExpandedTestName(r), r, test.Repeats);
|
||||
progresses.Add(progress);
|
||||
parent.Controls.Add(progress);
|
||||
Console.WriteLine(testName);
|
||||
|
||||
26
TBF/Utils.cs
26
TBF/Utils.cs
@ -265,32 +265,6 @@ namespace TBF
|
||||
return wmPartNr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return test title for a given test and a repetition number
|
||||
/// </summary>
|
||||
/// <param name="test">Test entity</param>
|
||||
/// <param name="repetitonNr">1 .. Nr. repetitions</param>
|
||||
/// <returns>Test title (string)</returns>
|
||||
public static string TestTitle(Test test, int repetitonNr)
|
||||
{
|
||||
if (test.Repeats == 1)
|
||||
{
|
||||
if (test.Part == 0)
|
||||
{
|
||||
return test.Name; /// Single test
|
||||
}
|
||||
else
|
||||
{
|
||||
return string.Format("{0} ({1})", test.Name, test.Part); /// A part of a single test
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/// More test repetitions
|
||||
return string.Format("{0} ({1}/{2})", test.Name, repetitonNr, test.Repeats);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return test title for a given test data and a repetition number
|
||||
/// </summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user