iPerlCommunication modifications : cfg.seMuxBoards parameter used in the worker thread, MuxBoardNr cannot be 0 anymore, should be 1..4, ver. 2.15.637
This commit is contained in:
parent
3fb2c0aeff
commit
442ac6969f
@ -34,6 +34,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
WrongIPerlType,
|
||||
CalibFactorOoRange,
|
||||
MissingTest,
|
||||
RFPowerRecordMissing,
|
||||
}
|
||||
|
||||
|
||||
@ -72,62 +73,67 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// <summary>
|
||||
/// Wrapper function with safe interface and unsafe body
|
||||
/// </summary>
|
||||
/// <param name="boardNr">0..3</param>
|
||||
/// <param name="comPort">Com port number</param>
|
||||
/// <param name="threadID">0..3</param>
|
||||
/// <param name="iperlHead">Water meter (iPerlHead) object</param>
|
||||
/// <returns>Value returned by openPort(...)</returns>
|
||||
public static unsafe int OpenPort(IperlHead iperlHead)
|
||||
public static unsafe int OpenPort(int threadID, IperlHead iperlHead)
|
||||
{
|
||||
if (iperlHead.DebugLevel != DebugMode.Normal) return 0; /// No function in debug mode
|
||||
|
||||
if (iperlHead.RfidComPortNr > 0)
|
||||
int rfidPortNr;
|
||||
if (cfg.UseMuxBoards)
|
||||
{
|
||||
return openPort1(iperlHead.RfidComPortNr);
|
||||
switch (iperlHead.MuxBoardNrOrGroup14)
|
||||
{
|
||||
default:
|
||||
case 1: rfidPortNr = cfg.RfidPortNrBoard1; break;
|
||||
case 2: rfidPortNr = cfg.RfidPortNrBoard2; break;
|
||||
case 3: rfidPortNr = cfg.RfidPortNrBoard3; break;
|
||||
case 4: rfidPortNr = cfg.RfidPortNrBoard4; break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (iperlHead.MuxBoardNr)
|
||||
{
|
||||
default:
|
||||
case 1: return openPort1(cfg.RfidPortNrBoard1);
|
||||
case 2: return openPort2(cfg.RfidPortNrBoard2);
|
||||
case 3: return openPort3(cfg.RfidPortNrBoard3);
|
||||
case 4: return openPort4(cfg.RfidPortNrBoard4);
|
||||
}
|
||||
rfidPortNr = iperlHead.RfidComPortNr;
|
||||
}
|
||||
|
||||
switch (threadID)
|
||||
{
|
||||
default:
|
||||
case 0: return openPort1(rfidPortNr);
|
||||
case 1: return openPort2(rfidPortNr);
|
||||
case 2: return openPort3(rfidPortNr);
|
||||
case 3: return openPort4(rfidPortNr);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wrapper function with safe interface and unsafe body
|
||||
/// </summary>
|
||||
/// <param name="boardNr">0..3</param>
|
||||
/// <param name="comPort">Com port number</param>
|
||||
/// <param name="threadID">0..3</param>
|
||||
/// <param name="iperlHead">Water meter (iPerlHead) object</param>
|
||||
/// <returns>Value returned by openPort(...)</returns>
|
||||
public static unsafe int ClosePort(IperlHead iperlHead)
|
||||
public static unsafe int ClosePort(int threadID, IperlHead iperlHead)
|
||||
{
|
||||
if (iperlHead.DebugLevel != DebugMode.Normal) return 0; /// No function in debug mode
|
||||
|
||||
if (iperlHead.RfidComPortNr > 0)
|
||||
switch (threadID)
|
||||
{
|
||||
return closePort1();
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (iperlHead.MuxBoardNr)
|
||||
{
|
||||
default:
|
||||
case 1: return closePort1();
|
||||
case 2: return closePort2();
|
||||
case 3: return closePort3();
|
||||
case 4: return closePort4();
|
||||
}
|
||||
default:
|
||||
case 0: return closePort1();
|
||||
case 1: return closePort2();
|
||||
case 2: return closePort3();
|
||||
case 3: return closePort4();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wrapper function with safe interface and unsafe body
|
||||
/// </summary>
|
||||
/// <param name="threadID">0..3</param>
|
||||
/// <param name="iperlHead">Water meter (iPerlHead) object</param>
|
||||
/// <returns>Value returned by readRequestPort(...)</returns>
|
||||
public static unsafe int ReadRequestPort(IperlHead iperlHead, MessageID messageID, int offset, int lenght, out byte[] buffer, int timeout)
|
||||
public static unsafe int ReadRequestPort(int threadID, IperlHead iperlHead, MessageID messageID, int offset, int lenght, out byte[] buffer, int timeout)
|
||||
{
|
||||
buffer = new byte[lenght];
|
||||
|
||||
@ -140,20 +146,13 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
{
|
||||
int retv;
|
||||
|
||||
if (iperlHead.RfidComPortNr > 0)
|
||||
switch (threadID)
|
||||
{
|
||||
retv = readRequestPort1(messageID, offset, lenght, pBuf, timeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (iperlHead.MuxBoardNr)
|
||||
{
|
||||
default:
|
||||
case 1: retv = readRequestPort1(messageID, offset, lenght, pBuf, timeout); break;
|
||||
case 2: retv = readRequestPort2(messageID, offset, lenght, pBuf, timeout); break;
|
||||
case 3: retv = readRequestPort3(messageID, offset, lenght, pBuf, timeout); break;
|
||||
case 4: retv = readRequestPort4(messageID, offset, lenght, pBuf, timeout); break;
|
||||
}
|
||||
default:
|
||||
case 0: retv = readRequestPort1(messageID, offset, lenght, pBuf, timeout); break;
|
||||
case 1: retv = readRequestPort2(messageID, offset, lenght, pBuf, timeout); break;
|
||||
case 2: retv = readRequestPort3(messageID, offset, lenght, pBuf, timeout); break;
|
||||
case 3: retv = readRequestPort4(messageID, offset, lenght, pBuf, timeout); break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < lenght; i++) buffer[i] = buf[i];
|
||||
@ -178,8 +177,10 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// <summary>
|
||||
/// Wrapper function with safe interface adn unsafe body
|
||||
/// </summary>
|
||||
/// <param name="threadID">0..3</param>
|
||||
/// <param name="iperlHead">Water meter (iPerlHead) object</param>
|
||||
/// <returns>Value returned by writeRequestPort(...)</returns>
|
||||
public static unsafe int WriteRequestPort(IperlHead iperlHead, MessageID messageID, int offset, int lenght, byte[] buffer, int timeout)
|
||||
public static unsafe int WriteRequestPort(int threadID, IperlHead iperlHead, MessageID messageID, int offset, int lenght, byte[] buffer, int timeout)
|
||||
{
|
||||
if (iperlHead.DebugLevel != DebugMode.Normal) return 0;
|
||||
|
||||
@ -187,20 +188,13 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
{
|
||||
int retv;
|
||||
|
||||
if (iperlHead.RfidComPortNr > 0)
|
||||
switch (threadID)
|
||||
{
|
||||
retv = writeRequestPort1(messageID, offset, lenght, pBuf, timeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (iperlHead.MuxBoardNr)
|
||||
{
|
||||
default:
|
||||
case 1: retv = writeRequestPort1(messageID, offset, lenght, pBuf, timeout); break;
|
||||
case 2: retv = writeRequestPort2(messageID, offset, lenght, pBuf, timeout); break;
|
||||
case 3: retv = writeRequestPort3(messageID, offset, lenght, pBuf, timeout); break;
|
||||
case 4: retv = writeRequestPort4(messageID, offset, lenght, pBuf, timeout); break;
|
||||
}
|
||||
default:
|
||||
case 0: retv = writeRequestPort1(messageID, offset, lenght, pBuf, timeout); break;
|
||||
case 1: retv = writeRequestPort2(messageID, offset, lenght, pBuf, timeout); break;
|
||||
case 2: retv = writeRequestPort3(messageID, offset, lenght, pBuf, timeout); break;
|
||||
case 3: retv = writeRequestPort4(messageID, offset, lenght, pBuf, timeout); break;
|
||||
}
|
||||
|
||||
Thread.Sleep(250);
|
||||
@ -282,7 +276,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
static int completedCommCount; /// Number of completed communication steps
|
||||
|
||||
static IList<Thread> workerThreads;
|
||||
static IList<int> rfidPortNrs;
|
||||
static IList<int> muxBrdOrGroup14Nrs;
|
||||
static bool stopWorkerThreads; /// form -> worker thread
|
||||
|
||||
|
||||
@ -333,11 +327,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
wmTextBox46, wmTextBox47, wmTextBox48,
|
||||
};
|
||||
|
||||
/// Initialize lists
|
||||
iperlHeads = new List<IperlHead>();
|
||||
waterMeterPositions = new List<int>();
|
||||
|
||||
formCompleted = false;
|
||||
formCompleted = false;
|
||||
|
||||
startTime = DateTime.Now;
|
||||
startTimeSec = StateMachine.Time;
|
||||
@ -418,6 +408,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
|
||||
void ConstructorCommon()
|
||||
{
|
||||
iperlHeads = new List<IperlHead>();
|
||||
waterMeterPositions = new List<int>();
|
||||
///
|
||||
for (int wmPos = 0; wmPos < ProcessData.RegisterReaders.Length; wmPos++)
|
||||
{
|
||||
IperlHead iperlHead = ProcessData.RegisterReaders[wmPos] as IperlHead;
|
||||
@ -436,35 +429,39 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
///
|
||||
/// Prepare worker threads, 'rfidPortNrs', 'lastGroup', etc..
|
||||
///
|
||||
workerThreads = new List<Thread>();
|
||||
rfidPortNrs = new List<int>();
|
||||
|
||||
currentActivityStep = 0;
|
||||
currentGroup = 0;
|
||||
lastGroup = 0; /// group numbers are >=1, lastGroup == 0 means no group
|
||||
completedCommCount = 0;
|
||||
stopWorkerThreads = false;
|
||||
|
||||
foreach (var iPerl in iPerlCommunicationForm.iperlHeads)
|
||||
/// group numbers are >=1, lastGroup == 0 means there is no group
|
||||
lastGroup = 0;
|
||||
foreach (var iPerl in iPerlCommunicationForm.iperlHeads)
|
||||
{
|
||||
if (iPerl.Group > lastGroup) lastGroup = iPerl.Group;
|
||||
}
|
||||
|
||||
workerThreads = new List<Thread>();
|
||||
for (int i = 0; i < cfg.NrThreads; i++)
|
||||
{
|
||||
Thread thread = new Thread(iPerlCommunicationForm.Worker);
|
||||
workerThreads.Add(thread);
|
||||
}
|
||||
|
||||
muxBrdOrGroup14Nrs = new List<int>();
|
||||
foreach (var iPerl in iPerlCommunicationForm.iperlHeads)
|
||||
{
|
||||
if (!rfidPortNrs.Contains(iPerl.MuxBoardNr))
|
||||
{
|
||||
rfidPortNrs.Add(iPerl.MuxBoardNr);
|
||||
|
||||
if (workerThreads.Count < cfg.NrThreads)
|
||||
{
|
||||
Thread thread = new Thread(iPerlCommunicationForm.Worker);
|
||||
workerThreads.Add(thread);
|
||||
}
|
||||
}
|
||||
|
||||
if (iPerl.Group > lastGroup) lastGroup = iPerl.Group;
|
||||
}
|
||||
if (!muxBrdOrGroup14Nrs.Contains(iPerl.MuxBoardNrOrGroup14)) muxBrdOrGroup14Nrs.Add(iPerl.MuxBoardNrOrGroup14);
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("rfidPortNrs = [");
|
||||
foreach (var v in rfidPortNrs) sb.Append(string.Format(" {0}", v));
|
||||
sb.Append(string.Format(" ], nrThreads = {0}", workerThreads.Count));
|
||||
if (cfg.UseMuxBoards)
|
||||
{
|
||||
sb.Append("rfidPortNrs = [");
|
||||
foreach (var v in muxBrdOrGroup14Nrs) sb.Append(string.Format(" {0}", v));
|
||||
sb.Append(" ], ");
|
||||
}
|
||||
sb.Append(string.Format("nrThreads = {0}", workerThreads.Count));
|
||||
log.WarnFormat(sb.ToString());
|
||||
}
|
||||
|
||||
@ -550,26 +547,22 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
counters[i].BackColor = Color.Red;
|
||||
}
|
||||
|
||||
///
|
||||
/// Start worker threads, etc.
|
||||
///
|
||||
if (workerThreads != null)
|
||||
{
|
||||
int wtId = 0;
|
||||
foreach (var wt in workerThreads) wt.Start(new Boxes.IntBox(wtId++));
|
||||
///
|
||||
/// Set QuidoRS outputs and start the whole communication process
|
||||
/// by incrementing 'currentGroup'.
|
||||
///
|
||||
if (cfg.UseMuxBoards && quido != null)
|
||||
{
|
||||
quido.SetOutputs((ushort)(16 - currentGroup - 1));
|
||||
Thread.Sleep(200);
|
||||
}
|
||||
|
||||
///
|
||||
/// Set QuidoRS outputs and start the whole communication process
|
||||
/// by incrementing 'currentGroup'.
|
||||
///
|
||||
if (quido != null)
|
||||
{
|
||||
quido.SetOutputs((ushort)(16 - currentGroup - 1));
|
||||
Thread.Sleep(200);
|
||||
}
|
||||
currentGroup++;
|
||||
}
|
||||
}
|
||||
currentGroup++;
|
||||
|
||||
/// Start worker threads
|
||||
int wtId = 0;
|
||||
foreach (var wt in workerThreads) wt.Start(new Boxes.IntBox(wtId++));
|
||||
}
|
||||
|
||||
|
||||
private void NormalClose()
|
||||
@ -625,7 +618,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// <param name="threadData">Thread ID (integer) wrapped into IntBox</param>
|
||||
static void Worker(object threadData)
|
||||
{
|
||||
int threadId = (threadData as Boxes.IntBox).Val;
|
||||
int threadID = (threadData as Boxes.IntBox).Val;
|
||||
|
||||
int activityStep = 0; /// activity step > 0 in case multiTestParams are used
|
||||
|
||||
@ -639,7 +632,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
string activity = testParams.Activity; /// Current activity
|
||||
|
||||
|
||||
if (threadId == 0)
|
||||
if (threadID == 0)
|
||||
{
|
||||
rfidDataLogger.InfoFormat(""); /// Makes the log more readable when there is a lot of data
|
||||
rfidDataLogger.WarnFormat("Activity = {0}", activity);
|
||||
@ -656,11 +649,10 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
|
||||
if (stopWorkerThreads) break;
|
||||
|
||||
for (int rfidPortIx = threadId; rfidPortIx < threadId + 4; rfidPortIx += cfg.NrThreads)
|
||||
for (int threadIx = threadID; threadIx < threadID + 4; threadIx += cfg.NrThreads)
|
||||
{
|
||||
if (rfidPortIx >= rfidPortNrs.Count) break; // quit, all RFID ports of all water meters done
|
||||
if (cfg.UseMuxBoards && threadIx >= muxBrdOrGroup14Nrs.Count) break; // quit, all RFID ports of all water meters done
|
||||
|
||||
int rfidPortNr = rfidPortNrs[rfidPortIx];
|
||||
int wmNr = 0;
|
||||
bool wmFound = false;
|
||||
|
||||
@ -668,7 +660,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
{
|
||||
IperlHead ihead = iperlHeads[j];
|
||||
|
||||
if ((ihead.MuxBoardNr == rfidPortNr) && (ihead.Group == group))
|
||||
if (ihead.Group == group && ihead.MuxBoardNrOrGroup14 == muxBrdOrGroup14Nrs[threadIx])
|
||||
{
|
||||
wmFound = true;
|
||||
Results.Entities.WaterMeter wm = ProcessData.BatchRslts.WaterMeters[waterMeterPositions[j]];
|
||||
@ -676,27 +668,27 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
CommErr error;
|
||||
string resultStr = string.Empty;
|
||||
|
||||
if (activity.ToLower().Contains(ReadConfigurationStr.ToLower())) error = ReadConfiguration(ihead, wm, ref resultStr);
|
||||
else if (activity.ToLower().Contains(SetTestModeStr.ToLower())) error = SetTestMode(ihead, wm, ref resultStr);
|
||||
else if (activity.ToLower().Equals(SetActiveModeStr.ToLower())) error = SetActiveMode(ihead, wm, ref resultStr);
|
||||
else if (activity.ToLower().Equals(ReadCalibrationStr.ToLower())) error = ReadCalibration(ihead, wm, ref resultStr);
|
||||
else if (activity.ToLower().Contains(WriteCalibrationFactorStr.ToLower())) error = WriteCalibrationFactor(ihead, wm, ref resultStr);
|
||||
else if (activity.ToLower().Equals(NormalizeCalibrationFactorStr.ToLower())) error = NormalizeCalibrationFactor(ihead, wm, ref resultStr);
|
||||
else if (activity.ToLower().Equals(ResetQ2CorrectionStr.ToLower())) error = ResetQ2Correction(ihead, wm, ref resultStr);
|
||||
if (activity.ToLower().Contains(ReadConfigurationStr.ToLower())) error = ReadConfiguration(threadID, ihead, wm, ref resultStr);
|
||||
else if (activity.ToLower().Contains(SetTestModeStr.ToLower())) error = SetTestMode(threadID, ihead, wm, ref resultStr);
|
||||
else if (activity.ToLower().Equals(SetActiveModeStr.ToLower())) error = SetActiveMode(threadID, ihead, wm, ref resultStr);
|
||||
else if (activity.ToLower().Equals(ReadCalibrationStr.ToLower())) error = ReadCalibration(threadID, ihead, wm, ref resultStr);
|
||||
else if (activity.ToLower().Contains(WriteCalibrationFactorStr.ToLower())) error = WriteCalibrationFactor(threadID, ihead, wm, ref resultStr);
|
||||
else if (activity.ToLower().Equals(NormalizeCalibrationFactorStr.ToLower())) error = NormalizeCalibrationFactor(threadID, ihead, wm, ref resultStr);
|
||||
else if (activity.ToLower().Equals(ResetQ2CorrectionStr.ToLower())) error = ResetQ2Correction(threadID, ihead, wm, ref resultStr);
|
||||
else if (activity.ToLower().Equals(WriteQ2CorrectionStr.ToLower()))
|
||||
{
|
||||
error = WriteQ2Correction(ihead, wm, ref resultStr, Q2CorrType.Standard, null, false);
|
||||
error = WriteQ2Correction(threadID, ihead, wm, ref resultStr, Q2CorrType.Standard, null, false);
|
||||
}
|
||||
else if (activity.ToLower().Equals(WriteQ2CorrectionAltStr.ToLower()))
|
||||
{
|
||||
error = WriteQ2Correction(ihead, wm, ref resultStr, Q2CorrType.Dewa, null, false);
|
||||
error = WriteQ2Correction(threadID, ihead, wm, ref resultStr, Q2CorrType.Dewa, null, false);
|
||||
}
|
||||
else if (activity.ToLower().Contains(WriteQ2CorrectionGreeceStr.ToLower()))
|
||||
{
|
||||
error = WriteQ2Correction(ihead, wm, ref resultStr, Q2CorrType.Greece, activity.Substring(WriteQ2CorrectionGreeceStr.Length).Trim(), true);
|
||||
error = WriteQ2Correction(threadID, ihead, wm, ref resultStr, Q2CorrType.Greece, activity.Substring(WriteQ2CorrectionGreeceStr.Length).Trim(), true);
|
||||
}
|
||||
else if (activity.ToLower().Equals(Reset2HzCorrectionStr.ToLower())) error = Reset2HzCorrection(ihead, wm, ref resultStr);
|
||||
else if (activity.ToLower().Equals(Write2HzCorrectionStr.ToLower())) error = Write2HzCorrection(ihead, wm, ref resultStr);
|
||||
else if (activity.ToLower().Equals(Reset2HzCorrectionStr.ToLower())) error = Reset2HzCorrection(threadID, ihead, wm, ref resultStr);
|
||||
else if (activity.ToLower().Equals(Write2HzCorrectionStr.ToLower())) error = Write2HzCorrection(threadID, ihead, wm, ref resultStr);
|
||||
else
|
||||
{
|
||||
error = CommErr.None;
|
||||
@ -706,16 +698,16 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
|
||||
if (error == CommErr.None)
|
||||
{
|
||||
OnCommCompleted(null, new CommCompletedEventArgs(threadId, wmNr, resultStr));
|
||||
OnCommCompleted(null, new CommCompletedEventArgs(threadID, wmNr, resultStr));
|
||||
}
|
||||
else if (ihead.CommFailed || error == CommErr.CommFailed)
|
||||
{
|
||||
OnCommCompleted(null, new CommCompletedEventArgs(threadId, wmNr, "Watermeter is disabled"));
|
||||
OnCommCompleted(null, new CommCompletedEventArgs(threadID, wmNr, "Watermeter is disabled"));
|
||||
}
|
||||
else
|
||||
{
|
||||
OnCommCompleted(null, new CommCompletedEventArgs(threadId, wmNr, string.Format("{0} failed ({1}) !!!", activity, error)));
|
||||
rfidDataLogger.ErrorFormat("Group={0}, Board={1}, {2} failed ({3}) !!!", currentGroup, ihead.MuxBoardNr, activity, error);
|
||||
OnCommCompleted(null, new CommCompletedEventArgs(threadID, wmNr, string.Format("{0} failed ({1}) !!!", activity, error)));
|
||||
rfidDataLogger.ErrorFormat("Group={0}, Board={1}, {2} failed ({3}) !!!", currentGroup, ihead.MuxBoardNrOrGroup14, activity, error);
|
||||
ihead.CommFailed = true;
|
||||
}
|
||||
break;
|
||||
@ -726,7 +718,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
|
||||
if (!wmFound)
|
||||
{
|
||||
OnCommCompleted(null, new CommCompletedEventArgs(threadId, -1, string.Empty)); /// Send negative wmNr
|
||||
OnCommCompleted(null, new CommCompletedEventArgs(threadID, -1, string.Empty)); /// Send negative wmNr
|
||||
}
|
||||
|
||||
if (stopWorkerThreads) break;
|
||||
@ -749,7 +741,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// <param name="ihead">Water meter object</param>
|
||||
/// <param name="resultStr">String passed to caller</param>
|
||||
/// <returns>true on success</returns>
|
||||
static CommErr ReadConfiguration(IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
|
||||
static CommErr ReadConfiguration(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
|
||||
{
|
||||
///
|
||||
/// The activity is "Read configuration" (this enables the watermeter, resets error flag)
|
||||
@ -762,7 +754,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
|
||||
if (ihead.CommFailed) return CommErr.CommFailed;
|
||||
|
||||
if (OpenPort(ihead) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
if (OpenPort(threadId, ihead) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
|
||||
CommErr error = CommErr.Read;
|
||||
|
||||
@ -770,7 +762,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
byte[] config = null;
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == ReadRequestPort(ihead, MessageID.Configuration, 0, ConfigStruct.Length, out config, cfg.CommTimeout))
|
||||
if (0 == ReadRequestPort(threadId, ihead, MessageID.Configuration, 0, ConfigStruct.Length, out config, cfg.CommTimeout))
|
||||
{
|
||||
error = CommErr.None;
|
||||
ihead.ConfigStruct = ConfigStruct.FromByteArray(config);
|
||||
@ -779,7 +771,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
}
|
||||
}
|
||||
|
||||
ClosePort(ihead); /// Close RFID port
|
||||
ClosePort(threadId, ihead); /// Close RFID port
|
||||
|
||||
return error;
|
||||
}
|
||||
@ -794,7 +786,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// <param name="ihead">Water meter object</param>
|
||||
/// <param name="resultStr">String passed to caller</param>
|
||||
/// <returns>true on success</returns>
|
||||
static CommErr SetTestMode(IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
|
||||
static CommErr SetTestMode(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
|
||||
{
|
||||
if (ihead.CommFailed) return CommErr.CommFailed;
|
||||
|
||||
@ -818,7 +810,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
}
|
||||
|
||||
/// Communication necessary
|
||||
if (OpenPort(ihead) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
if (OpenPort(threadId, ihead) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
|
||||
CommErr error = CommErr.None;
|
||||
|
||||
@ -829,7 +821,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
byte[] cmd = new byte[1] { (byte)6 };
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == WriteRequestPort(ihead, MessageID.Command, 0, 1, cmd, cfg.CommTimeout)) { error = CommErr.None; break; }
|
||||
if (0 == WriteRequestPort(threadId, ihead, MessageID.Command, 0, 1, cmd, cfg.CommTimeout)) { error = CommErr.None; break; }
|
||||
}
|
||||
|
||||
Thread.Sleep(250);
|
||||
@ -842,7 +834,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
byte[] tstMdCfg = new byte[1] { testModeConfig };
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == WriteRequestPort(ihead, MessageID.Configuration, 21, 1, tstMdCfg, cfg.CommTimeout))
|
||||
if (0 == WriteRequestPort(threadId, ihead, MessageID.Configuration, 21, 1, tstMdCfg, cfg.CommTimeout))
|
||||
{
|
||||
ihead.ConfigStruct.Update(21, tstMdCfg);
|
||||
error = CommErr.None;
|
||||
@ -860,7 +852,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
byte[] cmd = new byte[1] { (byte)7 };
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == WriteRequestPort(ihead, MessageID.Command, 0, 1, cmd, cfg.CommTimeout)) { error = CommErr.None; break; }
|
||||
if (0 == WriteRequestPort(threadId, ihead, MessageID.Command, 0, 1, cmd, cfg.CommTimeout)) { error = CommErr.None; break; }
|
||||
}
|
||||
|
||||
Thread.Sleep(250);
|
||||
@ -874,7 +866,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
byte[] cfg_0_3 = null;
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == ReadRequestPort(ihead, MessageID.Configuration, 0, 4, out cfg_0_3, cfg.CommTimeout))
|
||||
if (0 == ReadRequestPort(threadId, ihead, MessageID.Configuration, 0, 4, out cfg_0_3, cfg.CommTimeout))
|
||||
{
|
||||
ihead.ConfigStruct.Update(0, cfg_0_3);
|
||||
if (ihead.ConfigStruct.MeterState == MeterState.Test)
|
||||
@ -887,7 +879,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
}
|
||||
}
|
||||
|
||||
ClosePort(ihead); /// Close RFID port
|
||||
ClosePort(threadId, ihead); /// Close RFID port
|
||||
|
||||
return error;
|
||||
}
|
||||
@ -900,9 +892,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// <param name="ihead">Water meter object</param>
|
||||
/// <param name="resultStr">String passed to caller</param>
|
||||
/// <returns>true on success</returns>
|
||||
static CommErr SetActiveMode(IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
|
||||
static CommErr SetActiveMode(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
|
||||
{
|
||||
if (OpenPort(ihead) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
if (OpenPort(threadId, ihead) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
|
||||
CommErr error = CommErr.CmdActive;
|
||||
|
||||
@ -910,7 +902,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
byte[] cmd = new byte[1] { (byte)6 };
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == WriteRequestPort(ihead, MessageID.Command, 0, 1, cmd, cfg.CommTimeout))
|
||||
if (0 == WriteRequestPort(threadId, ihead, MessageID.Command, 0, 1, cmd, cfg.CommTimeout))
|
||||
{
|
||||
error = CommErr.None;
|
||||
break;
|
||||
@ -928,7 +920,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
{
|
||||
if (ihead.ConfigStruct == null)
|
||||
{
|
||||
if (0 == ReadRequestPort(ihead, MessageID.Configuration, 0, 4, out cfg_0_3, cfg.CommTimeout))
|
||||
if (0 == ReadRequestPort(threadId, ihead, MessageID.Configuration, 0, 4, out cfg_0_3, cfg.CommTimeout))
|
||||
{
|
||||
ihead.ConfigStruct.Update(0, cfg_0_3);
|
||||
if (ihead.ConfigStruct.MeterState == MeterState.Active)
|
||||
@ -951,7 +943,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
}
|
||||
#endif
|
||||
|
||||
ClosePort(ihead); /// Close RFID port
|
||||
ClosePort(threadId, ihead); /// Close RFID port
|
||||
|
||||
return error;
|
||||
}
|
||||
@ -963,11 +955,11 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// <param name="ihead">Water meter object</param>
|
||||
/// <param name="resultStr">String passed to caller</param>
|
||||
/// <returns>true on success</returns>
|
||||
static CommErr ReadCalibration(IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
|
||||
static CommErr ReadCalibration(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
|
||||
{
|
||||
if (ihead.CommFailed) return CommErr.CommFailed;
|
||||
|
||||
if (OpenPort(ihead) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
if (OpenPort(threadId, ihead) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
|
||||
CommErr error = CommErr.Read;
|
||||
|
||||
@ -975,7 +967,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
byte[] calib = null;
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == ReadRequestPort(ihead, MessageID.Calibration, 0, CalibrationStruct.Length, out calib, cfg.CommTimeout))
|
||||
if (0 == ReadRequestPort(threadId, ihead, MessageID.Calibration, 0, CalibrationStruct.Length, out calib, cfg.CommTimeout))
|
||||
{
|
||||
ihead.CalibrationStruct = CalibrationStruct.FromByteArray(calib);
|
||||
#if IPERL
|
||||
@ -991,7 +983,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
}
|
||||
}
|
||||
|
||||
ClosePort(ihead); /// Close RFID port
|
||||
ClosePort(threadId, ihead); /// Close RFID port
|
||||
|
||||
return error;
|
||||
}
|
||||
@ -1004,7 +996,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// <param name="ihead">Water meter object</param>
|
||||
/// <param name="resultStr">String passed to caller</param>
|
||||
/// <returns>true on success</returns>
|
||||
static CommErr WriteCalibrationFactor(IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
|
||||
static CommErr WriteCalibrationFactor(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
|
||||
{
|
||||
if (ihead.CommFailed) return CommErr.CommFailed;
|
||||
|
||||
@ -1084,7 +1076,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
///
|
||||
/// Start communication with iPerl
|
||||
///
|
||||
if (OpenPort(ihead) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
if (OpenPort(threadId, ihead) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
|
||||
CommErr error;
|
||||
byte[] data = new byte[2] { (byte)(newCalibFactor & 0x00FF), (byte)((newCalibFactor >> 8) & 0x00FF) };
|
||||
@ -1095,14 +1087,14 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// Write the new calibration factor (up to cfg.MaxCommRetries tims)
|
||||
///
|
||||
error = CommErr.Write;
|
||||
if (0 == WriteRequestPort(ihead, MessageID.Calibration, 2, 2, data, cfg.CommTimeout))
|
||||
if (0 == WriteRequestPort(threadId, ihead, MessageID.Calibration, 2, 2, data, cfg.CommTimeout))
|
||||
{
|
||||
///
|
||||
/// Read and verify the calibration factor
|
||||
///
|
||||
error = CommErr.ReadAfterWrite;
|
||||
byte[] calib_2_3 = null;
|
||||
if (0 == ReadRequestPort(ihead, MessageID.Calibration, 2, 2, out calib_2_3, cfg.CommTimeout))
|
||||
if (0 == ReadRequestPort(threadId, ihead, MessageID.Calibration, 2, 2, out calib_2_3, cfg.CommTimeout))
|
||||
{
|
||||
error = CommErr.Verify;
|
||||
if (calib_2_3 != null && calib_2_3.Length == 2 && data[0] == calib_2_3[0] && data[1] == calib_2_3[1])
|
||||
@ -1122,7 +1114,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
}
|
||||
while (++writeAndVerifyRetries <= cfg.MaxCommRetries);
|
||||
|
||||
ClosePort(ihead); /// Close RFID port
|
||||
ClosePort(threadId, ihead); /// Close RFID port
|
||||
|
||||
return error;
|
||||
}
|
||||
@ -1134,7 +1126,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// <param name="ihead">Water meter object</param>
|
||||
/// <param name="resultStr">String passed to caller</param>
|
||||
/// <returns>true on success</returns>
|
||||
static CommErr NormalizeCalibrationFactor(IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
|
||||
static CommErr NormalizeCalibrationFactor(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
|
||||
{
|
||||
if (ihead.CommFailed) return CommErr.CommFailed;
|
||||
|
||||
@ -1144,7 +1136,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
return CommErr.None; /// No need to update the calibration factor
|
||||
}
|
||||
|
||||
if (OpenPort(ihead) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
if (OpenPort(threadId, ihead) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
|
||||
CommErr error = CommErr.Write;
|
||||
|
||||
@ -1168,7 +1160,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
byte[] data = new byte[2] { (byte)(newCalibFactor & 0x00FF), (byte)((newCalibFactor >> 8) & 0x00FF) };
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == WriteRequestPort(ihead, MessageID.Calibration, 2, 2, data, cfg.CommTimeout))
|
||||
if (0 == WriteRequestPort(threadId, ihead, MessageID.Calibration, 2, 2, data, cfg.CommTimeout))
|
||||
{
|
||||
error = CommErr.None;
|
||||
ihead.CalibrationStruct.Update(data, 2);
|
||||
@ -1184,7 +1176,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
byte[] calib_2_3 = null;
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == ReadRequestPort(ihead, MessageID.Calibration, 2, 2, out calib_2_3, cfg.CommTimeout))
|
||||
if (0 == ReadRequestPort(threadId, ihead, MessageID.Calibration, 2, 2, out calib_2_3, cfg.CommTimeout))
|
||||
{
|
||||
error = CommErr.None;
|
||||
ihead.CalibrationStruct.Update(calib_2_3, 2);
|
||||
@ -1194,7 +1186,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
}
|
||||
}
|
||||
|
||||
ClosePort(ihead); /// Close RFID port
|
||||
ClosePort(threadId, ihead); /// Close RFID port
|
||||
|
||||
return error;
|
||||
}
|
||||
@ -1211,11 +1203,11 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// <param name="ihead">Water meter object</param>
|
||||
/// <param name="resultStr">String passed to caller</param>
|
||||
/// <returns>true on success</returns>
|
||||
static CommErr ResetQ2Correction(IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
|
||||
static CommErr ResetQ2Correction(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
|
||||
{
|
||||
if (ihead.CommFailed) return CommErr.CommFailed;
|
||||
|
||||
if (OpenPort(ihead) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
if (OpenPort(threadId, ihead) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
|
||||
CommErr error = CommErr.Write;
|
||||
|
||||
@ -1224,7 +1216,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
///
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == WriteRequestPort(ihead, MessageID.MetrologyMemory, Q2CorrFactorsAddr, wrData.Length, wrData, cfg.CommTimeout))
|
||||
if (0 == WriteRequestPort(threadId, ihead, MessageID.MetrologyMemory, Q2CorrFactorsAddr, wrData.Length, wrData, cfg.CommTimeout))
|
||||
{
|
||||
error = CommErr.None;
|
||||
break;
|
||||
@ -1244,7 +1236,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
byte[] rdData = null;
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if ((0 == ReadRequestPort(ihead, MessageID.MetrologyMemory, Q2CorrFactorsAddr, 2, out rdData, cfg.CommTimeout)) &&
|
||||
if ((0 == ReadRequestPort(threadId, ihead, MessageID.MetrologyMemory, Q2CorrFactorsAddr, 2, out rdData, cfg.CommTimeout)) &&
|
||||
(rdData != null) && (rdData.Length == 2) && (rdData[0] == 0) && (rdData[1] == 0))
|
||||
{
|
||||
error = CommErr.None;
|
||||
@ -1262,7 +1254,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
}
|
||||
#endif
|
||||
|
||||
ClosePort(ihead); /// Close RFID port
|
||||
ClosePort(threadId, ihead); /// Close RFID port
|
||||
|
||||
return error;
|
||||
}
|
||||
@ -1274,11 +1266,11 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// <param name="ihead">Water meter object</param>
|
||||
/// <param name="resultStr">String passed to caller</param>
|
||||
/// <returns>true on success</returns>
|
||||
static CommErr Reset2HzCorrection(IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
|
||||
static CommErr Reset2HzCorrection(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
|
||||
{
|
||||
if (ihead.CommFailed) return CommErr.CommFailed;
|
||||
|
||||
if (OpenPort(ihead) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
if (OpenPort(threadId, ihead) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
|
||||
CommErr error = CommErr.Write;
|
||||
|
||||
@ -1287,7 +1279,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
///
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == WriteRequestPort(ihead, MessageID.MetrologyMemory, Hz2CorrFactorsAddr, wrData.Length, wrData, cfg.CommTimeout))
|
||||
if (0 == WriteRequestPort(threadId, ihead, MessageID.MetrologyMemory, Hz2CorrFactorsAddr, wrData.Length, wrData, cfg.CommTimeout))
|
||||
{
|
||||
error = CommErr.None;
|
||||
break;
|
||||
@ -1307,7 +1299,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
byte[] rdData = null;
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if ((0 == ReadRequestPort(ihead, MessageID.MetrologyMemory, Hz2CorrFactorsAddr, 1, out rdData, cfg.CommTimeout)) &&
|
||||
if ((0 == ReadRequestPort(threadId, ihead, MessageID.MetrologyMemory, Hz2CorrFactorsAddr, 1, out rdData, cfg.CommTimeout)) &&
|
||||
(rdData != null) && (rdData.Length == 2) && (rdData[0] == 0) && (rdData[1] == 0))
|
||||
{
|
||||
error = CommErr.None;
|
||||
@ -1325,7 +1317,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
}
|
||||
#endif
|
||||
|
||||
ClosePort(ihead); /// Close RFID port
|
||||
ClosePort(threadId, ihead); /// Close RFID port
|
||||
|
||||
return error;
|
||||
}
|
||||
@ -1338,7 +1330,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// <param name="ihead">Water meter object</param>
|
||||
/// <param name="resultStr">String passed to caller</param>
|
||||
/// <returns>true on success</returns>
|
||||
static CommErr WriteQ2Correction(IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr, Q2CorrType q2CorrType, string q2TestName, bool updateQ2adjByCalibFactor)
|
||||
static CommErr WriteQ2Correction(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr, Q2CorrType q2CorrType, string q2TestName, bool updateQ2adjByCalibFactor)
|
||||
{
|
||||
//if (ihead == null || ihead.CommFailed) return CommErr.CommFailed;
|
||||
|
||||
@ -1459,7 +1451,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
q2CorrLFlow = (byte)((int)Math.Round(q2Correction) & 0x000000FF);
|
||||
}
|
||||
|
||||
if (OpenPort(ihead) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
if (OpenPort(threadId, ihead) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
|
||||
CommErr error = CommErr.Write;
|
||||
|
||||
@ -1467,7 +1459,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
///
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == WriteRequestPort(ihead, MessageID.MetrologyMemory, Q2CorrFactorsAddr, wrData.Length, wrData, cfg.CommTimeout))
|
||||
if (0 == WriteRequestPort(threadId, ihead, MessageID.MetrologyMemory, Q2CorrFactorsAddr, wrData.Length, wrData, cfg.CommTimeout))
|
||||
{
|
||||
error = CommErr.None;
|
||||
break;
|
||||
@ -1486,7 +1478,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
byte[] rdData = null;
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if ((0 == ReadRequestPort(ihead, MessageID.MetrologyMemory, Q2CorrFactorsAddr, 2, out rdData, cfg.CommTimeout)) &&
|
||||
if ((0 == ReadRequestPort(threadId, ihead, MessageID.MetrologyMemory, Q2CorrFactorsAddr, 2, out rdData, cfg.CommTimeout)) &&
|
||||
(rdData != null) && (rdData.Length == 2) && (rdData[0] == q2CorrRFlow) && (rdData[1] == q2CorrLFlow))
|
||||
{
|
||||
error = CommErr.None;
|
||||
@ -1532,7 +1524,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
}
|
||||
#endif
|
||||
|
||||
ClosePort(ihead); /// Close RFID port
|
||||
ClosePort(threadId, ihead); /// Close RFID port
|
||||
|
||||
return error;
|
||||
}
|
||||
@ -1544,7 +1536,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
/// <param name="ihead">Water meter object</param>
|
||||
/// <param name="resultStr">String passed to caller</param>
|
||||
/// <returns>true on success</returns>
|
||||
static CommErr Write2HzCorrection(IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
|
||||
static CommErr Write2HzCorrection(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr)
|
||||
{
|
||||
if (ihead.CommFailed) return CommErr.CommFailed;
|
||||
|
||||
@ -1559,7 +1551,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
return CommErr.None;
|
||||
}
|
||||
|
||||
if (OpenPort(ihead) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
if (OpenPort(threadId, ihead) != 0) return CommErr.OpenPort; /// Open RFID port
|
||||
|
||||
CommErr error = CommErr.Write;
|
||||
|
||||
@ -1568,7 +1560,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
///
|
||||
for (int j = 0; j < cfg.MaxCommRetries; j++)
|
||||
{
|
||||
if (0 == WriteRequestPort(ihead, MessageID.MetrologyMemory, Hz2CorrFactorsAddr, wrData.Length, wrData, cfg.CommTimeout))
|
||||
if (0 == WriteRequestPort(threadId, ihead, MessageID.MetrologyMemory, Hz2CorrFactorsAddr, wrData.Length, wrData, cfg.CommTimeout))
|
||||
{
|
||||
error = CommErr.None;
|
||||
ihead.Hz2Correction = hz2CorrectionFactor;
|
||||
@ -1633,7 +1625,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
}
|
||||
#endif
|
||||
|
||||
ClosePort(ihead); /// Close RFID port
|
||||
ClosePort(threadId, ihead); /// Close RFID port
|
||||
|
||||
return error;
|
||||
}
|
||||
@ -1661,7 +1653,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||
|
||||
lock (this)
|
||||
{
|
||||
if (++completedCommCount < rfidPortNrs.Count) return;
|
||||
if (++completedCommCount < muxBrdOrGroup14Nrs.Count) return;
|
||||
completedCommCount = 0;
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
readonly IperlHeadCfg iperlHeadCfg;
|
||||
|
||||
public int RfidComPortNr { get { return iperlHeadCfg.RfidComPortNr; } }
|
||||
public int MuxBoardNr { get { return iperlHeadCfg.MuxBoardNr; } }
|
||||
public int MuxBoardNrOrGroup14 { get { return iperlHeadCfg.MuxBoardNr; } }
|
||||
public int Group { get { return iperlHeadCfg.Group; } }
|
||||
|
||||
public double PulsesPerLtr { get { return 1000.0; } }
|
||||
|
||||
@ -29,7 +29,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
public int OptoComPortNr;
|
||||
public int RfidComPortNr; /// 0 = use MuxBoardNr
|
||||
public int MuxBoardNr; /// 0 = use RfidComPort(Nr), otherwise mux. board nr. 1 .. 4
|
||||
public int Group; /// Number written to QuidoRS to connct the watermeter to RfidComPort
|
||||
public int Group; /// Number written to QuidoRS to connct the watermeter to RfidComPort, 1 .. 10
|
||||
|
||||
/// <summary> Procedure parameters </summary>
|
||||
[XmlIgnore]
|
||||
@ -65,12 +65,12 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("Name={0}, Opto=COM{1}, RFID=COM{2}, MuxBoard#={3}, Group={4}",
|
||||
Name,
|
||||
OptoComPortNr,
|
||||
RfidComPortNr,
|
||||
return string.Format("{0} Group1 (mux#)={1}, Group2={2}, Opto=Com{3}, RFID=Com{4}",
|
||||
Name,
|
||||
MuxBoardNr,
|
||||
Group);
|
||||
Group,
|
||||
OptoComPortNr,
|
||||
RfidComPortNr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
{
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.None;
|
||||
|
||||
int dummy, dummy2;
|
||||
int dummy;
|
||||
if (radioButton1.Checked)
|
||||
{
|
||||
IPAddress dummyIPAddress;
|
||||
@ -106,26 +106,17 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'RFID serial port nr.' is not valid";
|
||||
}
|
||||
if (!int.TryParse(muxBoardNrTextBox.Text, out dummy2) || dummy2 < 0 || dummy2 > 4)
|
||||
|
||||
if (!int.TryParse(muxBoardNrTextBox.Text, out dummy) || dummy < 1 || dummy > 4)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Mux. board nr.' is not valid";
|
||||
message += Environment.NewLine + string.Format(Strings.Invalid_0, muxBoardNrLabel.Text);
|
||||
}
|
||||
if (dummy == 0 && dummy2 == 0)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Either 'RFID serial port nr.' or 'Mux. board nr.' should be nonzero";
|
||||
}
|
||||
if (dummy != 0 && dummy2 != 0)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Either 'RFID serial port nr.' or 'Mux. board nr.' should be zero";
|
||||
}
|
||||
|
||||
if (!int.TryParse(groupTextBox.Text, out dummy) || dummy < 1 || dummy > 10)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Group' is not valid";
|
||||
message += Environment.NewLine + string.Format(Strings.Invalid_0, groupLabel.Text);
|
||||
}
|
||||
|
||||
return flags;
|
||||
|
||||
@ -49,13 +49,17 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
this.tcpipPortTextBox = new System.Windows.Forms.TextBox();
|
||||
this.ipAddressLabel = new System.Windows.Forms.Label();
|
||||
this.ipAddressTextBox = new System.Windows.Forms.TextBox();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.optoDataGroupBox.SuspendLayout();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// nameTextBox
|
||||
//
|
||||
this.nameTextBox.Enabled = false;
|
||||
this.nameTextBox.Location = new System.Drawing.Point(135, 39);
|
||||
this.nameTextBox.Location = new System.Drawing.Point(135, 40);
|
||||
this.nameTextBox.Name = "nameTextBox";
|
||||
this.nameTextBox.Size = new System.Drawing.Size(121, 20);
|
||||
this.nameTextBox.TabIndex = 2;
|
||||
@ -63,7 +67,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
// nameLabel
|
||||
//
|
||||
this.nameLabel.AutoSize = true;
|
||||
this.nameLabel.Location = new System.Drawing.Point(25, 42);
|
||||
this.nameLabel.Location = new System.Drawing.Point(25, 43);
|
||||
this.nameLabel.Name = "nameLabel";
|
||||
this.nameLabel.Size = new System.Drawing.Size(35, 13);
|
||||
this.nameLabel.TabIndex = 1;
|
||||
@ -72,7 +76,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
// classNameLabel
|
||||
//
|
||||
this.classNameLabel.AutoSize = true;
|
||||
this.classNameLabel.Location = new System.Drawing.Point(132, 18);
|
||||
this.classNameLabel.Location = new System.Drawing.Point(132, 16);
|
||||
this.classNameLabel.Name = "classNameLabel";
|
||||
this.classNameLabel.Size = new System.Drawing.Size(60, 13);
|
||||
this.classNameLabel.TabIndex = 0;
|
||||
@ -98,7 +102,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
// muxBoardNrTextBox
|
||||
//
|
||||
this.muxBoardNrTextBox.Enabled = false;
|
||||
this.muxBoardNrTextBox.Location = new System.Drawing.Point(135, 207);
|
||||
this.muxBoardNrTextBox.Location = new System.Drawing.Point(135, 63);
|
||||
this.muxBoardNrTextBox.Name = "muxBoardNrTextBox";
|
||||
this.muxBoardNrTextBox.Size = new System.Drawing.Size(34, 20);
|
||||
this.muxBoardNrTextBox.TabIndex = 9;
|
||||
@ -106,16 +110,16 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
// muxBoardNrLabel
|
||||
//
|
||||
this.muxBoardNrLabel.AutoSize = true;
|
||||
this.muxBoardNrLabel.Location = new System.Drawing.Point(25, 210);
|
||||
this.muxBoardNrLabel.Location = new System.Drawing.Point(25, 66);
|
||||
this.muxBoardNrLabel.Name = "muxBoardNrLabel";
|
||||
this.muxBoardNrLabel.Size = new System.Drawing.Size(78, 13);
|
||||
this.muxBoardNrLabel.Size = new System.Drawing.Size(106, 13);
|
||||
this.muxBoardNrLabel.TabIndex = 8;
|
||||
this.muxBoardNrLabel.Text = "Mux. board nr.:";
|
||||
this.muxBoardNrLabel.Text = "Group 1 (mux. board)";
|
||||
//
|
||||
// groupTextBox
|
||||
//
|
||||
this.groupTextBox.Enabled = false;
|
||||
this.groupTextBox.Location = new System.Drawing.Point(135, 230);
|
||||
this.groupTextBox.Location = new System.Drawing.Point(135, 86);
|
||||
this.groupTextBox.Name = "groupTextBox";
|
||||
this.groupTextBox.Size = new System.Drawing.Size(34, 20);
|
||||
this.groupTextBox.TabIndex = 11;
|
||||
@ -123,16 +127,16 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
// groupLabel
|
||||
//
|
||||
this.groupLabel.AutoSize = true;
|
||||
this.groupLabel.Location = new System.Drawing.Point(25, 233);
|
||||
this.groupLabel.Location = new System.Drawing.Point(25, 89);
|
||||
this.groupLabel.Name = "groupLabel";
|
||||
this.groupLabel.Size = new System.Drawing.Size(39, 13);
|
||||
this.groupLabel.Size = new System.Drawing.Size(45, 13);
|
||||
this.groupLabel.TabIndex = 10;
|
||||
this.groupLabel.Text = "Group:";
|
||||
this.groupLabel.Text = "Group 2";
|
||||
//
|
||||
// rfidPortNrTextBox
|
||||
//
|
||||
this.rfidPortNrTextBox.Enabled = false;
|
||||
this.rfidPortNrTextBox.Location = new System.Drawing.Point(135, 184);
|
||||
this.rfidPortNrTextBox.Location = new System.Drawing.Point(329, 21);
|
||||
this.rfidPortNrTextBox.Name = "rfidPortNrTextBox";
|
||||
this.rfidPortNrTextBox.Size = new System.Drawing.Size(34, 20);
|
||||
this.rfidPortNrTextBox.TabIndex = 7;
|
||||
@ -140,11 +144,11 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
// rfidSerialPortNrLabel
|
||||
//
|
||||
this.rfidSerialPortNrLabel.AutoSize = true;
|
||||
this.rfidSerialPortNrLabel.Location = new System.Drawing.Point(25, 187);
|
||||
this.rfidSerialPortNrLabel.Location = new System.Drawing.Point(241, 24);
|
||||
this.rfidSerialPortNrLabel.Name = "rfidSerialPortNrLabel";
|
||||
this.rfidSerialPortNrLabel.Size = new System.Drawing.Size(98, 13);
|
||||
this.rfidSerialPortNrLabel.Size = new System.Drawing.Size(72, 13);
|
||||
this.rfidSerialPortNrLabel.TabIndex = 6;
|
||||
this.rfidSerialPortNrLabel.Text = "RFID serial port nr.:";
|
||||
this.rfidSerialPortNrLabel.Text = "Serial port nr.:";
|
||||
//
|
||||
// radioButton1
|
||||
//
|
||||
@ -180,9 +184,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
this.optoDataGroupBox.Controls.Add(this.radioButton2);
|
||||
this.optoDataGroupBox.Controls.Add(this.optoSerialPortLabel);
|
||||
this.optoDataGroupBox.Controls.Add(this.optoSerialPortTextBox);
|
||||
this.optoDataGroupBox.Location = new System.Drawing.Point(28, 67);
|
||||
this.optoDataGroupBox.Location = new System.Drawing.Point(28, 114);
|
||||
this.optoDataGroupBox.Name = "optoDataGroupBox";
|
||||
this.optoDataGroupBox.Size = new System.Drawing.Size(414, 101);
|
||||
this.optoDataGroupBox.Size = new System.Drawing.Size(414, 97);
|
||||
this.optoDataGroupBox.TabIndex = 5;
|
||||
this.optoDataGroupBox.TabStop = false;
|
||||
this.optoDataGroupBox.Text = "Opto-data";
|
||||
@ -221,13 +225,43 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
this.ipAddressTextBox.Size = new System.Drawing.Size(98, 20);
|
||||
this.ipAddressTextBox.TabIndex = 3;
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.rfidPortNrTextBox);
|
||||
this.groupBox1.Controls.Add(this.rfidSerialPortNrLabel);
|
||||
this.groupBox1.Location = new System.Drawing.Point(28, 218);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(414, 55);
|
||||
this.groupBox1.TabIndex = 12;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "RFID communication (in case mux. board is not used)";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(176, 66);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(31, 13);
|
||||
this.label3.TabIndex = 13;
|
||||
this.label3.Text = "1 .. 4";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(176, 89);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(37, 13);
|
||||
this.label4.TabIndex = 14;
|
||||
this.label4.Text = "1 .. 10";
|
||||
//
|
||||
// WaterMeterCfgCtrl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.label4);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.optoDataGroupBox);
|
||||
this.Controls.Add(this.rfidPortNrTextBox);
|
||||
this.Controls.Add(this.rfidSerialPortNrLabel);
|
||||
this.Controls.Add(this.groupTextBox);
|
||||
this.Controls.Add(this.groupLabel);
|
||||
this.Controls.Add(this.muxBoardNrTextBox);
|
||||
@ -240,6 +274,8 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
this.Load += new System.EventHandler(this.WaterMeterCfgCtrl_Load);
|
||||
this.optoDataGroupBox.ResumeLayout(false);
|
||||
this.optoDataGroupBox.PerformLayout();
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@ -265,5 +301,8 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
private System.Windows.Forms.TextBox tcpipPortTextBox;
|
||||
private System.Windows.Forms.Label ipAddressLabel;
|
||||
private System.Windows.Forms.TextBox ipAddressTextBox;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Label label4;
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("2.15.634.1")]
|
||||
[assembly: AssemblyFileVersion("2.15.634.1")]
|
||||
[assembly: AssemblyVersion("2.15.637.1")]
|
||||
[assembly: AssemblyFileVersion("2.15.637.1")]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user