UI2BenCmd.Shutdown is re-sent each 3 sec in MainWnd on exit, CheckUIOp and MainSeq modifications, ver. 2.18.813

This commit is contained in:
Milan Hanajik 2018-02-15 16:05:45 +01:00
parent 80999a8573
commit 17e605cfd9
5 changed files with 30 additions and 8 deletions

View File

@ -55,12 +55,12 @@ namespace TBF.BenchControl.Operations
public Event Run()
{
if (Bridge.Ui2MachineQueue.Count <= 0) return Event.None;
UI2BenchCmd cmd;
lock (Bridge.Ui2MachineQueue)
{
if (Bridge.Ui2MachineQueue.Count <= 0) return Event.None;
if (Bridge.Ui2MachineQueue.Contains(UI2BenchCmd.Stop))
{
do {
@ -68,6 +68,13 @@ namespace TBF.BenchControl.Operations
}
while (cmd != UI2BenchCmd.Stop);
}
else if (Bridge.Ui2MachineQueue.Contains(UI2BenchCmd.Shutdown))
{
do {
cmd = Bridge.Ui2MachineQueue.Dequeue();
}
while (cmd != UI2BenchCmd.Shutdown);
}
else
{
cmd = Bridge.Ui2MachineQueue.Dequeue();

View File

@ -1178,6 +1178,8 @@ namespace TBF.BenchControl.Sequences
{
log.WarnFormat("MakeSelection({0})", context);
IOperation checkUiOpWithClear = new Operations.CheckUIOp(true);
bool shutdownInProgress = false;
/// Tank emptying valves states
@ -1222,7 +1224,7 @@ namespace TBF.BenchControl.Sequences
State.Create("MainSeq : Select an activity")
.AddOperation(checkUiOp)
.AddOperation(checkUiOpWithClear)
.AddOperation((StateMachine.Scale1 != null) ? StateMachine.Scale1.ReadMassOp(ref mass1) : null)
.AddOperation((StateMachine.Scale2 != null) ? StateMachine.Scale2.ReadMassOp(ref mass2) : null)
.AddOperation((StateMachine.Scale3 != null) ? StateMachine.Scale3.ReadMassOp(ref mass3) : null)
@ -1237,6 +1239,7 @@ namespace TBF.BenchControl.Sequences
{
#if true
/// TBF shutdown without tank draining
log.Fatal("Returning from MakeSelection() after e.Contains(Event.UiCmdShutdown)==true");
return Selection.Shutdown;
#else
/// TBF shutdown with tank draining

View File

@ -625,7 +625,9 @@ namespace TBF.BenchControl
new Sequences.MainSeq().Execute(null);
log.Fatal("StateMachine.Worker() before State.StopOperations()");
State.StopOperations();
log.Fatal("StateMachine.Worker() after State.StopOperations()");
stateMachineRunning = false;
}

View File

@ -576,12 +576,22 @@ namespace TBF
{
if (BenchControl.StateMachine.Running)
{
Bridge.Ui2Bench(UI2BenchCmd.Shutdown); /// Drain tanks and quit the main sequence
int elapsedTimeMs;
do
{
Thread.Sleep(100);
Bridge.Ui2Bench(UI2BenchCmd.Shutdown); /// Quit the main sequence, optionally drain tanks
elapsedTimeMs = 0;
do
{
Thread.Sleep(100);
elapsedTimeMs += 100;
}
while (BenchControl.StateMachine.Running && elapsedTimeMs < 3000); /// Wait until StateMachine.Worker() completes
if (elapsedTimeMs < 3000) break;
}
while (BenchControl.StateMachine.Running); /// Wait until StateMachine.Worker() completes
while (elapsedTimeMs >= 3000); /// Keep resending UI2BenchCmd.Shutdown on 3s timeouts (BenchControl.StateMachine.Running stays true for 3s)
/// Show 'Closing_Test_Bench_Framework' modeless window in separate thread
var form = new TBF.Forms.ModelessActivityForm()

View File

@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.18.812.0")]
[assembly: AssemblyFileVersion("2.18.812.0")]
[assembly: AssemblyVersion("2.18.813.0")]
[assembly: AssemblyFileVersion("2.18.813.0")]