Many changes, iPerl-s have Board# param., iPerlCommunication has RFIT port nr. params, bugfixes, etc.
This commit is contained in:
@@ -40,7 +40,7 @@ namespace TBF.BenchControl.DB.SensusOracle
|
||||
|
||||
public Database()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public Database(DatabaseCfg cfg)
|
||||
: base(cfg)
|
||||
|
||||
@@ -341,7 +341,7 @@ namespace TBF.BenchControl.TestMethods.iPerlAdjustment
|
||||
{
|
||||
byte[] data = null;
|
||||
bool success = false;
|
||||
int r1 = openPort((uint)wm.RfidComPortNr);
|
||||
int r1 = openPort((uint)wm.MuxBoardNr);
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
if (0 == ReadRequestPort(MessageID.Configuration, 0, ConfigStruct.Length, out data, 1000))
|
||||
@@ -386,7 +386,7 @@ namespace TBF.BenchControl.TestMethods.iPerlAdjustment
|
||||
{
|
||||
if (wm.DebugLevel == Entities.DebugMode.Normal && wm.Group == group)
|
||||
{
|
||||
int r1 = openPort((uint)wm.RfidComPortNr);
|
||||
int r1 = openPort((uint)wm.MuxBoardNr);
|
||||
int r2 = WriteRequestPort(MessageID.Command, 0, 1, data, 1000);
|
||||
int r3 = closePort();
|
||||
}
|
||||
@@ -415,7 +415,7 @@ namespace TBF.BenchControl.TestMethods.iPerlAdjustment
|
||||
{
|
||||
if (wm.DebugLevel == Entities.DebugMode.Normal && wm.Group == group)
|
||||
{
|
||||
int r1 = openPort((uint)wm.RfidComPortNr);
|
||||
int r1 = openPort((uint)wm.MuxBoardNr);
|
||||
int r2 = WriteRequestPort(MessageID.Command, 0, 1, data, 1000);
|
||||
int r3 = closePort();
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
|
||||
public IList<Event> Execute(Entities.Test test)
|
||||
{
|
||||
return (new iPerlCommunicationSeq()).Execute(test, testMethodCfg.TestParams);
|
||||
return (new iPerlCommunicationSeq()).Execute(test, testMethodCfg, testMethodCfg.TestParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,14 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
public IComponent GetComponent(IList<IComponent> components) { return new TestMethod(this); }
|
||||
public IComponentCfgCtrl GetControl() { return new TestMethodCfgCtrl(); }
|
||||
|
||||
///
|
||||
/// Serialized parameters
|
||||
///
|
||||
public int RfidPortNrBoard1;
|
||||
public int RfidPortNrBoard2;
|
||||
public int RfidPortNrBoard3;
|
||||
public int RfidPortNrBoard4;
|
||||
|
||||
/// <summary> Test parameters </summary>
|
||||
[XmlIgnore]
|
||||
public iPerlCommunicationParams TestParams;
|
||||
@@ -31,6 +39,10 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
{
|
||||
Name = "iPerlCommunication";
|
||||
ParentName = string.Empty;
|
||||
RfidPortNrBoard1 = 51;
|
||||
RfidPortNrBoard1 = 52;
|
||||
RfidPortNrBoard1 = 53;
|
||||
RfidPortNrBoard1 = 54;
|
||||
TestParams = new iPerlCommunicationParams();
|
||||
}
|
||||
|
||||
|
||||
@@ -45,16 +45,46 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
classNameLabel.Text = config.Factory.ClassName;
|
||||
nameTextBox.Text = config.Name;
|
||||
rfidPortBoard1TextBox.Text = config.RfidPortNrBoard1.ToString();
|
||||
rfidPortBoard2TextBox.Text = config.RfidPortNrBoard2.ToString();
|
||||
rfidPortBoard3TextBox.Text = config.RfidPortNrBoard3.ToString();
|
||||
rfidPortBoard4TextBox.Text = config.RfidPortNrBoard4.ToString();
|
||||
}
|
||||
|
||||
public void Unlock()
|
||||
{
|
||||
nameTextBox.Enabled = true;
|
||||
rfidPortBoard1TextBox.Enabled = true;
|
||||
rfidPortBoard2TextBox.Enabled = true;
|
||||
rfidPortBoard3TextBox.Enabled = true;
|
||||
rfidPortBoard4TextBox.Enabled = true;
|
||||
}
|
||||
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
{
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.None;
|
||||
|
||||
int dummy;
|
||||
if (!int.TryParse(rfidPortBoard1TextBox.Text, out dummy) || dummy < 1 || dummy > 999)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'RFID Port #1' is not valid";
|
||||
}
|
||||
if (!int.TryParse(rfidPortBoard2TextBox.Text, out dummy) || dummy < 1 || dummy > 999)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'RFID Port #2' is not valid";
|
||||
}
|
||||
if (!int.TryParse(rfidPortBoard3TextBox.Text, out dummy) || dummy < 1 || dummy > 999)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'RFID Port #3' is not valid";
|
||||
}
|
||||
if (!int.TryParse(rfidPortBoard4TextBox.Text, out dummy) || dummy < 1 || dummy > 999)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'RFID Port #4' is not valid";
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
@@ -65,6 +95,10 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
|
||||
|
||||
config.Name = nameTextBox.Text;
|
||||
config.RfidPortNrBoard1 = int.Parse(rfidPortBoard1TextBox.Text);
|
||||
config.RfidPortNrBoard2 = int.Parse(rfidPortBoard2TextBox.Text);
|
||||
config.RfidPortNrBoard3 = int.Parse(rfidPortBoard3TextBox.Text);
|
||||
config.RfidPortNrBoard4 = int.Parse(rfidPortBoard4TextBox.Text);
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
Generated
+94
-2
@@ -35,6 +35,14 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
this.nameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.nameLabel = new System.Windows.Forms.Label();
|
||||
this.classNameLabel = new System.Windows.Forms.Label();
|
||||
this.rfidPortBoard1TextBox = new System.Windows.Forms.TextBox();
|
||||
this.rfidPortBoard1Label = new System.Windows.Forms.Label();
|
||||
this.rfidPortBoard2TextBox = new System.Windows.Forms.TextBox();
|
||||
this.rfidPortBoard2Label = new System.Windows.Forms.Label();
|
||||
this.rfidPortBoard3TextBox = new System.Windows.Forms.TextBox();
|
||||
this.rfidPortBoard3Label = new System.Windows.Forms.Label();
|
||||
this.rfidPortBoard4TextBox = new System.Windows.Forms.TextBox();
|
||||
this.rfidPortBoard4Label = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// nameTextBox
|
||||
@@ -63,14 +71,90 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
this.classNameLabel.TabIndex = 3;
|
||||
this.classNameLabel.Text = "ComonentName";
|
||||
//
|
||||
// BasicPrinterCfgCtrl
|
||||
// rfidPortBoard1TextBox
|
||||
//
|
||||
this.rfidPortBoard1TextBox.Enabled = false;
|
||||
this.rfidPortBoard1TextBox.Location = new System.Drawing.Point(137, 83);
|
||||
this.rfidPortBoard1TextBox.Name = "rfidPortBoard1TextBox";
|
||||
this.rfidPortBoard1TextBox.Size = new System.Drawing.Size(34, 20);
|
||||
this.rfidPortBoard1TextBox.TabIndex = 9;
|
||||
//
|
||||
// rfidPortBoard1Label
|
||||
//
|
||||
this.rfidPortBoard1Label.AutoSize = true;
|
||||
this.rfidPortBoard1Label.Location = new System.Drawing.Point(27, 86);
|
||||
this.rfidPortBoard1Label.Name = "rfidPortBoard1Label";
|
||||
this.rfidPortBoard1Label.Size = new System.Drawing.Size(99, 13);
|
||||
this.rfidPortBoard1Label.TabIndex = 8;
|
||||
this.rfidPortBoard1Label.Text = "RFID COM port #1:";
|
||||
//
|
||||
// rfidPortBoard2TextBox
|
||||
//
|
||||
this.rfidPortBoard2TextBox.Enabled = false;
|
||||
this.rfidPortBoard2TextBox.Location = new System.Drawing.Point(137, 109);
|
||||
this.rfidPortBoard2TextBox.Name = "rfidPortBoard2TextBox";
|
||||
this.rfidPortBoard2TextBox.Size = new System.Drawing.Size(34, 20);
|
||||
this.rfidPortBoard2TextBox.TabIndex = 11;
|
||||
//
|
||||
// rfidPortBoard2Label
|
||||
//
|
||||
this.rfidPortBoard2Label.AutoSize = true;
|
||||
this.rfidPortBoard2Label.Location = new System.Drawing.Point(27, 112);
|
||||
this.rfidPortBoard2Label.Name = "rfidPortBoard2Label";
|
||||
this.rfidPortBoard2Label.Size = new System.Drawing.Size(99, 13);
|
||||
this.rfidPortBoard2Label.TabIndex = 10;
|
||||
this.rfidPortBoard2Label.Text = "RFID COM port #2:";
|
||||
//
|
||||
// rfidPortBoard3TextBox
|
||||
//
|
||||
this.rfidPortBoard3TextBox.Enabled = false;
|
||||
this.rfidPortBoard3TextBox.Location = new System.Drawing.Point(137, 135);
|
||||
this.rfidPortBoard3TextBox.Name = "rfidPortBoard3TextBox";
|
||||
this.rfidPortBoard3TextBox.Size = new System.Drawing.Size(34, 20);
|
||||
this.rfidPortBoard3TextBox.TabIndex = 13;
|
||||
//
|
||||
// rfidPortBoard3Label
|
||||
//
|
||||
this.rfidPortBoard3Label.AutoSize = true;
|
||||
this.rfidPortBoard3Label.Location = new System.Drawing.Point(27, 138);
|
||||
this.rfidPortBoard3Label.Name = "rfidPortBoard3Label";
|
||||
this.rfidPortBoard3Label.Size = new System.Drawing.Size(99, 13);
|
||||
this.rfidPortBoard3Label.TabIndex = 12;
|
||||
this.rfidPortBoard3Label.Text = "RFID COM port #3:";
|
||||
//
|
||||
// rfidPortBoard4TextBox
|
||||
//
|
||||
this.rfidPortBoard4TextBox.Enabled = false;
|
||||
this.rfidPortBoard4TextBox.Location = new System.Drawing.Point(137, 161);
|
||||
this.rfidPortBoard4TextBox.Name = "rfidPortBoard4TextBox";
|
||||
this.rfidPortBoard4TextBox.Size = new System.Drawing.Size(34, 20);
|
||||
this.rfidPortBoard4TextBox.TabIndex = 15;
|
||||
//
|
||||
// rfidPortBoard4Label
|
||||
//
|
||||
this.rfidPortBoard4Label.AutoSize = true;
|
||||
this.rfidPortBoard4Label.Location = new System.Drawing.Point(27, 164);
|
||||
this.rfidPortBoard4Label.Name = "rfidPortBoard4Label";
|
||||
this.rfidPortBoard4Label.Size = new System.Drawing.Size(99, 13);
|
||||
this.rfidPortBoard4Label.TabIndex = 14;
|
||||
this.rfidPortBoard4Label.Text = "RFID COM port #4:";
|
||||
//
|
||||
// TestMethodCfgCtrl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.rfidPortBoard4TextBox);
|
||||
this.Controls.Add(this.rfidPortBoard4Label);
|
||||
this.Controls.Add(this.rfidPortBoard3TextBox);
|
||||
this.Controls.Add(this.rfidPortBoard3Label);
|
||||
this.Controls.Add(this.rfidPortBoard2TextBox);
|
||||
this.Controls.Add(this.rfidPortBoard2Label);
|
||||
this.Controls.Add(this.rfidPortBoard1TextBox);
|
||||
this.Controls.Add(this.rfidPortBoard1Label);
|
||||
this.Controls.Add(this.nameTextBox);
|
||||
this.Controls.Add(this.nameLabel);
|
||||
this.Controls.Add(this.classNameLabel);
|
||||
this.Name = "BasicPrinterCfgCtrl";
|
||||
this.Name = "TestMethodCfgCtrl";
|
||||
this.Size = new System.Drawing.Size(300, 200);
|
||||
this.Load += new System.EventHandler(this.EntryFormCfgCtrl_Load);
|
||||
this.ResumeLayout(false);
|
||||
@@ -83,5 +167,13 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
private System.Windows.Forms.TextBox nameTextBox;
|
||||
private System.Windows.Forms.Label nameLabel;
|
||||
private System.Windows.Forms.Label classNameLabel;
|
||||
private System.Windows.Forms.TextBox rfidPortBoard1TextBox;
|
||||
private System.Windows.Forms.Label rfidPortBoard1Label;
|
||||
private System.Windows.Forms.TextBox rfidPortBoard2TextBox;
|
||||
private System.Windows.Forms.Label rfidPortBoard2Label;
|
||||
private System.Windows.Forms.TextBox rfidPortBoard3TextBox;
|
||||
private System.Windows.Forms.Label rfidPortBoard3Label;
|
||||
private System.Windows.Forms.TextBox rfidPortBoard4TextBox;
|
||||
private System.Windows.Forms.Label rfidPortBoard4Label;
|
||||
}
|
||||
}
|
||||
|
||||
+44
-58
@@ -31,8 +31,8 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
public partial class iPerlCommunicationForm : Form, GenericDevices.IHasCompleted
|
||||
{
|
||||
const int CommTimeout = 1500;
|
||||
const int MaxCommRetries = 3;
|
||||
const int NrThreads = 4; /// 1, 2 or 4 threads
|
||||
const int MaxCommRetries = 4;
|
||||
const int NrThreads = 2; /// 1, 2 or 4 threads
|
||||
|
||||
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(iPerlCommunicationForm));
|
||||
@@ -64,7 +64,6 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
[DllImport("libRfid4.dll", EntryPoint = "readRequestPort")] static extern unsafe int readRequestPort4(MessageID messageId, int offset, int lenght, byte* ptr, int timeout_ms);
|
||||
[DllImport("libRfid4.dll", EntryPoint = "writeRequestPort")] static extern unsafe int writeRequestPort4(MessageID messageId, int offset, int lenght, byte* ptr, int timeout_ms);
|
||||
|
||||
static int[] currentPort;
|
||||
|
||||
/// <summary>
|
||||
/// Wrapper function with safe interface and unsafe body
|
||||
@@ -72,16 +71,15 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// <param name="boardNr">0..3</param>
|
||||
/// <param name="comPort">Com port number</param>
|
||||
/// <returns>Value returned by openPort(...)</returns>
|
||||
public static unsafe int OpenPort(int boardNr, int comPort)
|
||||
public static unsafe int OpenPort(int boardNr)
|
||||
{
|
||||
currentPort[boardNr] = comPort;
|
||||
switch (boardNr)
|
||||
{
|
||||
default:
|
||||
case 0: return openPort1(comPort);
|
||||
case 1: return openPort2(comPort);
|
||||
case 2: return openPort3(comPort);
|
||||
case 3: return openPort4(comPort);
|
||||
case 0: return openPort1(cfg.RfidPortNrBoard1);
|
||||
case 1: return openPort2(cfg.RfidPortNrBoard2);
|
||||
case 2: return openPort3(cfg.RfidPortNrBoard3);
|
||||
case 3: return openPort4(cfg.RfidPortNrBoard4);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +121,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
case 3: retv = readRequestPort4(messageID, offset, lenght, pBuf, timeout); break;
|
||||
}
|
||||
|
||||
rfidDataLogger.InfoFormat("Group={0}, Port={1}, ReadRequestPort({2}, {3}, {4}, ...) returned {5} {6}", currentGroup, currentPort[boardNr], messageID, offset, lenght, retv, (retv != 0) ? "!" : "");
|
||||
rfidDataLogger.InfoFormat("Group={0}, Board={1}, ReadRequestPort({2}, {3}, {4}, ...) returned {5} {6}", currentGroup, boardNr, messageID, offset, lenght, retv, (retv != 0) ? "!" : "");
|
||||
|
||||
buffer = new byte[lenght];
|
||||
for (int i = 0; i < lenght; i++) buffer[i] = buf[i];
|
||||
@@ -152,15 +150,15 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
|
||||
if (lenght == 1)
|
||||
{
|
||||
rfidDataLogger.InfoFormat("Group={0}, Port={1}, WriteRequestPort({3}, {4}, {5}, {6}) returned {2} {7}", currentGroup, currentPort[boardNr], retv, messageID, offset, lenght, pBuf[0].ToString("X2"), (retv != 0) ? "!" : "");
|
||||
rfidDataLogger.InfoFormat("Group={0}, Board={1}, WriteRequestPort({3}, {4}, {5}, {6}) returned {2} {7}", currentGroup, boardNr, retv, messageID, offset, lenght, pBuf[0].ToString("X2"), (retv != 0) ? "!" : "");
|
||||
}
|
||||
else if (lenght == 2)
|
||||
{
|
||||
rfidDataLogger.InfoFormat("Group={0}, Port={1}, WriteRequestPort({3}, {4}, {5}, {6} {7}) returned {2} {8}", currentGroup, currentPort[boardNr], retv, messageID, offset, lenght, pBuf[0].ToString("X2"), pBuf[1].ToString("X2"), (retv != 0) ? "!" : "");
|
||||
rfidDataLogger.InfoFormat("Group={0}, Board={1}, WriteRequestPort({3}, {4}, {5}, {6} {7}) returned {2} {8}", currentGroup, boardNr, retv, messageID, offset, lenght, pBuf[0].ToString("X2"), pBuf[1].ToString("X2"), (retv != 0) ? "!" : "");
|
||||
}
|
||||
else
|
||||
{
|
||||
rfidDataLogger.InfoFormat("Group={0}, Port={1}, WriteRequestPort({3}, {4}, {5}, {6} {7} ...) returned {2} {8}", currentGroup, currentPort[boardNr], retv, messageID, offset, lenght, pBuf[0].ToString("X2"), pBuf[1].ToString("X2"), (retv != 0) ? "!" : "");
|
||||
rfidDataLogger.InfoFormat("Group={0}, Board={1}, WriteRequestPort({3}, {4}, {5}, {6} {7} ...) returned {2} {8}", currentGroup, boardNr, retv, messageID, offset, lenght, pBuf[0].ToString("X2"), pBuf[1].ToString("X2"), (retv != 0) ? "!" : "");
|
||||
}
|
||||
}
|
||||
return retv;
|
||||
@@ -194,6 +192,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
Label[] labels;
|
||||
TextBox[] messages;
|
||||
|
||||
static TestMethodCfg cfg;
|
||||
static IList<WaterMeters.iPerl.WaterMeter> waterMeters;
|
||||
|
||||
Modbus.QuidoRS.QuidoRS quido;
|
||||
@@ -256,8 +255,6 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
formCompleted = false;
|
||||
tr = null;
|
||||
|
||||
currentPort = new int[4];
|
||||
|
||||
/// Find QuidoRS
|
||||
foreach (var comp in StateMachine.Components)
|
||||
{
|
||||
@@ -293,9 +290,10 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="waterMetersCount">Number of text boxes for serial numbers</param>
|
||||
public iPerlCommunicationForm(IList<GenericDevices.IWaterMeter> waterMeters, string activity)
|
||||
public iPerlCommunicationForm(TestMethodCfg cfg, IList<GenericDevices.IWaterMeter> waterMeters, string activity)
|
||||
: this()
|
||||
{
|
||||
iPerlCommunicationForm.cfg = cfg;
|
||||
iPerlCommunicationForm.activity = activity;
|
||||
this.WaterMetersCount = waterMeters.Count;
|
||||
iPerlCommunicationForm.waterMeters = new List<WaterMeters.iPerl.WaterMeter>();
|
||||
@@ -321,9 +319,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
{
|
||||
WaterMeters.iPerl.WaterMeter iPerlWM = wm as WaterMeters.iPerl.WaterMeter;
|
||||
iPerlCommunicationForm.waterMeters.Add(iPerlWM);
|
||||
if (!rfidPortNrs.Contains(iPerlWM.RfidComPortNr))
|
||||
if (!rfidPortNrs.Contains(iPerlWM.MuxBoardNr))
|
||||
{
|
||||
rfidPortNrs.Add(iPerlWM.RfidComPortNr);
|
||||
rfidPortNrs.Add(iPerlWM.MuxBoardNr);
|
||||
|
||||
int newThreadId = workerThreads.Count;
|
||||
if (newThreadId < NrThreads)
|
||||
@@ -509,7 +507,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
bool wmFound = false;
|
||||
foreach (var wm in waterMeters)
|
||||
{
|
||||
if ((wm.RfidComPortNr == rfidPortNr) && (wm.Group == group))
|
||||
if ((wm.MuxBoardNr == rfidPortNr) && (wm.Group == group))
|
||||
{
|
||||
wmFound = true;
|
||||
if (wm.DebugLevel == Entities.DebugMode.Normal)
|
||||
@@ -535,7 +533,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
else
|
||||
{
|
||||
OnCommCompleted(null, new CommCompletedEventArgs(threadId, wmNr, string.Format("{0} failed ({1}) !!!", activity, error)));
|
||||
rfidDataLogger.ErrorFormat("Group={0}, Port={1}, {2} failed ({3}) !!!", currentGroup, currentPort, activity, error);
|
||||
rfidDataLogger.ErrorFormat("Group={0}, Board={1}, {2} failed ({3}) !!!", currentGroup, wm.MuxBoardNr, activity, error);
|
||||
wm.Disabled = true;
|
||||
}
|
||||
}
|
||||
@@ -562,7 +560,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// <returns>true on success</returns>
|
||||
static CommErr ReadConfiguration(WaterMeters.iPerl.WaterMeter wm, ref string resultStr)
|
||||
{
|
||||
int boardNr = wm.RfidComPortNr - 51;
|
||||
int boardNr = wm.MuxBoardNr - 51;
|
||||
|
||||
///
|
||||
/// The activity is "Read configuration" (this enables the watermeter, resets error flag)
|
||||
@@ -575,7 +573,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
|
||||
if (wm.Disabled) return CommErr.Disabled;
|
||||
|
||||
if (OpenPort(boardNr, wm.RfidComPortNr) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
if (OpenPort(wm.MuxBoardNr) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
|
||||
CommErr error = CommErr.Read;
|
||||
|
||||
@@ -609,8 +607,6 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// <returns>true on success</returns>
|
||||
static CommErr SetTestMode(WaterMeters.iPerl.WaterMeter wm, ref string resultStr)
|
||||
{
|
||||
int boardNr = wm.RfidComPortNr - 51;
|
||||
|
||||
if (wm.Disabled) return CommErr.Disabled;
|
||||
|
||||
Byte testModeConfig = 0xA0; /// Default value
|
||||
@@ -633,7 +629,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
}
|
||||
|
||||
/// Communication necessary
|
||||
if (OpenPort(boardNr, wm.RfidComPortNr) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
if (OpenPort(wm.MuxBoardNr) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
|
||||
CommErr error = CommErr.None;
|
||||
|
||||
@@ -644,7 +640,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
byte[] cmd = new byte[1] { (byte)6 };
|
||||
for (int j = 0; j < MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == WriteRequestPort(boardNr, MessageID.Command, 0, 1, cmd, CommTimeout)) { error = CommErr.None; break; }
|
||||
if (0 == WriteRequestPort(wm.MuxBoardNr, MessageID.Command, 0, 1, cmd, CommTimeout)) { error = CommErr.None; break; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -655,7 +651,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
byte[] tstMdCfg = new byte[1] { testModeConfig };
|
||||
for (int j = 0; j < MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == WriteRequestPort(boardNr, MessageID.Configuration, 21, 1, tstMdCfg, CommTimeout))
|
||||
if (0 == WriteRequestPort(wm.MuxBoardNr, MessageID.Configuration, 21, 1, tstMdCfg, CommTimeout))
|
||||
{
|
||||
wm.ConfigStruct.Update(21, tstMdCfg);
|
||||
error = CommErr.None;
|
||||
@@ -671,7 +667,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
byte[] cmd = new byte[1] { (byte)7 };
|
||||
for (int j = 0; j < MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == WriteRequestPort(boardNr, MessageID.Command, 0, 1, cmd, CommTimeout)) { error = CommErr.None; break; }
|
||||
if (0 == WriteRequestPort(wm.MuxBoardNr, MessageID.Command, 0, 1, cmd, CommTimeout)) { error = CommErr.None; break; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -683,7 +679,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
byte[] cfg_0_3 = null;
|
||||
for (int j = 0; j < MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == ReadRequestPort(boardNr, MessageID.Configuration, 0, 4, out cfg_0_3, CommTimeout))
|
||||
if (0 == ReadRequestPort(wm.MuxBoardNr, MessageID.Configuration, 0, 4, out cfg_0_3, CommTimeout))
|
||||
{
|
||||
wm.ConfigStruct.Update(0, cfg_0_3);
|
||||
if (wm.ConfigStruct.MeterState == MeterState.Test)
|
||||
@@ -696,7 +692,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
}
|
||||
}
|
||||
|
||||
ClosePort(boardNr); /// Close RFID port
|
||||
ClosePort(wm.MuxBoardNr); /// Close RFID port
|
||||
|
||||
return error;
|
||||
}
|
||||
@@ -711,11 +707,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// <returns>true on success</returns>
|
||||
static CommErr SetActiveMode(WaterMeters.iPerl.WaterMeter wm, ref string resultStr)
|
||||
{
|
||||
int boardNr = wm.RfidComPortNr - 51;
|
||||
|
||||
if (wm.Disabled) return CommErr.Disabled;
|
||||
|
||||
if (OpenPort(boardNr, wm.RfidComPortNr) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
if (OpenPort(wm.MuxBoardNr) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
|
||||
CommErr error = CommErr.CmdActive;
|
||||
|
||||
@@ -723,7 +717,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
byte[] cmd = new byte[1] { (byte)6 };
|
||||
for (int j = 0; j < MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == WriteRequestPort(boardNr, MessageID.Command, 0, 1, cmd, CommTimeout)) { error = CommErr.None; break; }
|
||||
if (0 == WriteRequestPort(wm.MuxBoardNr, MessageID.Command, 0, 1, cmd, CommTimeout)) { error = CommErr.None; break; }
|
||||
}
|
||||
|
||||
if (error == CommErr.None)
|
||||
@@ -734,7 +728,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
byte[] cfg_0_3 = null;
|
||||
for (int j = 0; j < MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == ReadRequestPort(boardNr, MessageID.Configuration, 0, 4, out cfg_0_3, CommTimeout))
|
||||
if (0 == ReadRequestPort(wm.MuxBoardNr, MessageID.Configuration, 0, 4, out cfg_0_3, CommTimeout))
|
||||
{
|
||||
wm.ConfigStruct.Update(0, cfg_0_3);
|
||||
if (wm.ConfigStruct.MeterState == MeterState.Active)
|
||||
@@ -747,7 +741,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
}
|
||||
}
|
||||
|
||||
ClosePort(boardNr); /// Close RFID port
|
||||
ClosePort(wm.MuxBoardNr); /// Close RFID port
|
||||
|
||||
return error;
|
||||
}
|
||||
@@ -761,11 +755,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// <returns>true on success</returns>
|
||||
static CommErr ReadCalibration(WaterMeters.iPerl.WaterMeter wm, ref string resultStr)
|
||||
{
|
||||
int boardNr = wm.RfidComPortNr - 51;
|
||||
|
||||
if (wm.Disabled) return CommErr.Disabled;
|
||||
|
||||
if (OpenPort(boardNr, wm.RfidComPortNr) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
if (OpenPort(wm.MuxBoardNr) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
|
||||
CommErr error = CommErr.Read;
|
||||
|
||||
@@ -773,7 +765,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
byte[] calib = null;
|
||||
for (int j = 0; j < MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == ReadRequestPort(boardNr, MessageID.Calibration, 0, CalibrationStruct.Length, out calib, CommTimeout))
|
||||
if (0 == ReadRequestPort(wm.MuxBoardNr, MessageID.Calibration, 0, CalibrationStruct.Length, out calib, CommTimeout))
|
||||
{
|
||||
error = CommErr.None;
|
||||
wm.CalibrationStruct = CalibrationStruct.FromByteArray(calib);
|
||||
@@ -782,7 +774,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
}
|
||||
}
|
||||
|
||||
ClosePort(boardNr); /// Close RFID port
|
||||
ClosePort(wm.MuxBoardNr); /// Close RFID port
|
||||
|
||||
return error;
|
||||
}
|
||||
@@ -797,11 +789,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// <returns>true on success</returns>
|
||||
static CommErr WriteCalibrationFactor(WaterMeters.iPerl.WaterMeter wm, ref string resultStr)
|
||||
{
|
||||
int boardNr = wm.RfidComPortNr - 51;
|
||||
|
||||
if (wm.Disabled) return CommErr.Disabled;
|
||||
|
||||
if (OpenPort(boardNr, wm.RfidComPortNr) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
if (OpenPort(wm.MuxBoardNr) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
|
||||
CommErr error = CommErr.Write;
|
||||
|
||||
@@ -825,7 +815,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
byte[] data = new byte[2] { (byte)(newCalibFactor & 0x00FF), (byte)((newCalibFactor >> 8) & 0x00FF) };
|
||||
for (int j = 0; j < MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == WriteRequestPort(boardNr, MessageID.Calibration, 2, 2, data, CommTimeout)) { error = CommErr.None; break; }
|
||||
if (0 == WriteRequestPort(wm.MuxBoardNr, MessageID.Calibration, 2, 2, data, CommTimeout)) { error = CommErr.None; break; }
|
||||
}
|
||||
|
||||
if (error == CommErr.None)
|
||||
@@ -836,7 +826,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
byte[] calib_2_3 = null;
|
||||
for (int j = 0; j < MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == ReadRequestPort(boardNr, MessageID.Calibration, 2, 2, out calib_2_3, CommTimeout))
|
||||
if (0 == ReadRequestPort(wm.MuxBoardNr, MessageID.Calibration, 2, 2, out calib_2_3, CommTimeout))
|
||||
{
|
||||
error = CommErr.None;
|
||||
wm.CalibrationStruct.Update(calib_2_3, 2);
|
||||
@@ -846,7 +836,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
}
|
||||
}
|
||||
|
||||
ClosePort(boardNr); /// Close RFID port
|
||||
ClosePort(wm.MuxBoardNr); /// Close RFID port
|
||||
|
||||
return error;
|
||||
}
|
||||
@@ -864,11 +854,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// <returns>true on success</returns>
|
||||
static CommErr ResetQ2Correction(WaterMeters.iPerl.WaterMeter wm, ref string resultStr)
|
||||
{
|
||||
int boardNr = wm.RfidComPortNr - 51;
|
||||
|
||||
if (wm.Disabled) return CommErr.Disabled;
|
||||
|
||||
if (OpenPort(boardNr, wm.RfidComPortNr) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
if (OpenPort(wm.MuxBoardNr) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
|
||||
CommErr error = CommErr.Write;
|
||||
|
||||
@@ -879,7 +867,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
|
||||
for (int j = 0; j < MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == WriteRequestPort(boardNr, MessageID.MetrologyMemory, Q2CorrFactorsAddr, 2, wrData, CommTimeout)) { error = CommErr.None; break; }
|
||||
if (0 == WriteRequestPort(wm.MuxBoardNr, MessageID.MetrologyMemory, Q2CorrFactorsAddr, 2, wrData, CommTimeout)) { error = CommErr.None; break; }
|
||||
}
|
||||
|
||||
if (error == CommErr.None)
|
||||
@@ -890,7 +878,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
byte[] rdData = null;
|
||||
for (int j = 0; j < MaxCommRetries; j++)
|
||||
{
|
||||
if ((0 == ReadRequestPort(boardNr, MessageID.MetrologyMemory, Q2CorrFactorsAddr, 2, out rdData, CommTimeout)) &&
|
||||
if ((0 == ReadRequestPort(wm.MuxBoardNr, MessageID.MetrologyMemory, Q2CorrFactorsAddr, 2, out rdData, CommTimeout)) &&
|
||||
(rdData != null) && (rdData.Length == 2) && (rdData[0] == 0) && (rdData[1] == 0))
|
||||
{
|
||||
error = CommErr.None;
|
||||
@@ -900,7 +888,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
}
|
||||
}
|
||||
|
||||
ClosePort(boardNr); /// Close RFID port
|
||||
ClosePort(wm.MuxBoardNr); /// Close RFID port
|
||||
|
||||
return error;
|
||||
}
|
||||
@@ -915,11 +903,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// <returns>true on success</returns>
|
||||
static CommErr WriteQ2Correction(WaterMeters.iPerl.WaterMeter wm, ref string resultStr)
|
||||
{
|
||||
int boardNr = wm.RfidComPortNr - 51;
|
||||
|
||||
if (wm.Disabled) return CommErr.Disabled;
|
||||
|
||||
if (OpenPort(boardNr, wm.RfidComPortNr) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
if (OpenPort(wm.MuxBoardNr) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
|
||||
CommErr error = CommErr.Write;
|
||||
|
||||
@@ -930,7 +916,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
|
||||
for (int j = 0; j < MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == WriteRequestPort(boardNr, MessageID.MetrologyMemory, Q2CorrFactorsAddr, 2, wrData, CommTimeout)) { error = CommErr.None; break; }
|
||||
if (0 == WriteRequestPort(wm.MuxBoardNr, MessageID.MetrologyMemory, Q2CorrFactorsAddr, 2, wrData, CommTimeout)) { error = CommErr.None; break; }
|
||||
}
|
||||
|
||||
if (error == CommErr.None)
|
||||
@@ -941,7 +927,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
byte[] rdData = null;
|
||||
for (int j = 0; j < MaxCommRetries; j++)
|
||||
{
|
||||
if ((0 == ReadRequestPort(boardNr, MessageID.MetrologyMemory, Q2CorrFactorsAddr, 2, out rdData, CommTimeout)) &&
|
||||
if ((0 == ReadRequestPort(wm.MuxBoardNr, MessageID.MetrologyMemory, Q2CorrFactorsAddr, 2, out rdData, CommTimeout)) &&
|
||||
(rdData != null) && (rdData.Length == 2) && (rdData[0] == q2CorrRFlow) && (rdData[1] == q2CorrRFlow))
|
||||
{
|
||||
error = CommErr.None;
|
||||
|
||||
+5
-5
@@ -19,16 +19,16 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
|
||||
System.Windows.Forms.Form modelessDlg;
|
||||
///
|
||||
delegate void ICommFormFormDlgt(iPerlCommunicationSeq myRef, string activity);
|
||||
delegate void iPerlCommFormDlgt(iPerlCommunicationSeq myRef, TestMethodCfg cfg, string activity);
|
||||
///
|
||||
void OpenIPerlCommForm(iPerlCommunicationSeq myRef, string activity)
|
||||
void OpenIPerlCommForm(iPerlCommunicationSeq myRef, TestMethodCfg cfg, string activity)
|
||||
{
|
||||
IList<GenericDevices.IWaterMeter> wMtrs = new List<GenericDevices.IWaterMeter>();
|
||||
foreach (var rr in sensPath.RegisterReaders)
|
||||
{
|
||||
if (rr is GenericDevices.IWaterMeter) wMtrs.Add(rr as GenericDevices.IWaterMeter);
|
||||
}
|
||||
myRef.modelessDlg = new iPerlCommunicationForm(wMtrs, activity);
|
||||
myRef.modelessDlg = new iPerlCommunicationForm(cfg, wMtrs, activity);
|
||||
modelessDlg.Show();
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// Event.OpArgumentError . Target flow is out of range
|
||||
/// Event.Error . . . . . . Unspecified error
|
||||
/// </returns>
|
||||
public IList<Event> Execute(Entities.Test test, iPerlCommunicationParams testParams)
|
||||
public IList<Event> Execute(Entities.Test test, TestMethodCfg cfg, iPerlCommunicationParams testParams)
|
||||
{
|
||||
IList<Event> e = new List<Event>(); /// Events from currently running operations
|
||||
Event retVal = Event.Done;
|
||||
@@ -104,7 +104,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
///
|
||||
/// Show the modeless dialog with error indication
|
||||
///
|
||||
Program.MainWnd.Invoke(new ICommFormFormDlgt(OpenIPerlCommForm), new object[] { this, testParams.Activity });
|
||||
Program.MainWnd.Invoke(new iPerlCommFormDlgt(OpenIPerlCommForm), new object[] { this, cfg, testParams.Activity });
|
||||
}
|
||||
|
||||
loop:
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
||||
|
||||
readonly WaterMeterCfg iPerlCfg;
|
||||
|
||||
public int RfidComPortNr { get { return iPerlCfg.RfidComPortNr; } }
|
||||
public int MuxBoardNr { get { return iPerlCfg.MuxBoardNr; } }
|
||||
public int Group { get { return iPerlCfg.Group; } }
|
||||
|
||||
public float PulsesPerLtr { get { return iPerlCfg.ProcParams.PulsesPerLtr; } }
|
||||
@@ -164,6 +164,8 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
||||
synchronized = false;
|
||||
synchronized2 = false;
|
||||
partOfTelegram = string.Empty;
|
||||
|
||||
flushBuffer = new char[8192];
|
||||
}
|
||||
|
||||
public WaterMeter(WaterMeterCfg cfg)
|
||||
@@ -194,7 +196,9 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
||||
//optoDataLogger.Fatal("------------------------------------------------------------------------");
|
||||
//optoDataLogger.Fatal("Program restarted");
|
||||
|
||||
/// Allocate memory for opto-data from iPerl
|
||||
optoData = new OptoTelegramRaw[MaxOptoDataCount];
|
||||
for (int i = 0; i < MaxOptoDataCount; i++) optoData[i] = new OptoTelegramRaw();
|
||||
|
||||
/// Prepare serial port
|
||||
optoSerialPort = new SerialPort(string.Format("COM{0}", iPerlCfg.OptoComPortNr),
|
||||
@@ -207,7 +211,14 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
||||
|
||||
public void RunDeviceBefore()
|
||||
{
|
||||
ReadOptoSerialPort();
|
||||
if (optoSerialPortParsingEnabled)
|
||||
{
|
||||
ReadOptoSerialPort();
|
||||
}
|
||||
else
|
||||
{
|
||||
FlushOptoSerialPort();
|
||||
}
|
||||
}
|
||||
|
||||
public void RunDeviceAfter()
|
||||
@@ -294,7 +305,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
||||
/// Reset opto data
|
||||
optoDataCount = 0;
|
||||
optoDataLogFileName = (ConfigStruct != null) ? ConfigStruct.PCBNumber2String() : "Unknown PCBNumber";
|
||||
optoDataLogFileName += "_" + Name + "_" + DateTime.Now.ToShortTimeString();
|
||||
optoDataLogFileName += "_" + Name + "_" + Utils.ToMyString(DateTime.Now);
|
||||
|
||||
sampleNr = 0;
|
||||
|
||||
@@ -394,6 +405,16 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
||||
optoSerialPortParsingEnabled = false;
|
||||
}
|
||||
|
||||
|
||||
char[] flushBuffer;
|
||||
|
||||
void FlushOptoSerialPort()
|
||||
{
|
||||
int nrBytes = optoSerialPort.BytesToRead;
|
||||
if (nrBytes > 0) optoSerialPort.Read(flushBuffer, 0, nrBytes);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 9600 Bd, 8 data bits, 1 stop bit, no parity
|
||||
///
|
||||
@@ -408,66 +429,55 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
||||
/// </summary>
|
||||
void ReadOptoSerialPort()
|
||||
{
|
||||
if (!optoSerialPortParsingEnabled) return;
|
||||
|
||||
if (DebugLevel == Entities.DebugMode.Normal || DebugLevel == Entities.DebugMode.Record)
|
||||
int nrBytes = optoSerialPort.BytesToRead;
|
||||
if (nrBytes > 0)
|
||||
{
|
||||
int nrBytes = optoSerialPort.BytesToRead;
|
||||
if (nrBytes > 0)
|
||||
char[] buffer = new char[nrBytes];
|
||||
optoSerialPort.Read(buffer, 0, nrBytes);
|
||||
string received = new string(buffer);
|
||||
|
||||
string allRcvd = partOfTelegram + received;
|
||||
|
||||
while (true)
|
||||
{
|
||||
char[] buffer = new char[nrBytes];
|
||||
optoSerialPort.Read(buffer, 0, nrBytes);
|
||||
string received = new string(buffer);
|
||||
int pos = allRcvd.IndexOf("\r\n");
|
||||
|
||||
string allRcvd = partOfTelegram + received;
|
||||
|
||||
while (true)
|
||||
if (pos < 0)
|
||||
{
|
||||
int pos = allRcvd.IndexOf("\r\n");
|
||||
|
||||
if (pos < 0)
|
||||
{
|
||||
/// No CR+LF found, wait for more characters in the next invocation
|
||||
partOfTelegram = allRcvd;
|
||||
return;
|
||||
}
|
||||
// CR+LF found
|
||||
else if (pos < OptoTelegram.Length - 2)
|
||||
{
|
||||
/// CR+LF found too early, truncate the beginning incl CR+LF and keep scanning in this loop
|
||||
allRcvd = allRcvd.Substring(pos + 2);
|
||||
if (synchronized)
|
||||
{
|
||||
optoData[optoDataCount++].SetFlags(OptoTelegramFlags.SyncError);
|
||||
}
|
||||
synchronized = true;
|
||||
}
|
||||
// CR+LF found and (pos >= OptoTelegram.Length - 2)
|
||||
else if (optoData[optoDataCount].UpdateFromString(allRcvd.Substring(pos - OptoTelegramRaw.Length + 2)))
|
||||
{
|
||||
OptoTelegramRreceived(optoData[optoDataCount++], synchronized2);
|
||||
synchronized2 = synchronized;
|
||||
allRcvd = allRcvd.Substring(pos + 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
optoData[optoDataCount++].SetFlags(OptoTelegramFlags.InvalidTelegram);
|
||||
allRcvd = allRcvd.Substring(pos + 2);
|
||||
}
|
||||
/// No CR+LF found, wait for more characters in the next invocation
|
||||
partOfTelegram = allRcvd;
|
||||
return;
|
||||
}
|
||||
// CR+LF found
|
||||
else if (pos < OptoTelegram.Length - 2)
|
||||
{
|
||||
/// CR+LF found too early, truncate the beginning incl CR+LF and keep scanning in this loop
|
||||
allRcvd = allRcvd.Substring(pos + 2);
|
||||
if (synchronized)
|
||||
{
|
||||
optoData[optoDataCount++].SetFlags(OptoTelegramFlags.SyncError);
|
||||
}
|
||||
synchronized = true;
|
||||
}
|
||||
// CR+LF found and (pos >= OptoTelegram.Length - 2)
|
||||
else if (optoData[optoDataCount].UpdateFromString(allRcvd.Substring(pos - OptoTelegramRaw.Length + 2)))
|
||||
{
|
||||
OptoTelegramRreceived(optoData[optoDataCount++], synchronized2);
|
||||
synchronized2 = synchronized;
|
||||
allRcvd = allRcvd.Substring(pos + 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
optoData[optoDataCount++].SetFlags(OptoTelegramFlags.InvalidTelegram);
|
||||
allRcvd = allRcvd.Substring(pos + 2);
|
||||
}
|
||||
}
|
||||
|
||||
//OnOptoReceived(this, new OptoReceivedEventArgs(s));
|
||||
}
|
||||
else
|
||||
{
|
||||
//OnOptoReceived(this, new OptoReceivedEventArgs("."));
|
||||
}
|
||||
//OnOptoReceived(this, new OptoReceivedEventArgs(s));
|
||||
}
|
||||
else if (DebugLevel == Entities.DebugMode.Simulate)
|
||||
{
|
||||
}
|
||||
else if (DebugLevel == Entities.DebugMode.Reply)
|
||||
else
|
||||
{
|
||||
//OnOptoReceived(this, new OptoReceivedEventArgs("."));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
||||
///
|
||||
public MeterType MeterType;
|
||||
public int OptoComPortNr;
|
||||
public int RfidComPortNr;
|
||||
public int Group; /// Number written to QuidoRS to connct the watermeter to RfidComPort
|
||||
public int MuxBoardNr; /// Multiplexer board number 1 .. 4
|
||||
public int Group; /// Number written to QuidoRS to connct the watermeter to RfidComPort
|
||||
|
||||
/// <summary> Procedure parameters </summary>
|
||||
[XmlIgnore]
|
||||
@@ -56,7 +56,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
||||
Name,
|
||||
MeterType,
|
||||
OptoComPortNr,
|
||||
RfidComPortNr,
|
||||
MuxBoardNr,
|
||||
Group);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
||||
nameTextBox.Text = config.Name;
|
||||
meterTypeComboBox.Text = config.MeterType.ToString();
|
||||
optoPortNrTextBox.Text = config.OptoComPortNr.ToString();
|
||||
rfidPortNrTextBox.Text = config.RfidComPortNr.ToString();
|
||||
muxBoardNrTextBox.Text = config.MuxBoardNr.ToString();
|
||||
groupTextBox.Text = config.Group.ToString();
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
||||
nameTextBox.Enabled = true;
|
||||
meterTypeComboBox.Enabled = true;
|
||||
optoPortNrTextBox.Enabled = true;
|
||||
rfidPortNrTextBox.Enabled = true;
|
||||
muxBoardNrTextBox.Enabled = true;
|
||||
groupTextBox.Enabled = true;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Opto Serial Port Nr.' is not valid";
|
||||
}
|
||||
if (!int.TryParse(rfidPortNrTextBox.Text, out dummy) || dummy < 1 || dummy > 999)
|
||||
if (!int.TryParse(muxBoardNrTextBox.Text, out dummy) || dummy < 1 || dummy > 999)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'RFID Serial Port Nr.' is not valid";
|
||||
@@ -102,7 +102,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
||||
config.Name = nameTextBox.Text;
|
||||
config.MeterType = (MeterType)meterTypeComboBox.SelectedIndex;
|
||||
config.OptoComPortNr = int.Parse(optoPortNrTextBox.Text);
|
||||
config.RfidComPortNr = int.Parse(rfidPortNrTextBox.Text);
|
||||
config.MuxBoardNr = int.Parse(muxBoardNrTextBox.Text);
|
||||
config.Group = int.Parse(groupTextBox.Text);
|
||||
|
||||
return flags;
|
||||
|
||||
+130
-130
@@ -32,134 +32,134 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
||||
/// </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.optoPortNrTextBox = new System.Windows.Forms.TextBox();
|
||||
this.optoPortNrLabel = new System.Windows.Forms.Label();
|
||||
this.rfidPortNrTextBox = new System.Windows.Forms.TextBox();
|
||||
this.rfidPortNrLabel = new System.Windows.Forms.Label();
|
||||
this.groupTextBox = new System.Windows.Forms.TextBox();
|
||||
this.groupLabel = new System.Windows.Forms.Label();
|
||||
this.meterTypeLabel = new System.Windows.Forms.Label();
|
||||
this.meterTypeComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// nameTextBox
|
||||
//
|
||||
this.nameTextBox.Enabled = false;
|
||||
this.nameTextBox.Location = new System.Drawing.Point(135, 55);
|
||||
this.nameTextBox.Name = "nameTextBox";
|
||||
this.nameTextBox.Size = new System.Drawing.Size(121, 20);
|
||||
this.nameTextBox.TabIndex = 5;
|
||||
//
|
||||
// nameLabel
|
||||
//
|
||||
this.nameLabel.AutoSize = true;
|
||||
this.nameLabel.Location = new System.Drawing.Point(25, 58);
|
||||
this.nameLabel.Name = "nameLabel";
|
||||
this.nameLabel.Size = new System.Drawing.Size(35, 13);
|
||||
this.nameLabel.TabIndex = 4;
|
||||
this.nameLabel.Text = "Name";
|
||||
//
|
||||
// classNameLabel
|
||||
//
|
||||
this.classNameLabel.AutoSize = true;
|
||||
this.classNameLabel.Location = new System.Drawing.Point(132, 31);
|
||||
this.classNameLabel.Name = "classNameLabel";
|
||||
this.classNameLabel.Size = new System.Drawing.Size(60, 13);
|
||||
this.classNameLabel.TabIndex = 3;
|
||||
this.classNameLabel.Text = "ClassName";
|
||||
//
|
||||
// optoPortNrTextBox
|
||||
//
|
||||
this.optoPortNrTextBox.Enabled = false;
|
||||
this.optoPortNrTextBox.Location = new System.Drawing.Point(135, 104);
|
||||
this.optoPortNrTextBox.Name = "optoPortNrTextBox";
|
||||
this.optoPortNrTextBox.Size = new System.Drawing.Size(34, 20);
|
||||
this.optoPortNrTextBox.TabIndex = 7;
|
||||
//
|
||||
// optoPortNrLabel
|
||||
//
|
||||
this.optoPortNrLabel.AutoSize = true;
|
||||
this.optoPortNrLabel.Location = new System.Drawing.Point(25, 107);
|
||||
this.optoPortNrLabel.Name = "optoPortNrLabel";
|
||||
this.optoPortNrLabel.Size = new System.Drawing.Size(101, 13);
|
||||
this.optoPortNrLabel.TabIndex = 6;
|
||||
this.optoPortNrLabel.Text = "Opto Serial Port Nr.:";
|
||||
//
|
||||
// rfidPortNrTextBox
|
||||
//
|
||||
this.rfidPortNrTextBox.Enabled = false;
|
||||
this.rfidPortNrTextBox.Location = new System.Drawing.Point(135, 128);
|
||||
this.rfidPortNrTextBox.Name = "rfidPortNrTextBox";
|
||||
this.rfidPortNrTextBox.Size = new System.Drawing.Size(34, 20);
|
||||
this.rfidPortNrTextBox.TabIndex = 9;
|
||||
//
|
||||
// rfidPortNrLabel
|
||||
//
|
||||
this.rfidPortNrLabel.AutoSize = true;
|
||||
this.rfidPortNrLabel.Location = new System.Drawing.Point(25, 131);
|
||||
this.rfidPortNrLabel.Name = "rfidPortNrLabel";
|
||||
this.rfidPortNrLabel.Size = new System.Drawing.Size(103, 13);
|
||||
this.rfidPortNrLabel.TabIndex = 8;
|
||||
this.rfidPortNrLabel.Text = "RFID Serial Port Nr.:";
|
||||
//
|
||||
// groupTextBox
|
||||
//
|
||||
this.groupTextBox.Enabled = false;
|
||||
this.groupTextBox.Location = new System.Drawing.Point(135, 152);
|
||||
this.groupTextBox.Name = "groupTextBox";
|
||||
this.groupTextBox.Size = new System.Drawing.Size(34, 20);
|
||||
this.groupTextBox.TabIndex = 11;
|
||||
//
|
||||
// groupLabel
|
||||
//
|
||||
this.groupLabel.AutoSize = true;
|
||||
this.groupLabel.Location = new System.Drawing.Point(25, 155);
|
||||
this.groupLabel.Name = "groupLabel";
|
||||
this.groupLabel.Size = new System.Drawing.Size(39, 13);
|
||||
this.groupLabel.TabIndex = 10;
|
||||
this.groupLabel.Text = "Group:";
|
||||
//
|
||||
// meterTypeLabel
|
||||
//
|
||||
this.meterTypeLabel.AutoSize = true;
|
||||
this.meterTypeLabel.Location = new System.Drawing.Point(25, 82);
|
||||
this.meterTypeLabel.Name = "meterTypeLabel";
|
||||
this.meterTypeLabel.Size = new System.Drawing.Size(57, 13);
|
||||
this.meterTypeLabel.TabIndex = 12;
|
||||
this.meterTypeLabel.Text = "Meter type";
|
||||
//
|
||||
// meterTypeComboBox
|
||||
//
|
||||
this.meterTypeComboBox.Enabled = false;
|
||||
this.meterTypeComboBox.FormattingEnabled = true;
|
||||
this.meterTypeComboBox.Location = new System.Drawing.Point(135, 79);
|
||||
this.meterTypeComboBox.Name = "meterTypeComboBox";
|
||||
this.meterTypeComboBox.Size = new System.Drawing.Size(121, 21);
|
||||
this.meterTypeComboBox.TabIndex = 13;
|
||||
//
|
||||
// WaterMeterCfgCtrl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.meterTypeComboBox);
|
||||
this.Controls.Add(this.meterTypeLabel);
|
||||
this.Controls.Add(this.groupTextBox);
|
||||
this.Controls.Add(this.groupLabel);
|
||||
this.Controls.Add(this.rfidPortNrTextBox);
|
||||
this.Controls.Add(this.rfidPortNrLabel);
|
||||
this.Controls.Add(this.optoPortNrTextBox);
|
||||
this.Controls.Add(this.optoPortNrLabel);
|
||||
this.Controls.Add(this.nameTextBox);
|
||||
this.Controls.Add(this.nameLabel);
|
||||
this.Controls.Add(this.classNameLabel);
|
||||
this.Name = "WaterMeterCfgCtrl";
|
||||
this.Size = new System.Drawing.Size(300, 200);
|
||||
this.Load += new System.EventHandler(this.WaterMeterCfgCtrl_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
this.nameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.nameLabel = new System.Windows.Forms.Label();
|
||||
this.classNameLabel = new System.Windows.Forms.Label();
|
||||
this.optoPortNrTextBox = new System.Windows.Forms.TextBox();
|
||||
this.optoPortNrLabel = new System.Windows.Forms.Label();
|
||||
this.muxBoardNrTextBox = new System.Windows.Forms.TextBox();
|
||||
this.muxBoardNrLabel = new System.Windows.Forms.Label();
|
||||
this.groupTextBox = new System.Windows.Forms.TextBox();
|
||||
this.groupLabel = new System.Windows.Forms.Label();
|
||||
this.meterTypeLabel = new System.Windows.Forms.Label();
|
||||
this.meterTypeComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// nameTextBox
|
||||
//
|
||||
this.nameTextBox.Enabled = false;
|
||||
this.nameTextBox.Location = new System.Drawing.Point(135, 55);
|
||||
this.nameTextBox.Name = "nameTextBox";
|
||||
this.nameTextBox.Size = new System.Drawing.Size(121, 20);
|
||||
this.nameTextBox.TabIndex = 5;
|
||||
//
|
||||
// nameLabel
|
||||
//
|
||||
this.nameLabel.AutoSize = true;
|
||||
this.nameLabel.Location = new System.Drawing.Point(25, 58);
|
||||
this.nameLabel.Name = "nameLabel";
|
||||
this.nameLabel.Size = new System.Drawing.Size(35, 13);
|
||||
this.nameLabel.TabIndex = 4;
|
||||
this.nameLabel.Text = "Name";
|
||||
//
|
||||
// classNameLabel
|
||||
//
|
||||
this.classNameLabel.AutoSize = true;
|
||||
this.classNameLabel.Location = new System.Drawing.Point(132, 31);
|
||||
this.classNameLabel.Name = "classNameLabel";
|
||||
this.classNameLabel.Size = new System.Drawing.Size(60, 13);
|
||||
this.classNameLabel.TabIndex = 3;
|
||||
this.classNameLabel.Text = "ClassName";
|
||||
//
|
||||
// optoPortNrTextBox
|
||||
//
|
||||
this.optoPortNrTextBox.Enabled = false;
|
||||
this.optoPortNrTextBox.Location = new System.Drawing.Point(135, 104);
|
||||
this.optoPortNrTextBox.Name = "optoPortNrTextBox";
|
||||
this.optoPortNrTextBox.Size = new System.Drawing.Size(34, 20);
|
||||
this.optoPortNrTextBox.TabIndex = 7;
|
||||
//
|
||||
// optoPortNrLabel
|
||||
//
|
||||
this.optoPortNrLabel.AutoSize = true;
|
||||
this.optoPortNrLabel.Location = new System.Drawing.Point(25, 107);
|
||||
this.optoPortNrLabel.Name = "optoPortNrLabel";
|
||||
this.optoPortNrLabel.Size = new System.Drawing.Size(96, 13);
|
||||
this.optoPortNrLabel.TabIndex = 6;
|
||||
this.optoPortNrLabel.Text = "Opto serial port nr.:";
|
||||
//
|
||||
// muxBoardNrTextBox
|
||||
//
|
||||
this.muxBoardNrTextBox.Enabled = false;
|
||||
this.muxBoardNrTextBox.Location = new System.Drawing.Point(135, 128);
|
||||
this.muxBoardNrTextBox.Name = "muxBoardNrTextBox";
|
||||
this.muxBoardNrTextBox.Size = new System.Drawing.Size(34, 20);
|
||||
this.muxBoardNrTextBox.TabIndex = 9;
|
||||
//
|
||||
// muxBoardNrLabel
|
||||
//
|
||||
this.muxBoardNrLabel.AutoSize = true;
|
||||
this.muxBoardNrLabel.Location = new System.Drawing.Point(25, 131);
|
||||
this.muxBoardNrLabel.Name = "muxBoardNrLabel";
|
||||
this.muxBoardNrLabel.Size = new System.Drawing.Size(78, 13);
|
||||
this.muxBoardNrLabel.TabIndex = 8;
|
||||
this.muxBoardNrLabel.Text = "Mux. board nr.:";
|
||||
//
|
||||
// groupTextBox
|
||||
//
|
||||
this.groupTextBox.Enabled = false;
|
||||
this.groupTextBox.Location = new System.Drawing.Point(135, 152);
|
||||
this.groupTextBox.Name = "groupTextBox";
|
||||
this.groupTextBox.Size = new System.Drawing.Size(34, 20);
|
||||
this.groupTextBox.TabIndex = 11;
|
||||
//
|
||||
// groupLabel
|
||||
//
|
||||
this.groupLabel.AutoSize = true;
|
||||
this.groupLabel.Location = new System.Drawing.Point(25, 155);
|
||||
this.groupLabel.Name = "groupLabel";
|
||||
this.groupLabel.Size = new System.Drawing.Size(39, 13);
|
||||
this.groupLabel.TabIndex = 10;
|
||||
this.groupLabel.Text = "Group:";
|
||||
//
|
||||
// meterTypeLabel
|
||||
//
|
||||
this.meterTypeLabel.AutoSize = true;
|
||||
this.meterTypeLabel.Location = new System.Drawing.Point(25, 82);
|
||||
this.meterTypeLabel.Name = "meterTypeLabel";
|
||||
this.meterTypeLabel.Size = new System.Drawing.Size(57, 13);
|
||||
this.meterTypeLabel.TabIndex = 12;
|
||||
this.meterTypeLabel.Text = "Meter type";
|
||||
//
|
||||
// meterTypeComboBox
|
||||
//
|
||||
this.meterTypeComboBox.Enabled = false;
|
||||
this.meterTypeComboBox.FormattingEnabled = true;
|
||||
this.meterTypeComboBox.Location = new System.Drawing.Point(135, 79);
|
||||
this.meterTypeComboBox.Name = "meterTypeComboBox";
|
||||
this.meterTypeComboBox.Size = new System.Drawing.Size(121, 21);
|
||||
this.meterTypeComboBox.TabIndex = 13;
|
||||
//
|
||||
// WaterMeterCfgCtrl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.meterTypeComboBox);
|
||||
this.Controls.Add(this.meterTypeLabel);
|
||||
this.Controls.Add(this.groupTextBox);
|
||||
this.Controls.Add(this.groupLabel);
|
||||
this.Controls.Add(this.muxBoardNrTextBox);
|
||||
this.Controls.Add(this.muxBoardNrLabel);
|
||||
this.Controls.Add(this.optoPortNrTextBox);
|
||||
this.Controls.Add(this.optoPortNrLabel);
|
||||
this.Controls.Add(this.nameTextBox);
|
||||
this.Controls.Add(this.nameLabel);
|
||||
this.Controls.Add(this.classNameLabel);
|
||||
this.Name = "WaterMeterCfgCtrl";
|
||||
this.Size = new System.Drawing.Size(300, 200);
|
||||
this.Load += new System.EventHandler(this.WaterMeterCfgCtrl_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
@@ -170,8 +170,8 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
||||
private System.Windows.Forms.Label classNameLabel;
|
||||
private System.Windows.Forms.TextBox optoPortNrTextBox;
|
||||
private System.Windows.Forms.Label optoPortNrLabel;
|
||||
private System.Windows.Forms.TextBox rfidPortNrTextBox;
|
||||
private System.Windows.Forms.Label rfidPortNrLabel;
|
||||
private System.Windows.Forms.TextBox muxBoardNrTextBox;
|
||||
private System.Windows.Forms.Label muxBoardNrLabel;
|
||||
private System.Windows.Forms.TextBox groupTextBox;
|
||||
private System.Windows.Forms.Label groupLabel;
|
||||
private System.Windows.Forms.Label meterTypeLabel;
|
||||
|
||||
@@ -255,8 +255,9 @@ namespace TBF.Entities
|
||||
public static bool IsPowerUser(string userName, string password)
|
||||
{
|
||||
return (userName.Equals("milan") && password.Equals("napajedla")) ||
|
||||
(userName.Equals("igor") && password.Equals("ronko4")) ||
|
||||
(userName.Equals("janb") && password.Equals("sen345bnaj21"));
|
||||
(userName.Equals("igor") && password.Equals("ronko4")) ||
|
||||
(userName.Equals("janb") && password.Equals("sen345bnaj21")) ||
|
||||
(userName.Equals("vlado") && password.Equals("luskovica.430"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,5 +326,15 @@ namespace TBF
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public static string ToMyString(DateTime dateTime)
|
||||
{
|
||||
return string.Format("{0}{1}{2}_{3}{4}",
|
||||
dateTime.Year,
|
||||
dateTime.Month.ToString("D2"),
|
||||
dateTime.Day.ToString("D2"),
|
||||
dateTime.Hour.ToString("D2"),
|
||||
dateTime.Minute.ToString("D2"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user