Simultaneous Tank-Empty op-s possible

This commit is contained in:
Milan Hanajik 2014-07-31 00:03:19 +02:00
parent 4bcffdc3a9
commit 26b2c1f1a9
3 changed files with 222 additions and 95 deletions

View File

@ -27,6 +27,7 @@ namespace TBF.BenchControl.Sequences
Q1, Q1,
Q2, Q2,
Q3, Q3,
Stop,
PurgeBegin, PurgeBegin,
PurgeEnd, PurgeEnd,
EmptyTank1, EmptyTank1,
@ -96,17 +97,34 @@ namespace TBF.BenchControl.Sequences
idle: idle:
Bridge.Bench2UI(ButtonsEtc.ProcedureCmbBoxEn | ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn | bool emptying1 = false;
ButtonsEtc.StartCycleBtnEn | ButtonsEtc.StartTestBtnsEn | bool emptying2 = false;
ButtonsEtc.EmptyTankBtnsEn | ButtonsEtc.PurgeBeginBtnEn | do
ButtonsEtc.CalibrationBtnEn); {
/// Used for emptying
FloatBox mass1 = new FloatBox();
FloatBox mass2 = new FloatBox();
//--------------------------------------------------------- //---------------------------------------------------------
if (emptying1 || emptying2)
Bridge.OnActivity(this, Strings.Emptying_tank);
else
Bridge.OnActivity(this, Strings.Please_select_a_procedure); Bridge.OnActivity(this, Strings.Please_select_a_procedure);
//--------------------------------------------------------- //---------------------------------------------------------
/// 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)) |
(emptying1 ? 0 : ButtonsEtc.EmptyTankBtn1En) |
(emptying2 ? 0 : ButtonsEtc.EmptyTankBtn2En));
selection = Selection.None; selection = Selection.None;
State.Create("MainSeq : Select a procedure") State.Create("MainSeq : Select a procedure")
.AddOperation(cBrd.UpdateTankWeightOp())
.AddOperation(checkUiOp) .AddOperation(checkUiOp)
.AddOperation(StateMachine.Balance1.ReadMassOp(ref mass1))
.AddOperation(StateMachine.Balance2.ReadMassOp(ref mass2))
.AddOperation(cBrd.UpdateTankWeightOp())
.EnterState(); .EnterState();
do do
{ {
@ -118,12 +136,75 @@ namespace TBF.BenchControl.Sequences
if (e.Contains(Event.UiCmdStartQ2)) selection = Selection.Q2; if (e.Contains(Event.UiCmdStartQ2)) selection = Selection.Q2;
if (e.Contains(Event.UiCmdStartQ3)) selection = Selection.Q3; if (e.Contains(Event.UiCmdStartQ3)) selection = Selection.Q3;
if (e.Contains(Event.UiCmdStartCycle)) selection = Selection.Cycle; if (e.Contains(Event.UiCmdStartCycle)) selection = Selection.Cycle;
if (e.Contains(Event.UiCmdEmptyTank1)) goto empty_tank1_idle; if (e.Contains(Event.UiCmdStop)) selection = Selection.Stop;
if (e.Contains(Event.UiCmdEmptyTank2)) goto empty_tank2_idle; 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 (e.Contains(Event.UiCmdCameraTest)) goto camera_test;
} }
while (selection == Selection.None); while (selection == Selection.None);
if (selection == Selection.Stop)
{
if (emptying1 || emptying2)
{
IList<IValve> valvesClose = new List<IValve>();
if (emptying1) valvesClose.Add(StateMachine.EmptyTankValve1);
if (emptying2) valvesClose.Add(StateMachine.EmptyTankValve2);
State.Create("MainSeq : Close emptying valve(s)")
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, valvesClose))
.EnterState();
do { e = StateMachine.WaitRunDevsRunOps(); }
while (!e.Contains(Event.ValvesSet));
emptying1 = emptying2 = false;
}
selection = Selection.None;
}
else if ((selection == Selection.EmptyTank1) && (emptying1 == false))
{
emptying1 = true;
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")
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.EmptyTankValve1, null))
.EnterState();
do { e = StateMachine.WaitRunDevsRunOps(); }
while (!e.Contains(Event.ValvesSet));
}
else if ((selection == Selection.EmptyTank2) && (emptying2 == false))
{
emptying2 = true;
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")
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.EmptyTankValve2, null))
.EnterState();
do { e = StateMachine.WaitRunDevsRunOps(); }
while (!e.Contains(Event.ValvesSet));
}
else if ((emptying1 == true) && (mass1.F < (StateMachine.Balance1.Capacity / 100.0f + 20.0f)))
{
State.Create("MainSeq : Close emptying valve 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.F < (StateMachine.Balance1.Capacity / 100.0f + 20.0f)))
{
State.Create("MainSeq : Close emptying valve 2")
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, StateMachine.EmptyTankValve2))
.EnterState();
do { e = StateMachine.WaitRunDevsRunOps(); }
while (!e.Contains(Event.ValvesSet));
emptying2 = false;
}
}
while (emptying1 || emptying2 || (selection == Selection.None));
//-------------------------------- //--------------------------------
Bridge.Bench2UI(ButtonsEtc.StopBtnEn); Bridge.Bench2UI(ButtonsEtc.StopBtnEn);
StateMachine.LoadProcedure(false); StateMachine.LoadProcedure(false);
@ -201,22 +282,41 @@ namespace TBF.BenchControl.Sequences
if (selection != Selection.PurgeBegin) goto cycle_or_test; if (selection != Selection.PurgeBegin) goto cycle_or_test;
ready: ready:
//--------------------------------------------------------- emptying1 = false;
emptying2 = false;
do
{
/// Used for emptying
FloatBox mass1 = new FloatBox();
FloatBox mass2 = new FloatBox();
//------------------------------------------------
if (emptying1 || emptying2)
Bridge.OnActivity(this, Strings.Emptying_tank);
else
Bridge.OnActivity(this, Strings.Please_select_a_cycle_a_test_or_empty); Bridge.OnActivity(this, Strings.Please_select_a_cycle_a_test_or_empty);
//--------------------------------------------------------- //------------------------------------------------
Bridge.Bench2UI(ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn | ButtonsEtc.StartCycleBtnEn |
ButtonsEtc.StartTestBtnsEn | ButtonsEtc.PurgeBeginBtnEn | ButtonsEtc.PurgeEndBtnEn | Bridge.Bench2UI(ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn |
ButtonsEtc.EmptyTankBtnsEn | ((Cameras.Count > 0) ? ButtonsEtc.CalibrationBtnEn : 0) | ((emptying1 || emptying2) ? 0 : (ButtonsEtc.StartCycleBtnEn | ButtonsEtc.StartTestBtnsEn |
ButtonsEtc.SensitivityTestBtnEn | ButtonsEtc.TryOpticalHeadsBtnEn); ButtonsEtc.PurgeBeginBtnEn | ButtonsEtc.PurgeEndBtnEn |
((Cameras.Count > 0) ? ButtonsEtc.CalibrationBtnEn : 0)) |
ButtonsEtc.SensitivityTestBtnEn | ButtonsEtc.TryOpticalHeadsBtnEn) |
(emptying1 ? 0 : ButtonsEtc.EmptyTankBtn1En) |
(emptying2 ? 0 : ButtonsEtc.EmptyTankBtn2En));
selection = Selection.None; selection = Selection.None;
State.Create("MainSeq : Select an activity for the selected procedure") State.Create("MainSeq : Select an activity for the selected procedure")
.AddOperation(checkUiOp) .AddOperation(checkUiOp)
.AddOperation(StateMachine.Balance1.ReadMassOp(ref mass1))
.AddOperation(StateMachine.Balance2.ReadMassOp(ref mass2))
.AddOperation(cBrd.UpdateTankWeightOp())
.EnterState(); .EnterState();
do do
{ {
e = StateMachine.WaitRunDevsRunOps(); e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) goto error; if (e.Contains(Event.Error)) goto error;
if (e.Contains(Event.UiCmdStop)) goto stop; if (e.Contains(Event.UiCmdStop)) selection = Selection.Stop;
if (e.Contains(Event.UiCmdStartTest)) selection = Selection.Test; if (e.Contains(Event.UiCmdStartTest)) selection = Selection.Test;
if (e.Contains(Event.UiCmdStartQ1)) selection = Selection.Q1; if (e.Contains(Event.UiCmdStartQ1)) selection = Selection.Q1;
if (e.Contains(Event.UiCmdStartQ2)) selection = Selection.Q2; if (e.Contains(Event.UiCmdStartQ2)) selection = Selection.Q2;
@ -224,12 +324,74 @@ namespace TBF.BenchControl.Sequences
if (e.Contains(Event.UiCmdStartCycle)) selection = Selection.Cycle; if (e.Contains(Event.UiCmdStartCycle)) selection = Selection.Cycle;
if (e.Contains(Event.UiCmdPurgeBegin)) { selection = Selection.PurgeBegin; goto fill_the_bench; } if (e.Contains(Event.UiCmdPurgeBegin)) { selection = Selection.PurgeBegin; goto fill_the_bench; }
if (e.Contains(Event.UiCmdPurgeEnd)) goto purge_end; if (e.Contains(Event.UiCmdPurgeEnd)) goto purge_end;
if (e.Contains(Event.UiCmdEmptyTank1)) goto empty_tank1; if (e.Contains(Event.UiCmdEmptyTank1)) selection = Selection.EmptyTank1;
if (e.Contains(Event.UiCmdEmptyTank2)) goto empty_tank2; if (e.Contains(Event.UiCmdEmptyTank2)) selection = Selection.EmptyTank2;
if (e.Contains(Event.UiCmdAcceptResults)) goto save_results; if (e.Contains(Event.UiCmdAcceptResults)) goto save_results;
} }
while (selection == Selection.None); while (selection == Selection.None);
if (selection == Selection.Stop)
{
if (emptying1 || emptying2)
{
IList<IValve> valvesClose = new List<IValve>();
if (emptying1) valvesClose.Add(StateMachine.EmptyTankValve1);
if (emptying2) valvesClose.Add(StateMachine.EmptyTankValve2);
State.Create("MainSeq : Close emptying valve(s)")
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, valvesClose))
.EnterState();
do { e = StateMachine.WaitRunDevsRunOps(); }
while (!e.Contains(Event.ValvesSet));
emptying1 = emptying2 = false;
}
selection = Selection.None;
}
else if ((selection == Selection.EmptyTank1) && (emptying1 == false))
{
emptying1 = true;
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")
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.EmptyTankValve1, null))
.EnterState();
do { e = StateMachine.WaitRunDevsRunOps(); }
while (!e.Contains(Event.ValvesSet));
}
else if ((selection == Selection.EmptyTank2) && (emptying2 == false))
{
emptying2 = true;
Bridge.OnActivity(this, Strings.Emptying_tank);
Bridge.Bench2UI(ButtonsEtc.ProcedureCmbBoxEn | ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn |
(emptying1 ? 0 : ButtonsEtc.EmptyTankBtn1En));
State.Create("MainSeq : Open emptying valve 2")
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.EmptyTankValve2, null))
.EnterState();
do { e = StateMachine.WaitRunDevsRunOps(); }
while (!e.Contains(Event.ValvesSet));
}
else if ((emptying1 == true) && (mass1.F < (StateMachine.Balance1.Capacity / 100.0f + 20.0f)))
{
State.Create("MainSeq : Close emptying valve 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.F < (StateMachine.Balance1.Capacity / 100.0f + 20.0f)))
{
State.Create("MainSeq : Close emptying valve 2")
.AddOperation(StateMachine.ControlBoard.SetValvesOp(null, StateMachine.EmptyTankValve2))
.EnterState();
do { e = StateMachine.WaitRunDevsRunOps(); }
while (!e.Contains(Event.ValvesSet));
emptying2 = false;
}
}
while (emptying1 || emptying2 || (selection == Selection.None));
cycle_or_test: cycle_or_test:
Bridge.Bench2UI(ButtonsEtc.StopBtnEn); /// Hide buttons Bridge.Bench2UI(ButtonsEtc.StopBtnEn); /// Hide buttons
@ -303,42 +465,6 @@ namespace TBF.BenchControl.Sequences
goto ready; goto ready;
empty_tank1:
switch (EmptyTheTank(StateMachine.EmptyTankValve1, StateMachine.Balance1))
{
case Event.Error: goto error;
case Event.UiCmdStop: goto stop;
default: goto ready;
}
empty_tank2:
switch (EmptyTheTank(StateMachine.EmptyTankValve2, StateMachine.Balance2))
{
case Event.Error: goto error;
case Event.UiCmdStop: goto stop;
default: goto ready;
}
empty_tank1_idle:
switch (EmptyTheTank(StateMachine.EmptyTankValve1, StateMachine.Balance1))
{
case Event.Error: goto error;
case Event.UiCmdStop: goto stop;
default: goto idle;
}
empty_tank2_idle:
switch (EmptyTheTank(StateMachine.EmptyTankValve2, StateMachine.Balance2))
{
case Event.Error: goto error;
case Event.UiCmdStop: goto stop;
default: goto idle;
}
purge_end: purge_end:
save_results: save_results:

View File

@ -37,12 +37,13 @@ namespace TBF.UiBridge
StartCycleBtnEn = 0x10, StartCycleBtnEn = 0x10,
PurgeBeginBtnEn = 0x20, PurgeBeginBtnEn = 0x20,
PurgeEndBtnEn = 0x40, PurgeEndBtnEn = 0x40,
EmptyTankBtnsEn = 0x80, EmptyTankBtn1En = 0x80,
TryOpticalHeadsBtnEn = 0x100, EmptyTankBtn2En = 0x100,
ResetResultsBtnEn = 0x200, TryOpticalHeadsBtnEn = 0x200,
AcceptResultsBtnEn = 0x300, ResetResultsBtnEn = 0x400,
CalibrationBtnEn = 0x800, AcceptResultsBtnEn = 0x800,
SensitivityTestBtnEn = 0x1000, 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 0x1000 are ignored
/// ///

View File

@ -246,10 +246,10 @@ namespace TBF.UiControls
purgeEndBtn.Enabled = ((args.Flags & ButtonsEtc.PurgeEndBtnEn) != 0); purgeEndBtn.Enabled = ((args.Flags & ButtonsEtc.PurgeEndBtnEn) != 0);
purgeEndBtn.BackColor = purgeEndBtn.Enabled ? colorPurgeEn : colorPurgeDis; purgeEndBtn.BackColor = purgeEndBtn.Enabled ? colorPurgeEn : colorPurgeDis;
emptyTank1Btn.Enabled = ((args.Flags & ButtonsEtc.EmptyTankBtnsEn) != 0); emptyTank1Btn.Enabled = ((args.Flags & ButtonsEtc.EmptyTankBtn1En) != 0);
emptyTank1Btn.BackColor = emptyTank1Btn.Enabled ? colorEmptyEn : colorEmptyDis; emptyTank1Btn.BackColor = emptyTank1Btn.Enabled ? colorEmptyEn : colorEmptyDis;
emptyTank2Btn.Enabled = ((args.Flags & ButtonsEtc.EmptyTankBtnsEn) != 0); emptyTank2Btn.Enabled = ((args.Flags & ButtonsEtc.EmptyTankBtn2En) != 0);
emptyTank2Btn.BackColor = emptyTank2Btn.Enabled ? colorEmptyEn : colorEmptyDis; emptyTank2Btn.BackColor = emptyTank2Btn.Enabled ? colorEmptyEn : colorEmptyDis;
resetResultsBtn.Enabled = ((args.Flags & ButtonsEtc.ResetResultsBtnEn) != 0); resetResultsBtn.Enabled = ((args.Flags & ButtonsEtc.ResetResultsBtnEn) != 0);