EndCondition in transition steps is checked. Transition steps are finished when tank is empty.
This commit is contained in:
@@ -27,6 +27,11 @@ namespace TBF.BenchControl.GenericDevices
|
||||
/// </summary>
|
||||
bool IsEmpty(float mass);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if tank s empty, the last measured mass is less then some threshold
|
||||
/// </summary>
|
||||
bool IsEmpty();
|
||||
|
||||
/// <summary>
|
||||
/// Format string to be used as ToString() argument (e.g. "F3" to obtain resolution 1g)
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using log4net;
|
||||
|
||||
namespace TBF.BenchControl.MettlerToledo
|
||||
{
|
||||
public class KeepReadingMassesOp : IOperation
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(KeepReadingMassesOp));
|
||||
public override string ToString() { return string.Format("KeepReadingMassesOp()"); }
|
||||
|
||||
bool done;
|
||||
|
||||
/// <summary>
|
||||
/// Events: BalanceDone, Error
|
||||
/// </summary>
|
||||
/// <param name="balanceDev">Balance device instance</param>
|
||||
/// <param name="requiredReadingsCount">Required mass readings count (>= 3)</param>
|
||||
/// <param name="result">Reference to the measured mass in kg</param>
|
||||
public KeepReadingMassesOp()
|
||||
{
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
done = false;
|
||||
|
||||
for (int i = 0; i < Standard.BalanceDev.BalancesCount; i++)
|
||||
{
|
||||
Standard.BalanceDev.Balances[i].GetImmediateMassMeasurement();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Run this operation</summary>
|
||||
/// <returns>
|
||||
/// Event.None
|
||||
/// </returns>
|
||||
public Event Run()
|
||||
{
|
||||
if (done) return Event.BalanceDone; /// Mass has already been read
|
||||
|
||||
for (int i = 0; i < Standard.BalanceDev.BalancesCount; i++)
|
||||
{
|
||||
if (Standard.BalanceDev.Balances[i].MsrmntState != MsrmntState.Busy)
|
||||
{
|
||||
Standard.BalanceDev.Balances[i].GetImmediateMassMeasurement();
|
||||
}
|
||||
}
|
||||
return Event.None;
|
||||
}
|
||||
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,6 +106,11 @@ namespace TBF.BenchControl.MettlerToledo.Multi
|
||||
log.FatalFormat("Successfully initialized device {0}", ToString());
|
||||
}
|
||||
|
||||
public bool IsEmpty()
|
||||
{
|
||||
return (Mass <= balanceCfg.Empty);
|
||||
}
|
||||
|
||||
public bool IsEmpty(float mass)
|
||||
{
|
||||
return (mass <= balanceCfg.Empty);
|
||||
|
||||
@@ -104,6 +104,11 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
log.FatalFormat("Successfully initialized device {0}", ToString());
|
||||
}
|
||||
|
||||
public bool IsEmpty()
|
||||
{
|
||||
return (this.mass <= balanceCfg.Empty);
|
||||
}
|
||||
|
||||
public bool IsEmpty(float mass)
|
||||
{
|
||||
return (mass <= balanceCfg.Empty);
|
||||
|
||||
@@ -400,9 +400,12 @@ namespace TBF.BenchControl.Sequences
|
||||
if (context == TransitionContext.BeforeTest)
|
||||
{
|
||||
State.Create("SequenceBase : Transition : TestStart - Default action")
|
||||
.AddOperation(checkUiOp).AddOperation(StateMachine.ControlBoard
|
||||
.SetValvesOp(GenericDevices.ValveBase.Merge(inPath.ValvesOpen, benchPath.ValvesOpen, outPath.ValvesOpen),
|
||||
GenericDevices.ValveBase.Merge(inPath.ValvesClose, benchPath.ValvesClose, outPath.ValvesClose)))
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(new MettlerToledo.KeepReadingMassesOp())
|
||||
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
|
||||
.AddOperation(StateMachine.ControlBoard
|
||||
.SetValvesOp(GenericDevices.ValveBase.Merge(inPath.ValvesOpen, benchPath.ValvesOpen, outPath.ValvesOpen),
|
||||
GenericDevices.ValveBase.Merge(inPath.ValvesClose, benchPath.ValvesClose, outPath.ValvesClose)))
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
@@ -414,8 +417,11 @@ namespace TBF.BenchControl.Sequences
|
||||
else if (context == TransitionContext.AfterTest)
|
||||
{
|
||||
State.Create("SequenceBase : Transition : TestEnd - Default action")
|
||||
.AddOperation(checkUiOp).AddOperation(StateMachine.ControlBoard
|
||||
.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose))
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(new MettlerToledo.KeepReadingMassesOp())
|
||||
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
|
||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DefaultValvesOpen,
|
||||
StateMachine.DefaultValvesClose))
|
||||
.EnterState();
|
||||
do {
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
@@ -488,8 +494,11 @@ namespace TBF.BenchControl.Sequences
|
||||
for (int i = 0; i < rvPosOps.Count; i++)
|
||||
{
|
||||
log.DebugFormat("SequenceBase.Transition() : Step {0} start, opening={1}, closing={2}", step.ItemNr + 1, step.ValvesOpen, step.ValvesClose);
|
||||
State stepStrt = State.Create(string.Format("SequenceBase.Transition() : Step {0} start, opening={1}, closing={2}", step.ItemNr + 1, step.ValvesOpen, step.ValvesClose))
|
||||
State stepStrt = State
|
||||
.Create(string.Format("SequenceBase.Transition() : Step {0} start, opening={1}, closing={2}", step.ItemNr + 1, step.ValvesOpen, step.ValvesClose))
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(new MettlerToledo.KeepReadingMassesOp())
|
||||
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
|
||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(Utils.ValvesOpen(step), Utils.ValvesClose(step)));
|
||||
for (int j = 0; j <= i; j++)
|
||||
{
|
||||
@@ -507,9 +516,12 @@ namespace TBF.BenchControl.Sequences
|
||||
if (!(stopFlag || errorFlag))
|
||||
{
|
||||
log.DebugFormat("SequenceBase.Transition() : Step {0} delay {1}s, opening={2}, closing={3}", step.ItemNr + 1, delay, step.ValvesOpen, step.ValvesClose);
|
||||
State stepDelay = State.Create(string.Format("SequenceBase.Transition() : Step {0} delay {1}s, opening={2}, closing={3}", step.ItemNr + 1, delay, step.ValvesOpen, step.ValvesClose))
|
||||
State stepDelay = State
|
||||
.Create(string.Format("SequenceBase.Transition() : Step {0} delay {1}s, opening={2}, closing={3}", step.ItemNr + 1, delay, step.ValvesOpen, step.ValvesClose))
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(Utils.ValvesOpen(step), Utils.ValvesClose(step)))
|
||||
.AddOperation(new MettlerToledo.KeepReadingMassesOp())
|
||||
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
|
||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(Utils.ValvesOpen(step), Utils.ValvesClose(step)))
|
||||
.AddOperation(new TimerOp(delay));
|
||||
for (int j = 0; j <= lastStartedRV; j++)
|
||||
{
|
||||
@@ -517,13 +529,32 @@ namespace TBF.BenchControl.Sequences
|
||||
log.Debug(rvPosStr[j]);
|
||||
}
|
||||
stepDelay.EnterState();
|
||||
do
|
||||
bool endContitionFulfilled = false;
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error) || e.Contains(Event.RegulValveTimeOut)) { errorFlag = true; break; }
|
||||
if (e.Contains(Event.UiCmdStop)) { stopFlag = true; break; }
|
||||
|
||||
switch (step.EndCondition)
|
||||
{
|
||||
case Entities.StepCondition.Scale1Empty:
|
||||
endContitionFulfilled = (StateMachine.Balance1 == null) || StateMachine.Balance1.IsEmpty();
|
||||
break;
|
||||
case Entities.StepCondition.Scale2Empty:
|
||||
endContitionFulfilled = (StateMachine.Balance2 == null) || StateMachine.Balance2.IsEmpty();
|
||||
break;
|
||||
case Entities.StepCondition.Scale3Empty:
|
||||
endContitionFulfilled = (StateMachine.Balance3 == null) || StateMachine.Balance3.IsEmpty();
|
||||
break;
|
||||
case Entities.StepCondition.AllScalesEmpty:
|
||||
endContitionFulfilled = ((StateMachine.Balance1 == null) || StateMachine.Balance1.IsEmpty()) &&
|
||||
((StateMachine.Balance2 == null) || StateMachine.Balance2.IsEmpty()) &&
|
||||
((StateMachine.Balance3 == null) || StateMachine.Balance3.IsEmpty());
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (e.Contains(Event.TimerBusy) || e.Contains(Event.ValvesBusy));
|
||||
while (e.Contains(Event.ValvesBusy) || (!endContitionFulfilled && e.Contains(Event.TimerBusy)));
|
||||
}
|
||||
|
||||
for (int first = 1; first <= lastStartedRV; first++)
|
||||
@@ -531,7 +562,9 @@ namespace TBF.BenchControl.Sequences
|
||||
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))
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(Utils.ValvesOpen(step), Utils.ValvesClose(step)));
|
||||
.AddOperation(new MettlerToledo.KeepReadingMassesOp())
|
||||
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
|
||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(Utils.ValvesOpen(step), Utils.ValvesClose(step)));
|
||||
for (int j = first; j <= lastStartedRV; j++)
|
||||
{
|
||||
stepStop.AddOperation(rvPosOps[j]);
|
||||
@@ -556,9 +589,9 @@ namespace TBF.BenchControl.Sequences
|
||||
foreach (var fmPump in PumpsWithFM) fmPump.TurnOff();
|
||||
State.Create("SequenceBase : Test(s) completed -> Stopping the pump")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
|
||||
.AddOperation((inPath.Pump is GenericDevices.IPumpFM) ? (inPath.Pump as GenericDevices.IPumpFM).TurnOffOp() : null)
|
||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, inPath.Pump))
|
||||
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
|
||||
@@ -204,6 +204,7 @@
|
||||
<DependentUpon>TempMeterCfgCtrl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\Elde\TempMeterInternal\TempMeterFactory.cs" />
|
||||
<Compile Include="BenchControl\MettlerToledo\KeepReadingMassesOp.cs" />
|
||||
<Compile Include="BenchControl\MettlerToledo\Multi\BalanceCfg.cs" />
|
||||
<Compile Include="BenchControl\MettlerToledo\Multi\BalanceCfgCtrl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
|
||||
Reference in New Issue
Block a user