(1) Publish.Internal&Never tests not saved to rslts.DB, (2) Publish.Never tests are in TestRslts, (3) bool Batch.IsRemoteProcedure field, etc. ver. 2.25.1410

This commit is contained in:
Milan Hanajik
2020-02-07 12:40:20 +01:00
parent 7dcb5ba6ce
commit a7965a7ffc
14 changed files with 283 additions and 237 deletions
+120 -65
View File
@@ -440,13 +440,43 @@ namespace TBF.BenchControl.Sequences
}
while (selection == Selection.Shutdown);
switch (selection)
{
case Selection.Q1: selectedTestName = "Q1"; break;
case Selection.Q2: selectedTestName = "Q2"; break;
case Selection.Q3: selectedTestName = "Q3"; break;
default: selectedTestName = Bridge.SelectedTestName; break;
}
selectedTestName = (selection == Selection.Q1) ? "Q1"
: ((selection == Selection.Q2) ? "Q2"
: ((selection == Selection.Q3) ? "Q3" : Bridge.SelectedTestName));
///
/// Collect information about the interrupted procedure (if applicable)
///
bool processDataHeaderOK = false;
string interruptedProcedureName = string.Empty;
bool isRemoteIntProc = false;
///
if (selection == Selection.RestoreInterruptedSession)
{
int batchNr;
string version;
processDataHeaderOK = ProcessData.LoadProcessDataHeader(out batchNr, out version, out interruptedProcedureName, out isRemoteIntProc);
if (!processDataHeaderOK)
{
UiBridge.Bridge.OnError(this, "Invalid process data");
continue;
}
else if (version != Program.Version)
{
/// Program version does not match the one stored in process data
UiBridge.Bridge.OnError(this, Strings.Program_version_does_not_match);
continue;
}
else if (batchNr != Program.LocalSettings.BatchNr)
{
/// Program version does not match the one stored in process data
UiBridge.Bridge.OnError(this, Strings.Invalid_batch_number);
continue;
}
}
try
{
@@ -456,14 +486,31 @@ namespace TBF.BenchControl.Sequences
}
///
/// Try to load all parameters for the selected procedure from databases as specifie in BenchInfo
/// Try to load all parameters of selected or restored procedure from the respective database
///
if ((Bridge.SelectedProcedure != null) && !string.IsNullOrEmpty(Bridge.SelectedProcedure.Name))
if (processDataHeaderOK)
{
/// TODO: Repeate twice for Users.Entities.DBKind.Config and Users.Entities.DBKind.RemoteConfig
using (ISession remoteOrLocalSession = Config.FluentCommon.CreateSession(Bridge.SelectedProcedure.DBKind))
using (ISession remoteOrLocalSession = Config.FluentCommon.CreateSession(isRemoteIntProc ?
Users.Entities.DBKind.RemoteConfig :
Users.Entities.DBKind.Config))
{
StateMachine.LoadProcedure(remoteOrLocalSession, Bridge.SelectedProcedure.Name);
StateMachine.LoadProcedure(remoteOrLocalSession, interruptedProcedureName, isRemoteIntProc);
StateMachine.LoadProcedureParams(StateMachine.Procedure);
/// This is to load Procedure.Tests and tets.MoreParams for each test
int a = 0;
foreach (var test in StateMachine.Procedure.Tests) a += test.MoreParams.Count;
}
}
else if ((Bridge.SelectedProcedure != null) && !string.IsNullOrEmpty(Bridge.SelectedProcedure.Name))
{
/// TODO: Repeate twice for Users.Entities.DBKind.Config and Users.Entities.DBKind.RemoteConfig
using (ISession remoteOrLocalSession = Config.FluentCommon.CreateSession(Bridge.SelectedProcedure.IsRemote ?
Users.Entities.DBKind.RemoteConfig :
Users.Entities.DBKind.Config))
{
StateMachine.LoadProcedure(remoteOrLocalSession, Bridge.SelectedProcedure.Name, Bridge.SelectedProcedure.IsRemote);
StateMachine.LoadProcedureParams(StateMachine.Procedure);
/// This is to load Procedure.Tests and tets.MoreParams for each test
@@ -496,36 +543,33 @@ namespace TBF.BenchControl.Sequences
UiBridge.Bridge.OnError(this, string.Empty); /// Clear an error message (if any)
///
/// Procedure selected at this point, a new batch was started
///
StateMachine.ControlBoard.ManualUIAllowed = !StateMachine.Procedure.ManualCtrlDisabled;
Bridge.Bench2UI(ButtonsEtc.StopBtnEn); /// A new cycle started : Enable STOP button
int newBatchNr = Program.LocalSettings.BatchNr;
log.FatalFormat("New measurement session started: batch = {0}, procedure = {1}", newBatchNr, StateMachine.Procedure.Name);
if (selection == Selection.RestoreInterruptedSession)
{
if (!LoadProcessData(Program.Version))
if (!LoadProcessData())
{
/// Program version does not match the one stored in process data
UiBridge.Bridge.OnError(this, Strings.Program_version_does_not_match);
/// Restorig interrupted session failed
UiBridge.Bridge.OnError(this, "Restorig interrupted session failed");
goto stop;
}
else if (BatchRslts.Batch.BatchNr != newBatchNr)
{
/// Program version does not match the one stored in process data
UiBridge.Bridge.OnError(this, Strings.Invalid_batch_number);
goto stop;
}
else
{
/// Everythign is OK
}
}
else if (selection == Selection.RestoreBatch)
else
{
/// Clear session data in case this is not an interrupted/restored session
ClearSessionData();
}
///
/// Procedure selected at this point, a new batch was started
///
int newBatchNr = Program.LocalSettings.BatchNr;
StateMachine.ControlBoard.ManualUIAllowed = !StateMachine.Procedure.ManualCtrlDisabled;
Bridge.Bench2UI(ButtonsEtc.StopBtnEn); /// A new cycle started : Enable STOP button
log.FatalFormat("New measurement session started: batch = {0}, procedure = {1}", newBatchNr, StateMachine.Procedure.Name);
if (selection == Selection.RestoreBatch)
{
BatchRslts = CreateNewBatchResults(newBatchNr, StateMachine.Procedure);
RestoreBatchResults(TBF.UiBridge.Bridge.BatchNr, ref BatchRslts); /// pass the original batch number of the batch to be restored
@@ -573,12 +617,14 @@ namespace TBF.BenchControl.Sequences
}
}
}
else
else if (selection != Selection.RestoreInterruptedSession)
{
/// This is a regular session => initialize BatchRslts
BatchRslts = CreateNewBatchResults(newBatchNr, StateMachine.Procedure);
}
BatchRslts.Batch.IsRemoteProcedure = StateMachine.IsRemoteProcedure;
StateMachine.CycleStartTimeStamp = BatchRslts.Batch.StartTime;
Bridge.OnProcedureSelected(this, new ProcedureSelectedEventArgs(StateMachine.Procedure)); /// Select procedure in case of interrupted session
@@ -801,17 +847,10 @@ namespace TBF.BenchControl.Sequences
}
else if (selection == Selection.RestoreInterruptedSession)
{
///
/// Make progress bars of completed test green
///
foreach (var testRslt in BatchRslts.Batch.TestRslts)
{
if (testRslt.TestDone)
{
TestProgressEventArgs testProgress = new TestProgressEventArgs(testRslt.Name(), Progress.Completed);
testProgress.Progress = 100;
Bridge.OnTestProgress(this, testProgress);
}
Bridge.OnTestProgress(this, new TestProgressEventArgs(testRslt));
}
/// TODO: Try to find out where the cycle stopped
@@ -1361,33 +1400,49 @@ namespace TBF.BenchControl.Sequences
//--------------------------------
GenericDevices.IDataEntry dataEntryCmpnt = TbfComponents.FindComponent(StateMachine.Procedure.DataEntry) as GenericDevices.IDataEntry;
if (dataEntryCmpnt != null)
if (dataEntryCmpnt is IHasCycleEndForm)
{
if (dataEntryCmpnt is IHasCycleEndForm)
{
/// Open the modeless form for the end of the cycle
State.Create("MainSeq : Enter end data")
.AddOperation((dataEntryCmpnt as GenericDevices.IHasCycleEndForm).ShowCycleEndFormOp())
.AddOperation(checkUiOp)
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.UiCmdStop)) goto stop;
}
while (!e.Contains(Event.ModelessFormClosed));
}
/// Open the modeless form for the end of the cycle
State.Create("MainSeq : Enter end data")
.AddOperation((dataEntryCmpnt as GenericDevices.IHasCycleEndForm).ShowCycleEndFormOp())
.AddOperation(checkUiOp)
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.UiCmdStop)) goto stop;
}
while (!e.Contains(Event.ModelessFormClosed));
}
if (TBF.BenchControl.Sequences.ProcessData.BatchRslts != null && Program.LocalSettings != null)
{
Results.Utils.GetCounterStates(ProcessData.BatchRslts.Batch, Program.LocalSettings.Counters);
}
///
/// Update batch results, determine whether watermeters passed all required tests
///
ProcessData.BatchRslts.Batch.EndTime = DateTime.Now;
BatchRslts.Batch.EndTime = DateTime.Now; /// Set cycle end time
Results.Utils.GetCounterStates(BatchRslts.Batch, Program.LocalSettings.Counters); /// Update counters
/// Remove results of internal tests
for (int i = BatchRslts.Batch.TestRslts.Count - 1; i >= 0; i--)
{
foreach (var wm in BatchRslts.Batch.WaterMeters)
{
for (int j = wm.MeterTestRslts.Count - 1; j >= 0; j--)
{
MeterTestRslt mtr = wm.MeterTestRslts[j];
if ((mtr.Publish() == Publish.Never || mtr.Publish() == Publish.Internal) && !mtr.Evaluate())
{
wm.MeterTestRslts.RemoveAt(j);
}
}
}
TestRslt tr = BatchRslts.Batch.TestRslts[i];
if ((tr.Publish() == Publish.Never || tr.Publish() == Publish.Internal) && !tr.Evaluate())
{
BatchRslts.Batch.TestRslts.RemoveAt(i);
}
}
/// (1) Set boolean WaterMeter.Passed variable, (2) Remove disabled water meters
for (int wmNr0 = ProcessData.BatchRslts.Batch.WaterMeters.Count - 1; wmNr0 >= 0; wmNr0--)
{
WaterMeter wm = ProcessData.BatchRslts.Batch.WaterMeters[wmNr0];