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,
Q2,
Q3,
Stop,
PurgeBegin,
PurgeEnd,
EmptyTank1,
@ -96,33 +97,113 @@ namespace TBF.BenchControl.Sequences
idle:
Bridge.Bench2UI(ButtonsEtc.ProcedureCmbBoxEn | ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn |
ButtonsEtc.StartCycleBtnEn | ButtonsEtc.StartTestBtnsEn |
ButtonsEtc.EmptyTankBtnsEn | ButtonsEtc.PurgeBeginBtnEn |
ButtonsEtc.CalibrationBtnEn);
//---------------------------------------------------------
Bridge.OnActivity(this, Strings.Please_select_a_procedure);
//---------------------------------------------------------
selection = Selection.None;
State.Create("MainSeq : Select a procedure")
.AddOperation(cBrd.UpdateTankWeightOp())
.AddOperation(checkUiOp)
.EnterState();
bool emptying1 = false;
bool emptying2 = false;
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) goto error;
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;
if (e.Contains(Event.UiCmdStartQ3)) selection = Selection.Q3;
if (e.Contains(Event.UiCmdStartCycle)) selection = Selection.Cycle;
if (e.Contains(Event.UiCmdEmptyTank1)) goto empty_tank1_idle;
if (e.Contains(Event.UiCmdEmptyTank2)) goto empty_tank2_idle;
if (e.Contains(Event.UiCmdCameraTest)) goto camera_test;
}
while (selection == Selection.None);
/// 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);
//---------------------------------------------------------
/// 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;
State.Create("MainSeq : Select a procedure")
.AddOperation(checkUiOp)
.AddOperation(StateMachine.Balance1.ReadMassOp(ref mass1))
.AddOperation(StateMachine.Balance2.ReadMassOp(ref mass2))
.AddOperation(cBrd.UpdateTankWeightOp())
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) goto error;
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;
if (e.Contains(Event.UiCmdStartQ3)) selection = Selection.Q3;
if (e.Contains(Event.UiCmdStartCycle)) selection = Selection.Cycle;
if (e.Contains(Event.UiCmdStop)) selection = Selection.Stop;
if (e.Contains(Event.UiCmdEmptyTank1)) selection = Selection.EmptyTank1;
if (e.Contains(Event.UiCmdEmptyTank2)) selection = Selection.EmptyTank2;
if (e.Contains(Event.UiCmdCameraTest)) goto camera_test;
}
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);
@ -201,34 +282,115 @@ namespace TBF.BenchControl.Sequences
if (selection != Selection.PurgeBegin) goto cycle_or_test;
ready:
//---------------------------------------------------------
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 |
ButtonsEtc.EmptyTankBtnsEn | ((Cameras.Count > 0) ? ButtonsEtc.CalibrationBtnEn : 0) |
ButtonsEtc.SensitivityTestBtnEn | ButtonsEtc.TryOpticalHeadsBtnEn);
selection = Selection.None;
State.Create("MainSeq : Select an activity for the selected procedure")
.AddOperation(checkUiOp)
.EnterState();
emptying1 = false;
emptying2 = false;
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) goto error;
if (e.Contains(Event.UiCmdStop)) goto stop;
if (e.Contains(Event.UiCmdStartTest)) selection = Selection.Test;
if (e.Contains(Event.UiCmdStartQ1)) selection = Selection.Q1;
if (e.Contains(Event.UiCmdStartQ2)) selection = Selection.Q2;
if (e.Contains(Event.UiCmdStartQ3)) selection = Selection.Q3;
if (e.Contains(Event.UiCmdStartCycle)) selection = Selection.Cycle;
if (e.Contains(Event.UiCmdPurgeBegin)) { selection = Selection.PurgeBegin; goto fill_the_bench; }
if (e.Contains(Event.UiCmdPurgeEnd)) goto purge_end;
if (e.Contains(Event.UiCmdEmptyTank1)) goto empty_tank1;
if (e.Contains(Event.UiCmdEmptyTank2)) goto empty_tank2;
if (e.Contains(Event.UiCmdAcceptResults)) goto save_results;
}
while (selection == Selection.None);
/// 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.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) |
(emptying1 ? 0 : ButtonsEtc.EmptyTankBtn1En) |
(emptying2 ? 0 : ButtonsEtc.EmptyTankBtn2En));
selection = Selection.None;
State.Create("MainSeq : Select an activity for the selected procedure")
.AddOperation(checkUiOp)
.AddOperation(StateMachine.Balance1.ReadMassOp(ref mass1))
.AddOperation(StateMachine.Balance2.ReadMassOp(ref mass2))
.AddOperation(cBrd.UpdateTankWeightOp())
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) goto error;
if (e.Contains(Event.UiCmdStop)) selection = Selection.Stop;
if (e.Contains(Event.UiCmdStartTest)) selection = Selection.Test;
if (e.Contains(Event.UiCmdStartQ1)) selection = Selection.Q1;
if (e.Contains(Event.UiCmdStartQ2)) selection = Selection.Q2;
if (e.Contains(Event.UiCmdStartQ3)) selection = Selection.Q3;
if (e.Contains(Event.UiCmdStartCycle)) selection = Selection.Cycle;
if (e.Contains(Event.UiCmdPurgeBegin)) { selection = Selection.PurgeBegin; goto fill_the_bench; }
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;
}
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:
@ -303,42 +465,6 @@ namespace TBF.BenchControl.Sequences
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:
save_results:

View File

@ -37,12 +37,13 @@ namespace TBF.UiBridge
StartCycleBtnEn = 0x10,
PurgeBeginBtnEn = 0x20,
PurgeEndBtnEn = 0x40,
EmptyTankBtnsEn = 0x80,
TryOpticalHeadsBtnEn = 0x100,
ResetResultsBtnEn = 0x200,
AcceptResultsBtnEn = 0x300,
CalibrationBtnEn = 0x800,
SensitivityTestBtnEn = 0x1000,
EmptyTankBtn1En = 0x80,
EmptyTankBtn2En = 0x100,
TryOpticalHeadsBtnEn = 0x200,
ResetResultsBtnEn = 0x400,
AcceptResultsBtnEn = 0x800,
CalibrationBtnEn = 0x1000,
SensitivityTestBtnEn = 0x2000,
/// 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.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;
emptyTank2Btn.Enabled = ((args.Flags & ButtonsEtc.EmptyTankBtnsEn) != 0);
emptyTank2Btn.Enabled = ((args.Flags & ButtonsEtc.EmptyTankBtn2En) != 0);
emptyTank2Btn.BackColor = emptyTank2Btn.Enabled ? colorEmptyEn : colorEmptyDis;
resetResultsBtn.Enabled = ((args.Flags & ButtonsEtc.ResetResultsBtnEn) != 0);