Draining can be stopped by drain buttons, not by STOP button.
This commit is contained in:
@@ -119,7 +119,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
{
|
||||
serialNumber = fields[2].Substring(1, fields[2].Length - 2);
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.WarnFormat("{0} - Balance response = {1}, s/n = {1}", Name,
|
||||
log.WarnFormat("{0} - Balance response = {1}, s/n = {2}", Name,
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"), serialNumber);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -122,7 +122,10 @@ namespace TBF.BenchControl.Sequences
|
||||
}
|
||||
while (e.Contains(Event.ValvesBusy));
|
||||
|
||||
//--------------------------------------------------------------------------------------------
|
||||
|
||||
///
|
||||
/// Read S/N-s from scales (cannot be stopped, but is limitted to Scales count x 3s (=timeout)
|
||||
///
|
||||
IScale[] scales = new IScale[] { StateMachine.Scale1, StateMachine.Scale2, StateMachine.Scale3 };
|
||||
|
||||
foreach (var scale in scales)
|
||||
@@ -135,7 +138,6 @@ namespace TBF.BenchControl.Sequences
|
||||
if (getSNOp != null)
|
||||
{
|
||||
State.Create(string.Format("MainSeq : Reading S/N of scale {0}", scale.Name))
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(getSNOp)
|
||||
.AddOperation(new Operations.TimerOp(3))
|
||||
.EnterState();
|
||||
@@ -152,7 +154,6 @@ namespace TBF.BenchControl.Sequences
|
||||
Bridge.OnError(this, string.Format("{0} : {1}", scale.Name, Strings.Scale_communication_timeout));
|
||||
goto error;
|
||||
}
|
||||
if (e.Contains(Event.UiCmdStop)) goto stop;
|
||||
}
|
||||
while (e.Contains(Event.Busy));
|
||||
|
||||
@@ -161,8 +162,14 @@ namespace TBF.BenchControl.Sequences
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------
|
||||
IntBox remainingTime = new IntBox();
|
||||
///
|
||||
/// Drain tanls for the first time, use defined drain times
|
||||
///
|
||||
Bridge.Bench2UI(((StateMachine.Scale1 != null && StateMachine.DrainValve1 != null) ? ButtonsEtc.DrainTankBtn1Hi : 0) |
|
||||
((StateMachine.Scale2 != null && StateMachine.DrainValve2 != null) ? ButtonsEtc.DrainTankBtn2Hi : 0) |
|
||||
((StateMachine.Scale3 != null && StateMachine.DrainValve3 != null) ? ButtonsEtc.DrainTankBtn3Hi : 0));
|
||||
|
||||
IntBox remainingTime = new IntBox();
|
||||
State startNew = State.Create("MainSeq : Drain tanks")
|
||||
.AddOperation(checkUiOp);
|
||||
IList<IValve> allDrainValves = new List<IValve>();
|
||||
@@ -197,9 +204,8 @@ namespace TBF.BenchControl.Sequences
|
||||
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) goto error;
|
||||
if (e.Contains(Event.UiCmdStop) &&
|
||||
!e.Contains(Event.ValvesBusy) &&
|
||||
!e.Contains(Event.CameraBusy))
|
||||
bool stopDrainingCmd = e.Contains(Event.UiCmdStopDrainingTank1) || e.Contains(Event.UiCmdStopDrainingTank2) || e.Contains(Event.UiCmdStopDrainingTank3);
|
||||
if (stopDrainingCmd && !e.Contains(Event.ValvesBusy) && !e.Contains(Event.CameraBusy))
|
||||
{
|
||||
goto stop_draining;
|
||||
}
|
||||
@@ -214,7 +220,9 @@ namespace TBF.BenchControl.Sequences
|
||||
|
||||
stop_draining:
|
||||
//--------------------------------------------------------------------------------------------
|
||||
State stopDraining = State.Create("MainSeq : Stop draining water tanks")
|
||||
Bridge.Bench2UI(ButtonsEtc.StopBtnEn);
|
||||
|
||||
State stopDraining = State.Create("MainSeq : Stop draining water tanks")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, allDrainValves))
|
||||
.EnterState();
|
||||
@@ -1069,15 +1077,7 @@ namespace TBF.BenchControl.Sequences
|
||||
/// </summary>
|
||||
/// <param name="context">Context where MakeSelection() is called</param>
|
||||
/// <returns>
|
||||
/// Selection.PurgeBegin
|
||||
/// Selection.PurgeEnd
|
||||
/// Selection.Break
|
||||
/// Selection.Cycle
|
||||
/// Selection.Test
|
||||
/// Selection.Q1
|
||||
/// Selection.Q2
|
||||
/// Selection.Q3
|
||||
/// Selection.SaveResults
|
||||
/// Selection.PurgeBegin, PurgeEnd, Break, Cycle, Test, Q1, Q2, Q3 or SaveResults
|
||||
/// </returns>
|
||||
private Selection MakeSelection(MKSelContext context)
|
||||
{
|
||||
@@ -1095,38 +1095,31 @@ namespace TBF.BenchControl.Sequences
|
||||
|
||||
while (true)
|
||||
{
|
||||
/// Display an appropriate activity message
|
||||
if (draining1 || draining2 || draining3)
|
||||
{
|
||||
Bridge.OnActivity(this, Strings.Emptying_tank);
|
||||
}
|
||||
else if (context == MKSelContext.ProcedureNotSelected)
|
||||
{
|
||||
Bridge.OnActivity(this, Strings.Please_select_a_procedure);
|
||||
}
|
||||
else if (context == MKSelContext.InsideProcedure)
|
||||
{
|
||||
Bridge.OnActivity(this, Strings.Please_select_a_cycle_a_test_or_empty);
|
||||
}
|
||||
bool draining = draining1 || draining2 || draining3;
|
||||
|
||||
///
|
||||
/// Activity message
|
||||
///
|
||||
Bridge.OnActivity(this, draining ? Strings.Emptying_tank
|
||||
: ((context == MKSelContext.ProcedureNotSelected) ? Strings.Please_select_a_procedure
|
||||
: Strings.Please_select_a_cycle_a_test_or_empty));
|
||||
|
||||
bool saveResultsActive = (context == MKSelContext.InsideProcedure)
|
||||
&& (StateMachine.Procedure != null)
|
||||
&& (!StateMachine.Procedure.MustBeComplete || BatchRslts.AllTestsDone());
|
||||
&& (!StateMachine.Procedure.MustBeComplete || BatchRslts.AllTestsDone());
|
||||
|
||||
/// Enable appropriate UI controls and buttons
|
||||
Bridge.Bench2UI(((context == MKSelContext.ProcedureNotSelected) ? ButtonsEtc.ProcedureCmbBoxEn : 0) |
|
||||
ButtonsEtc.TestCmbBoxEn |
|
||||
ButtonsEtc.StopBtnEn |
|
||||
((context == MKSelContext.InsideProcedure) ? ButtonsEtc.Break : 0) |
|
||||
(saveResultsActive ? ButtonsEtc.AcceptResultsBtnEn : 0) |
|
||||
((draining1 || draining2 || draining3) ? 0 :
|
||||
(ButtonsEtc.StartCycleBtnEn |
|
||||
ButtonsEtc.StartTestBtnsEn |
|
||||
ButtonsEtc.PurgeBeginBtnEn |
|
||||
((context == MKSelContext.InsideProcedure) ? ButtonsEtc.PurgeEndBtnEn : 0))) |
|
||||
(((StateMachine.Scale1 != null) && (StateMachine.DrainValve1 != null) && !draining1) ? ButtonsEtc.DrainTankBtn1En : 0) |
|
||||
(((StateMachine.Scale2 != null) && (StateMachine.DrainValve2 != null) && !draining2) ? ButtonsEtc.DrainTankBtn2En : 0) |
|
||||
(((StateMachine.Scale3 != null) && (StateMachine.DrainValve3 != null) && !draining3) ? ButtonsEtc.DrainTankBtn3En : 0));
|
||||
(draining ? 0 : ButtonsEtc.StartCycleBtnEn) |
|
||||
(draining ? 0 : ButtonsEtc.StartTestBtnsEn) |
|
||||
(draining ? 0 : ButtonsEtc.PurgeBeginBtnEn) |
|
||||
(draining ? 0 : ((context == MKSelContext.InsideProcedure) ? ButtonsEtc.PurgeEndBtnEn : 0)) |
|
||||
((StateMachine.DrainValve1 == null) ? 0 : (draining1 ? ButtonsEtc.DrainTankBtn1Hi : ButtonsEtc.DrainTankBtn1En)) |
|
||||
((StateMachine.DrainValve2 == null) ? 0 : (draining2 ? ButtonsEtc.DrainTankBtn2Hi : ButtonsEtc.DrainTankBtn2En)) |
|
||||
((StateMachine.DrainValve3 == null) ? 0 : (draining3 ? ButtonsEtc.DrainTankBtn3Hi : ButtonsEtc.DrainTankBtn3En)));
|
||||
|
||||
|
||||
State.Create("MainSeq : Select an activity")
|
||||
@@ -1142,10 +1135,12 @@ namespace TBF.BenchControl.Sequences
|
||||
|
||||
/// Handled inside MakeSelection() inside the selection loop
|
||||
if (e.Contains(Event.Error)) break;
|
||||
if (e.Contains(Event.UiCmdStop)) break;
|
||||
if (e.Contains(Event.UiCmdDrainTank1)) break;
|
||||
if (e.Contains(Event.UiCmdDrainTank2)) break;
|
||||
if (e.Contains(Event.UiCmdDrainTank3)) break;
|
||||
if (!draining1 && e.Contains(Event.UiCmdDrainTank1)) break;
|
||||
if (!draining2 && e.Contains(Event.UiCmdDrainTank2)) break;
|
||||
if (!draining3 && e.Contains(Event.UiCmdDrainTank3)) break;
|
||||
if (draining1 && e.Contains(Event.UiCmdStopDrainingTank1)) break;
|
||||
if (draining2 && e.Contains(Event.UiCmdStopDrainingTank2)) break;
|
||||
if (draining3 && e.Contains(Event.UiCmdStopDrainingTank3)) break;
|
||||
if (draining1 && StateMachine.Scale1.IsEmpty(mass1.Val)) break;
|
||||
if (draining2 && StateMachine.Scale2.IsEmpty(mass2.Val)) break;
|
||||
if (draining3 && StateMachine.Scale3.IsEmpty(mass3.Val)) break;
|
||||
@@ -1175,97 +1170,64 @@ namespace TBF.BenchControl.Sequences
|
||||
.EnterState();
|
||||
while (true) StateMachine.WaitRunDevsRunOps(); /// Endless loop
|
||||
}
|
||||
else if (e.Contains(Event.UiCmdStop))
|
||||
else
|
||||
{
|
||||
if (draining1 || draining2 || draining3)
|
||||
{
|
||||
IList<IValve> valvesClose = new List<IValve>();
|
||||
if (draining1) valvesClose.Add(StateMachine.DrainValve1);
|
||||
if (draining2) valvesClose.Add(StateMachine.DrainValve2);
|
||||
if (draining3) valvesClose.Add(StateMachine.DrainValve3);
|
||||
string stateText = "MainSeq : ";
|
||||
IList<IValve> openValves = new List<IValve>();
|
||||
IList<IValve> closeValves = new List<IValve>();
|
||||
|
||||
State.Create("MainSeq : Close emptying valve(s)")
|
||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, valvesClose))
|
||||
.EnterState();
|
||||
do { e = StateMachine.WaitRunDevsRunOps(); }
|
||||
while (!e.Contains(Event.ValvesSet));
|
||||
draining1 = draining2 = draining3 = false;
|
||||
if (draining1 && (StateMachine.Scale1.IsEmpty(mass1.Val) || e.Contains(Event.UiCmdStopDrainingTank1)))
|
||||
{
|
||||
draining1 = false;
|
||||
closeValves.Add(StateMachine.DrainValve1);
|
||||
stateText = stateText + "close tank 1, ";
|
||||
}
|
||||
}
|
||||
else if (e.Contains(Event.UiCmdDrainTank1) && !draining1)
|
||||
{
|
||||
draining1 = true;
|
||||
///--------------------------------------------
|
||||
Bridge.OnActivity(this, Strings.Emptying_tank);
|
||||
///--------------------------------------------
|
||||
else if (draining2 && (StateMachine.Scale2.IsEmpty(mass2.Val) || e.Contains(Event.UiCmdStopDrainingTank2)))
|
||||
{
|
||||
draining2 = false;
|
||||
closeValves.Add(StateMachine.DrainValve2);
|
||||
stateText = stateText + "close tank 2, ";
|
||||
}
|
||||
else if (draining3 && (StateMachine.Scale3.IsEmpty(mass3.Val) || e.Contains(Event.UiCmdStopDrainingTank3)))
|
||||
{
|
||||
draining3 = false;
|
||||
closeValves.Add(StateMachine.DrainValve3);
|
||||
stateText = stateText + "close tank 3, ";
|
||||
}
|
||||
else if (!draining1 && e.Contains(Event.UiCmdDrainTank1))
|
||||
{
|
||||
draining1 = true;
|
||||
openValves.Add(StateMachine.DrainValve1);
|
||||
stateText = stateText + "open tank 1, ";
|
||||
}
|
||||
else if (!draining2 && e.Contains(Event.UiCmdDrainTank2))
|
||||
{
|
||||
draining2 = true;
|
||||
openValves.Add(StateMachine.DrainValve2);
|
||||
stateText = stateText + "open tank 2, ";
|
||||
}
|
||||
else if (!draining3 && e.Contains(Event.UiCmdDrainTank3))
|
||||
{
|
||||
draining3 = true;
|
||||
openValves.Add(StateMachine.DrainValve3);
|
||||
stateText = stateText + "open tank 3, ";
|
||||
}
|
||||
|
||||
draining = draining1 || draining2 || draining3;
|
||||
if (draining) Bridge.OnActivity(this, Strings.Emptying_tank);
|
||||
|
||||
Bridge.Bench2UI(((context == MKSelContext.ProcedureNotSelected) ? ButtonsEtc.ProcedureCmbBoxEn : 0) |
|
||||
ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn |
|
||||
(draining2 ? 0 : ButtonsEtc.DrainTankBtn2En) |
|
||||
(draining3 ? 0 : ButtonsEtc.DrainTankBtn3En));
|
||||
State.Create("MainSeq : Open tank 1")
|
||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DrainValve1, null))
|
||||
.EnterState();
|
||||
do { e = StateMachine.WaitRunDevsRunOps(); }
|
||||
while (!e.Contains(Event.ValvesSet));
|
||||
}
|
||||
else if (e.Contains(Event.UiCmdDrainTank2) && !draining2)
|
||||
{
|
||||
draining2 = true;
|
||||
///--------------------------------------------
|
||||
Bridge.OnActivity(this, Strings.Emptying_tank);
|
||||
///--------------------------------------------
|
||||
Bridge.Bench2UI(((context == MKSelContext.ProcedureNotSelected) ? ButtonsEtc.ProcedureCmbBoxEn : 0) |
|
||||
ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn |
|
||||
(draining1 ? 0 : ButtonsEtc.DrainTankBtn1En) |
|
||||
(draining3 ? 0 : ButtonsEtc.DrainTankBtn3En));
|
||||
State.Create("MainSeq : Open tank 2")
|
||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DrainValve2, null))
|
||||
.EnterState();
|
||||
do { e = StateMachine.WaitRunDevsRunOps(); }
|
||||
while (!e.Contains(Event.ValvesSet));
|
||||
}
|
||||
else if (e.Contains(Event.UiCmdDrainTank3) && !draining3)
|
||||
{
|
||||
draining3 = true;
|
||||
///--------------------------------------------
|
||||
Bridge.OnActivity(this, Strings.Emptying_tank);
|
||||
///--------------------------------------------
|
||||
Bridge.Bench2UI(((context == MKSelContext.ProcedureNotSelected) ? ButtonsEtc.ProcedureCmbBoxEn : 0) |
|
||||
ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn |
|
||||
(draining1 ? 0 : ButtonsEtc.DrainTankBtn1En) |
|
||||
(draining2 ? 0 : ButtonsEtc.DrainTankBtn2En));
|
||||
State.Create("MainSeq : Open tank 3")
|
||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DrainValve3, null))
|
||||
.EnterState();
|
||||
do { e = StateMachine.WaitRunDevsRunOps(); }
|
||||
while (!e.Contains(Event.ValvesSet));
|
||||
}
|
||||
else if (draining1 && StateMachine.Scale1.IsEmpty(mass1.Val))
|
||||
{
|
||||
State.Create("MainSeq : Close tank 1")
|
||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, StateMachine.DrainValve1))
|
||||
.EnterState();
|
||||
do { e = StateMachine.WaitRunDevsRunOps(); }
|
||||
while (!e.Contains(Event.ValvesSet));
|
||||
draining1 = false;
|
||||
}
|
||||
else if (draining2 && StateMachine.Scale2.IsEmpty(mass2.Val))
|
||||
{
|
||||
State.Create("MainSeq : Close tank 2")
|
||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, StateMachine.DrainValve2))
|
||||
.EnterState();
|
||||
do { e = StateMachine.WaitRunDevsRunOps(); }
|
||||
while (!e.Contains(Event.ValvesSet));
|
||||
draining2 = false;
|
||||
}
|
||||
else if (draining3 && StateMachine.Scale3.IsEmpty(mass3.Val))
|
||||
{
|
||||
State.Create("MainSeq : Close tank 3")
|
||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, StateMachine.DrainValve3))
|
||||
.EnterState();
|
||||
do { e = StateMachine.WaitRunDevsRunOps(); }
|
||||
while (!e.Contains(Event.ValvesSet));
|
||||
draining3 = false;
|
||||
((StateMachine.DrainValve1 == null) ? 0 : (draining1 ? ButtonsEtc.DrainTankBtn1Hi : ButtonsEtc.DrainTankBtn1En)) |
|
||||
((StateMachine.DrainValve2 == null) ? 0 : (draining2 ? ButtonsEtc.DrainTankBtn2Hi : ButtonsEtc.DrainTankBtn2En)) |
|
||||
((StateMachine.DrainValve3 == null) ? 0 : (draining3 ? ButtonsEtc.DrainTankBtn3Hi : ButtonsEtc.DrainTankBtn3En)));
|
||||
|
||||
State.Create(stateText)
|
||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(openValves, closeValves))
|
||||
.EnterState();
|
||||
do {
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
}
|
||||
while (e.Contains(Event.ValvesBusy));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,25 +309,25 @@ namespace TBF.BenchControl
|
||||
|
||||
if (cmpnt is IScale)
|
||||
{
|
||||
IScale balance = cmpnt as IScale;
|
||||
IScale scale = cmpnt as IScale;
|
||||
|
||||
if (balance.ScaleNr == 0)
|
||||
if (scale.ScaleNr == 0)
|
||||
{
|
||||
DrainValve1 = balance.DrainValve;
|
||||
DrainValve1 = scale.DrainValve;
|
||||
log.WarnFormat("InitializeBoardEtc() ... Scale1={0} Draining valve1={1}",
|
||||
balance.Name, (DrainValve1 != null) ? DrainValve1.Name : "---");
|
||||
scale.Name, (DrainValve1 != null) ? DrainValve1.Name : "---");
|
||||
}
|
||||
else if (balance.ScaleNr == 1)
|
||||
else if (scale.ScaleNr == 1)
|
||||
{
|
||||
DrainValve2 = balance.DrainValve;
|
||||
DrainValve2 = scale.DrainValve;
|
||||
log.WarnFormat("InitializeBoardEtc() ... Scale2={0} Draining valve2={1}",
|
||||
balance.Name, (DrainValve2 != null) ? DrainValve2.Name : "---");
|
||||
scale.Name, (DrainValve2 != null) ? DrainValve2.Name : "---");
|
||||
}
|
||||
else if (balance.ScaleNr == 2)
|
||||
else if (scale.ScaleNr == 2)
|
||||
{
|
||||
DrainValve3 = balance.DrainValve;
|
||||
DrainValve3 = scale.DrainValve;
|
||||
log.WarnFormat("InitializeBoardEtc() ... Scale3={0} Draining valve3={1}",
|
||||
balance.Name, (DrainValve3 != null) ? DrainValve3.Name : "---");
|
||||
scale.Name, (DrainValve3 != null) ? DrainValve3.Name : "---");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user