CalculatedInitQ2CorrXY added to ProcessData, used in InitOrReadQ2Correction(...), TestMethods.Q2CorrectionFromHistory added, ver. 2.18.1295

This commit is contained in:
Milan Hanajik 2019-08-15 08:59:51 +02:00
parent e37dd87ece
commit ef5320917a
14 changed files with 988 additions and 13 deletions

View File

@ -331,6 +331,28 @@ namespace TBF.BenchControl.Sequences
}
/// <summary>
/// This function is called after a procedure was selected and all components procedure parameters of components were loaded
/// </summary>
void ClearSessionData()
{
///
/// Clear iperlhead data (including PCB Number, avoid double use)
///
foreach (var cmpnt in StateMachine.Components)
{
if (cmpnt is TestMethods.iPerlCommunication.iPerlHead.IperlHead)
{
(cmpnt as TestMethods.iPerlCommunication.iPerlHead.IperlHead).ClearData();
}
}
IsInitQ2CorrCalculated = false;
CalculatedInitQ2CorrLR = 0;
CalculatedInitQ2CorrRL = 0;
}
/// <summary>
/// Main sequence
/// </summary>
@ -480,16 +502,7 @@ namespace TBF.BenchControl.Sequences
int newBatchNr = Program.LocalSettings.BatchNr;
log.FatalFormat("New measurement session started: batch = {0}, procedure = {1}", newBatchNr, StateMachine.Procedure.Name);
///
/// Clear iperlhead data (including PCB Number, avoid double use)
///
foreach (var cmpnt in StateMachine.Components)
{
if (cmpnt is TestMethods.iPerlCommunication.iPerlHead.IperlHead)
{
(cmpnt as TestMethods.iPerlCommunication.iPerlHead.IperlHead).ClearData();
}
}
ClearSessionData();
if (selection == Selection.RestoreBatch)
{

View File

@ -48,6 +48,10 @@ namespace TBF.BenchControl.Sequences
public static Results.BatchResults BatchRslts;
public static IRegisterReader[] RegisterReaders;
public static bool IsInitQ2CorrCalculated;
public static int CalculatedInitQ2CorrLR;
public static int CalculatedInitQ2CorrRL;
///
static ProcessData()
{
@ -56,6 +60,10 @@ namespace TBF.BenchControl.Sequences
/// RegisterReader[i] where i = 0..Config.Data.WMsCount-1 may be null and should always be tested
///
RegisterReaders = new IRegisterReader[Config.Data.WMsCount];
IsInitQ2CorrCalculated = false;
CalculatedInitQ2CorrLR = 0;
CalculatedInitQ2CorrRL = 0;
}

View File

@ -93,6 +93,7 @@ namespace TBF.BenchControl
Factories.Add(new TestMethods.PMaxTest.TestMethodFactory());
Factories.Add(new TestMethods.PulsesTest.Factory());
Factories.Add(new TestMethods.PulsesTestManual.Factory());
Factories.Add(new TestMethods.Q2CorrectionFromHistory.Factory());
Factories.Add(new TestMethods.SensitivityTest.Factory());
Factories.Add(new TestMethods.iPerlCommunication.TestMethodFactory()); /// iPerlCommunication
Factories.Add(new TestMethods.RoiDetection.RoiDetectionFactory());

View File

@ -0,0 +1,74 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using Config.Entities;
namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
{
public class Component : ComponentBase, GenericDevices.ISimultTestMethod, GenericDevices.ITestMethod
{
private static readonly ILog log = LogManager.GetLogger(typeof(Component));
public override string ToString() { return string.Format("TestMethods.GrabImage({0})", Cfg.ToString(1)); }
public bool CanTest(MetersKind meters) { return true; }
public bool DoTransitions() { return false; }
readonly FromHistoryCfg cfg;
public bool SimultWithPrevious { get { return true; } }
public bool SimultWithNext { get { return false; } }
#region Configuration Change Handling
public static void OnCfgChange(object sender, CfgChangeArgs args)
{
if (CfgChangeHandler == null) return;
try { CfgChangeHandler(sender, args); }
catch (Exception e) { log.Error("CfgChangeHandler(...) failed", e); }
}
public static event EventHandler<CfgChangeArgs> CfgChangeHandler;
public override void StartChangeHandler()
{
CfgChangeHandler += delegate(object sender, CfgChangeArgs args)
{
FromHistoryCfg tmpcfg = args.Cfg as FromHistoryCfg;
if (tmpcfg != null && tmpcfg.Name.Equals(Name))
{
if (args.Command == CfgChangeCmd.CfgChange)
{
cfg.UseLocalDB = tmpcfg.UseLocalDB;
cfg.ProcedureName = tmpcfg.ProcedureName;
cfg.ProcedureNameAlt1 = tmpcfg.ProcedureNameAlt1;
cfg.ProcedureNameAlt2 = tmpcfg.ProcedureNameAlt2;
cfg.UseWebService = tmpcfg.UseWebService;
}
}
};
}
#endregion Configuration Change Handling
public Component()
{
}
public Component(Generic.IComponentCfg cfg)
: base(cfg)
{
this.cfg = cfg as FromHistoryCfg;
StartChangeHandler();
log.Debug(this.ToString());
}
public IList<Event> Execute(Test test, int idummy, bool bdummy)
{
return (new FromHistorySeq()).Execute(test, cfg);
}
}
}

View File

@ -0,0 +1,26 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
{
public class Factory : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(17); } }
public void ResetStaticProperties() { Component.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Component(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Component(cfg); }
public IComponentCfg DefaultConfig() { return new FromHistoryCfg(this, this.GetType().Namespace.Substring(29)); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(FromHistoryCfg.Serializer, component, this);
}
}
}

View File

@ -0,0 +1,47 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Xml.Serialization;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
{
public class FromHistoryCfg : ComponentCfgBase, Generic.IComponentCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(FromHistoryCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl() { return new FromHistoryCfgCtrl(); }
public bool UseLocalDB;
public string ProcedureName;
public string ProcedureNameAlt1;
public string ProcedureNameAlt2;
public bool UseWebService;
/// Private parameterless constructor invoked by all other (public) constructors
FromHistoryCfg() {}
public FromHistoryCfg(IComponentFactory factory, string name)
: this()
{
this.Factory = factory;
Name = name;
ParentName = string.Empty;
UseLocalDB = true;
ProcedureName = "iPERL Smart Suez DN15 Q3_2.5 R800";
ProcedureNameAlt1 = "iPERL Suez DN15 Q3_2.5 R800";
ProcedureNameAlt2 = string.Empty;
UseWebService = false;
}
public string ToString(int i)
{
return string.Format("Name={0}, UseLocalDB={1}, UseWebService={2}", Name, UseLocalDB, UseWebService);
}
}
}

View File

@ -0,0 +1,266 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using TBF.BenchControl.Generic;
using TBF.Resources;
namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
{
public partial class FromHistoryCfgCtrl : UserControl, IComponentCfgCtrl
{
static readonly ILog log = LogManager.GetLogger(typeof(FromHistoryCfgCtrl));
private Label classNameLabel;
private Label nameLabel;
private TextBox nameTextBox;
private CheckBox useLocalDBCheckBox;
private Label procedureNameLabel;
private TextBox procedureNameTextBox;
private Label procedureNameAlt1Label;
private TextBox procedureNameAlt1TextBox;
private Label procedureNameAlt2Label;
private TextBox procedureNameAlt2TextBox;
private CheckBox useWebServiceCheckBox;
public bool ShowMore { get { return false; } }
FromHistoryCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as FromHistoryCfg;
Redraw();
}
}
public FromHistoryCfgCtrl()
{
InitializeComponent();
}
private void GrabImageCfgCtrl_Load(object sender, EventArgs e)
{
Redraw();
}
public void Closing()
{
}
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
useLocalDBCheckBox.Checked = config.UseLocalDB;
procedureNameTextBox.Text = config.ProcedureName;
procedureNameAlt1TextBox.Text = config.ProcedureNameAlt1;
procedureNameAlt2TextBox.Text = config.ProcedureNameAlt2;
useWebServiceCheckBox.Checked = config.UseWebService;
}
public void Unlock()
{
nameTextBox.Enabled = true;
useLocalDBCheckBox.Enabled = true;
procedureNameTextBox.Enabled = true;
procedureNameAlt1TextBox.Enabled = true;
procedureNameAlt2TextBox.Enabled = true;
useWebServiceCheckBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
return CfgUpdateFlags.None;
}
public CfgUpdateFlags UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
if (config.Name != nameTextBox.Text)
{
config.Name = nameTextBox.Text;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
}
if (config.UseLocalDB != useLocalDBCheckBox.Checked)
{
config.UseLocalDB = useLocalDBCheckBox.Checked;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
}
if (config.ProcedureName != procedureNameTextBox.Text)
{
config.ProcedureName = procedureNameTextBox.Text;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
}
if (config.ProcedureNameAlt1 != procedureNameAlt1TextBox.Text)
{
config.ProcedureNameAlt1 = procedureNameAlt1TextBox.Text;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
}
if (config.ProcedureNameAlt2 != procedureNameAlt2TextBox.Text)
{
config.ProcedureNameAlt2 = procedureNameAlt2TextBox.Text;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
}
if (config.UseWebService != useWebServiceCheckBox.Checked)
{
config.UseWebService = useWebServiceCheckBox.Checked;
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
}
if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0)
{
Component.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config));
}
return flags;
}
private void InitializeComponent()
{
this.procedureNameTextBox = new System.Windows.Forms.TextBox();
this.procedureNameLabel = new System.Windows.Forms.Label();
this.useLocalDBCheckBox = new System.Windows.Forms.CheckBox();
this.useWebServiceCheckBox = new System.Windows.Forms.CheckBox();
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.procedureNameAlt1TextBox = new System.Windows.Forms.TextBox();
this.procedureNameAlt1Label = new System.Windows.Forms.Label();
this.procedureNameAlt2TextBox = new System.Windows.Forms.TextBox();
this.procedureNameAlt2Label = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// procedureNameTextBox
//
this.procedureNameTextBox.Enabled = false;
this.procedureNameTextBox.Location = new System.Drawing.Point(160, 104);
this.procedureNameTextBox.Name = "procedureNameTextBox";
this.procedureNameTextBox.Size = new System.Drawing.Size(171, 20);
this.procedureNameTextBox.TabIndex = 13;
//
// procedureNameLabel
//
this.procedureNameLabel.AutoSize = true;
this.procedureNameLabel.Location = new System.Drawing.Point(35, 107);
this.procedureNameLabel.Name = "procedureNameLabel";
this.procedureNameLabel.Size = new System.Drawing.Size(85, 13);
this.procedureNameLabel.TabIndex = 12;
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.Name = "useLocalDBCheckBox";
this.useLocalDBCheckBox.Size = new System.Drawing.Size(117, 17);
this.useLocalDBCheckBox.TabIndex = 14;
this.useLocalDBCheckBox.Text = "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.Name = "useWebServiceCheckBox";
this.useWebServiceCheckBox.Size = new System.Drawing.Size(105, 17);
this.useWebServiceCheckBox.TabIndex = 15;
this.useWebServiceCheckBox.Text = "Use web service";
this.useWebServiceCheckBox.UseVisualStyleBackColor = true;
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(160, 45);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(171, 20);
this.nameTextBox.TabIndex = 11;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(35, 48);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 10;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(157, 16);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(89, 13);
this.classNameLabel.TabIndex = 9;
this.classNameLabel.Text = "ComponentName";
//
// procedureNameAlt1TextBox
//
this.procedureNameAlt1TextBox.Enabled = false;
this.procedureNameAlt1TextBox.Location = new System.Drawing.Point(160, 128);
this.procedureNameAlt1TextBox.Name = "procedureNameAlt1TextBox";
this.procedureNameAlt1TextBox.Size = new System.Drawing.Size(171, 20);
this.procedureNameAlt1TextBox.TabIndex = 17;
//
// procedureNameAlt1Label
//
this.procedureNameAlt1Label.AutoSize = true;
this.procedureNameAlt1Label.Location = new System.Drawing.Point(35, 131);
this.procedureNameAlt1Label.Name = "procedureNameAlt1Label";
this.procedureNameAlt1Label.Size = new System.Drawing.Size(106, 13);
this.procedureNameAlt1Label.TabIndex = 16;
this.procedureNameAlt1Label.Text = "Procedure name Alt1";
//
// procedureNameAlt2TextBox
//
this.procedureNameAlt2TextBox.Enabled = false;
this.procedureNameAlt2TextBox.Location = new System.Drawing.Point(160, 152);
this.procedureNameAlt2TextBox.Name = "procedureNameAlt2TextBox";
this.procedureNameAlt2TextBox.Size = new System.Drawing.Size(171, 20);
this.procedureNameAlt2TextBox.TabIndex = 19;
//
// procedureNameAlt2Label
//
this.procedureNameAlt2Label.AutoSize = true;
this.procedureNameAlt2Label.Location = new System.Drawing.Point(35, 155);
this.procedureNameAlt2Label.Name = "procedureNameAlt2Label";
this.procedureNameAlt2Label.Size = new System.Drawing.Size(106, 13);
this.procedureNameAlt2Label.TabIndex = 18;
this.procedureNameAlt2Label.Text = "Procedure name Alt2";
//
// FromHistoryCfgCtrl
//
this.Controls.Add(this.procedureNameAlt2TextBox);
this.Controls.Add(this.procedureNameAlt2Label);
this.Controls.Add(this.procedureNameAlt1TextBox);
this.Controls.Add(this.procedureNameAlt1Label);
this.Controls.Add(this.procedureNameTextBox);
this.Controls.Add(this.procedureNameLabel);
this.Controls.Add(this.useLocalDBCheckBox);
this.Controls.Add(this.useWebServiceCheckBox);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "FromHistoryCfgCtrl";
this.Size = new System.Drawing.Size(400, 250);
this.ResumeLayout(false);
this.PerformLayout();
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,123 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Linq;
using NHibernate;
using NHibernate.Criterion;
using log4net;
using Results.Entities;
using TBF.UiBridge;
namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
{
public class FromHistorySeq : Sequences.SequenceBase
{
private static readonly ILog log = LogManager.GetLogger(typeof(FromHistorySeq));
public IList<Event> Execute(Config.Entities.Test test, FromHistoryCfg cfg)
{
IList<Event> e;
Event retVal = Event.Done;
/// Operations
checkUiOp = new Operations.CheckUIOp(true);
//------------------------------------------------
Bridge.OnActivity(this, test.Method);
//------------------------------------------------
State.Create(string.Format("{0}({1}) : Q2 correction from history", test.Method, test.Name))
.AddOperation(checkUiOp)
.EnterState();
/// Read database here
bool success = ReadCorrectionsFromLocalDB(cfg);
{
e = StateMachine.WaitRunDevsRunOps();
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, 1, Config.Entities.Progress.Test));
if (e.Contains(Event.Error))
retVal = Event.Error;
else if (TestAndLogUiCmdStop(test, e))
retVal = Event.UiCmdStop;
}
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, 1, Config.Entities.Progress.Completed));
return new List<Event> { retVal };
}
bool ReadCorrectionsFromLocalDB(FromHistoryCfg cfg)
{
try
{
using (ISession session = Results.DB.CreateSession())
{
Batch btc = null;
var batches = session.QueryOver<Batch>(() => btc)
.Where(bb => (bb.ProcedureName == cfg.ProcedureName))
.List();
if (!string.IsNullOrEmpty(cfg.ProcedureNameAlt1))
{
IList<Batch> batches2 = session.QueryOver<Batch>(() => btc)
.Where(bb => (bb.ProcedureName == cfg.ProcedureNameAlt1))
.List();
foreach (var b in batches2) batches.Add(b);
}
if (!string.IsNullOrEmpty(cfg.ProcedureNameAlt2))
{
IList<Batch> batches3 = session.QueryOver<Batch>(() => btc)
.Where(bb => (bb.ProcedureName == cfg.ProcedureNameAlt2))
.List();
foreach (var b in batches3) batches.Add(b);
}
int samplesCount = 0;
double q2CorrLRsum = 0;
double q2CorrRLsum = 0;
var sortedBatches = batches.OrderByDescending(b => b.EndTime);
foreach (var b in sortedBatches)
{
foreach (var wm in b.WaterMeters)
{
if ((wm != null) && !wm.Disabled && wm.Passed)
{
q2CorrLRsum += wm.Q2CorrLR;
q2CorrRLsum += wm.Q2CorrRL;
samplesCount++;
}
}
if (samplesCount >= 200) break;
}
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);
return true;
}
else
{
log.ErrorFormat("Not enough samples to calculate Q2 corrections ({0})", samplesCount);
return false;
}
}
}
catch (Exception exc)
{
log.ErrorFormat("Failed to calculate Q2 corrections: {0}", exc.Message);
return false;
}
}
}
}

View File

@ -0,0 +1,159 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
{
partial class GrabImageCfgCtrl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.loResolutionCheckBox = new System.Windows.Forms.CheckBox();
this.blackAndWhiteCheckBox = new System.Windows.Forms.CheckBox();
this.imageNameTextBox = new System.Windows.Forms.TextBox();
this.imageNameLabel = new System.Windows.Forms.Label();
this.imageRotationLabel = new System.Windows.Forms.Label();
this.imageRotationComboBox = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(149, 69);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(171, 20);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(24, 72);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(95, 13);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Test method name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(146, 43);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComonentName";
//
// loResolutionCheckBox
//
this.loResolutionCheckBox.AutoSize = true;
this.loResolutionCheckBox.Enabled = false;
this.loResolutionCheckBox.Location = new System.Drawing.Point(149, 149);
this.loResolutionCheckBox.Name = "loResolutionCheckBox";
this.loResolutionCheckBox.Size = new System.Drawing.Size(94, 17);
this.loResolutionCheckBox.TabIndex = 6;
this.loResolutionCheckBox.Text = "Low resolution";
this.loResolutionCheckBox.UseVisualStyleBackColor = true;
//
// blackAndWhiteCheckBox
//
this.blackAndWhiteCheckBox.AutoSize = true;
this.blackAndWhiteCheckBox.Enabled = false;
this.blackAndWhiteCheckBox.Location = new System.Drawing.Point(149, 126);
this.blackAndWhiteCheckBox.Name = "blackAndWhiteCheckBox";
this.blackAndWhiteCheckBox.Size = new System.Drawing.Size(93, 17);
this.blackAndWhiteCheckBox.TabIndex = 5;
this.blackAndWhiteCheckBox.Text = "Black && White";
this.blackAndWhiteCheckBox.UseVisualStyleBackColor = true;
//
// imageNameTextBox
//
this.imageNameTextBox.Enabled = false;
this.imageNameTextBox.Location = new System.Drawing.Point(149, 95);
this.imageNameTextBox.Name = "imageNameTextBox";
this.imageNameTextBox.Size = new System.Drawing.Size(171, 20);
this.imageNameTextBox.TabIndex = 4;
//
// imageNameLabel
//
this.imageNameLabel.AutoSize = true;
this.imageNameLabel.Location = new System.Drawing.Point(24, 98);
this.imageNameLabel.Name = "imageNameLabel";
this.imageNameLabel.Size = new System.Drawing.Size(81, 13);
this.imageNameLabel.TabIndex = 3;
this.imageNameLabel.Text = "Image file name";
//
// imageRotationLabel
//
this.imageRotationLabel.AutoSize = true;
this.imageRotationLabel.Location = new System.Drawing.Point(24, 175);
this.imageRotationLabel.Name = "imageRotationLabel";
this.imageRotationLabel.Size = new System.Drawing.Size(103, 13);
this.imageRotationLabel.TabIndex = 7;
this.imageRotationLabel.Text = "Image rotation (ccw)";
//
// imageRotationComboBox
//
this.imageRotationComboBox.Enabled = false;
this.imageRotationComboBox.FormattingEnabled = true;
this.imageRotationComboBox.Location = new System.Drawing.Point(149, 172);
this.imageRotationComboBox.Name = "imageRotationComboBox";
this.imageRotationComboBox.Size = new System.Drawing.Size(93, 21);
this.imageRotationComboBox.TabIndex = 8;
//
// GrabImageCfgCtrl
//
this.Controls.Add(this.imageRotationComboBox);
this.Controls.Add(this.imageRotationLabel);
this.Controls.Add(this.imageNameTextBox);
this.Controls.Add(this.imageNameLabel);
this.Controls.Add(this.blackAndWhiteCheckBox);
this.Controls.Add(this.loResolutionCheckBox);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "GrabImageCfgCtrl";
this.Size = new System.Drawing.Size(400, 250);
this.Load += new System.EventHandler(this.GrabImageCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label classNameLabel;
private System.Windows.Forms.CheckBox loResolutionCheckBox;
private System.Windows.Forms.CheckBox blackAndWhiteCheckBox;
private System.Windows.Forms.TextBox imageNameTextBox;
private System.Windows.Forms.Label imageNameLabel;
private System.Windows.Forms.Label imageRotationLabel;
private System.Windows.Forms.ComboBox imageRotationComboBox;
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1780,7 +1780,15 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
if (wm.Pruefindex == 1)
{
return SetQ2Correction(threadId, ihead, wm, ref resultStr, ihead.InitQ2CorrLR, ihead.InitQ2CorrRL);
if (TBF.BenchControl.Sequences.ProcessData.IsInitQ2CorrCalculated)
{
return SetQ2Correction(threadId, ihead, wm, ref resultStr, TBF.BenchControl.Sequences.ProcessData.CalculatedInitQ2CorrLR,
TBF.BenchControl.Sequences.ProcessData.CalculatedInitQ2CorrRL);
}
else
{
return SetQ2Correction(threadId, ihead, wm, ref resultStr, ihead.InitQ2CorrLR, ihead.InitQ2CorrRL);
}
}
else
{

View File

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

View File

@ -1467,6 +1467,13 @@
<Compile Include="BenchControl\TestMethods\PulsesTest\WMPulsesForm24.designer.cs">
<DependentUpon>WMPulsesForm24.cs</DependentUpon>
</Compile>
<Compile Include="BenchControl\TestMethods\Q2CorrectionFromHistory\Component.cs" />
<Compile Include="BenchControl\TestMethods\Q2CorrectionFromHistory\Factory.cs" />
<Compile Include="BenchControl\TestMethods\Q2CorrectionFromHistory\FromHistoryCfg.cs" />
<Compile Include="BenchControl\TestMethods\Q2CorrectionFromHistory\FromHistoryCfgCtrl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="BenchControl\TestMethods\Q2CorrectionFromHistory\FromHistorySeq.cs" />
<Compile Include="BenchControl\TestMethods\SensitivityTest\SensitivityTestSeq.cs" />
<Compile Include="BenchControl\TestMethods\SensitivityTest\TestMethodCfgCtrl.cs">
<SubType>UserControl</SubType>
@ -2897,6 +2904,9 @@
<EmbeddedResource Include="BenchControl\TestMethods\PulsesTest\WMPulsesForm24.resx">
<DependentUpon>WMPulsesForm24.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="BenchControl\TestMethods\Q2CorrectionFromHistory\FromHistoryCfgCtrl.resx">
<DependentUpon>FromHistoryCfgCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="BenchControl\TestMethods\RoiDetection\RoiDetectionCfgCtrl.resx">
<DependentUpon>RoiDetectionCfgCtrl.cs</DependentUpon>
</EmbeddedResource>