UiBridge.Bridge.CloseModelessFormHandler isn't used, tank draining before a test is optional, fixes in simulations, ver. 2.18.1056
This commit is contained in:
@@ -25,7 +25,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
|
|||||||
{
|
{
|
||||||
if (debugLevel == Config.Entities.DebugMode.Simulate)
|
if (debugLevel == Config.Entities.DebugMode.Simulate)
|
||||||
{
|
{
|
||||||
Simulate(test, repetitionNr, isLastRepetition, testParams);
|
return Simulate(test, repetitionNr, isLastRepetition, testParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+11
-8
@@ -95,14 +95,17 @@ namespace TBF.BenchControl.TestMethods.FixedStartTankCollection
|
|||||||
string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
|
string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Drain the water tank
|
/// Optionally drain the water tank
|
||||||
///
|
///
|
||||||
switch (DrainTheTank(tank))
|
if (test.DoDraining)
|
||||||
{
|
{
|
||||||
case Event.Error: { retVal = Event.Error; goto stopTest; }
|
switch (DrainTheTank(tank))
|
||||||
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
|
{
|
||||||
}
|
case Event.Error: { retVal = Event.Error; goto stopTest; }
|
||||||
|
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------
|
//------------------------------------------------
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl
|
|||||||
{
|
{
|
||||||
if (debugLevel == Config.Entities.DebugMode.Simulate)
|
if (debugLevel == Config.Entities.DebugMode.Simulate)
|
||||||
{
|
{
|
||||||
Simulate(test, repetitionNr, isLastRepetition, singleTestParams, compoundTestParams, heatMetersTestParams);
|
return Simulate(test, repetitionNr, isLastRepetition, singleTestParams, compoundTestParams, heatMetersTestParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -36,7 +36,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged
|
|||||||
{
|
{
|
||||||
if (debugLevel == Config.Entities.DebugMode.Simulate)
|
if (debugLevel == Config.Entities.DebugMode.Simulate)
|
||||||
{
|
{
|
||||||
Simulate(test, repetitionNr, isLastRepetition, singleTestParams, compoundTestParams, heatMetersTestParams);
|
return Simulate(test, repetitionNr, isLastRepetition, singleTestParams, compoundTestParams, heatMetersTestParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -34,11 +34,11 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
|
|||||||
{
|
{
|
||||||
if (debugLevel == Config.Entities.DebugMode.Simulate)
|
if (debugLevel == Config.Entities.DebugMode.Simulate)
|
||||||
{
|
{
|
||||||
Simulate1(test, repetitionNr, isLastRepetition, compoundTestParams, heatMetersTestParams);
|
return Simulate1(test, repetitionNr, isLastRepetition, compoundTestParams, heatMetersTestParams);
|
||||||
}
|
}
|
||||||
else if (debugLevel == Config.Entities.DebugMode.Inherit)
|
else if (debugLevel == Config.Entities.DebugMode.Inherit)
|
||||||
{
|
{
|
||||||
Simulate2(test, repetitionNr, isLastRepetition, compoundTestParams, heatMetersTestParams);
|
return Simulate2(test, repetitionNr, isLastRepetition, compoundTestParams, heatMetersTestParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+93
-9
@@ -29,7 +29,12 @@ namespace TBF.BenchControl.TestMethods.FlyingStartTankCollection
|
|||||||
Compound.CombinedTestParams compoundTestParams,
|
Compound.CombinedTestParams compoundTestParams,
|
||||||
Config.Entities.DebugMode debugLevel)
|
Config.Entities.DebugMode debugLevel)
|
||||||
{
|
{
|
||||||
IList<Event> e = new List<Event>(); /// Events from currently running operations
|
if (debugLevel == Config.Entities.DebugMode.Simulate)
|
||||||
|
{
|
||||||
|
return Simulate(test, repetitionNr, isLastRepetition, compoundTestParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
IList<Event> e = new List<Event>(); /// Events from currently running operations
|
||||||
|
|
||||||
ITankWithVolumeMsrmnt tank = outPath.Scale as ITankWithVolumeMsrmnt;
|
ITankWithVolumeMsrmnt tank = outPath.Scale as ITankWithVolumeMsrmnt;
|
||||||
if (tank == null)
|
if (tank == null)
|
||||||
@@ -90,14 +95,17 @@ namespace TBF.BenchControl.TestMethods.FlyingStartTankCollection
|
|||||||
TestStartTime = DateTime.Now;
|
TestStartTime = DateTime.Now;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Drain the water tank
|
/// Optionally drain the water tank
|
||||||
///
|
///
|
||||||
switch (DrainTheTank(tank))
|
if (test.DoDraining)
|
||||||
{
|
{
|
||||||
case Event.Error: { retVal = Event.Error; goto stopTest; }
|
switch (DrainTheTank(tank))
|
||||||
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
|
{
|
||||||
}
|
case Event.Error: { retVal = Event.Error; goto stopTest; }
|
||||||
|
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------
|
//------------------------------------------------
|
||||||
@@ -759,5 +767,81 @@ namespace TBF.BenchControl.TestMethods.FlyingStartTankCollection
|
|||||||
retList.Add(retVal);
|
retList.Add(retVal);
|
||||||
return retList;
|
return retList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public IList<Event> Simulate(Config.Entities.Test test, int repetitionNr, bool isLastRepetition,
|
||||||
|
Compound.CombinedTestParams compoundTestParams)
|
||||||
|
{
|
||||||
|
///
|
||||||
|
/// Test method simulation
|
||||||
|
///
|
||||||
|
ITankWithVolumeMsrmnt tank = outPath.Scale as ITankWithVolumeMsrmnt;
|
||||||
|
if (tank == null)
|
||||||
|
{
|
||||||
|
Bridge.OnError(this, Strings.Missing_a_tank_with_volume_measurement);
|
||||||
|
|
||||||
|
/// Create a list with one item 'retVal' (default is Event.Done) and return it
|
||||||
|
IList<Event> retListSim1 = new List<Event>(1);
|
||||||
|
retListSim1.Add(Event.ConfigurationError);
|
||||||
|
return retListSim1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting));
|
||||||
|
|
||||||
|
IList<Event> e = new List<Event>(); /// Events from currently running operations
|
||||||
|
Event retVal = Event.Done;
|
||||||
|
DoubleBox volumeBox = new DoubleBox();
|
||||||
|
///
|
||||||
|
IOperation msrVolOp = tank.MeasureVolumeOp(ref volumeBox);
|
||||||
|
State.Create(string.Format("{0}({1}) : Water level measurement", test.Method, test.Name))
|
||||||
|
.AddOperation(checkUiOp)
|
||||||
|
.AddOperation(msrVolOp)
|
||||||
|
.EnterState();
|
||||||
|
do
|
||||||
|
{
|
||||||
|
e = StateMachine.WaitRunDevsRunOps();
|
||||||
|
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopSimulation; }
|
||||||
|
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopSimulation; }
|
||||||
|
}
|
||||||
|
while (!e.Contains(Event.VolumeDone));
|
||||||
|
///
|
||||||
|
log.WarnFormat("Volumes = {0}l", volumeBox.Val);
|
||||||
|
|
||||||
|
|
||||||
|
if (compoundTestParams != null)
|
||||||
|
{
|
||||||
|
if (test.Name.ToLower().Contains("nok")) MakeSimulatedCompound(test, 1, 0, 4.7f, 0.9f);
|
||||||
|
else MakeSimulatedCompound(test, 1, 0, 0.7f, 1.0f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
float errorPctBase = -1.0f;
|
||||||
|
if (test.Name.ToLower().Contains("q3")) errorPctBase = -0.5f;
|
||||||
|
else if (test.Name.ToLower().Contains("q2")) errorPctBase = 0.5f;
|
||||||
|
else if (test.Name.ToLower().Contains("q1")) errorPctBase = -5.1f;
|
||||||
|
|
||||||
|
MakeSimulated(test, repetitionNr, 0, errorPctBase + repetitionNr * 0.1f);
|
||||||
|
}
|
||||||
|
|
||||||
|
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Completed));
|
||||||
|
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(test.Name, BatchRslts.GetTestRslt(Results.Utils.GetTestName(test.Name, 1, 1), 0)));
|
||||||
|
allResults.Info(TestResult2CsvLine(test.Name, 0)); /// Append the results to the CSV-file
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
Bridge.OnActivity(this, string.Format("{0} Simulation", test.Name));
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
|
||||||
|
State.Create(string.Format("{0}({1}) : Simulation", test.Method, test.Name))
|
||||||
|
.AddOperation(checkUiOp)
|
||||||
|
.EnterState();
|
||||||
|
e = StateMachine.WaitRunDevsRunOps();
|
||||||
|
|
||||||
|
stopSimulation:
|
||||||
|
|
||||||
|
/// Create a list with one item 'retVal' (default is Event.Done) and return it
|
||||||
|
IList<Event> retListSim = new List<Event>(1);
|
||||||
|
retListSim.Add(retVal);
|
||||||
|
return retListSim;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace TBF.BenchControl.Various.ManualLevelMsrmnt
|
|||||||
|
|
||||||
public double WaterLevelMm;
|
public double WaterLevelMm;
|
||||||
|
|
||||||
System.Windows.Forms.Form modelessDlg;
|
WaterLevelForm waterLevelForm;
|
||||||
|
|
||||||
bool resultSaved; /// Set in Run() when results are saved
|
bool resultSaved; /// Set in Run() when results are saved
|
||||||
|
|
||||||
@@ -61,10 +61,11 @@ namespace TBF.BenchControl.Various.ManualLevelMsrmnt
|
|||||||
///
|
///
|
||||||
void OpenWaterLevelForm(ManualLevelMsrmnt myRef)
|
void OpenWaterLevelForm(ManualLevelMsrmnt myRef)
|
||||||
{
|
{
|
||||||
myRef.modelessDlg = new WaterLevelForm();
|
myRef.waterLevelForm = new WaterLevelForm();
|
||||||
modelessDlg.Show();
|
waterLevelForm.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>Start this operation</summary>
|
/// <summary>Start this operation</summary>
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
@@ -79,20 +80,17 @@ namespace TBF.BenchControl.Various.ManualLevelMsrmnt
|
|||||||
/// <returns>Event.ResultsPrinted</returns>
|
/// <returns>Event.ResultsPrinted</returns>
|
||||||
public Event Run()
|
public Event Run()
|
||||||
{
|
{
|
||||||
if ((modelessDlg is IHasCompleted) && !(modelessDlg as IHasCompleted).Completed)
|
if ((waterLevelForm != null) && !waterLevelForm.Completed)
|
||||||
{
|
{
|
||||||
return Event.Busy; /// = Form open
|
return Event.Busy; /// = Form open
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!resultSaved) /// This is to save the result only once
|
if (!resultSaved && (currentOp == CurrentOp.EnterLevel) && (waterLevelForm != null))
|
||||||
{
|
{
|
||||||
if ((modelessDlg is WaterLevelForm) && (currentOp == CurrentOp.EnterLevel))
|
/// Save the result (only once)
|
||||||
{
|
WaterLevelMm = waterLevelForm.WaterLevelMm;
|
||||||
WaterLevelMm = (modelessDlg as WaterLevelForm).WaterLevelMm;
|
if (levelBox != null) levelBox.Val = WaterLevelMm;
|
||||||
if (levelBox != null) levelBox.Val = WaterLevelMm;
|
resultSaved = true;
|
||||||
resultSaved = true;
|
|
||||||
modelessDlg = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Event.LevelDone; /// = Form closed
|
return Event.LevelDone; /// = Form closed
|
||||||
@@ -101,10 +99,10 @@ namespace TBF.BenchControl.Various.ManualLevelMsrmnt
|
|||||||
/// <summary>Stop this operation</summary>
|
/// <summary>Stop this operation</summary>
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
if (modelessDlg is IHasCompleted)
|
if (waterLevelForm != null)
|
||||||
{
|
{
|
||||||
UiBridge.Bridge.OnCloseModelessForm(this, null);
|
waterLevelForm.OnCloseThisForm(this, null);
|
||||||
modelessDlg = null;
|
waterLevelForm = null;
|
||||||
}
|
}
|
||||||
currentOp = CurrentOp.None;
|
currentOp = CurrentOp.None;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ using TBF.Resources;
|
|||||||
|
|
||||||
namespace TBF.BenchControl.Various.ManualLevelMsrmnt
|
namespace TBF.BenchControl.Various.ManualLevelMsrmnt
|
||||||
{
|
{
|
||||||
public partial class WaterLevelForm : Form, GenericDevices.IHasCompleted
|
public partial class WaterLevelForm : Form
|
||||||
{
|
{
|
||||||
private static readonly ILog log = LogManager.GetLogger(typeof(WaterLevelForm));
|
private static readonly ILog log = LogManager.GetLogger(typeof(WaterLevelForm));
|
||||||
|
|
||||||
@@ -69,23 +69,43 @@ namespace TBF.BenchControl.Various.ManualLevelMsrmnt
|
|||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Forced close handling
|
#region Forced close handling
|
||||||
|
|
||||||
public void StartForceCloseHandler()
|
/// <summary>
|
||||||
{
|
/// Used by CoverTest, AskYesNoOp and MessageBoxOp.
|
||||||
UiBridge.Bridge.CloseModelessFormHandler += delegate(object sender, EventArgs args)
|
/// </summary>
|
||||||
{
|
public void OnCloseThisForm(object sender, EventArgs args)
|
||||||
if (InvokeRequired) { Invoke(new EventHandler<EventArgs>(OnForceClose), sender, args); }
|
{
|
||||||
else OnForceClose(sender, args);
|
if (CloseThisFormHandler == null) return;
|
||||||
};
|
try
|
||||||
}
|
{
|
||||||
|
CloseThisFormHandler(sender, null);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.Error("CloseThisFormHandler(...) failed", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void OnForceClose(object sender, EventArgs args)
|
public event EventHandler<EventArgs> CloseThisFormHandler;
|
||||||
{
|
|
||||||
DialogResult = DialogResult.Cancel;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
public void StartForceCloseHandler()
|
||||||
}
|
{
|
||||||
|
CloseThisFormHandler += delegate(object sender, EventArgs args)
|
||||||
|
{
|
||||||
|
if (InvokeRequired)
|
||||||
|
Invoke(new EventHandler<EventArgs>(OnForceClose), sender, args);
|
||||||
|
else
|
||||||
|
OnForceClose(sender, args);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnForceClose(object sender, EventArgs args)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -300,12 +300,8 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
|
|||||||
public IOperation MeasureVolumeOp(ref DoubleBox volume)
|
public IOperation MeasureVolumeOp(ref DoubleBox volume)
|
||||||
{
|
{
|
||||||
if (currentOp != CurrentOp.None) throw new Exception("Sequence error");
|
if (currentOp != CurrentOp.None) throw new Exception("Sequence error");
|
||||||
|
this.volumeBox = volume;
|
||||||
if (readLevelOp == null)
|
readLevelOp = levelMeter.ReadLevelOp(ref levelBox);
|
||||||
{
|
|
||||||
readLevelOp = levelMeter.ReadLevelOp(ref levelBox);
|
|
||||||
}
|
|
||||||
this.volumeBox = volume;
|
|
||||||
currentOp = CurrentOp.MeasureVolume;
|
currentOp = CurrentOp.MeasureVolume;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
|||||||
// Build Number
|
// Build Number
|
||||||
// Revision
|
// Revision
|
||||||
//
|
//
|
||||||
[assembly: AssemblyVersion("2.18.1055.0")]
|
[assembly: AssemblyVersion("2.18.1056.0")]
|
||||||
[assembly: AssemblyFileVersion("2.18.1055.0")]
|
[assembly: AssemblyFileVersion("2.18.1056.0")]
|
||||||
|
|||||||
Reference in New Issue
Block a user