- Fixed bugs in (simultaneous) tank emptying

This commit is contained in:
Milan Hanajik 2014-08-11 21:19:28 +02:00
parent 7cdfad0738
commit d177a4f892
3 changed files with 66 additions and 40 deletions

View File

@ -46,19 +46,21 @@ namespace TBF.BenchControl.MettlerToledo
/// </returns>
public Event Run()
{
if (done) return Event.BalanceDone; /// Mass has already been read
if (balanceDev.MsrmntState == MsrmntState.Busy) return Event.None;
if (balanceDev.MsrmntState == MsrmntState.Valid)
{
result.Val = balanceDev.Mass;
done = true;
return Event.BalanceDone; /// Mass read OK
}
balanceDev.GetImmediateMassMeasurement(); /// Failed -> repeat the measurement
return Event.None;
if (balanceDev.MsrmntState == MsrmntState.Valid)
{
result.Val = balanceDev.Mass;
done = true;
balanceDev.GetImmediateMassMeasurement(); /// Start another measurement
return Event.BalanceDone; /// Mass read OK
}
else if (done)
{
return Event.BalanceDone; /// Mass has already been read (at least once)
}
else
{
return Event.None;
}
}
/// <summary>Stop this operation</summary>

View File

@ -30,10 +30,12 @@ namespace TBF.BenchControl.Sequences
Q3,
Stop,
PurgeBegin,
PurgeEnd,
EmptyTank1,
EmptyTank2,
}
PurgeEnd,
EmptyTank1,
EmptyTank2,
CloseTank1,
CloseTank2,
}
public MainSeq()
{
@ -116,7 +118,9 @@ namespace TBF.BenchControl.Sequences
/// Start something buttons are hidden when emptyign is in progress
Bridge.Bench2UI(ButtonsEtc.ProcedureCmbBoxEn | ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn |
((emptying1 || emptying2) ? 0 : (ButtonsEtc.StartCycleBtnEn | ButtonsEtc.StartTestBtnsEn |
ButtonsEtc.PurgeBeginBtnEn | ButtonsEtc.CalibrationBtnEn)) |
ButtonsEtc.PurgeBeginBtnEn | ButtonsEtc.SensitivityTestBtnEn |
((Cameras.Count > 0) ? ButtonsEtc.CalibrationBtnEn : 0) |
ButtonsEtc.TryOpticalHeadsBtnEn)) |
(((StateMachine.Balance1 != null) && !emptying1) ? ButtonsEtc.EmptyTankBtn1En : 0) |
(((StateMachine.Balance2 != null) && !emptying2) ? ButtonsEtc.EmptyTankBtn2En : 0));
@ -131,7 +135,7 @@ namespace TBF.BenchControl.Sequences
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) goto error;
if (e.Contains(Event.UiCmdPurgeBegin)) selection = Selection.PurgeBegin;
if (e.Contains(Event.UiCmdPurgeBegin)) selection = Selection.PurgeBegin;
if (e.Contains(Event.UiCmdStartTest)) selection = Selection.Test;
if (e.Contains(Event.UiCmdStartQ1)) selection = Selection.Q1;
if (e.Contains(Event.UiCmdStartQ2)) selection = Selection.Q2;
@ -141,7 +145,15 @@ namespace TBF.BenchControl.Sequences
if (e.Contains(Event.UiCmdEmptyTank1)) selection = Selection.EmptyTank1;
if (e.Contains(Event.UiCmdEmptyTank2)) selection = Selection.EmptyTank2;
if (e.Contains(Event.UiCmdCameraTest)) goto camera_test;
}
if ((emptying1 == true) && (mass1.Val < (StateMachine.Balance1.Capacity / 100.0f + 20.0f)))
{
selection = Selection.CloseTank1;
}
if ((emptying2 == true) && (mass2.Val < (StateMachine.Balance2.Capacity / 100.0f + 20.0f)))
{
selection = Selection.CloseTank2;
}
}
while (selection == Selection.None);
if (selection == Selection.Stop)
@ -167,7 +179,7 @@ namespace TBF.BenchControl.Sequences
Bridge.OnActivity(this, Strings.Emptying_tank);
Bridge.Bench2UI(ButtonsEtc.ProcedureCmbBoxEn | ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn |
(emptying2 ? 0 : ButtonsEtc.EmptyTankBtn2En));
State.Create("MainSeq : Open emptying valve 1")
State.Create("MainSeq : Open tank 1")
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.EmptyTankValve1, null))
.EnterState();
do { e = StateMachine.WaitRunDevsRunOps(); }
@ -179,24 +191,24 @@ namespace TBF.BenchControl.Sequences
Bridge.Bench2UI(ButtonsEtc.ProcedureCmbBoxEn | ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn |
(emptying1 ? 0 : ButtonsEtc.EmptyTankBtn1En));
Bridge.OnActivity(this, Strings.Emptying_tank);
State.Create("MainSeq : Open emptying valve 2")
State.Create("MainSeq : Open tank 2")
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.EmptyTankValve2, null))
.EnterState();
do { e = StateMachine.WaitRunDevsRunOps(); }
while (!e.Contains(Event.ValvesSet));
}
else if ((emptying1 == true) && (mass1.Val < (StateMachine.Balance1.Capacity / 100.0f + 20.0f)))
else if (selection == Selection.CloseTank1)
{
State.Create("MainSeq : Close emptying valve 1")
State.Create("MainSeq : Close tank 1")
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, StateMachine.EmptyTankValve1))
.EnterState();
do { e = StateMachine.WaitRunDevsRunOps(); }
while (!e.Contains(Event.ValvesSet));
emptying1 = false;
}
else if ((emptying2 == true) && (mass1.Val < (StateMachine.Balance1.Capacity / 100.0f + 20.0f)))
else if (selection == Selection.CloseTank2)
{
State.Create("MainSeq : Close emptying valve 2")
State.Create("MainSeq : Close tank 2")
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, StateMachine.EmptyTankValve2))
.EnterState();
do { e = StateMachine.WaitRunDevsRunOps(); }
@ -204,7 +216,9 @@ namespace TBF.BenchControl.Sequences
emptying2 = false;
}
}
while (emptying1 || emptying2 || (selection == Selection.None));
while ((selection != Selection.Cycle) && (selection != Selection.Test)
&& (selection != Selection.Q1) && (selection != Selection.Q2) && (selection != Selection.Q3)
|| emptying1 || emptying2);
//--------------------------------
Bridge.Bench2UI(ButtonsEtc.StopBtnEn);
@ -296,10 +310,10 @@ namespace TBF.BenchControl.Sequences
Bridge.Bench2UI(ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn |
((emptying1 || emptying2) ? 0 : (ButtonsEtc.StartCycleBtnEn | ButtonsEtc.StartTestBtnsEn |
ButtonsEtc.PurgeBeginBtnEn | ButtonsEtc.PurgeEndBtnEn |
((Cameras.Count > 0) ? ButtonsEtc.CalibrationBtnEn : 0)) |
ButtonsEtc.SensitivityTestBtnEn | ButtonsEtc.TryOpticalHeadsBtnEn) |
(((StateMachine.Balance1 != null) && !emptying1) ? ButtonsEtc.EmptyTankBtn1En : 0) |
ButtonsEtc.PurgeBeginBtnEn | ButtonsEtc.SensitivityTestBtnEn |
((Cameras.Count > 0) ? ButtonsEtc.CalibrationBtnEn : 0) |
ButtonsEtc.TryOpticalHeadsBtnEn)) |
(((StateMachine.Balance1 != null) && !emptying1) ? ButtonsEtc.EmptyTankBtn1En : 0) |
(((StateMachine.Balance2 != null) && !emptying2) ? ButtonsEtc.EmptyTankBtn2En : 0));
selection = Selection.None;
@ -327,7 +341,15 @@ namespace TBF.BenchControl.Sequences
if (e.Contains(Event.UiCmdPurgeEnd)) goto purge_end;
if (e.Contains(Event.UiCmdEmptyTank1)) selection = Selection.EmptyTank1;
if (e.Contains(Event.UiCmdEmptyTank2)) selection = Selection.EmptyTank2;
if (e.Contains(Event.UiCmdAcceptResults)) goto save_results;
if ((emptying1 == true) && (mass1.Val < (StateMachine.Balance1.Capacity / 100.0f + 20.0f)))
{
selection = Selection.CloseTank1;
}
if ((emptying2 == true) && (mass2.Val < (StateMachine.Balance2.Capacity / 100.0f + 20.0f)))
{
selection = Selection.CloseTank2;
}
if (e.Contains(Event.UiCmdAcceptResults)) goto save_results;
}
while (selection == Selection.None);
@ -372,18 +394,18 @@ namespace TBF.BenchControl.Sequences
do { e = StateMachine.WaitRunDevsRunOps(); }
while (!e.Contains(Event.ValvesSet));
}
else if ((emptying1 == true) && (mass1.Val < (StateMachine.Balance1.Capacity / 100.0f + 20.0f)))
else if (selection == Selection.CloseTank1)
{
State.Create("MainSeq : Close emptying valve 1")
State.Create("MainSeq : Close tank 1")
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, StateMachine.EmptyTankValve1))
.EnterState();
do { e = StateMachine.WaitRunDevsRunOps(); }
while (!e.Contains(Event.ValvesSet));
emptying1 = false;
}
else if ((emptying2 == true) && (mass1.Val < (StateMachine.Balance1.Capacity / 100.0f + 20.0f)))
else if (selection == Selection.CloseTank2)
{
State.Create("MainSeq : Close emptying valve 2")
State.Create("MainSeq : Close tank 2")
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, StateMachine.EmptyTankValve2))
.EnterState();
do { e = StateMachine.WaitRunDevsRunOps(); }
@ -391,7 +413,9 @@ namespace TBF.BenchControl.Sequences
emptying2 = false;
}
}
while (emptying1 || emptying2 || (selection == Selection.None));
while ((selection != Selection.Cycle) && (selection != Selection.Test)
&& (selection != Selection.Q1) && (selection != Selection.Q2) && (selection != Selection.Q3)
|| emptying1 || emptying2);
cycle_or_test:

View File

@ -45,9 +45,9 @@ namespace TBF.UiBridge
CalibrationBtnEn = 0x1000,
SensitivityTestBtnEn = 0x2000,
/// If one of the following flags is set, flags 0x1 through 0x1000 are ignored
/// If one of the following flags is set, flags 0x1 through 0x2000 are ignored
///
ShowBenchEmpty = 0x2000,
ShowBenchFilled = 0x4000,
ShowBenchEmpty = 0x1000000,
ShowBenchFilled = 0x2000000,
}
}