RFID communication properties are iPerlCommunication component parameters.
This commit is contained in:
parent
d041cd1d20
commit
e9440411bc
@ -21,6 +21,10 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
public int RfidPortNrBoard2;
|
||||
public int RfidPortNrBoard3;
|
||||
public int RfidPortNrBoard4;
|
||||
public int CommTimeout; /// Communication timeout in ms (500 .. 5000)
|
||||
public int MaxCommRetries; /// Max. number of retries (1 .. 10)
|
||||
public int NrThreads; /// Numbwr of parallel threads (1, 2 or 4)
|
||||
|
||||
|
||||
/// <summary> Test parameters </summary>
|
||||
[XmlIgnore]
|
||||
@ -42,6 +46,10 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
RfidPortNrBoard1 = 52;
|
||||
RfidPortNrBoard1 = 53;
|
||||
RfidPortNrBoard1 = 54;
|
||||
CommTimeout = 1800; /// ms
|
||||
MaxCommRetries = 4;
|
||||
NrThreads = 2; /// 1, 2 or 4 threads
|
||||
|
||||
TestParams = new iPerlCommunicationParams();
|
||||
}
|
||||
|
||||
@ -53,8 +61,8 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("Name={0}, Board#1=COM{1}, Board#2=COM{2}, Board#3=COM{3}, Board#4=COM{4}",
|
||||
Name, RfidPortNrBoard1, RfidPortNrBoard2, RfidPortNrBoard3, RfidPortNrBoard4);
|
||||
return string.Format("Name={0}, Brd#1=COM{1}, Brd#2=COM{2}, Brd#3=COM{3}, Brd#4=COM{4}, CommTimeout={5}, MaxRetries={6}, NrThreads={7}",
|
||||
Name, RfidPortNrBoard1, RfidPortNrBoard2, RfidPortNrBoard3, RfidPortNrBoard4, CommTimeout, MaxCommRetries, NrThreads);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,6 +48,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
rfidPortBoard2TextBox.Text = config.RfidPortNrBoard2.ToString();
|
||||
rfidPortBoard3TextBox.Text = config.RfidPortNrBoard3.ToString();
|
||||
rfidPortBoard4TextBox.Text = config.RfidPortNrBoard4.ToString();
|
||||
commTimeoutTextBox.Text = config.CommTimeout.ToString();
|
||||
maxCommRetriesTextBox.Text = config.MaxCommRetries.ToString();
|
||||
nrThreadsTextBox.Text = config.NrThreads.ToString();
|
||||
}
|
||||
|
||||
public void Unlock()
|
||||
@ -57,6 +60,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
rfidPortBoard2TextBox.Enabled = true;
|
||||
rfidPortBoard3TextBox.Enabled = true;
|
||||
rfidPortBoard4TextBox.Enabled = true;
|
||||
commTimeoutTextBox.Enabled = true;
|
||||
maxCommRetriesTextBox.Enabled = true;
|
||||
nrThreadsTextBox.Enabled = true;
|
||||
}
|
||||
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
@ -84,6 +90,21 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'RFID Port #4' is not valid";
|
||||
}
|
||||
if (!int.TryParse(commTimeoutTextBox.Text, out dummy) || dummy < 500 || dummy > 5000)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Comm. timeout' should be in range 500 .. 5000";
|
||||
}
|
||||
if (!int.TryParse(maxCommRetriesTextBox.Text, out dummy) || dummy < 1 || dummy > 10)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Max. retries' should be in range 1 .. 10";
|
||||
}
|
||||
if (!int.TryParse(nrThreadsTextBox.Text, out dummy) || (dummy != 1 && dummy != 2 && dummy != 4))
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Nr. threads' should be 1, 2 or 4";
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
@ -95,17 +116,26 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
|
||||
if (config.Name != nameTextBox.Text) { config.Name = nameTextBox.Text; flags = CfgUpdateFlags.RestartRqrd; }
|
||||
|
||||
int comPortNr = int.Parse(rfidPortBoard1TextBox.Text);
|
||||
if (config.RfidPortNrBoard1 != comPortNr) { config.RfidPortNrBoard1 = comPortNr; flags = CfgUpdateFlags.RestartRqrd; }
|
||||
int tmp = int.Parse(rfidPortBoard1TextBox.Text);
|
||||
if (config.RfidPortNrBoard1 != tmp) { config.RfidPortNrBoard1 = tmp; flags = CfgUpdateFlags.RestartRqrd; }
|
||||
|
||||
comPortNr = int.Parse(rfidPortBoard2TextBox.Text);
|
||||
if (config.RfidPortNrBoard2 != comPortNr) { config.RfidPortNrBoard2 = comPortNr; flags = CfgUpdateFlags.RestartRqrd; }
|
||||
tmp = int.Parse(rfidPortBoard2TextBox.Text);
|
||||
if (config.RfidPortNrBoard2 != tmp) { config.RfidPortNrBoard2 = tmp; flags = CfgUpdateFlags.RestartRqrd; }
|
||||
|
||||
comPortNr = int.Parse(rfidPortBoard3TextBox.Text);
|
||||
if (config.RfidPortNrBoard3 != comPortNr) { config.RfidPortNrBoard3 = comPortNr; flags = CfgUpdateFlags.RestartRqrd; }
|
||||
tmp = int.Parse(rfidPortBoard3TextBox.Text);
|
||||
if (config.RfidPortNrBoard3 != tmp) { config.RfidPortNrBoard3 = tmp; flags = CfgUpdateFlags.RestartRqrd; }
|
||||
|
||||
comPortNr = int.Parse(rfidPortBoard4TextBox.Text);
|
||||
if (config.RfidPortNrBoard4 != comPortNr) { config.RfidPortNrBoard4 = comPortNr; flags = CfgUpdateFlags.RestartRqrd; }
|
||||
tmp = int.Parse(rfidPortBoard4TextBox.Text);
|
||||
if (config.RfidPortNrBoard4 != tmp) { config.RfidPortNrBoard4 = tmp; flags = CfgUpdateFlags.RestartRqrd; }
|
||||
|
||||
tmp = int.Parse(commTimeoutTextBox.Text);
|
||||
if (config.CommTimeout != tmp) { config.CommTimeout = tmp; flags = CfgUpdateFlags.RestartRqrd; }
|
||||
|
||||
tmp = int.Parse(maxCommRetriesTextBox.Text);
|
||||
if (config.MaxCommRetries != tmp) { config.MaxCommRetries = tmp; flags = CfgUpdateFlags.RestartRqrd; }
|
||||
|
||||
tmp = int.Parse(nrThreadsTextBox.Text);
|
||||
if (config.NrThreads != tmp) { config.NrThreads = tmp; flags = CfgUpdateFlags.RestartRqrd; }
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
@ -43,12 +43,18 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
this.rfidPortBoard3Label = new System.Windows.Forms.Label();
|
||||
this.rfidPortBoard4TextBox = new System.Windows.Forms.TextBox();
|
||||
this.rfidPortBoard4Label = new System.Windows.Forms.Label();
|
||||
this.commTimeoutTextBox = new System.Windows.Forms.TextBox();
|
||||
this.commTimeoutLabel = new System.Windows.Forms.Label();
|
||||
this.maxCommRetriesTextBox = new System.Windows.Forms.TextBox();
|
||||
this.maxNrRetriesLabel = new System.Windows.Forms.Label();
|
||||
this.nrThreadsTextBox = new System.Windows.Forms.TextBox();
|
||||
this.nrThreadsLabel = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// nameTextBox
|
||||
//
|
||||
this.nameTextBox.Enabled = false;
|
||||
this.nameTextBox.Location = new System.Drawing.Point(137, 57);
|
||||
this.nameTextBox.Location = new System.Drawing.Point(133, 25);
|
||||
this.nameTextBox.Name = "nameTextBox";
|
||||
this.nameTextBox.Size = new System.Drawing.Size(130, 20);
|
||||
this.nameTextBox.TabIndex = 5;
|
||||
@ -56,7 +62,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
// nameLabel
|
||||
//
|
||||
this.nameLabel.AutoSize = true;
|
||||
this.nameLabel.Location = new System.Drawing.Point(27, 60);
|
||||
this.nameLabel.Location = new System.Drawing.Point(23, 28);
|
||||
this.nameLabel.Name = "nameLabel";
|
||||
this.nameLabel.Size = new System.Drawing.Size(35, 13);
|
||||
this.nameLabel.TabIndex = 4;
|
||||
@ -65,7 +71,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
// classNameLabel
|
||||
//
|
||||
this.classNameLabel.AutoSize = true;
|
||||
this.classNameLabel.Location = new System.Drawing.Point(134, 33);
|
||||
this.classNameLabel.Location = new System.Drawing.Point(132, 7);
|
||||
this.classNameLabel.Name = "classNameLabel";
|
||||
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
|
||||
this.classNameLabel.TabIndex = 3;
|
||||
@ -74,75 +80,132 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
// rfidPortBoard1TextBox
|
||||
//
|
||||
this.rfidPortBoard1TextBox.Enabled = false;
|
||||
this.rfidPortBoard1TextBox.Location = new System.Drawing.Point(137, 83);
|
||||
this.rfidPortBoard1TextBox.Location = new System.Drawing.Point(133, 47);
|
||||
this.rfidPortBoard1TextBox.Name = "rfidPortBoard1TextBox";
|
||||
this.rfidPortBoard1TextBox.Size = new System.Drawing.Size(34, 20);
|
||||
this.rfidPortBoard1TextBox.Size = new System.Drawing.Size(45, 20);
|
||||
this.rfidPortBoard1TextBox.TabIndex = 9;
|
||||
//
|
||||
// rfidPortBoard1Label
|
||||
//
|
||||
this.rfidPortBoard1Label.AutoSize = true;
|
||||
this.rfidPortBoard1Label.Location = new System.Drawing.Point(27, 86);
|
||||
this.rfidPortBoard1Label.Location = new System.Drawing.Point(23, 50);
|
||||
this.rfidPortBoard1Label.Name = "rfidPortBoard1Label";
|
||||
this.rfidPortBoard1Label.Size = new System.Drawing.Size(99, 13);
|
||||
this.rfidPortBoard1Label.Size = new System.Drawing.Size(96, 13);
|
||||
this.rfidPortBoard1Label.TabIndex = 8;
|
||||
this.rfidPortBoard1Label.Text = "RFID COM port #1:";
|
||||
this.rfidPortBoard1Label.Text = "RFID COM port #1";
|
||||
//
|
||||
// rfidPortBoard2TextBox
|
||||
//
|
||||
this.rfidPortBoard2TextBox.Enabled = false;
|
||||
this.rfidPortBoard2TextBox.Location = new System.Drawing.Point(137, 109);
|
||||
this.rfidPortBoard2TextBox.Location = new System.Drawing.Point(133, 69);
|
||||
this.rfidPortBoard2TextBox.Name = "rfidPortBoard2TextBox";
|
||||
this.rfidPortBoard2TextBox.Size = new System.Drawing.Size(34, 20);
|
||||
this.rfidPortBoard2TextBox.Size = new System.Drawing.Size(45, 20);
|
||||
this.rfidPortBoard2TextBox.TabIndex = 11;
|
||||
//
|
||||
// rfidPortBoard2Label
|
||||
//
|
||||
this.rfidPortBoard2Label.AutoSize = true;
|
||||
this.rfidPortBoard2Label.Location = new System.Drawing.Point(27, 112);
|
||||
this.rfidPortBoard2Label.Location = new System.Drawing.Point(23, 72);
|
||||
this.rfidPortBoard2Label.Name = "rfidPortBoard2Label";
|
||||
this.rfidPortBoard2Label.Size = new System.Drawing.Size(99, 13);
|
||||
this.rfidPortBoard2Label.Size = new System.Drawing.Size(96, 13);
|
||||
this.rfidPortBoard2Label.TabIndex = 10;
|
||||
this.rfidPortBoard2Label.Text = "RFID COM port #2:";
|
||||
this.rfidPortBoard2Label.Text = "RFID COM port #2";
|
||||
//
|
||||
// rfidPortBoard3TextBox
|
||||
//
|
||||
this.rfidPortBoard3TextBox.Enabled = false;
|
||||
this.rfidPortBoard3TextBox.Location = new System.Drawing.Point(137, 135);
|
||||
this.rfidPortBoard3TextBox.Location = new System.Drawing.Point(133, 91);
|
||||
this.rfidPortBoard3TextBox.Name = "rfidPortBoard3TextBox";
|
||||
this.rfidPortBoard3TextBox.Size = new System.Drawing.Size(34, 20);
|
||||
this.rfidPortBoard3TextBox.Size = new System.Drawing.Size(45, 20);
|
||||
this.rfidPortBoard3TextBox.TabIndex = 13;
|
||||
//
|
||||
// rfidPortBoard3Label
|
||||
//
|
||||
this.rfidPortBoard3Label.AutoSize = true;
|
||||
this.rfidPortBoard3Label.Location = new System.Drawing.Point(27, 138);
|
||||
this.rfidPortBoard3Label.Location = new System.Drawing.Point(23, 94);
|
||||
this.rfidPortBoard3Label.Name = "rfidPortBoard3Label";
|
||||
this.rfidPortBoard3Label.Size = new System.Drawing.Size(99, 13);
|
||||
this.rfidPortBoard3Label.Size = new System.Drawing.Size(96, 13);
|
||||
this.rfidPortBoard3Label.TabIndex = 12;
|
||||
this.rfidPortBoard3Label.Text = "RFID COM port #3:";
|
||||
this.rfidPortBoard3Label.Text = "RFID COM port #3";
|
||||
//
|
||||
// rfidPortBoard4TextBox
|
||||
//
|
||||
this.rfidPortBoard4TextBox.Enabled = false;
|
||||
this.rfidPortBoard4TextBox.Location = new System.Drawing.Point(137, 161);
|
||||
this.rfidPortBoard4TextBox.Location = new System.Drawing.Point(133, 113);
|
||||
this.rfidPortBoard4TextBox.Name = "rfidPortBoard4TextBox";
|
||||
this.rfidPortBoard4TextBox.Size = new System.Drawing.Size(34, 20);
|
||||
this.rfidPortBoard4TextBox.Size = new System.Drawing.Size(45, 20);
|
||||
this.rfidPortBoard4TextBox.TabIndex = 15;
|
||||
//
|
||||
// rfidPortBoard4Label
|
||||
//
|
||||
this.rfidPortBoard4Label.AutoSize = true;
|
||||
this.rfidPortBoard4Label.Location = new System.Drawing.Point(27, 164);
|
||||
this.rfidPortBoard4Label.Location = new System.Drawing.Point(23, 116);
|
||||
this.rfidPortBoard4Label.Name = "rfidPortBoard4Label";
|
||||
this.rfidPortBoard4Label.Size = new System.Drawing.Size(99, 13);
|
||||
this.rfidPortBoard4Label.Size = new System.Drawing.Size(96, 13);
|
||||
this.rfidPortBoard4Label.TabIndex = 14;
|
||||
this.rfidPortBoard4Label.Text = "RFID COM port #4:";
|
||||
this.rfidPortBoard4Label.Text = "RFID COM port #4";
|
||||
//
|
||||
// commTimeoutTextBox
|
||||
//
|
||||
this.commTimeoutTextBox.Enabled = false;
|
||||
this.commTimeoutTextBox.Location = new System.Drawing.Point(133, 135);
|
||||
this.commTimeoutTextBox.Name = "commTimeoutTextBox";
|
||||
this.commTimeoutTextBox.Size = new System.Drawing.Size(45, 20);
|
||||
this.commTimeoutTextBox.TabIndex = 17;
|
||||
//
|
||||
// commTimeoutLabel
|
||||
//
|
||||
this.commTimeoutLabel.AutoSize = true;
|
||||
this.commTimeoutLabel.Location = new System.Drawing.Point(23, 138);
|
||||
this.commTimeoutLabel.Name = "commTimeoutLabel";
|
||||
this.commTimeoutLabel.Size = new System.Drawing.Size(98, 13);
|
||||
this.commTimeoutLabel.TabIndex = 16;
|
||||
this.commTimeoutLabel.Text = "Comm. timeout [ms]";
|
||||
//
|
||||
// maxNrRetriesTextBox
|
||||
//
|
||||
this.maxCommRetriesTextBox.Enabled = false;
|
||||
this.maxCommRetriesTextBox.Location = new System.Drawing.Point(133, 157);
|
||||
this.maxCommRetriesTextBox.Name = "maxNrRetriesTextBox";
|
||||
this.maxCommRetriesTextBox.Size = new System.Drawing.Size(45, 20);
|
||||
this.maxCommRetriesTextBox.TabIndex = 19;
|
||||
//
|
||||
// maxNrRetriesLabel
|
||||
//
|
||||
this.maxNrRetriesLabel.AutoSize = true;
|
||||
this.maxNrRetriesLabel.Location = new System.Drawing.Point(23, 160);
|
||||
this.maxNrRetriesLabel.Name = "maxNrRetriesLabel";
|
||||
this.maxNrRetriesLabel.Size = new System.Drawing.Size(61, 13);
|
||||
this.maxNrRetriesLabel.TabIndex = 18;
|
||||
this.maxNrRetriesLabel.Text = "Max. retries";
|
||||
//
|
||||
// nrThreadsTextBox
|
||||
//
|
||||
this.nrThreadsTextBox.Enabled = false;
|
||||
this.nrThreadsTextBox.Location = new System.Drawing.Point(133, 179);
|
||||
this.nrThreadsTextBox.Name = "nrThreadsTextBox";
|
||||
this.nrThreadsTextBox.Size = new System.Drawing.Size(45, 20);
|
||||
this.nrThreadsTextBox.TabIndex = 21;
|
||||
//
|
||||
// nrThreadsLabel
|
||||
//
|
||||
this.nrThreadsLabel.AutoSize = true;
|
||||
this.nrThreadsLabel.Location = new System.Drawing.Point(23, 182);
|
||||
this.nrThreadsLabel.Name = "nrThreadsLabel";
|
||||
this.nrThreadsLabel.Size = new System.Drawing.Size(59, 13);
|
||||
this.nrThreadsLabel.TabIndex = 20;
|
||||
this.nrThreadsLabel.Text = "Nr. threads";
|
||||
//
|
||||
// TestMethodCfgCtrl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.nrThreadsTextBox);
|
||||
this.Controls.Add(this.nrThreadsLabel);
|
||||
this.Controls.Add(this.maxCommRetriesTextBox);
|
||||
this.Controls.Add(this.maxNrRetriesLabel);
|
||||
this.Controls.Add(this.commTimeoutTextBox);
|
||||
this.Controls.Add(this.commTimeoutLabel);
|
||||
this.Controls.Add(this.rfidPortBoard4TextBox);
|
||||
this.Controls.Add(this.rfidPortBoard4Label);
|
||||
this.Controls.Add(this.rfidPortBoard3TextBox);
|
||||
@ -175,5 +238,11 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
private System.Windows.Forms.Label rfidPortBoard3Label;
|
||||
private System.Windows.Forms.TextBox rfidPortBoard4TextBox;
|
||||
private System.Windows.Forms.Label rfidPortBoard4Label;
|
||||
private System.Windows.Forms.TextBox commTimeoutTextBox;
|
||||
private System.Windows.Forms.Label commTimeoutLabel;
|
||||
private System.Windows.Forms.TextBox maxCommRetriesTextBox;
|
||||
private System.Windows.Forms.Label maxNrRetriesLabel;
|
||||
private System.Windows.Forms.TextBox nrThreadsTextBox;
|
||||
private System.Windows.Forms.Label nrThreadsLabel;
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,11 +29,6 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
|
||||
public partial class iPerlCommunicationForm : Form, GenericDevices.IHasCompleted
|
||||
{
|
||||
const int CommTimeout = 1800;
|
||||
const int MaxCommRetries = 4;
|
||||
const int NrThreads = 2; /// 1, 2 or 4 threads
|
||||
|
||||
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(iPerlCommunicationForm));
|
||||
protected static readonly ILog rfidDataLogger = LogManager.GetLogger("RfidData");
|
||||
|
||||
@ -141,7 +136,11 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
else if (messageID == MessageID.MetrologyMemory)
|
||||
{
|
||||
}
|
||||
retv = 0;
|
||||
|
||||
if (wm.Name.Equals("iPerl13"))
|
||||
retv = 2;
|
||||
else
|
||||
retv = 0;
|
||||
}
|
||||
|
||||
rfidDataLogger.InfoFormat("{0}, ReadRequestPort({1}, {2}, {3}, ...) returned {4} {5}", wm.Name, messageID, offset, lenght, retv, (retv != 0) ? "!" : "");
|
||||
@ -328,9 +327,11 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// Creates a list of iPerl-s, re-shuffles UI conrols and allocates 'disabled' array.
|
||||
/// </summary>
|
||||
/// <param name="waterMetersCount">Number of text boxes for serial numbers</param>
|
||||
public iPerlCommunicationForm(IList<GenericDevices.IWaterMeter> waterMeters)
|
||||
public iPerlCommunicationForm(IList<GenericDevices.IWaterMeter> waterMeters, TestMethodCfg cfg)
|
||||
: this()
|
||||
{
|
||||
iPerlCommunicationForm.cfg = cfg;
|
||||
|
||||
this.WaterMetersCount = waterMeters.Count;
|
||||
iPerlCommunicationForm.waterMeters = new List<WaterMeters.iPerl.WaterMeter>();
|
||||
///
|
||||
@ -362,7 +363,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
{
|
||||
rfidPortNrs.Add(iPerl.MuxBoardNr);
|
||||
|
||||
if (workerThreads.Count < NrThreads)
|
||||
if (workerThreads.Count < cfg.NrThreads)
|
||||
{
|
||||
Thread thread = new Thread(iPerlCommunicationForm.Worker);
|
||||
workerThreads.Add(thread);
|
||||
@ -379,10 +380,8 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// <param name="waterMetersCount">Number of text boxes for serial numbers</param>
|
||||
public iPerlCommunicationForm(IList<GenericDevices.IWaterMeter> waterMeters,
|
||||
TestMethodCfg cfg, iPerlCommunicationParams testParams)
|
||||
: this(waterMeters)
|
||||
: this(waterMeters, cfg)
|
||||
{
|
||||
iPerlCommunicationForm.cfg = cfg;
|
||||
|
||||
iPerlCommunicationForm.multiTestParams = new List<iPerlCommunicationParams>();
|
||||
iPerlCommunicationForm.multiTestParams.Add(testParams);
|
||||
|
||||
@ -396,9 +395,8 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// <param name="waterMetersCount">Number of text boxes for serial numbers</param>
|
||||
public iPerlCommunicationForm(IList<GenericDevices.IWaterMeter> waterMeters, TestMethodCfg cfg,
|
||||
IList<iPerlCommunicationParams> multiTestParams)
|
||||
: this(waterMeters)
|
||||
: this(waterMeters, cfg)
|
||||
{
|
||||
iPerlCommunicationForm.cfg = cfg;
|
||||
iPerlCommunicationForm.multiTestParams = multiTestParams;
|
||||
|
||||
if (multiTestParams.Count > 0) activityLabel.Text = multiTestParams[0].Activity;
|
||||
@ -560,7 +558,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
|
||||
if (stopWorkerThreads) break;
|
||||
|
||||
for (int rfidPortIx = threadId; rfidPortIx < threadId + 4; rfidPortIx += NrThreads)
|
||||
for (int rfidPortIx = threadId; rfidPortIx < threadId + 4; rfidPortIx += cfg.NrThreads)
|
||||
{
|
||||
int rfidPortNr = rfidPortNrs[rfidPortIx];
|
||||
int wmNr = 0;
|
||||
@ -648,9 +646,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
|
||||
/// Read configuration
|
||||
byte[] config = null;
|
||||
for (int j = 0; j < MaxCommRetries; j++)
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == ReadRequestPort(wm, MessageID.Configuration, 0, ConfigStruct.Length, out config, CommTimeout))
|
||||
if (0 == ReadRequestPort(wm, MessageID.Configuration, 0, ConfigStruct.Length, out config, cfg.CommTimeout))
|
||||
{
|
||||
error = CommErr.None;
|
||||
wm.ConfigStruct = ConfigStruct.FromByteArray(config);
|
||||
@ -707,9 +705,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// Switch to Active mode in order to change TestModeConfig
|
||||
error = CommErr.CmdActive;
|
||||
byte[] cmd = new byte[1] { (byte)6 };
|
||||
for (int j = 0; j < MaxCommRetries; j++)
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == WriteRequestPort(wm, MessageID.Command, 0, 1, cmd, CommTimeout)) { error = CommErr.None; break; }
|
||||
if (0 == WriteRequestPort(wm, MessageID.Command, 0, 1, cmd, cfg.CommTimeout)) { error = CommErr.None; break; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -718,9 +716,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// Change the TestModeConfig if necessary
|
||||
error = CommErr.Write;
|
||||
byte[] tstMdCfg = new byte[1] { testModeConfig };
|
||||
for (int j = 0; j < MaxCommRetries; j++)
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == WriteRequestPort(wm, MessageID.Configuration, 21, 1, tstMdCfg, CommTimeout))
|
||||
if (0 == WriteRequestPort(wm, MessageID.Configuration, 21, 1, tstMdCfg, cfg.CommTimeout))
|
||||
{
|
||||
wm.ConfigStruct.Update(21, tstMdCfg);
|
||||
error = CommErr.None;
|
||||
@ -734,9 +732,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// Switch to test mode
|
||||
error = CommErr.CmdTest;
|
||||
byte[] cmd = new byte[1] { (byte)7 };
|
||||
for (int j = 0; j < MaxCommRetries; j++)
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == WriteRequestPort(wm, MessageID.Command, 0, 1, cmd, CommTimeout)) { error = CommErr.None; break; }
|
||||
if (0 == WriteRequestPort(wm, MessageID.Command, 0, 1, cmd, cfg.CommTimeout)) { error = CommErr.None; break; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -746,9 +744,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// Verify the configuration
|
||||
error = CommErr.Verify;
|
||||
byte[] cfg_0_3 = null;
|
||||
for (int j = 0; j < MaxCommRetries; j++)
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == ReadRequestPort(wm, MessageID.Configuration, 0, 4, out cfg_0_3, CommTimeout))
|
||||
if (0 == ReadRequestPort(wm, MessageID.Configuration, 0, 4, out cfg_0_3, cfg.CommTimeout))
|
||||
{
|
||||
wm.ConfigStruct.Update(0, cfg_0_3);
|
||||
if (wm.ConfigStruct.MeterState == MeterState.Test)
|
||||
@ -784,9 +782,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
|
||||
/// Switch to active mode
|
||||
byte[] cmd = new byte[1] { (byte)6 };
|
||||
for (int j = 0; j < MaxCommRetries; j++)
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == WriteRequestPort(wm, MessageID.Command, 0, 1, cmd, CommTimeout)) { error = CommErr.None; break; }
|
||||
if (0 == WriteRequestPort(wm, MessageID.Command, 0, 1, cmd, cfg.CommTimeout)) { error = CommErr.None; break; }
|
||||
}
|
||||
|
||||
if (error == CommErr.None)
|
||||
@ -795,9 +793,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
|
||||
/// Read configuration
|
||||
byte[] cfg_0_3 = null;
|
||||
for (int j = 0; j < MaxCommRetries; j++)
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == ReadRequestPort(wm, MessageID.Configuration, 0, 4, out cfg_0_3, CommTimeout))
|
||||
if (0 == ReadRequestPort(wm, MessageID.Configuration, 0, 4, out cfg_0_3, cfg.CommTimeout))
|
||||
{
|
||||
wm.ConfigStruct.Update(0, cfg_0_3);
|
||||
if (wm.ConfigStruct.MeterState == MeterState.Active)
|
||||
@ -832,9 +830,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
|
||||
/// Read calibration
|
||||
byte[] calib = null;
|
||||
for (int j = 0; j < MaxCommRetries; j++)
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == ReadRequestPort(wm, MessageID.Calibration, 0, CalibrationStruct.Length, out calib, CommTimeout))
|
||||
if (0 == ReadRequestPort(wm, MessageID.Calibration, 0, CalibrationStruct.Length, out calib, cfg.CommTimeout))
|
||||
{
|
||||
error = CommErr.None;
|
||||
wm.CalibrationStruct = CalibrationStruct.FromByteArray(calib);
|
||||
@ -882,9 +880,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
}
|
||||
|
||||
byte[] data = new byte[2] { (byte)(newCalibFactor & 0x00FF), (byte)((newCalibFactor >> 8) & 0x00FF) };
|
||||
for (int j = 0; j < MaxCommRetries; j++)
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == WriteRequestPort(wm, MessageID.Calibration, 2, 2, data, CommTimeout))
|
||||
if (0 == WriteRequestPort(wm, MessageID.Calibration, 2, 2, data, cfg.CommTimeout))
|
||||
{
|
||||
error = CommErr.None;
|
||||
wm.CalibrationStruct.Update(data, 2);
|
||||
@ -898,9 +896,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
|
||||
/// Read calibration
|
||||
byte[] calib_2_3 = null;
|
||||
for (int j = 0; j < MaxCommRetries; j++)
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == ReadRequestPort(wm, MessageID.Calibration, 2, 2, out calib_2_3, CommTimeout))
|
||||
if (0 == ReadRequestPort(wm, MessageID.Calibration, 2, 2, out calib_2_3, cfg.CommTimeout))
|
||||
{
|
||||
error = CommErr.None;
|
||||
wm.CalibrationStruct.Update(calib_2_3, 2);
|
||||
@ -937,9 +935,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// Write zero Q2 correction
|
||||
byte[] wrData = new byte[2] { 0, 0 };
|
||||
///
|
||||
for (int j = 0; j < MaxCommRetries; j++)
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == WriteRequestPort(wm, MessageID.MetrologyMemory, Q2CorrFactorsAddr, 2, wrData, CommTimeout)) { error = CommErr.None; break; }
|
||||
if (0 == WriteRequestPort(wm, MessageID.MetrologyMemory, Q2CorrFactorsAddr, 2, wrData, cfg.CommTimeout)) { error = CommErr.None; break; }
|
||||
}
|
||||
|
||||
/// Verify the correction factors
|
||||
@ -949,9 +947,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
|
||||
/// Read calibration
|
||||
byte[] rdData = null;
|
||||
for (int j = 0; j < MaxCommRetries; j++)
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if ((0 == ReadRequestPort(wm, MessageID.MetrologyMemory, Q2CorrFactorsAddr, 2, out rdData, CommTimeout)) &&
|
||||
if ((0 == ReadRequestPort(wm, MessageID.MetrologyMemory, Q2CorrFactorsAddr, 2, out rdData, cfg.CommTimeout)) &&
|
||||
(rdData != null) && (rdData.Length == 2) && (rdData[0] == 0) && (rdData[1] == 0))
|
||||
{
|
||||
error = CommErr.None;
|
||||
@ -989,9 +987,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
Byte q2CorrLFlow = (byte)((int)Math.Round(q2CorrectionFactor) & 0x000000FF);
|
||||
byte[] wrData = new byte[2] { q2CorrRFlow, q2CorrLFlow };
|
||||
///
|
||||
for (int j = 0; j < MaxCommRetries; j++)
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == WriteRequestPort(wm, MessageID.MetrologyMemory, Q2CorrFactorsAddr, 2, wrData, CommTimeout)) { error = CommErr.None; break; }
|
||||
if (0 == WriteRequestPort(wm, MessageID.MetrologyMemory, Q2CorrFactorsAddr, 2, wrData, cfg.CommTimeout)) { error = CommErr.None; break; }
|
||||
}
|
||||
|
||||
if (error == CommErr.None)
|
||||
@ -1000,9 +998,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
|
||||
/// Read calibration
|
||||
byte[] rdData = null;
|
||||
for (int j = 0; j < MaxCommRetries; j++)
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if ((0 == ReadRequestPort(wm, MessageID.MetrologyMemory, Q2CorrFactorsAddr, 2, out rdData, CommTimeout)) &&
|
||||
if ((0 == ReadRequestPort(wm, MessageID.MetrologyMemory, Q2CorrFactorsAddr, 2, out rdData, cfg.CommTimeout)) &&
|
||||
(rdData != null) && (rdData.Length == 2) && (rdData[0] == q2CorrRFlow) && (rdData[1] == q2CorrLFlow))
|
||||
{
|
||||
error = CommErr.None;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user