TestMethods.Q2CorrectionFromHistory sets test results, TODO: Web service.

This commit is contained in:
Milan Hanajik
2019-08-27 14:40:30 +02:00
parent ff3118068d
commit e61e5c59cb
8 changed files with 155 additions and 62 deletions
+3 -3
View File
@@ -347,9 +347,9 @@ namespace TBF.BenchControl.Sequences
}
}
IsInitQ2CorrCalculated = false;
CalculatedInitQ2CorrLR = 0;
CalculatedInitQ2CorrRL = 0;
IsQ2PreCorrectionCalculated = false;
CalculatedQ2PreCorrectionLR = 0;
CalculatedQ2PreCorrectionRL = 0;
}
+6 -6
View File
@@ -49,9 +49,9 @@ namespace TBF.BenchControl.Sequences
public static IRegisterReader[] RegisterReaders;
public static bool IsInitQ2CorrCalculated;
public static int CalculatedInitQ2CorrLR;
public static int CalculatedInitQ2CorrRL;
public static bool IsQ2PreCorrectionCalculated;
public static int CalculatedQ2PreCorrectionLR;
public static int CalculatedQ2PreCorrectionRL;
///
static ProcessData()
{
@@ -61,9 +61,9 @@ namespace TBF.BenchControl.Sequences
///
RegisterReaders = new IRegisterReader[Config.Data.WMsCount];
IsInitQ2CorrCalculated = false;
CalculatedInitQ2CorrLR = 0;
CalculatedInitQ2CorrRL = 0;
IsQ2PreCorrectionCalculated = false;
CalculatedQ2PreCorrectionLR = 0;
CalculatedQ2PreCorrectionRL = 0;
}
@@ -66,9 +66,9 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
log.Debug(this.ToString());
}
public IList<Event> Execute(Test test, int idummy, bool bdummy)
public IList<Event> Execute(Test test, int repetitionNr, bool isLastRepetition)
{
return (new FromHistorySeq()).Execute(test, cfg);
return (new FromHistorySeq()).Execute(test, repetitionNr, isLastRepetition, cfg);
}
}
}
@@ -15,11 +15,12 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
public IComponentCfgCtrl GetControl() { return new FromHistoryCfgCtrl(); }
public bool UseWebService;
public bool UseLocalDB;
public string ProcedureName;
public string ProcedureNameAlt1;
public string ProcedureNameAlt2;
public bool UseWebService;
public bool UseDefaultValues;
/// Private parameterless constructor invoked by all other (public) constructors
@@ -32,11 +33,12 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
Name = name;
ParentName = string.Empty;
UseWebService = false;
UseLocalDB = true;
ProcedureName = "iPERL Smart Suez DN15 Q3_2.5 R800";
ProcedureNameAlt1 = "iPERL Suez DN15 Q3_2.5 R800";
ProcedureNameAlt2 = string.Empty;
UseWebService = false;
UseDefaultValues = true;
}
public string ToString(int i)
@@ -25,6 +25,7 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
private Label procedureNameAlt2Label;
private TextBox procedureNameAlt2TextBox;
private CheckBox useWebServiceCheckBox;
private CheckBox useDefaultValuesCheckBox;
public bool ShowMore { get { return false; } }
@@ -58,21 +59,23 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
if (config == null) return; /// Control was not loaded, settings were not changed
classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
useWebServiceCheckBox.Checked = config.UseWebService;
useLocalDBCheckBox.Checked = config.UseLocalDB;
procedureNameTextBox.Text = config.ProcedureName;
procedureNameAlt1TextBox.Text = config.ProcedureNameAlt1;
procedureNameAlt2TextBox.Text = config.ProcedureNameAlt2;
useWebServiceCheckBox.Checked = config.UseWebService;
useDefaultValuesCheckBox.Checked = config.UseDefaultValues;
}
public void Unlock()
{
nameTextBox.Enabled = true;
useWebServiceCheckBox.Enabled = true;
useLocalDBCheckBox.Enabled = true;
procedureNameTextBox.Enabled = true;
procedureNameAlt1TextBox.Enabled = true;
procedureNameAlt2TextBox.Enabled = true;
useWebServiceCheckBox.Enabled = true;
useDefaultValuesCheckBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
@@ -92,6 +95,12 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
}
if (config.UseWebService != useWebServiceCheckBox.Checked)
{
config.UseWebService = useWebServiceCheckBox.Checked;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
}
if (config.UseLocalDB != useLocalDBCheckBox.Checked)
{
config.UseLocalDB = useLocalDBCheckBox.Checked;
@@ -116,9 +125,9 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
}
if (config.UseWebService != useWebServiceCheckBox.Checked)
if (config.UseDefaultValues != useDefaultValuesCheckBox.Checked)
{
config.UseWebService = useWebServiceCheckBox.Checked;
config.UseDefaultValues = useDefaultValuesCheckBox.Checked;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
}
@@ -143,109 +152,122 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
this.procedureNameAlt1Label = new System.Windows.Forms.Label();
this.procedureNameAlt2TextBox = new System.Windows.Forms.TextBox();
this.procedureNameAlt2Label = new System.Windows.Forms.Label();
this.useDefaultValuesCheckBox = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// procedureNameTextBox
//
this.procedureNameTextBox.Enabled = false;
this.procedureNameTextBox.Location = new System.Drawing.Point(160, 104);
this.procedureNameTextBox.Location = new System.Drawing.Point(190, 124);
this.procedureNameTextBox.Name = "procedureNameTextBox";
this.procedureNameTextBox.Size = new System.Drawing.Size(171, 20);
this.procedureNameTextBox.TabIndex = 13;
this.procedureNameTextBox.TabIndex = 6;
//
// procedureNameLabel
//
this.procedureNameLabel.AutoSize = true;
this.procedureNameLabel.Location = new System.Drawing.Point(35, 107);
this.procedureNameLabel.Location = new System.Drawing.Point(65, 127);
this.procedureNameLabel.Name = "procedureNameLabel";
this.procedureNameLabel.Size = new System.Drawing.Size(85, 13);
this.procedureNameLabel.TabIndex = 12;
this.procedureNameLabel.TabIndex = 5;
this.procedureNameLabel.Text = "Procedure name";
//
// useLocalDBCheckBox
//
this.useLocalDBCheckBox.AutoSize = true;
this.useLocalDBCheckBox.Enabled = false;
this.useLocalDBCheckBox.Location = new System.Drawing.Point(38, 78);
this.useLocalDBCheckBox.Location = new System.Drawing.Point(38, 103);
this.useLocalDBCheckBox.Name = "useLocalDBCheckBox";
this.useLocalDBCheckBox.Size = new System.Drawing.Size(117, 17);
this.useLocalDBCheckBox.TabIndex = 14;
this.useLocalDBCheckBox.Text = "Use local database";
this.useLocalDBCheckBox.Size = new System.Drawing.Size(129, 17);
this.useLocalDBCheckBox.TabIndex = 4;
this.useLocalDBCheckBox.Text = "2. Use local database";
this.useLocalDBCheckBox.UseVisualStyleBackColor = true;
//
// useWebServiceCheckBox
//
this.useWebServiceCheckBox.AutoSize = true;
this.useWebServiceCheckBox.Enabled = false;
this.useWebServiceCheckBox.Location = new System.Drawing.Point(36, 187);
this.useWebServiceCheckBox.Location = new System.Drawing.Point(38, 78);
this.useWebServiceCheckBox.Name = "useWebServiceCheckBox";
this.useWebServiceCheckBox.Size = new System.Drawing.Size(105, 17);
this.useWebServiceCheckBox.TabIndex = 15;
this.useWebServiceCheckBox.Text = "Use web service";
this.useWebServiceCheckBox.Size = new System.Drawing.Size(117, 17);
this.useWebServiceCheckBox.TabIndex = 3;
this.useWebServiceCheckBox.Text = "1. Use web service";
this.useWebServiceCheckBox.UseVisualStyleBackColor = true;
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(160, 45);
this.nameTextBox.Location = new System.Drawing.Point(190, 45);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(171, 20);
this.nameTextBox.TabIndex = 11;
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(35, 48);
this.nameLabel.Location = new System.Drawing.Point(132, 48);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 10;
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(157, 16);
this.classNameLabel.Location = new System.Drawing.Point(187, 16);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(89, 13);
this.classNameLabel.TabIndex = 9;
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComponentName";
//
// procedureNameAlt1TextBox
//
this.procedureNameAlt1TextBox.Enabled = false;
this.procedureNameAlt1TextBox.Location = new System.Drawing.Point(160, 128);
this.procedureNameAlt1TextBox.Location = new System.Drawing.Point(190, 147);
this.procedureNameAlt1TextBox.Name = "procedureNameAlt1TextBox";
this.procedureNameAlt1TextBox.Size = new System.Drawing.Size(171, 20);
this.procedureNameAlt1TextBox.TabIndex = 17;
this.procedureNameAlt1TextBox.TabIndex = 8;
//
// procedureNameAlt1Label
//
this.procedureNameAlt1Label.AutoSize = true;
this.procedureNameAlt1Label.Location = new System.Drawing.Point(35, 131);
this.procedureNameAlt1Label.Location = new System.Drawing.Point(65, 150);
this.procedureNameAlt1Label.Name = "procedureNameAlt1Label";
this.procedureNameAlt1Label.Size = new System.Drawing.Size(106, 13);
this.procedureNameAlt1Label.TabIndex = 16;
this.procedureNameAlt1Label.TabIndex = 7;
this.procedureNameAlt1Label.Text = "Procedure name Alt1";
//
// procedureNameAlt2TextBox
//
this.procedureNameAlt2TextBox.Enabled = false;
this.procedureNameAlt2TextBox.Location = new System.Drawing.Point(160, 152);
this.procedureNameAlt2TextBox.Location = new System.Drawing.Point(190, 170);
this.procedureNameAlt2TextBox.Name = "procedureNameAlt2TextBox";
this.procedureNameAlt2TextBox.Size = new System.Drawing.Size(171, 20);
this.procedureNameAlt2TextBox.TabIndex = 19;
this.procedureNameAlt2TextBox.TabIndex = 10;
//
// procedureNameAlt2Label
//
this.procedureNameAlt2Label.AutoSize = true;
this.procedureNameAlt2Label.Location = new System.Drawing.Point(35, 155);
this.procedureNameAlt2Label.Location = new System.Drawing.Point(65, 173);
this.procedureNameAlt2Label.Name = "procedureNameAlt2Label";
this.procedureNameAlt2Label.Size = new System.Drawing.Size(106, 13);
this.procedureNameAlt2Label.TabIndex = 18;
this.procedureNameAlt2Label.TabIndex = 9;
this.procedureNameAlt2Label.Text = "Procedure name Alt2";
//
// useDefaultValuesCheckBox
//
this.useDefaultValuesCheckBox.AutoSize = true;
this.useDefaultValuesCheckBox.Enabled = false;
this.useDefaultValuesCheckBox.Location = new System.Drawing.Point(38, 202);
this.useDefaultValuesCheckBox.Name = "useDefaultValuesCheckBox";
this.useDefaultValuesCheckBox.Size = new System.Drawing.Size(126, 17);
this.useDefaultValuesCheckBox.TabIndex = 11;
this.useDefaultValuesCheckBox.Text = "3. Use default values";
this.useDefaultValuesCheckBox.UseVisualStyleBackColor = true;
//
// FromHistoryCfgCtrl
//
this.Controls.Add(this.useDefaultValuesCheckBox);
this.Controls.Add(this.procedureNameAlt2TextBox);
this.Controls.Add(this.procedureNameAlt2Label);
this.Controls.Add(this.procedureNameAlt1TextBox);
@@ -261,6 +283,7 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
this.Size = new System.Drawing.Size(400, 250);
this.ResumeLayout(false);
this.PerformLayout();
}
}
}
@@ -16,17 +16,83 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
private static readonly ILog log = LogManager.GetLogger(typeof(FromHistorySeq));
public IList<Event> Execute(Config.Entities.Test test, FromHistoryCfg cfg)
public IList<Event> Execute(Config.Entities.Test test, int repetitionNr, bool isLastRepetition, FromHistoryCfg cfg)
{
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, 1, Config.Entities.Progress.Test));
bool success = ReadCorrectionsFromLocalDB(cfg);
bool success = false;
/// 1. Use a web service if enabled
if (cfg.UseWebService)
{
success = ReadCorrectionsFromWebService(cfg);
}
/// 2. Calculate pre-corrections from a local database if enabled
if (!success && cfg.UseLocalDB)
{
success = ReadCorrectionsFromLocalDB(cfg);
}
/// 3. Use pre-defined values (IperlHead procedure parameters) if enabled
if (!success && cfg.UseDefaultValues)
{
success = true;
}
///
/// Populate TestResult data entity with data
///
string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
if (tstRslt != null)
{
tstRslt.StartTime = DateTime.Now;
tstRslt.EndTime = DateTime.Now;
tstRslt.TestDone = true;
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
{
Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single);
if (meterRslt != null)
{
meterRslt.TestDone = true;
meterRslt.Passed = success;
}
}
}
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, 1, Config.Entities.Progress.Completed));
return new List<Event> { success ? Event.Done : Event.RecoverableError };
}
bool ReadCorrectionsFromWebService(FromHistoryCfg cfg)
{
/// Invalidate any previous Q2 Pre-Corrections
IsQ2PreCorrectionCalculated = false;
try
{
return false;
/// TODO: Use webservice
//IsQ2PreCorrectionCalculated = true;
//return true;
}
catch (Exception exc)
{
log.ErrorFormat("Failed to calculate Q2 corrections: {0}", exc.Message);
return false;
}
}
bool ReadCorrectionsFromLocalDB(FromHistoryCfg cfg)
{
/// Invalidate any previous Q2 Pre-Corrections
IsQ2PreCorrectionCalculated = false;
try
{
using (ISession session = Results.DB.CreateSession())
@@ -62,8 +128,10 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
{
if ((wm != null) && !wm.Disabled && wm.Passed)
{
#if IPERL
q2CorrLRsum += wm.Q2CorrLR;
q2CorrRLsum += wm.Q2CorrRL;
#endif
samplesCount++;
}
}
@@ -73,10 +141,10 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
if (samplesCount >= 200)
{
IsInitQ2CorrCalculated = true;
CalculatedInitQ2CorrLR = (int)Math.Round(q2CorrLRsum / samplesCount);
CalculatedInitQ2CorrRL = (int)Math.Round(q2CorrRLsum / samplesCount);
log.WarnFormat("Q2 corrections calculated OK: LR = {0}, RL = {1}", CalculatedInitQ2CorrLR, CalculatedInitQ2CorrRL);
IsQ2PreCorrectionCalculated = true;
CalculatedQ2PreCorrectionLR = (int)Math.Round(q2CorrLRsum / samplesCount);
CalculatedQ2PreCorrectionRL = (int)Math.Round(q2CorrRLsum / samplesCount);
log.WarnFormat("Q2 corrections calculated OK: LR = {0}, RL = {1}", CalculatedQ2PreCorrectionLR, CalculatedQ2PreCorrectionRL);
return true;
}
else
@@ -1778,14 +1778,14 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
if (wm.Pruefindex == 1)
{
if (TBF.BenchControl.Sequences.ProcessData.IsInitQ2CorrCalculated)
if (TBF.BenchControl.Sequences.ProcessData.IsQ2PreCorrectionCalculated)
{
return SetQ2Correction(threadId, ihead, wm, ref resultStr, TBF.BenchControl.Sequences.ProcessData.CalculatedInitQ2CorrLR,
TBF.BenchControl.Sequences.ProcessData.CalculatedInitQ2CorrRL);
return SetQ2Correction(threadId, ihead, wm, ref resultStr, TBF.BenchControl.Sequences.ProcessData.CalculatedQ2PreCorrectionLR,
TBF.BenchControl.Sequences.ProcessData.CalculatedQ2PreCorrectionRL);
}
else
{
return SetQ2Correction(threadId, ihead, wm, ref resultStr, ihead.InitQ2CorrLR, ihead.InitQ2CorrRL);
return SetQ2Correction(threadId, ihead, wm, ref resultStr, ihead.Q2PreCorrectionLR, ihead.Q2PreCorrectionRL);
}
}
else
@@ -41,8 +41,8 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
public ushort FactorLimitHi { get { return (ushort)iperlHeadCfg.ProcParams.FactorLimitHi; } }
public Counting InitFlowDir { get { return (iperlHeadCfg != null && iperlHeadCfg.ProcParams != null) ? iperlHeadCfg.ProcParams.Counting : Counting.Arbitrary; } }
public int WMType_ID { get { return iperlHeadCfg.ProcParams.WMType_ID; } } /// Required by Oracle DB
public int InitQ2CorrLR { get { return iperlHeadCfg.ProcParams.InitQ2CorrLR; } } /// Used by InitOrReadQ2Corrections activity
public int InitQ2CorrRL { get { return iperlHeadCfg.ProcParams.InitQ2CorrRL; } } /// Required by Oracle DB
public int Q2PreCorrectionLR { get { return iperlHeadCfg.ProcParams.InitQ2CorrLR; } } /// Used by InitOrReadQ2Corrections activity
public int Q2PreCorrectionRL { get { return iperlHeadCfg.ProcParams.InitQ2CorrRL; } } /// Required by Oracle DB
/// Properties set by the Begin and the End form