iPerl and iPerlHead separated, iPerl removed (WaterMeter should be used instead).

This commit is contained in:
Milan Hanajik 2017-05-31 14:51:26 +02:00
parent 8a4ad1c2d4
commit 21016a1500
27 changed files with 587 additions and 802 deletions

View File

@ -226,45 +226,7 @@ namespace TBF.BenchControl.DataEntry.iPerl
{
foreach (var wm in batchResults.WaterMeters)
{
if (wm != null && !wm.Disabled)
{
wm.PurchaseOrder = PurchaseOrder;
if (Sequences.SequenceBase.WaterMeters != null &&
wm.WMPosition > 0 &&
wm.WMPosition <= Sequences.SequenceBase.WaterMeters.Count)
{
WaterMeters.iPerl.WaterMeter iPerl = Sequences.SequenceBase.WaterMeters[wm.WMPosition - 1] as WaterMeters.iPerl.WaterMeter;
if (iPerl != null)
{
#if IPERL
wm.OrigCalibFactor = iPerl.OriginalCalibFactor;
wm.CalibFactor = iPerl.CalibrationFactor;
wm.Q2ErrWOCorrection = iPerl.Q2ErrorWOCorrection;
wm.Q2CorrectionDone = iPerl.Q2CorrectionDone;
wm.Q2Correction = iPerl.Q2Correction;
wm.Q2CorrRFlow = iPerl.Q2CorrRFlow;
wm.Q2CorrLFlow = iPerl.Q2CorrLFlow;
wm.Diff2Hz8Hz = iPerl.Diff2Hz8Hz;
wm.Hz2CorrectionDone = iPerl.Hz2CorrectionDone;
wm.Hz2Correction = iPerl.Hz2CorrectionFactor;
if (iPerl.CalibrationStruct == null)
{
wm.Q2CorrFlowRight = 0;
}
else if (iPerl.CalibrationStruct.FlowArrow == WaterMeters.iPerl.FlowArrow.Left)
{
wm.Q2CorrFlowRight = iPerl.PositiveCounting ? 1 : 2;
}
else
{
wm.Q2CorrFlowRight = iPerl.PositiveCounting ? 2 : 1;
}
#endif
}
}
}
if (wm != null && !wm.Disabled) wm.PurchaseOrder = PurchaseOrder;
}
}
}

View File

@ -8,7 +8,7 @@ namespace TBF.BenchControl.Elde.FixedStartRegisterReader
{
public class RegisterReaderFactory : IComponentFactory
{
public string ClassName { get { return "Fixed-Start-Register-Reader"; } }
public string ClassName { get { return "RegisterReader for standing start/stop"; } }
public void ResetStaticProperties() { RegisterReader.ResetStaticProperties(); }

View File

@ -529,9 +529,9 @@ namespace TBF.BenchControl.Sequences
foreach (var rr in sensPath.RegisterReaders)
{
if ((rr is WaterMeters.iPerl.WaterMeter) && (BenchInfo != null))
if (rr is TestMethods.iPerlCommunication.iPerlHead.IperlHead && BenchInfo != null)
{
(rr as WaterMeters.iPerl.WaterMeter).BenchName = BenchInfo.TestBenchName;
(rr as TestMethods.iPerlCommunication.iPerlHead.IperlHead).BenchName = BenchInfo.TestBenchName;
}
}
@ -671,9 +671,9 @@ namespace TBF.BenchControl.Sequences
foreach (var rr in sensPath.RegisterReaders)
{
if ((rr is WaterMeters.iPerl.WaterMeter) && (BenchInfo != null))
if ((rr is TestMethods.iPerlCommunication.iPerlHead.IperlHead) && (BenchInfo != null))
{
(rr as WaterMeters.iPerl.WaterMeter).BenchName = BenchInfo.TestBenchName;
(rr as TestMethods.iPerlCommunication.iPerlHead.IperlHead).BenchName = BenchInfo.TestBenchName;
}
}
@ -766,9 +766,9 @@ namespace TBF.BenchControl.Sequences
foreach (var rr in sensPath.RegisterReaders)
{
if ((rr is WaterMeters.iPerl.WaterMeter) && (BenchInfo != null))
if ((rr is TestMethods.iPerlCommunication.iPerlHead.IperlHead) && (BenchInfo != null))
{
(rr as WaterMeters.iPerl.WaterMeter).BenchName = BenchInfo.TestBenchName;
(rr as TestMethods.iPerlCommunication.iPerlHead.IperlHead).BenchName = BenchInfo.TestBenchName;
}
}

View File

@ -39,7 +39,6 @@ namespace TBF.BenchControl
Factories.Add(new Dummy.RegulValve.Factory());
Factories.Add(new Dummy.Valve.Factory());
Factories.Add(new Elde.Diverter.DiverterFactory());
Factories.Add(new Elde.FixedStartRegisterReader.RegisterReaderFactory());
Factories.Add(new Elde.FlowMeter.FlowMeterFactory());
Factories.Add(new Elde.FlowMeterTwins.FlowMeterFactory());
Factories.Add(new TestMethods.Adjustment.Factory());
@ -66,7 +65,6 @@ namespace TBF.BenchControl
Factories.Add(new DataEntry.WMStates.EntryFormFactory());
Factories.Add(new Ambient.Comet.Factory());
Factories.Add(new Ambient.Greco.Factory());
Factories.Add(new WaterMeters.iPerl.WaterMeterFactory()); /// iPerl
Factories.Add(new Keithley.Multimeter_2010_RS232.Factory()); /// Keithley.Multimeter_2010_RS232
Factories.Add(new Keithley.TempMeter.Factory()); /// Keithley.TempMeter
Factories.Add(new ResultsPrinters.LabelPrinter.PrinterFactory()); /// LabelPrinter
@ -102,6 +100,8 @@ namespace TBF.BenchControl
Factories.Add(new Elde.PumpWithFM.PumpFactory());
Factories.Add(new Elde.PumpTandem.PumpFactory());
Factories.Add(new Elde.RegisterReader.Factory());
Factories.Add(new Elde.FixedStartRegisterReader.RegisterReaderFactory());
Factories.Add(new TestMethods.iPerlCommunication.iPerlHead.Factory()); /// iPerl head
Factories.Add(new Elde.RegulValve.RegulValveFactory());
Factories.Add(new Elde.RegulValveTandem.RegulValveTandemFactory());
Factories.Add(new ResultsPrinters.Cevak.PrinterFactory());

View File

@ -57,14 +57,14 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
for (int i = 0; i < Config.Data.WMsCount; i++)
{
WaterMeters.iPerl.WaterMeter iPerl = ((sensPath.RegisterReaders != null) && (i < sensPath.RegisterReaders.Length))
? (sensPath.RegisterReaders[i] as WaterMeters.iPerl.WaterMeter)
: null;
TestMethods.iPerlCommunication.iPerlHead.IperlHead iPerl = ((sensPath.RegisterReaders != null) && (i < sensPath.RegisterReaders.Length))
? (sensPath.RegisterReaders[i] as TestMethods.iPerlCommunication.iPerlHead.IperlHead)
: null;
if (iPerl != null)
{
/// TODO: Reimplement
//iPerl.LastTestResult = meterRslt; /// Save this water meter test result to iPerl WM
iPerl.NominalTestFlow = 500.0 * (double)(test.Qfrom + test.Qto); /// Ave. + convert to liter/hour
iPerl.NominalTestFlowLph = 500.0 * (double)(test.Qfrom + test.Qto); /// Ave. + convert to liter/hour
}
}

View File

@ -219,8 +219,11 @@ namespace TBF.BenchControl.TestMethods.Endurance
foreach (var rr in sensPath.RegisterReaders)
{
if (rr is WaterMeters.iPerl.WaterMeter) (rr as WaterMeters.iPerl.WaterMeter).TestName = test.Name;
}
if (rr is TestMethods.iPerlCommunication.iPerlHead.IperlHead)
{
(rr as TestMethods.iPerlCommunication.iPerlHead.IperlHead).TestName = test.Name;
}
}
/// Measurement loop - preparation
@ -336,7 +339,7 @@ namespace TBF.BenchControl.TestMethods.Endurance
Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single);
GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[i];
WaterMeters.iPerl.WaterMeter iPerl = regReader as WaterMeters.iPerl.WaterMeter;
TestMethods.iPerlCommunication.iPerlHead.IperlHead iPerl = regReader as TestMethods.iPerlCommunication.iPerlHead.IperlHead;
if (meterRslt != null && regReader != null)
{
@ -354,9 +357,6 @@ namespace TBF.BenchControl.TestMethods.Endurance
meterRslt.VolumeMeter = Math.Abs(iPerl.VolumeLtrEnd - iPerl.VolumeLtrStart);
meterRslt.VolumeRef = tstRslt.VolumeCTV * meterRslt.TestTime / tstRslt.TestTime;
iPerl.VolumeLtrRef = meterRslt.VolumeRef;
iPerl.LastTestResult2 = iPerl.LastTestResult; /// Save shift previous test result
iPerl.LastTestResult = meterRslt; /// Save this test result
iPerl.NominalTestFlow = 500.0 * (test.Qfrom + test.Qto); /// Ave. + convert to liter/hour
}
else
{
@ -371,7 +371,14 @@ namespace TBF.BenchControl.TestMethods.Endurance
meterRslt.Passed = (meterRslt.Error >= test.ErrLimLo + test.Uncertainty)
&& (meterRslt.Error <= test.ErrLimHi - test.Uncertainty);
meterRslt.TestDone = true;
}
if (iPerl != null)
{
iPerl.LastTestResult2 = iPerl.LastTestResult; /// Save shift previous test result
iPerl.LastTestResult = meterRslt; /// Save this test result
iPerl.NominalTestFlowLph = 500.0 * (test.Qfrom + test.Qto); /// Ave. + convert to liter/hour
}
}
}
}

View File

@ -64,14 +64,14 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
for (int i = 0; i < Config.Data.WMsCount; i++)
{
WaterMeters.iPerl.WaterMeter iPerl = ((sensPath.RegisterReaders != null) && (i < sensPath.RegisterReaders.Length))
? (sensPath.RegisterReaders[i] as WaterMeters.iPerl.WaterMeter)
: null;
TestMethods.iPerlCommunication.iPerlHead.IperlHead iPerl = ((sensPath.RegisterReaders != null) && (i < sensPath.RegisterReaders.Length))
? (sensPath.RegisterReaders[i] as TestMethods.iPerlCommunication.iPerlHead.IperlHead)
: null;
if (iPerl != null)
{
/// TODO: Reimplement
//iPerl.LastTestResult = meterRslt; /// Save this water meter test result to iPerl WM
iPerl.NominalTestFlow = 500.0 * (double)(test.Qfrom + test.Qto); /// Ave. + convert to liter/hour
iPerl.NominalTestFlowLph = 500.0 * (double)(test.Qfrom + test.Qto); /// Ave. + convert to liter/hour
}
}
@ -312,8 +312,11 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
foreach (var rr in sensPath.RegisterReaders)
{
if (rr is WaterMeters.iPerl.WaterMeter) (rr as WaterMeters.iPerl.WaterMeter).TestName = test.Name;
}
if (rr is TestMethods.iPerlCommunication.iPerlHead.IperlHead)
{
(rr as TestMethods.iPerlCommunication.iPerlHead.IperlHead).TestName = test.Name;
}
}
/// Measurement loop - preparation
@ -522,7 +525,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single);
GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[i];
WaterMeters.iPerl.WaterMeter iPerl = regReader as WaterMeters.iPerl.WaterMeter;
TestMethods.iPerlCommunication.iPerlHead.IperlHead iPerl = regReader as TestMethods.iPerlCommunication.iPerlHead.IperlHead;
GenericDevices.IRoi cameraRoi = regReader as GenericDevices.IRoi;
if (meterRslt != null && regReader != null)
@ -541,15 +544,6 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
meterRslt.VolumeMeter = Math.Abs(iPerl.VolumeLtrEnd - iPerl.VolumeLtrStart);
meterRslt.VolumeRef = tstRslt.VolumeCTV * meterRslt.TestTime / tstRslt.TestTime;
iPerl.VolumeLtrRef = meterRslt.VolumeRef;
#if IPERL
meterRslt.WaterMeter.CalibFactor = (iPerl.CalibrationStruct != null) ? iPerl.CalibrationStruct.Calibration : 0;
meterRslt.WaterMeter.Q2Correction = iPerl.Q2Correction;
meterRslt.WaterMeter.Q2CorrRFlow = iPerl.Q2CorrRFlow;
meterRslt.WaterMeter.Q2CorrLFlow = iPerl.Q2CorrLFlow;
#endif
iPerl.LastTestResult2 = iPerl.LastTestResult; /// Save shift previous test result
iPerl.LastTestResult = meterRslt; /// Save this test result
iPerl.NominalTestFlow = 500.0 * (test.Qfrom + test.Qto); /// Ave. + convert to liter/hour
}
else if (cameraRoi != null)
{
@ -576,6 +570,13 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
meterRslt.Passed = (meterRslt.Error >= test.ErrLimLo + test.Uncertainty)
&& (meterRslt.Error <= test.ErrLimHi - test.Uncertainty);
meterRslt.TestDone = true;
if (iPerl != null)
{
iPerl.LastTestResult2 = iPerl.LastTestResult; /// Save shift previous test result
iPerl.LastTestResult = meterRslt; /// Save this test result
iPerl.NominalTestFlowLph = 500.0 * (test.Qfrom + test.Qto); /// Ave. + convert to liter/hour
}
}
}
}

View File

@ -67,14 +67,14 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
for (int i = 0; i < Config.Data.WMsCount; i++)
{
WaterMeters.iPerl.WaterMeter iPerl = ((sensPath.RegisterReaders != null) && (i < sensPath.RegisterReaders.Length))
? (sensPath.RegisterReaders[i] as WaterMeters.iPerl.WaterMeter)
: null;
if (iPerl != null)
TestMethods.iPerlCommunication.iPerlHead.IperlHead iPerl = ((sensPath.RegisterReaders != null) && (i < sensPath.RegisterReaders.Length))
? (sensPath.RegisterReaders[i] as TestMethods.iPerlCommunication.iPerlHead.IperlHead)
: null;
if (iPerl != null)
{
/// TODO: Reimplement
//iPerl.LastTestResult = meterRslt; /// Save this water meter test result to iPerl WM
iPerl.NominalTestFlow = 500.0 * (double)(test.Qfrom + test.Qto); /// Ave. + convert to liter/hour
iPerl.NominalTestFlowLph = 500.0 * (double)(test.Qfrom + test.Qto); /// Ave. + convert to liter/hour
}
}
@ -531,8 +531,11 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
foreach (var rr in sensPath.RegisterReaders)
{
if (rr is WaterMeters.iPerl.WaterMeter) (rr as WaterMeters.iPerl.WaterMeter).TestName = test.Name;
}
if (rr is TestMethods.iPerlCommunication.iPerlHead.IperlHead)
{
(rr as TestMethods.iPerlCommunication.iPerlHead.IperlHead).TestName = test.Name;
}
}
/// Measurement loop - preparation
@ -868,7 +871,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
/// MetersKind.Single meters
Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single);
GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[i];
WaterMeters.iPerl.WaterMeter iPerl = regReader as WaterMeters.iPerl.WaterMeter;
TestMethods.iPerlCommunication.iPerlHead.IperlHead iPerl = regReader as TestMethods.iPerlCommunication.iPerlHead.IperlHead;
GenericDevices.IRoi cameraRoi = regReader as GenericDevices.IRoi;
if (meterRslt != null && regReader != null)
@ -887,15 +890,6 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
meterRslt.VolumeMeter = Math.Abs(iPerl.VolumeLtrEnd - iPerl.VolumeLtrStart);
meterRslt.VolumeRef = tstRslt.VolumeCTV * meterRslt.TestTime / tstRslt.TestTime;
iPerl.VolumeLtrRef = meterRslt.VolumeRef;
#if IPERL
meterRslt.WaterMeter.CalibFactor = (iPerl.CalibrationStruct != null) ? iPerl.CalibrationStruct.Calibration : 0;
meterRslt.WaterMeter.Q2Correction = iPerl.Q2Correction;
meterRslt.WaterMeter.Q2CorrRFlow = iPerl.Q2CorrRFlow;
meterRslt.WaterMeter.Q2CorrLFlow = iPerl.Q2CorrLFlow;
#endif
iPerl.LastTestResult2 = iPerl.LastTestResult; /// Save shift previous test result
iPerl.LastTestResult = meterRslt; /// Save this test result
iPerl.NominalTestFlow = 500.0 * (test.Qfrom + test.Qto); /// Ave. + convert to liter/hour
}
else if (cameraRoi != null)
{
@ -922,6 +916,13 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
meterRslt.Passed = (meterRslt.Error >= test.ErrLimLo + test.Uncertainty)
&& (meterRslt.Error <= test.ErrLimHi - test.Uncertainty);
meterRslt.TestDone = true;
if (iPerl != null)
{
iPerl.LastTestResult2 = iPerl.LastTestResult; /// Save shift previous test result
iPerl.LastTestResult = meterRslt; /// Save this test result
iPerl.NominalTestFlowLph = 500.0 * (test.Qfrom + test.Qto); /// Ave. + convert to liter/hour
}
}
}
}

View File

@ -16,7 +16,7 @@ using log4net;
using Config.Entities;
using TBF.Resources;
using TBF.BenchControl.Sequences;
using TBF.BenchControl.WaterMeters.iPerl;
using TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead;
namespace TBF.BenchControl.TestMethods.iPerlCommunication
{
@ -74,17 +74,17 @@ 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(WaterMeters.iPerl.WaterMeter wm)
public static unsafe int OpenPort(IperlHead iperlHead)
{
if (wm.DebugLevel != DebugMode.Normal) return 0; /// No function in debug mode
if (iperlHead.DebugLevel != DebugMode.Normal) return 0; /// No function in debug mode
if (wm.RfidComPortNr > 0)
if (iperlHead.RfidComPortNr > 0)
{
return openPort1(wm.RfidComPortNr);
return openPort1(iperlHead.RfidComPortNr);
}
else
{
switch (wm.MuxBoardNr)
switch (iperlHead.MuxBoardNr)
{
default:
case 1: return openPort1(cfg.RfidPortNrBoard1);
@ -101,17 +101,17 @@ 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 ClosePort(WaterMeters.iPerl.WaterMeter wm)
public static unsafe int ClosePort(IperlHead iperlHead)
{
if (wm.DebugLevel != DebugMode.Normal) return 0; /// No function in debug mode
if (iperlHead.DebugLevel != DebugMode.Normal) return 0; /// No function in debug mode
if (wm.RfidComPortNr > 0)
if (iperlHead.RfidComPortNr > 0)
{
return closePort1();
}
else
{
switch (wm.MuxBoardNr)
switch (iperlHead.MuxBoardNr)
{
default:
case 1: return closePort1();
@ -126,11 +126,11 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
/// Wrapper function with safe interface and unsafe body
/// </summary>
/// <returns>Value returned by readRequestPort(...)</returns>
public static unsafe int ReadRequestPort(WaterMeters.iPerl.WaterMeter wm, MessageID messageID, int offset, int lenght, out byte[] buffer, int timeout)
public static unsafe int ReadRequestPort(IperlHead iperlHead, MessageID messageID, int offset, int lenght, out byte[] buffer, int timeout)
{
buffer = new byte[lenght];
if (wm.DebugLevel != DebugMode.Normal) return wm.Name.Equals("iPerl13") ? 2 : 0; /// Simulates an error on position 13
if (iperlHead.DebugLevel != DebugMode.Normal) return iperlHead.Name.Equals("iPerl13") ? 2 : 0; /// Simulates an error on position 13
byte[] buf = new byte[200];
@ -139,13 +139,13 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
{
int retv;
if (wm.RfidComPortNr > 0)
if (iperlHead.RfidComPortNr > 0)
{
retv = readRequestPort1(messageID, offset, lenght, pBuf, timeout);
}
else
{
switch (wm.MuxBoardNr)
switch (iperlHead.MuxBoardNr)
{
default:
case 1: retv = readRequestPort1(messageID, offset, lenght, pBuf, timeout); break;
@ -160,11 +160,11 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
///
/// Logging
///
string name = string.Format("{0}({1})", wm.Name, wm.SerialNr);
if ((messageID == MessageID.Configuration) && (offset == 0) && (lenght == WaterMeters.iPerl.ConfigStruct.Length))
rfidDataLogger.InfoFormat("{0}: ReadRequestPort({1},...) returned {2} {3}", name, messageID, retv, (retv != 0) ? "!" : WaterMeters.iPerl.ConfigStruct.FromByteArray(buffer).ToString());
else if ((messageID == MessageID.Calibration) && (offset == 0) && (lenght == WaterMeters.iPerl.CalibrationStruct.Length))
rfidDataLogger.InfoFormat("{0}: ReadRequestPort({1},...) returned {2} {3}", name, messageID, retv, (retv != 0) ? "!" : WaterMeters.iPerl.CalibrationStruct.FromByteArray(buffer).ToString());
string name = string.Format("{0}({1})", iperlHead.Name, iperlHead.SerialNr);
if ((messageID == MessageID.Configuration) && (offset == 0) && (lenght == ConfigStruct.Length))
rfidDataLogger.InfoFormat("{0}: ReadRequestPort({1},...) returned {2} {3}", name, messageID, retv, (retv != 0) ? "!" : ConfigStruct.FromByteArray(buffer).ToString());
else if ((messageID == MessageID.Calibration) && (offset == 0) && (lenght == CalibrationStruct.Length))
rfidDataLogger.InfoFormat("{0}: ReadRequestPort({1},...) returned {2} {3}", name, messageID, retv, (retv != 0) ? "!" : CalibrationStruct.FromByteArray(buffer).ToString());
else if ((messageID == MessageID.Calibration) && (offset == 2) && (lenght == 2))
rfidDataLogger.InfoFormat("{0}: ReadRequestPort({1},2,2,...) returned {2} {3}", name, messageID, retv, (retv != 0) ? "!" : string.Format("Cal={0}", buf[0] + 256 * buf[1]));
else
@ -178,21 +178,21 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
/// Wrapper function with safe interface adn unsafe body
/// </summary>
/// <returns>Value returned by writeRequestPort(...)</returns>
public static unsafe int WriteRequestPort(WaterMeters.iPerl.WaterMeter wm, MessageID messageID, int offset, int lenght, byte[] buffer, int timeout)
public static unsafe int WriteRequestPort(IperlHead iperlHead, MessageID messageID, int offset, int lenght, byte[] buffer, int timeout)
{
if (wm.DebugLevel != DebugMode.Normal) return 0;
if (iperlHead.DebugLevel != DebugMode.Normal) return 0;
fixed (byte* pBuf = buffer)
{
int retv;
if (wm.RfidComPortNr > 0)
if (iperlHead.RfidComPortNr > 0)
{
retv = writeRequestPort1(messageID, offset, lenght, pBuf, timeout);
}
else
{
switch (wm.MuxBoardNr)
switch (iperlHead.MuxBoardNr)
{
default:
case 1: retv = writeRequestPort1(messageID, offset, lenght, pBuf, timeout); break;
@ -207,7 +207,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
///
/// Logging
///
string name = string.Format("{0}({1})", wm.Name, wm.SerialNr);
string name = string.Format("{0}({1})", iperlHead.Name, iperlHead.SerialNr);
if (lenght == 1)
rfidDataLogger.InfoFormat("{0}: WriteRequestPort({2}, {3}, {4}, {5}) returned {1} {6}", name, retv, messageID, offset, lenght, pBuf[0].ToString("X2"), (retv != 0) ? "!" : "");
else if (lenght == 2)
@ -260,7 +260,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
PictureBox[] counters;
TextBox[] messages;
static IList<WaterMeters.iPerl.WaterMeter> waterMeters;
static IList<IperlHead> iperlHeads;
static IList<int> waterMeterPositions; /// keeps original indices in RegisterReaders list
Modbus.QuidoRS.QuidoRS quido;
@ -331,7 +331,11 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
wmTextBox46, wmTextBox47, wmTextBox48,
};
formCompleted = false;
/// Initialize lists
iperlHeads = new List<IperlHead>();
waterMeterPositions = new List<int>();
formCompleted = false;
startTime = DateTime.Now;
startTimeSec = StateMachine.Time;
@ -412,21 +416,18 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
void ConstructorCommon()
{
waterMeters = new List<WaterMeters.iPerl.WaterMeter>();
waterMeterPositions = new List<int>();
///
for (int wmPos = 0; wmPos < ProcessData.RegisterReaders.Length; wmPos++)
{
WaterMeters.iPerl.WaterMeter iPerl = ProcessData.RegisterReaders[wmPos] as WaterMeters.iPerl.WaterMeter;
IperlHead iperlHead = ProcessData.RegisterReaders[wmPos] as IperlHead;
if (iPerl != null)
if (iperlHead != null)
{
waterMeters.Add(iPerl);
iperlHeads.Add(iperlHead);
waterMeterPositions.Add(wmPos);
}
}
WaterMetersCount = waterMeters.Count;
WaterMetersCount = iperlHeads.Count;
ShuffleTextBoxes(WaterMetersCount, Config.Data.LineSize);
@ -442,7 +443,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
completedCommCount = 0;
stopWorkerThreads = false;
foreach (var iPerl in iPerlCommunicationForm.waterMeters)
foreach (var iPerl in iPerlCommunicationForm.iperlHeads)
{
if (!rfidPortNrs.Contains(iPerl.MuxBoardNr))
{
@ -510,9 +511,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
void Localize()
{
Text = Strings.Water_Meter_States;
for (int i = 0; i < Math.Min(textBoxesCount, waterMeters.Count); i++)
for (int i = 0; i < Math.Min(textBoxesCount, iperlHeads.Count); i++)
{
labels[i].Text = waterMeters[i].Name;
labels[i].Text = iperlHeads[i].Name;
}
}
@ -541,9 +542,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
Top = (ls.iPerlCommunicationsFormTop != 0) ? ls.iPerlCommunicationsFormTop : 150;
/// Reset opto-data indication
for (int i = 0; i < waterMeters.Count; i++)
for (int i = 0; i < iperlHeads.Count; i++)
{
waterMeters[i].FlushedDataCount = 0;
iperlHeads[i].FlushedDataCount = 0;
counters[i].BackColor = Color.Red;
}
@ -661,26 +662,29 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
int wmNr = 0;
bool wmFound = false;
foreach (var wm in waterMeters)
for (int j = 0; j < iperlHeads.Count; j++)
{
if ((wm.MuxBoardNr == rfidPortNr) && (wm.Group == group))
IperlHead ihead = iperlHeads[j];
if ((ihead.MuxBoardNr == rfidPortNr) && (ihead.Group == group))
{
wmFound = true;
WaterMeters.WaterMeter.WaterMeter wm = SequenceBase.WaterMeters[waterMeterPositions[j]] as WaterMeters.WaterMeter.WaterMeter; /// WaterMeters.WaterMeter.WaterMeter implements iPerl specific variables
CommErr error;
string resultStr = string.Empty;
if (activity.ToLower().Contains(ReadConfigurationStr.ToLower())) error = ReadConfiguration(wm, ref resultStr);
else if (activity.ToLower().Contains(SetTestModeStr.ToLower())) error = SetTestMode(wm, ref resultStr);
else if (activity.ToLower().Equals(SetActiveModeStr.ToLower())) error = SetActiveMode(wm, ref resultStr);
else if (activity.ToLower().Equals(ReadCalibrationStr.ToLower())) error = ReadCalibration(wm, ref resultStr);
else if (activity.ToLower().Contains(WriteCalibrationFactorStr.ToLower())) error = WriteCalibrationFactor(wm, ref resultStr);
else if (activity.ToLower().Equals(NormalizeCalibrationFactorStr.ToLower())) error = NormalizeCalibrationFactor(wm, ref resultStr);
else if (activity.ToLower().Equals(ResetQ2CorrectionStr.ToLower())) error = ResetQ2Correction(wm, ref resultStr);
else if (activity.ToLower().Equals(WriteQ2CorrectionStr.ToLower())) error = WriteQ2Correction(wm, ref resultStr, false); /// standard iPerl
else if (activity.ToLower().Equals(WriteQ2CorrectionAltStr.ToLower())) error = WriteQ2Correction(wm, ref resultStr, true); /// DEWA iPerl
else if (activity.ToLower().Equals(Reset2HzCorrectionStr.ToLower())) error = Reset2HzCorrection(wm, ref resultStr);
else if (activity.ToLower().Equals(Write2HzCorrectionStr.ToLower())) error = Write2HzCorrection(wm, ref resultStr);
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);
else if (activity.ToLower().Equals(WriteQ2CorrectionStr.ToLower())) error = WriteQ2Correction(ihead, wm, ref resultStr, false); /// standard iPerl
else if (activity.ToLower().Equals(WriteQ2CorrectionAltStr.ToLower())) error = WriteQ2Correction(ihead, wm, ref resultStr, true); /// DEWA iPerl
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
{
error = CommErr.None;
@ -692,20 +696,20 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
{
OnCommCompleted(null, new CommCompletedEventArgs(threadId, wmNr, resultStr));
}
else if (wm.CommFailed || error == CommErr.CommFailed)
else if (ihead.CommFailed || error == CommErr.CommFailed)
{
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, wm.MuxBoardNr, activity, error);
wm.CommFailed = true;
rfidDataLogger.ErrorFormat("Group={0}, Board={1}, {2} failed ({3}) !!!", currentGroup, ihead.MuxBoardNr, activity, error);
ihead.CommFailed = true;
}
break;
}
wmNr++;
TBF.UiBridge.Bridge.OnTestProgress(null, new TBF.UiBridge.TestProgressEventArgs(tests[i], Config.Entities.Progress.FlowSetting));
TBF.UiBridge.Bridge.OnTestProgress(null, new TBF.UiBridge.TestProgressEventArgs(tests[i], Config.Entities.Progress.FlowSetting));
}
if (!wmFound)
@ -730,10 +734,10 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
/// <summary>
/// Read a complete configuration structure of the watermeter
/// </summary>
/// <param name="wm">Water meter object</param>
/// <param name="ihead">Water meter object</param>
/// <param name="resultStr">String passed to caller</param>
/// <returns>true on success</returns>
static CommErr ReadConfiguration(WaterMeters.iPerl.WaterMeter wm, ref string resultStr)
static CommErr ReadConfiguration(IperlHead ihead, WaterMeters.WaterMeter.WaterMeter wm, ref string resultStr)
{
///
/// The activity is "Read configuration" (this enables the watermeter, resets error flag)
@ -741,12 +745,12 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
///
if (!multiTestParams[currentActivityStep].Activity.ToLower().Contains(" if enabled"))
{
wm.CommFailed = false;
ihead.CommFailed = false;
}
if (wm.CommFailed) return CommErr.CommFailed;
if (ihead.CommFailed) return CommErr.CommFailed;
if (OpenPort(wm) != 0) return CommErr.OpenPort; /// Open RFID port
if (OpenPort(ihead) != 0) return CommErr.OpenPort; /// Open RFID port
CommErr error = CommErr.Read;
@ -754,16 +758,16 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
byte[] config = null;
for (int j = 0; j < cfg.MaxCommRetries; j++)
{
if (0 == ReadRequestPort(wm, MessageID.Configuration, 0, ConfigStruct.Length, out config, cfg.CommTimeout))
if (0 == ReadRequestPort(ihead, MessageID.Configuration, 0, ConfigStruct.Length, out config, cfg.CommTimeout))
{
error = CommErr.None;
wm.ConfigStruct = ConfigStruct.FromByteArray(config);
resultStr = wm.ConfigStruct.ToString(1);
ihead.ConfigStruct = ConfigStruct.FromByteArray(config);
resultStr = ihead.ConfigStruct.ToString(1);
break;
}
}
ClosePort(wm); /// Close RFID port
ClosePort(ihead); /// Close RFID port
return error;
}
@ -775,12 +779,12 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
/// whether the testModeConfig is correctly set, if necessary it is changed to the specified value.
/// Read a part of configuration afterwards to verify the mode was set correctly.
/// </summary>
/// <param name="wm">Water meter object</param>
/// <param name="ihead">Water meter object</param>
/// <param name="resultStr">String passed to caller</param>
/// <returns>true on success</returns>
static CommErr SetTestMode(WaterMeters.iPerl.WaterMeter wm, ref string resultStr)
static CommErr SetTestMode(IperlHead ihead, WaterMeters.WaterMeter.WaterMeter wm, ref string resultStr)
{
if (wm.CommFailed) return CommErr.CommFailed;
if (ihead.CommFailed) return CommErr.CommFailed;
Byte testModeConfig = 0xA0; /// Default value
///
@ -794,41 +798,41 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
}
}
if (wm.ConfigStruct.MeterState == MeterState.Test && wm.ConfigStruct.TestModeConfig == testModeConfig)
if (ihead.ConfigStruct.MeterState == MeterState.Test && ihead.ConfigStruct.TestModeConfig == testModeConfig)
{
/// Already in the correct test mode
resultStr = "Already " + wm.ConfigStruct.ToString(1);
resultStr = "Already " + ihead.ConfigStruct.ToString(1);
return CommErr.None;
}
/// Communication necessary
if (OpenPort(wm) != 0) return CommErr.OpenPort; /// Open RFID port
if (OpenPort(ihead) != 0) return CommErr.OpenPort; /// Open RFID port
CommErr error = CommErr.None;
if (error==CommErr.None && (wm.ConfigStruct.TestModeConfig != testModeConfig) && (wm.ConfigStruct.MeterState != MeterState.Active))
if (error==CommErr.None && (ihead.ConfigStruct.TestModeConfig != testModeConfig) && (ihead.ConfigStruct.MeterState != MeterState.Active))
{
/// Switch to Active mode in order to change TestModeConfig
error = CommErr.CmdActive;
byte[] cmd = new byte[1] { (byte)6 };
for (int j = 0; j < cfg.MaxCommRetries; j++)
{
if (0 == WriteRequestPort(wm, MessageID.Command, 0, 1, cmd, cfg.CommTimeout)) { error = CommErr.None; break; }
if (0 == WriteRequestPort(ihead, MessageID.Command, 0, 1, cmd, cfg.CommTimeout)) { error = CommErr.None; break; }
}
Thread.Sleep(250);
}
if (error == CommErr.None && (wm.ConfigStruct.TestModeConfig != testModeConfig))
if (error == CommErr.None && (ihead.ConfigStruct.TestModeConfig != testModeConfig))
{
/// Change the TestModeConfig if necessary
error = CommErr.Write;
byte[] tstMdCfg = new byte[1] { testModeConfig };
for (int j = 0; j < cfg.MaxCommRetries; j++)
{
if (0 == WriteRequestPort(wm, MessageID.Configuration, 21, 1, tstMdCfg, cfg.CommTimeout))
if (0 == WriteRequestPort(ihead, MessageID.Configuration, 21, 1, tstMdCfg, cfg.CommTimeout))
{
wm.ConfigStruct.Update(21, tstMdCfg);
ihead.ConfigStruct.Update(21, tstMdCfg);
error = CommErr.None;
break;
}
@ -844,7 +848,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
byte[] cmd = new byte[1] { (byte)7 };
for (int j = 0; j < cfg.MaxCommRetries; j++)
{
if (0 == WriteRequestPort(wm, MessageID.Command, 0, 1, cmd, cfg.CommTimeout)) { error = CommErr.None; break; }
if (0 == WriteRequestPort(ihead, MessageID.Command, 0, 1, cmd, cfg.CommTimeout)) { error = CommErr.None; break; }
}
Thread.Sleep(250);
@ -858,20 +862,20 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
byte[] cfg_0_3 = null;
for (int j = 0; j < cfg.MaxCommRetries; j++)
{
if (0 == ReadRequestPort(wm, MessageID.Configuration, 0, 4, out cfg_0_3, cfg.CommTimeout))
if (0 == ReadRequestPort(ihead, MessageID.Configuration, 0, 4, out cfg_0_3, cfg.CommTimeout))
{
wm.ConfigStruct.Update(0, cfg_0_3);
if (wm.ConfigStruct.MeterState == MeterState.Test)
ihead.ConfigStruct.Update(0, cfg_0_3);
if (ihead.ConfigStruct.MeterState == MeterState.Test)
{
error = CommErr.None;
resultStr = wm.ConfigStruct.ToString(1);
resultStr = ihead.ConfigStruct.ToString(1);
break;
}
}
}
}
ClosePort(wm); /// Close RFID port
ClosePort(ihead); /// Close RFID port
return error;
}
@ -881,12 +885,12 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
/// Set the watermeter to the active mode.
/// Read a part of configuration afterwards to verify the mode was set correctly.
/// </summary>
/// <param name="wm">Water meter object</param>
/// <param name="ihead">Water meter object</param>
/// <param name="resultStr">String passed to caller</param>
/// <returns>true on success</returns>
static CommErr SetActiveMode(WaterMeters.iPerl.WaterMeter wm, ref string resultStr)
static CommErr SetActiveMode(IperlHead ihead, WaterMeters.WaterMeter.WaterMeter wm, ref string resultStr)
{
if (OpenPort(wm) != 0) return CommErr.OpenPort; /// Open RFID port
if (OpenPort(ihead) != 0) return CommErr.OpenPort; /// Open RFID port
CommErr error = CommErr.CmdActive;
@ -894,7 +898,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
byte[] cmd = new byte[1] { (byte)6 };
for (int j = 0; j < cfg.MaxCommRetries; j++)
{
if (0 == WriteRequestPort(wm, MessageID.Command, 0, 1, cmd, cfg.CommTimeout))
if (0 == WriteRequestPort(ihead, MessageID.Command, 0, 1, cmd, cfg.CommTimeout))
{
error = CommErr.None;
break;
@ -928,14 +932,14 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
#else
if (error == CommErr.None)
{
if (wm.ConfigStruct == null)
if (ihead.ConfigStruct == null)
resultStr = "OK (Config not available)";
else
resultStr = wm.ConfigStruct.ToString(1);
resultStr = ihead.ConfigStruct.ToString(1);
}
#endif
ClosePort(wm); /// Close RFID port
ClosePort(ihead); /// Close RFID port
return error;
}
@ -944,14 +948,14 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
/// <summary>
/// Read a complete calibration structure from the watermeter
/// </summary>
/// <param name="wm">Water meter object</param>
/// <param name="ihead">Water meter object</param>
/// <param name="resultStr">String passed to caller</param>
/// <returns>true on success</returns>
static CommErr ReadCalibration(WaterMeters.iPerl.WaterMeter wm, ref string resultStr)
static CommErr ReadCalibration(IperlHead ihead, WaterMeters.WaterMeter.WaterMeter wm, ref string resultStr)
{
if (wm.CommFailed) return CommErr.CommFailed;
if (ihead.CommFailed) return CommErr.CommFailed;
if (OpenPort(wm) != 0) return CommErr.OpenPort; /// Open RFID port
if (OpenPort(ihead) != 0) return CommErr.OpenPort; /// Open RFID port
CommErr error = CommErr.Read;
@ -959,16 +963,19 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
byte[] calib = null;
for (int j = 0; j < cfg.MaxCommRetries; j++)
{
if (0 == ReadRequestPort(wm, MessageID.Calibration, 0, CalibrationStruct.Length, out calib, cfg.CommTimeout))
if (0 == ReadRequestPort(ihead, MessageID.Calibration, 0, CalibrationStruct.Length, out calib, cfg.CommTimeout))
{
wm.CalibrationStruct = CalibrationStruct.FromByteArray(calib);
resultStr = wm.CalibrationStruct.ToString();
error = wm.VerifyIPerlType() ? CommErr.None : CommErr.WrongIPerlType;
ihead.CalibrationStruct = CalibrationStruct.FromByteArray(calib);
#if IPERL
if (wm != null && wm.OriginalCalibFactor == 0) wm.OriginalCalibFactor = ihead.CalibrationStruct.Calibration;
#endif
resultStr = ihead.CalibrationStruct.ToString();
error = ihead.VerifyIPerlType() ? CommErr.None : CommErr.WrongIPerlType;
break;
}
}
ClosePort(wm); /// Close RFID port
ClosePort(ihead); /// Close RFID port
return error;
}
@ -978,12 +985,12 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
/// Write the calculated calibration factor to the water meter.
/// Read a part of CalibrationStruct afterwards to verify factor was written correctly.
/// </summary>
/// <param name="wm">Water meter object</param>
/// <param name="ihead">Water meter object</param>
/// <param name="resultStr">String passed to caller</param>
/// <returns>true on success</returns>
static CommErr WriteCalibrationFactor(WaterMeters.iPerl.WaterMeter wm, ref string resultStr)
static CommErr WriteCalibrationFactor(IperlHead ihead, WaterMeters.WaterMeter.WaterMeter wm, ref string resultStr)
{
if (wm.CommFailed) return CommErr.CommFailed;
if (ihead.CommFailed) return CommErr.CommFailed;
///
/// Parse calibration factor (1 argument) or calibration factor limits (2 arguments)
@ -1002,7 +1009,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
UInt16.TryParse(arguments[0], out factorLimitLo) && factorLimitLo > 0 &&
UInt16.TryParse(arguments[1], out factorLimitHi) && factorLimitHi > 0)
{
newCalibFactor = wm.CalculateNewCalibFactor(wm.CalibrationFactor, factorLimitLo, factorLimitHi);
newCalibFactor = ihead.CalculateNewCalibFactor(ihead.CalibrationFactor, factorLimitLo, factorLimitHi);
}
else if (arguments.Length == 1 && UInt16.TryParse(arguments[0], out val) && val > 0)
{
@ -1010,12 +1017,12 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
}
else
{
newCalibFactor = wm.CalculateNewCalibFactor(wm.CalibrationFactor, wm.FactorLimitLo, wm.FactorLimitHi);
newCalibFactor = ihead.CalculateNewCalibFactor(ihead.CalibrationFactor, ihead.FactorLimitLo, ihead.FactorLimitHi);
}
}
else
{
newCalibFactor = wm.CalculateNewCalibFactor(wm.CalibrationFactor, wm.FactorLimitLo, wm.FactorLimitHi);
newCalibFactor = ihead.CalculateNewCalibFactor(ihead.CalibrationFactor, ihead.FactorLimitLo, ihead.FactorLimitHi);
}
if (newCalibFactor == 0) return CommErr.CalibFactorOoRange;
@ -1023,7 +1030,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
///
/// Start communication with iPerl
///
if (OpenPort(wm) != 0) return CommErr.OpenPort; /// Open RFID port
if (OpenPort(ihead) != 0) return CommErr.OpenPort; /// Open RFID port
CommErr error;
byte[] data = new byte[2] { (byte)(newCalibFactor & 0x00FF), (byte)((newCalibFactor >> 8) & 0x00FF) };
@ -1034,31 +1041,34 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
/// Write the new calibration factor (up to cfg.MaxCommRetries tims)
///
error = CommErr.Write;
if (0 == WriteRequestPort(wm, MessageID.Calibration, 2, 2, data, cfg.CommTimeout))
if (0 == WriteRequestPort(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(wm, MessageID.Calibration, 2, 2, out calib_2_3, cfg.CommTimeout))
if (0 == ReadRequestPort(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])
{
error = CommErr.None;
wm.CalibrationStruct.Update(data, 2);
resultStr = wm.CalibrationStruct.ToString();
ihead.CalibrationStruct.Update(data, 2);
#if IPERL
if (wm != null) wm.CalibFactor = newCalibFactor;
#endif
resultStr = ihead.CalibrationStruct.ToString();
break;
}
}
}
wm.CalibrationStruct.Update(data, 2);
ihead.CalibrationStruct.Update(data, 2);
}
while (++writeAndVerifyRetries <= cfg.MaxCommRetries);
ClosePort(wm); /// Close RFID port
ClosePort(ihead); /// Close RFID port
return error;
}
@ -1067,26 +1077,26 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
/// <summary>
/// Normalize calibration factor in case ti is close to value 8000.
/// </summary>
/// <param name="wm">Water meter object</param>
/// <param name="ihead">Water meter object</param>
/// <param name="resultStr">String passed to caller</param>
/// <returns>true on success</returns>
static CommErr NormalizeCalibrationFactor(WaterMeters.iPerl.WaterMeter wm, ref string resultStr)
static CommErr NormalizeCalibrationFactor(IperlHead ihead, WaterMeters.WaterMeter.WaterMeter wm, ref string resultStr)
{
if (wm.CommFailed) return CommErr.CommFailed;
if (ihead.CommFailed) return CommErr.CommFailed;
if (wm.CalibrationFactor <= 5000)
if (ihead.CalibrationFactor <= 5000)
{
resultStr = "Calibratin factor is OK";
return CommErr.None; /// No need to update the calibration factor
}
if (OpenPort(wm) != 0) return CommErr.OpenPort; /// Open RFID port
if (OpenPort(ihead) != 0) return CommErr.OpenPort; /// Open RFID port
CommErr error = CommErr.Write;
/// Determine the new calibration factor
UInt16 newCalibFactor = 0;
switch (wm.CalibrationStruct.MeterType)
switch (ihead.CalibrationStruct.MeterType)
{
case MeterType.DN15: newCalibFactor = 2650; break;
case MeterType.DN20: newCalibFactor = 3746; break;
@ -1104,10 +1114,10 @@ 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(wm, MessageID.Calibration, 2, 2, data, cfg.CommTimeout))
if (0 == WriteRequestPort(ihead, MessageID.Calibration, 2, 2, data, cfg.CommTimeout))
{
error = CommErr.None;
wm.CalibrationStruct.Update(data, 2);
ihead.CalibrationStruct.Update(data, 2);
break;
}
}
@ -1120,17 +1130,17 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
byte[] calib_2_3 = null;
for (int j = 0; j < cfg.MaxCommRetries; j++)
{
if (0 == ReadRequestPort(wm, MessageID.Calibration, 2, 2, out calib_2_3, cfg.CommTimeout))
if (0 == ReadRequestPort(ihead, MessageID.Calibration, 2, 2, out calib_2_3, cfg.CommTimeout))
{
error = CommErr.None;
wm.CalibrationStruct.Update(calib_2_3, 2);
resultStr = wm.CalibrationStruct.ToString();
ihead.CalibrationStruct.Update(calib_2_3, 2);
resultStr = ihead.CalibrationStruct.ToString();
break;
}
}
}
ClosePort(wm); /// Close RFID port
ClosePort(ihead); /// Close RFID port
return error;
}
@ -1144,14 +1154,14 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
/// Reset both Q2 correction factors in the memory to 0.
/// Read them back to verify factors were written correctly.
/// </summary>
/// <param name="wm">Water meter object</param>
/// <param name="ihead">Water meter object</param>
/// <param name="resultStr">String passed to caller</param>
/// <returns>true on success</returns>
static CommErr ResetQ2Correction(WaterMeters.iPerl.WaterMeter wm, ref string resultStr)
static CommErr ResetQ2Correction(IperlHead ihead, WaterMeters.WaterMeter.WaterMeter wm, ref string resultStr)
{
if (wm.CommFailed) return CommErr.CommFailed;
if (ihead.CommFailed) return CommErr.CommFailed;
if (OpenPort(wm) != 0) return CommErr.OpenPort; /// Open RFID port
if (OpenPort(ihead) != 0) return CommErr.OpenPort; /// Open RFID port
CommErr error = CommErr.Write;
@ -1160,7 +1170,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
///
for (int j = 0; j < cfg.MaxCommRetries; j++)
{
if (0 == WriteRequestPort(wm, MessageID.MetrologyMemory, Q2CorrFactorsAddr, wrData.Length, wrData, cfg.CommTimeout))
if (0 == WriteRequestPort(ihead, MessageID.MetrologyMemory, Q2CorrFactorsAddr, wrData.Length, wrData, cfg.CommTimeout))
{
error = CommErr.None;
break;
@ -1194,11 +1204,11 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
if (error == CommErr.None)
{
resultStr = "Q2 corrections reset to 0";
wm.Q2CorrRFlow = 0;
ihead.Q2CorrRFlow = 0;
}
#endif
ClosePort(wm); /// Close RFID port
ClosePort(ihead); /// Close RFID port
return error;
}
@ -1207,14 +1217,14 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
/// <summary>
/// Reset 2Hz correction factor in the memory to 0.
/// </summary>
/// <param name="wm">Water meter object</param>
/// <param name="ihead">Water meter object</param>
/// <param name="resultStr">String passed to caller</param>
/// <returns>true on success</returns>
static CommErr Reset2HzCorrection(WaterMeters.iPerl.WaterMeter wm, ref string resultStr)
static CommErr Reset2HzCorrection(IperlHead ihead, WaterMeters.WaterMeter.WaterMeter wm, ref string resultStr)
{
if (wm.CommFailed) return CommErr.CommFailed;
if (ihead.CommFailed) return CommErr.CommFailed;
if (OpenPort(wm) != 0) return CommErr.OpenPort; /// Open RFID port
if (OpenPort(ihead) != 0) return CommErr.OpenPort; /// Open RFID port
CommErr error = CommErr.Write;
@ -1223,7 +1233,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
///
for (int j = 0; j < cfg.MaxCommRetries; j++)
{
if (0 == WriteRequestPort(wm, MessageID.MetrologyMemory, Hz2CorrFactorsAddr, wrData.Length, wrData, cfg.CommTimeout))
if (0 == WriteRequestPort(ihead, MessageID.MetrologyMemory, Hz2CorrFactorsAddr, wrData.Length, wrData, cfg.CommTimeout))
{
error = CommErr.None;
break;
@ -1257,11 +1267,11 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
if (error == CommErr.None)
{
resultStr = "2Hz correction reset to 0";
wm.Hz2CorrectionFactor = 0;
ihead.Hz2CorrectionFactor = 0;
}
#endif
ClosePort(wm); /// Close RFID port
ClosePort(ihead); /// Close RFID port
return error;
}
@ -1271,17 +1281,17 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
/// Write the calculated Q2 correction factors to the memory.
/// Read them back to verify factors were written correctly.
/// </summary>
/// <param name="wm">Water meter object</param>
/// <param name="ihead">Water meter object</param>
/// <param name="resultStr">String passed to caller</param>
/// <returns>true on success</returns>
static CommErr WriteQ2Correction(WaterMeters.iPerl.WaterMeter wm, ref string resultStr, bool DEWA)
static CommErr WriteQ2Correction(IperlHead ihead, WaterMeters.WaterMeter.WaterMeter wm, ref string resultStr, bool DEWA)
{
if (wm.CommFailed) return CommErr.CommFailed;
if (wm.LastTestResult == null) return CommErr.CommFailed; /// This should never happen
if (ihead.CommFailed) return CommErr.CommFailed;
if (ihead.LastTestResult == null) return CommErr.CommFailed; /// This should never happen
wm.Q2ErrorWOCorrection = wm.LastTestResult.Error;
wm.Q2CorrectionDone = false;
wm.Q2CorrRFlow = 0;
ihead.Q2ErrorWOCorrection = ihead.LastTestResult.Error;
ihead.Q2CorrectionDone = false;
ihead.Q2CorrRFlow = 0;
double q2Correction = 0;
Byte q2CorrRFlow = 0;
@ -1292,13 +1302,13 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
///
/// Standard process
///
if (Math.Abs(wm.LastTestResult.Error) <= 0.5)
if (Math.Abs(ihead.LastTestResult.Error) <= 0.5)
{
resultStr = string.Format("Q2 correction = 0 (writing bypassed)");
return CommErr.None;
}
if (!wm.CalculateQ2CorrectionFactor(wm.LastTestResult, out q2Correction))
if (!ihead.CalculateQ2CorrectionFactor(ihead.LastTestResult, out q2Correction))
{
return CommErr.None; /// Q2 error is too large, water meter failed anyhow
}
@ -1311,18 +1321,18 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
///
/// DEWA process
///
if (wm.LastTestResult.Error >= 0 && wm.LastTestResult.Error <= 1.0)
if (ihead.LastTestResult.Error >= 0 && ihead.LastTestResult.Error <= 1.0)
{
resultStr = string.Format("Q2 correction = 0 (writing bypassed)");
return CommErr.None;
}
if (!wm.CalculateQ2CorrectionFactor(wm.LastTestResult, out q2Correction))
if (!ihead.CalculateQ2CorrectionFactor(ihead.LastTestResult, out q2Correction))
{
return CommErr.None; /// Q2 error is too large, water meter failed anyhow
}
if (wm.LastTestResult.Error < 0)
if (ihead.LastTestResult.Error < 0)
{
q2CorrRFlow = (byte)((int)Math.Round(1.1 * q2Correction) & 0x000000FF);
q2CorrLFlow = (byte)((int)Math.Round(1.1 * q2Correction) & 0x000000FF);
@ -1334,7 +1344,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
}
}
if (OpenPort(wm) != 0) return CommErr.OpenPort; /// Open RFID port
if (OpenPort(ihead) != 0) return CommErr.OpenPort; /// Open RFID port
CommErr error = CommErr.Write;
@ -1342,7 +1352,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
///
for (int j = 0; j < cfg.MaxCommRetries; j++)
{
if (0 == WriteRequestPort(wm, MessageID.MetrologyMemory, Q2CorrFactorsAddr, wrData.Length, wrData, cfg.CommTimeout))
if (0 == WriteRequestPort(ihead, MessageID.MetrologyMemory, Q2CorrFactorsAddr, wrData.Length, wrData, cfg.CommTimeout))
{
error = CommErr.None;
break;
@ -1366,9 +1376,21 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
{
error = CommErr.None;
resultStr = string.Format("Q2 factors: R-flow={0}, L-flow={1}", (SByte)q2CorrRFlow, (SByte)q2CorrLFlow);
rfidDataLogger.Warn(wm.Name + ": " + resultStr);
wm.Q2CorrectionDone = true;
wm.Q2CorrectionFactor = q2CorrectionFactor;
rfidDataLogger.Warn(ihead.Name + ": " + resultStr);
ihead.Q2CorrectionDone = true;
ihead.Q2Correction = q2Correction;
ihead.Q2CorrRFlow = (int)(sbyte)q2CorrRFlow;
ihead.Q2CorrLFlow = (int)(sbyte)q2CorrLFlow;
#if IPERL
if (wm != null)
{
wm.Q2ErrorWOCorrection = ihead.Q2ErrorWOCorrection;
wm.Q2CorrectionDone = ihead.Q2CorrectionDone;
wm.Q2Correction = ihead.Q2Correction;
wm.Q2CorrRFlow = ihead.Q2CorrRFlow;
wm.Q2CorrLFlow = ihead.Q2CorrLFlow;
}
#endif
break;
}
}
@ -1377,15 +1399,25 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
if (error == CommErr.None)
{
resultStr = string.Format("Q2 correction: R-flow={0}, L-flow={1}", (SByte)q2CorrRFlow, (SByte)q2CorrLFlow);
rfidDataLogger.Warn(wm.Name + ": " + resultStr);
wm.Q2CorrectionDone = true;
wm.Q2Correction = q2Correction;
wm.Q2CorrRFlow = (int)(sbyte)q2CorrRFlow;
wm.Q2CorrLFlow = (int)(sbyte)q2CorrLFlow;
rfidDataLogger.Warn(ihead.Name + ": " + resultStr);
ihead.Q2CorrectionDone = true;
ihead.Q2Correction = q2Correction;
ihead.Q2CorrRFlow = (int)(sbyte)q2CorrRFlow;
ihead.Q2CorrLFlow = (int)(sbyte)q2CorrLFlow;
#if IPERL
if (wm != null)
{
wm.Q2ErrorWOCorrection = ihead.Q2ErrorWOCorrection;
wm.Q2CorrectionDone = ihead.Q2CorrectionDone;
wm.Q2Correction = ihead.Q2Correction;
wm.Q2CorrRFlow = ihead.Q2CorrRFlow;
wm.Q2CorrLFlow = ihead.Q2CorrLFlow;
}
#endif
}
#endif
ClosePort(wm); /// Close RFID port
ClosePort(ihead); /// Close RFID port
return error;
}
@ -1394,17 +1426,17 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
/// <summary>
/// Write the calculated 2Hz correction factor to the memory.
/// </summary>
/// <param name="wm">Water meter object</param>
/// <param name="ihead">Water meter object</param>
/// <param name="resultStr">String passed to caller</param>
/// <returns>true on success</returns>
static CommErr Write2HzCorrection(WaterMeters.iPerl.WaterMeter wm, ref string resultStr)
static CommErr Write2HzCorrection(IperlHead ihead, WaterMeters.WaterMeter.WaterMeter wm, ref string resultStr)
{
if (wm.CommFailed) return CommErr.CommFailed;
if (ihead.CommFailed) return CommErr.CommFailed;
/// Calculate the correction
wm.Hz2CorrectionDone = false;
ihead.Hz2CorrectionDone = false;
int hz2CorrectionFactor;
bool wmOK = wm.Calculate2HzCorrectionFactor(wm.LastTestResult2, wm.LastTestResult, out wm.Diff2Hz8Hz, out hz2CorrectionFactor);
bool wmOK = ihead.Calculate2HzCorrectionFactor(ihead.LastTestResult2, ihead.LastTestResult, out ihead.Diff2Hz8Hz, out hz2CorrectionFactor);
if (hz2CorrectionFactor == 0)
{
@ -1412,7 +1444,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
return CommErr.None;
}
if (OpenPort(wm) != 0) return CommErr.OpenPort; /// Open RFID port
if (OpenPort(ihead) != 0) return CommErr.OpenPort; /// Open RFID port
CommErr error = CommErr.Write;
@ -1421,9 +1453,18 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
///
for (int j = 0; j < cfg.MaxCommRetries; j++)
{
if (0 == WriteRequestPort(wm, MessageID.MetrologyMemory, Hz2CorrFactorsAddr, wrData.Length, wrData, cfg.CommTimeout))
if (0 == WriteRequestPort(ihead, MessageID.MetrologyMemory, Hz2CorrFactorsAddr, wrData.Length, wrData, cfg.CommTimeout))
{
error = CommErr.None;
ihead.Hz2CorrectionFactor = hz2CorrectionFactor;
ihead.Hz2CorrectionDone = true;
#if IPERL
if (wm != null)
{
wm.Hz2CorrectionDone = ihead.Hz2CorrectionDone;
wm.Hz2CorrectionFactor = ihead.Hz2CorrectionFactor;
}
#endif
break;
}
}
@ -1455,13 +1496,13 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
if (error == CommErr.None)
{
resultStr = string.Format("2Hz correction = {0}", (SByte)hz2CorrectionByte);
rfidDataLogger.Warn(wm.Name + ": " + resultStr);
wm.Hz2CorrectionDone = true;
wm.Hz2CorrectionFactor = hz2CorrectionFactor;
rfidDataLogger.Warn(ihead.Name + ": " + resultStr);
ihead.Hz2CorrectionDone = true;
ihead.Hz2CorrectionFactor = hz2CorrectionFactor;
}
#endif
ClosePort(wm); /// Close RFID port
ClosePort(ihead); /// Close RFID port
return error;
}
@ -1482,9 +1523,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
{
if (data.WMNr >= 0) messages[data.WMNr].Text = data.CommMessage;
for (int i = 0; i < waterMeters.Count; i++)
for (int i = 0; i < iperlHeads.Count; i++)
{
counters[i].BackColor = (waterMeters[i].FlushedDataDelta == 0) ? Color.Red : Color.Green;
counters[i].BackColor = (iperlHeads[i].FlushedDataDelta == 0) ? Color.Red : Color.Green;
}
lock (this)
@ -1567,21 +1608,19 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
tstRslt.EndTime = endTime;
tstRslt.FlowSetTime = 0;
tstRslt.TestTime += testTime; /// [s] total communication time of all tests
for (int i = 0; i < waterMeters.Count; i++)
{
Results.Entities.MeterTestRslt meterRslt =
for (int i = 0; i < iperlHeads.Count; i++)
{
Results.Entities.MeterTestRslt meterRslt =
ProcessData.BatchRslts.GetMeterTestRslt(test.Name, waterMeterPositions[i], Config.Entities.CompoundMeterId.Single);
WaterMeters.iPerl.WaterMeter iPerl = waterMeters[i] as WaterMeters.iPerl.WaterMeter;
if (meterRslt != null && iPerl != null)
{
meterRslt.WaterMeter.SerialNr = iPerl.SerialNr;
meterRslt.Passed = (!iPerl.CommFailed && !iPerl.Disabled);
meterRslt.TestDone = true;
}
}
if (meterRslt != null && iperlHeads[i] != null)
{
meterRslt.WaterMeter.SerialNr = iperlHeads[i].SerialNr;
meterRslt.Passed = (!iperlHeads[i].CommFailed && !iperlHeads[i].Disabled);
meterRslt.TestDone = true;
}
}
}
}
}

View File

@ -124,14 +124,14 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
for (int i = 0; i < Config.Data.WMsCount; i++)
{
WaterMeters.iPerl.WaterMeter iPerl = ((sensPath.RegisterReaders != null) && (i < sensPath.RegisterReaders.Length))
? (sensPath.RegisterReaders[i] as WaterMeters.iPerl.WaterMeter)
: null;
TestMethods.iPerlCommunication.iPerlHead.IperlHead iPerl = ((sensPath.RegisterReaders != null) && (i < sensPath.RegisterReaders.Length))
? (sensPath.RegisterReaders[i] as TestMethods.iPerlCommunication.iPerlHead.IperlHead)
: null;
if (iPerl != null)
{
/// TODO: Reimplement
//iPerl.LastTestResult = meterRslt; /// Save this water meter test result to iPerl WM
iPerl.NominalTestFlow = 500.0 * (double)(test.Qfrom + test.Qto); /// Ave. + convert to liter/hour
iPerl.NominalTestFlowLph = 500.0 * (double)(test.Qfrom + test.Qto); /// Ave. + convert to liter/hour
}
}
@ -293,9 +293,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
Results.Entities.MeterTestRslt meterRslt = ProcessData.BatchRslts.GetMeterTestRslt(testName, i, CompoundMeterId.Single);
/// Reference to iPerl water meter or null:
WaterMeters.iPerl.WaterMeter iPerl = ((sensPath.RegisterReaders != null) && (i < sensPath.RegisterReaders.Length))
? (sensPath.RegisterReaders[i] as WaterMeters.iPerl.WaterMeter)
: null;
TestMethods.iPerlCommunication.iPerlHead.IperlHead iPerl = ((sensPath.RegisterReaders != null) && (i < sensPath.RegisterReaders.Length))
? (sensPath.RegisterReaders[i] as TestMethods.iPerlCommunication.iPerlHead.IperlHead)
: null;
if (meterRslt != null && oriMeterRslt != null)
{

View File

@ -1,10 +1,9 @@
///
/// Copyright (c) 2015 Sensus Metering Systems
/// Author: Milan Hanajík
/// Copyright (c) 2015-2017 Sensus Metering Systems
///
using System;
namespace TBF.BenchControl.WaterMeters.iPerl
namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
{
public class CalibrationStruct
{

View File

@ -1,10 +1,9 @@
///
/// Copyright (c) 2015 Sensus Metering Systems
/// Author: Milan Hanajík
/// Copyright (c) 2015-2017 Sensus Metering Systems
///
using System;
namespace TBF.BenchControl.WaterMeters.iPerl
namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
{
public class ConfigStruct
{

View File

@ -1,13 +1,12 @@
///
/// Copyright (c) 2015 Sensus Metering Systems
/// Author: Milan Hanajík
/// Copyright (c) 2015-2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TBF.BenchControl.WaterMeters.iPerl
namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
{
public enum MessageID
{

View File

@ -0,0 +1,26 @@
///
/// Copyright (c) 2015-2017 Sensus Metering Systems
///
using System.Collections.Generic;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
{
public class Factory : IComponentFactory
{
public string ClassName { get { return "RegisterReader for iPerl/iPerl Head"; } }
public void ResetStaticProperties() { IperlHead.ResetStaticProperties(); }
public IComponent DummyComponent() { return new IperlHead(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new IperlHead(cfg); }
public IComponentCfg DefaultConfig() { return new IperlHeadCfg(this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(typeof(IperlHeadCfg), component, this);
}
}
}

View File

@ -1,6 +1,5 @@
///
/// Copyright (c) 2015-2017 Sensus Metering Systems
/// Author: Milan Hanajík
///
using System;
using System.Collections.Generic;
@ -14,68 +13,32 @@ using TBF.BenchControl;
using TBF.BenchControl.Generic;
using TBF.Resources;
namespace TBF.BenchControl.WaterMeters.iPerl
namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
{
/// <summary>
/// This component = instance of this class is a placeholder for a combined main watermeter
/// </summary>
public class WaterMeter : ComponentBase, IDevice, GenericDevices.IWaterMeter, GenericDevices.IRegisterReader, IOperation
public class IperlHead : ComponentBase, IDevice, GenericDevices.IRegisterReader, IOperation
{
private static readonly ILog log = LogManager.GetLogger(typeof(WaterMeter));
private static readonly ILog log = LogManager.GetLogger(typeof(IperlHead));
public override string ToString() { return string.Format("iPerl({0})", Cfg.ToString(1)); }
readonly WaterMeterCfg iPerlCfg;
readonly IperlHeadCfg iperlHeadCfg;
public int RfidComPortNr { get { return iPerlCfg.RfidComPortNr; } }
public int MuxBoardNr { get { return iPerlCfg.MuxBoardNr; } }
public int Group { get { return iPerlCfg.Group; } }
public int RfidComPortNr { get { return iperlHeadCfg.RfidComPortNr; } }
public int MuxBoardNr { get { return iperlHeadCfg.MuxBoardNr; } }
public int Group { get { return iperlHeadCfg.Group; } }
public double PulsesPerLtr { get { return (double)iPerlCfg.ProcParams.PulsesPerLtr; } }
public double LtrsPerPulse { get { return ltrsPerPulse; } }
readonly double ltrsPerPulse;
/// <summary>WaterMeter type (product name) and producer</summary>
public string ProductName { get { return iPerlCfg.ProcParams.ProductName; } }
public string Producer { get { return iPerlCfg.ProcParams.Producer; } }
/// <summary>Pipe diameter [mm]</summary>
public float DN { get { return iPerlCfg.ProcParams.DN; } }
/// <summary>Build lenght [mm]</summary>
public float L { get { return iPerlCfg.ProcParams.L; } }
public Mounting Mounting { get { return iPerlCfg.ProcParams.Mounting; } }
/// <summary>Nominal water flow in [m3/h]</summary>
public float Q4_Qmax { get { return iPerlCfg.ProcParams.Q4; } }
public float Q3_Qn { get { return iPerlCfg.ProcParams.Qn; } }
public float Q2_Qt { get { return iPerlCfg.ProcParams.Q2; } }
public float Q1_Qmin { get { return iPerlCfg.ProcParams.Q1; } }
/// <summary>Metrological class, etc</summary>
public string MetrologicalClass { get { return iPerlCfg.ProcParams.MetrologicalClass; } }
public TemperatureClass TemperatureClass { get { return iPerlCfg.ProcParams.TemperatureClass; } }
public PressureLossClass PressureLossClass { get { return iPerlCfg.ProcParams.PressureLossClass; } }
public MaxAdmissiblePressure MaxAdmissiblePressure { get { return iPerlCfg.ProcParams.MaxAdmissiblePressure; } }
public FlowProfileSensitivityClass FlowProfileSensitivityClass { get { return iPerlCfg.ProcParams.FlowProfileSensitivityClass; } }
/// <summary>WaterMeter approval information or signature</summary>
public string ApprovalInfo { get { return iPerlCfg.ProcParams.ApprovalInfo; } }
public string Certificate { get { return iPerlCfg.ProcParams.Certificate; } }
public string Text1 { get { return iPerlCfg.ProcParams.Text1; } }
public string Text2 { get { return iPerlCfg.ProcParams.Text2; } }
public string Text3 { get { return iPerlCfg.ProcParams.Text3; } }
public string Text4 { get { return iPerlCfg.ProcParams.Text4; } }
public string Text5 { get { return iPerlCfg.ProcParams.Text5; } }
public double PulsesPerLtr { get { return 1000.0; } }
public double LtrsPerPulse { get { return 1 / PulsesPerLtr; } }
#if ORACLE_DB
public int WMType_ID { get { return iPerlCfg.ProcParams.WMType_ID; } } /// Required by Oracle DB
public int WMType_Rev { get { return iPerlCfg.ProcParams.WMType_Rev; } } /// Required by Oracle DB
public int WMType_ID { get { return iperlHeadCfg.ProcParams.WMType_ID; } } /// Required by Oracle DB
public int WMType_Rev { get { return iperlHeadCfg.ProcParams.WMType_Rev; } } /// Required by Oracle DB
#endif
public ushort FactorLimitLo { get { return (ushort)iPerlCfg.ProcParams.FactorLimitLo; } }
public ushort FactorLimitHi { get { return (ushort)iPerlCfg.ProcParams.FactorLimitHi; } }
public ushort FactorLimitLo { get { return (ushort)iperlHeadCfg.ProcParams.FactorLimitLo; } }
public ushort FactorLimitHi { get { return (ushort)iperlHeadCfg.ProcParams.FactorLimitHi; } }
/// Properties set by the Begin and the End form
public string SerialNr
@ -158,7 +121,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
/// <summary> Result of the last test used to calculate Q2 correction factors, etc </summary>
public Results.Entities.MeterTestRslt LastTestResult2;
public Results.Entities.MeterTestRslt LastTestResult;
public double NominalTestFlow; /// liter per hour
public double NominalTestFlowLph; /// in liter per hour
///
@ -240,7 +203,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
const double B = 8.0; /// Raw units per minute, 8
const double C = B * 60.0; /// Raw units per hour, 480
double D = C / A; /// ml correction per hour
double F = D / (NominalTestFlow * 10.0); /// Error corrected with 8 Raw Units per minute [%]
double F = D / (NominalTestFlowLph * 10.0); /// Error corrected with 8 Raw Units per minute [%]
double G = F / B; /// Error corrected with 1 Raw Unit per minute [%]
q2CorrectionFactor = (-1) * (q2TestResult.Error / G) * (q2TestResult.VolumeRef / q2TestResult.VolumeMeter);
@ -371,18 +334,17 @@ namespace TBF.BenchControl.WaterMeters.iPerl
private SerialPort optoSerialPort;
public WaterMeter()
public IperlHead()
{
ClearData();
}
public WaterMeter(Generic.IComponentCfg cfg)
public IperlHead(Generic.IComponentCfg cfg)
: base(cfg)
{
ClearData();
iPerlCfg = cfg as WaterMeterCfg;
ltrsPerPulse = (iPerlCfg.ProcParams.PulsesPerLtr <= float.Epsilon) ? 0 : (1 / iPerlCfg.ProcParams.PulsesPerLtr);
iperlHeadCfg = cfg as IperlHeadCfg;
log.Debug(this.ToString());
}
@ -401,7 +363,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
calibrationStruct = null;
LastTestResult = null;
NominalTestFlow = 0;
NominalTestFlowLph = 0;
OriginalCalibFactor = 0;
Q2ErrorWOCorrection = 0;
@ -431,7 +393,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
partOfTelegram = string.Empty;
/// Prepare serial port
optoSerialPort = new SerialPort(string.Format("COM{0}", iPerlCfg.OptoComPortNr),
optoSerialPort = new SerialPort(string.Format("COM{0}", iperlHeadCfg.OptoComPortNr),
9600, Parity.None, 8, StopBits.One);
optoSerialPort.Handshake = Handshake.None;
@ -808,12 +770,12 @@ namespace TBF.BenchControl.WaterMeters.iPerl
/// <returns>true when type is OK</returns>
public bool VerifyIPerlType()
{
if (iPerlCfg.MeterType == MeterType.AutoDetect || CalibrationStruct == null)
if (iperlHeadCfg.MeterType == MeterType.AutoDetect || CalibrationStruct == null)
{
return true;
}
return iPerlCfg.MeterType == CalibrationStruct.MeterType;
return iperlHeadCfg.MeterType == CalibrationStruct.MeterType;
}
public static double UnitVolume(VolumeUnits units)
@ -829,17 +791,17 @@ namespace TBF.BenchControl.WaterMeters.iPerl
public double ScalingFactor()
{
if ((iPerlCfg.MeterType == MeterType.AutoDetect) && (CalibrationStruct != null))
if ((iperlHeadCfg.MeterType == MeterType.AutoDetect) && (CalibrationStruct != null))
{
return WaterMeter.ScalingFactor(CalibrationStruct.MeterType);
return IperlHead.ScalingFactor(CalibrationStruct.MeterType);
}
else if (iPerlCfg.MeterType != MeterType.AutoDetect)
else if (iperlHeadCfg.MeterType != MeterType.AutoDetect)
{
return WaterMeter.ScalingFactor(iPerlCfg.MeterType);
return IperlHead.ScalingFactor(iperlHeadCfg.MeterType);
}
else
{
return WaterMeter.ScalingFactor(MeterType.DN20);
return IperlHead.ScalingFactor(MeterType.DN20);
}
}

View File

@ -11,11 +11,11 @@ using Config.Entities;
using TBF.BenchControl.Generic;
using TBF.Resources;
namespace TBF.BenchControl.WaterMeters.iPerl
namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
{
public class WaterMeterCfg : ComponentCfgBase, Generic.IComponentCfg
public class IperlHeadCfg : ComponentCfgBase, Generic.IComponentCfg
{
public IComponentCfgCtrl GetControl() { return new WaterMeterCfgCtrl(); }
public IComponentCfgCtrl GetControl() { return new IperlHeadCfgCtrl(); }
///
/// Serialized parameters
@ -44,7 +44,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
/// Private parameterless constructor invoked by all other (public) constructors
WaterMeterCfg()
IperlHeadCfg()
{
Name = "iPerl";
ParentName = string.Empty;
@ -54,7 +54,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
ProcParams = new ProcParams(true);
}
public WaterMeterCfg(IComponentFactory factory)
public IperlHeadCfg(IComponentFactory factory)
: this()
{
this.Factory = factory;

View File

@ -1,6 +1,5 @@
///
/// Copyright (c) 2015 Sensus Metering Systems
/// Author: Milan Hanajík
/// Copyright (c) 2015-2017 Sensus Metering Systems
///
using System;
using System.Net;
@ -10,26 +9,26 @@ using log4net;
using TBF.BenchControl.Generic;
using TBF.Resources;
namespace TBF.BenchControl.WaterMeters.iPerl
namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
{
public partial class WaterMeterCfgCtrl : UserControl, IComponentCfgCtrl
public partial class IperlHeadCfgCtrl : UserControl, IComponentCfgCtrl
{
static readonly ILog log = LogManager.GetLogger(typeof(WaterMeterCfgCtrl));
static readonly ILog log = LogManager.GetLogger(typeof(IperlHeadCfgCtrl));
public bool ShowMore { get { return false; } }
WaterMeterCfg config;
IperlHeadCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as WaterMeterCfg;
config = value as IperlHeadCfg;
Redraw();
}
}
public WaterMeterCfgCtrl()
public IperlHeadCfgCtrl()
{
InitializeComponent();
}

View File

@ -1,10 +1,9 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Author: Milan Hanajík
/// Copyright (c) 2015-2017 Sensus Metering Systems
///
namespace TBF.BenchControl.WaterMeters.iPerl
namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
{
partial class WaterMeterCfgCtrl
partial class IperlHeadCfgCtrl
{
/// <summary>
/// Required designer variable.

View File

@ -1,13 +1,12 @@
///
/// Copyright (c) 2015 Sensus Metering Systems
/// Author: Milan Hanajík
/// Copyright (c) 2015-2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TBF.BenchControl.WaterMeters.iPerl
namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
{
public class OptoReceivedEventArgs : EventArgs
{

View File

@ -1,7 +1,10 @@
using System;
///
/// Copyright (c) 2015-2017 Sensus Metering Systems
///
using System;
using System.Globalization;
namespace TBF.BenchControl.WaterMeters.iPerl
namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
{
public class OptoTelegramRaw
{

View File

@ -0,0 +1,169 @@
///
/// Copyright (c) 2015-2017 Sensus Metering Systems
///
using System;
using System.IO;
using System.Text;
using System.Xml.Serialization;
using Config.Entities;
using TBF.BenchControl.Generic;
using TBF.Resources;
namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
{
public class ProcParams : ProcedureParamsBase, IParamsProvider, IProcedureParams
{
public MeterType MeterType;
public int FactorLimitLo; /// Lower limit for the calibration factor
public int FactorLimitHi; /// Upper limit for the calibration factor
#if ORACLE_DB
public int WMType_ID; /// Required for Oracle DB: ID_WZTyp in table VT_PRUEFPUNKT_SOLL_SD
public int WMType_Rev; /// Required for Oracle DB: Rev_WZTyp in table VT_PRUEFPUNKT_SOLL_SD
#endif
public override void InitializeAll()
{
MeterType = MeterType.AutoDetect;
FactorLimitLo = 1000;
FactorLimitHi = 8000;
#if ORACLE_DB
WMType_ID = 2; /// Value for iPerl DN15
WMType_Rev = 1; /// Value for iPerl DN15
#endif
}
string[] paramNames = new string[]
{
"iPerl type",
"Calib. factor Lo",
"Calib. factor Hi",
#if ORACLE_DB
"WMType ID",
"WMType Rev.",
#endif
};
public override string ParamName(int i) { return paramNames[i]; }
public override int ParamsCount() { return paramNames.Length; }
public override string ToString(int i)
{
switch (i)
{
case 0: return MeterType.ToString();
case 1: return FactorLimitLo.ToString();
case 2: return FactorLimitHi.ToString();
#if ORACLE_DB
case 3: return WMType_ID.ToString();
case 4: return WMType_Rev.ToString();
#endif
default: return string.Empty;
}
}
public void UpdateParam(int i, string strValue)
{
switch (i)
{
case 0:
for (MeterType mt = 0; mt < MeterType.Count; mt++)
{
if (mt.ToString().Equals(strValue)) { MeterType = mt; return; }
}
break;
case 1: FactorLimitLo = int.Parse(strValue); return;
case 2: FactorLimitHi = int.Parse(strValue); return;
#if ORACLE_DB
case 3: WMType_ID = int.Parse(strValue); return;
case 4: WMType_Rev = int.Parse(strValue); return;
#endif
default: return;
}
}
public bool ValidateParam(int i, string strValue, out string message)
{
message = string.Empty;
int iDummy;
switch (i)
{
case 0:
for (MeterType mt = 0; mt < MeterType.Count; mt++) if (mt.ToString().Equals(strValue)) return true;
break;
case 1:
case 2:
if (int.TryParse(strValue, out iDummy) && iDummy >= 1000 && iDummy <= 8000) return true;
break;
#if ORACLE_DB
case 3: /// WMType_ID
case 4: /// WMType_Rev
if (int.TryParse(strValue, out iDummy)) return true;
break;
#endif
default:
message = "Invalid index";
return false;
}
message = ParamName(i) + " is invalid";
return false;
}
void CopyContentTo(ProcParams prms)
{
prms.MeterType = this.MeterType;
prms.FactorLimitLo = this.FactorLimitLo;
prms.FactorLimitHi = this.FactorLimitHi;
#if ORACLE_DB
prms.WMType_ID = this.WMType_ID;
prms.WMType_Rev = this.WMType_Rev;
#endif
}
public IParamsProvider Clone()
{
ProcParams pars = new ProcParams();
CopyContentTo(pars);
return pars;
}
public override void UpdateProcedureParams(ComponentProcedure dbEntity)
{
if (dbEntity == null) return;
try
{
ProcParams tmp = (ProcParams)(new XmlSerializer(typeof(ProcParams)))
.Deserialize(new StringReader(dbEntity.Parameters));
procedureParamsEntity = dbEntity;
componentName = dbEntity.CmpntName;
procedure = dbEntity.Procedure;
tmp.CopyContentTo(this);
}
catch
{
}
}
public ProcParams()
{
}
public ProcParams(bool initialize)
{
if (initialize) InitializeAll();
}
public ProcParams(ComponentProcedure procParamsEntity, string componentName, Procedure procedure)
{
this.procedureParamsEntity = procParamsEntity;
this.componentName = componentName;
this.procedure = procedure;
}
}
}

View File

@ -1,10 +1,9 @@
///
/// Copyright (c) 2015 Sensus Metering Systems
/// Author: Milan Hanajík
/// Copyright (c) 2015-2017 Sensus Metering Systems
///
using System;
namespace TBF.BenchControl.WaterMeters.iPerl
namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
{
public class StatusStruct
{

View File

@ -1,10 +1,7 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using log4net;
using TBF.BenchControl;
using Config.Entities;
namespace TBF.BenchControl.WaterMeters.WaterMeter
@ -59,7 +56,27 @@ namespace TBF.BenchControl.WaterMeters.WaterMeter
/// <summary>Water: cold / hot</summary>
public Config.Entities.Medium WaterTemp { get { return waterMeterCfg.ProcParams.WaterTemp; } }
/// Properties set by the Begin and the End form
#if IPERL
public ushort OriginalCalibFactor;
public ushort CalibFactor;
public double Q2ErrorWOCorrection;
public bool Q2CorrectionDone;
public double Q2Correction;
public int Q2CorrRFlow;
public int Q2CorrLFlow;
public double Diff2Hz8Hz;
public bool Hz2CorrectionDone;
public int Hz2CorrectionFactor;
#endif
#if ORACLE_DB
public int WMType_ID; /// Required by Oracle DB
public int WMType_Rev; /// Required by Oracle DB
#endif
/// Properties set by the Begin and the End form or the iPerl head
public string SerialNr
{
get { return serialNr; }

View File

@ -1,369 +0,0 @@
///
/// Copyright (c) 2015-2017 Sensus Metering Systems
/// Author: Milan Hanajík
///
using System;
using System.IO;
using System.Text;
using System.Xml.Serialization;
using Config.Entities;
using TBF.BenchControl.Generic;
using TBF.Resources;
namespace TBF.BenchControl.WaterMeters.iPerl
{
public class ProcParams : ProcedureParamsBase, IParamsProvider, IProcedureParams
{
public string ProductName; /// Znak fabryczny (PL)
public string Producer; /// Producent (PL), Hersteller (D)
public float DN;
public float L; /// stavebná dĺžka [mm]
public Mounting Mounting;
public float Q4; /// [m3/h]
public float Qn; /// [m3/h]
public float Q2; /// [m3/h]
public float Q1; /// [m3/h]
public string MetrologicalClass; /// Metr. Klasse
public TemperatureClass TemperatureClass;
public PressureLossClass PressureLossClass;
public MaxAdmissiblePressure MaxAdmissiblePressure;
public FlowProfileSensitivityClass FlowProfileSensitivityClass;
public string ApprovalInfo; /// Zulassungszeichen, WE (PL)
public string Certificate;
public float PulsesPerLtr; /// Target low limit of the flow increase or decrease
public string Text1;
public string Text2;
public string Text3;
public string Text4;
public string Text5;
public MeterType MeterType;
#if ORACLE_DB
public int WMType_ID; /// Required for Oracle DB: ID_WZTyp in table VT_PRUEFPUNKT_SOLL_SD
public int WMType_Rev; /// Required for Oracle DB: Rev_WZTyp in table VT_PRUEFPUNKT_SOLL_SD
#endif
public int FactorLimitLo; /// Lower limit for the calibration factor
public int FactorLimitHi; /// Upper limit for the calibration factor
public override void InitializeAll()
{
ProductName = string.Empty;
Producer = string.Empty;
DN = 0;
L = 0;
Mounting = Mounting.NotSpecified;
Q4 = 4.0f;
Qn = 2.5f;
Q2 = 0.005f;
Q1 = 0.003125f;
MetrologicalClass = "R800";
TemperatureClass = TemperatureClass.NotSpecified;
PressureLossClass = PressureLossClass.NotSpecified;
MaxAdmissiblePressure = MaxAdmissiblePressure.NotSpecified;
FlowProfileSensitivityClass = FlowProfileSensitivityClass.NotSpecified;
ApprovalInfo = string.Empty;
Certificate = string.Empty;
PulsesPerLtr = 1.0f;
Text1 = string.Empty;
Text2 = string.Empty;
Text3 = string.Empty;
Text4 = string.Empty;
Text5 = string.Empty;
MeterType = MeterType.AutoDetect;
#if ORACLE_DB
WMType_ID = 2; /// Value for iPerl DN15
WMType_Rev = 1; /// Value for iPerl DN15
#endif
FactorLimitLo = 1000;
FactorLimitHi = 8000;
}
string[] paramNames = new string[]
{
Strings.Product_name,
Strings.Producer,
"DN",
Strings.L,
Strings.Mounting,
"Q4",
"Q3",
"Q2",
"Q1",
Strings.Metrological_class,
Strings.Temperature_class,
Strings.Pressure_loss_class,
Strings.Maximum_admissible_pressure,
Strings.Flow_profile_sensitivity_class,
Strings.Approval_info,
Strings.Certificate,
Strings.PulsesPerLtr,
"Text1",
"Text2",
"Text3",
"Text4",
"Text5",
"iPerl type",
#if ORACLE_DB
"WMType ID",
"WMType Rev.",
#endif
"Calib. factor Lo",
"Calib. factor Hi",
};
public override string ParamName(int i) { return paramNames[i]; }
public override int ParamsCount() { return paramNames.Length; }
public override string ToString(int i)
{
switch (i)
{
case 0: return ProductName;
case 1: return Producer;
case 2: return DN.ToString();
case 3: return L.ToString();
case 4: return Mounting.ToDescription();
case 5: return Q4.ToString();
case 6: return Qn.ToString();
case 7: return Q2.ToString();
case 8: return Q1.ToString();
case 9: return MetrologicalClass;
case 10: return TemperatureClass.ToDescription();
case 11: return PressureLossClass.ToDescription();
case 12: return MaxAdmissiblePressure.ToDescription();
case 13: return FlowProfileSensitivityClass.ToDescription();
case 14: return ApprovalInfo;
case 15: return Certificate;
case 16: return PulsesPerLtr.ToString();
case 17: return Text1;
case 18: return Text2;
case 19: return Text3;
case 20: return Text4;
case 21: return Text5;
case 22: return MeterType.ToString();
#if ORACLE_DB
case 23: return WMType_ID.ToString();
case 24: return WMType_Rev.ToString();
#endif
case 25: return FactorLimitLo.ToString();
case 26: return FactorLimitHi.ToString();
default: return string.Empty;
}
}
public void UpdateParam(int i, string strValue)
{
switch (i)
{
case 0: ProductName = strValue; return;
case 1: Producer = strValue; return;
case 2: DN = Utils.ParseUFloat(strValue); return;
case 3: L = Utils.ParseUFloat(strValue); return;
case 4:
for (Mounting m = 0; m < Mounting.Count; m++)
{
if (m.ToDescription().Equals(strValue)) { Mounting = m; return; }
}
break;
case 5: Q4 = Utils.ParseUFloat(strValue); return;
case 6: Qn = Utils.ParseUFloat(strValue); return;
case 7: Q2 = Utils.ParseUFloat(strValue); return;
case 8: Q1 = Utils.ParseUFloat(strValue); return;
case 9: MetrologicalClass = strValue; return;
case 10:
for (TemperatureClass tc = 0; tc < TemperatureClass.Count; tc++)
{
if (tc.ToDescription().Equals(strValue)) { TemperatureClass = tc; return; }
}
break;
case 11:
for (PressureLossClass dp = 0; dp < PressureLossClass.Count; dp++)
{
if (dp.ToDescription().Equals(strValue)) { PressureLossClass = dp; return; }
}
break;
case 12:
for (MaxAdmissiblePressure map = 0; map < MaxAdmissiblePressure.Count; map++)
{
if (map.ToDescription().Equals(strValue)) { MaxAdmissiblePressure = map; return; }
}
break;
case 13:
for (FlowProfileSensitivityClass fps = 0; fps < FlowProfileSensitivityClass.Count; fps++)
{
if (fps.ToDescription().Equals(strValue)) { FlowProfileSensitivityClass = fps; return; }
}
break;
case 14: ApprovalInfo = strValue; return;
case 15: Certificate = strValue; return;
case 16: PulsesPerLtr = Utils.ParseUFloat(strValue); return;
case 17: Text1 = strValue; return;
case 18: Text2 = strValue; return;
case 19: Text3 = strValue; return;
case 20: Text4 = strValue; return;
case 21: Text5 = strValue; return;
case 22:
for (MeterType mt = 0; mt < MeterType.Count; mt++)
{
if (mt.ToString().Equals(strValue)) { MeterType = mt; return; }
}
break;
#if ORACLE_DB
case 23: WMType_ID = int.Parse(strValue); return;
case 24: WMType_Rev = int.Parse(strValue); return;
#endif
case 25: FactorLimitLo = int.Parse(strValue); return;
case 26: FactorLimitHi = int.Parse(strValue); return;
default: return;
}
}
public bool ValidateParam(int i, string strValue, out string message)
{
message = string.Empty;
float dummy;
int iDummy;
switch (i)
{
case 0: /// ProductName
case 1: /// Producer
case 9: /// MetrologicalClass
case 14: /// ApprovalInfo
case 15: /// Certificate
case 17: /// Text1
case 18: /// Text2
case 19: /// Text3
case 20: /// Text4
case 21: /// Text5
return true;
case 2: /// DN
case 3: /// L
case 5: /// Q4
case 6: /// Q3
case 7: /// Q2
case 8: /// Q1
case 16: /// PulsesPerLtr
if (Utils.TryParseUFloat(strValue, out dummy)) return true;
break;
case 4:
for (Mounting tc = 0; tc < Mounting.Count; tc++) if (tc.ToDescription().Equals(strValue)) return true;
break;
case 10:
for (TemperatureClass tc = 0; tc < TemperatureClass.Count; tc++) if (tc.ToDescription().Equals(strValue)) return true;
break;
case 11:
for (PressureLossClass tc = 0; tc < PressureLossClass.Count; tc++) if (tc.ToDescription().Equals(strValue)) return true;
break;
case 12:
for (MaxAdmissiblePressure map = 0; map < MaxAdmissiblePressure.Count; map++) if (map.ToDescription().Equals(strValue)) return true;
break;
case 13:
for (FlowProfileSensitivityClass tc = 0; tc < FlowProfileSensitivityClass.Count; tc++) if (tc.ToDescription().Equals(strValue)) return true;
break;
case 22:
for (MeterType mt = 0; mt < MeterType.Count; mt++) if (mt.ToString().Equals(strValue)) return true;
break;
#if ORACLE_DB
case 23: /// WMType_ID
case 24: /// WMType_Rev
if (int.TryParse(strValue, out iDummy)) return true;
break;
#endif
case 25:
case 26:
if (int.TryParse(strValue, out iDummy) && iDummy >= 1000 && iDummy <= 8000) return true;
break;
default:
message = "Invalid index";
return false;
}
message = ParamName(i) + " is invalid";
return false;
}
void CopyContentTo(ProcParams prms)
{
prms.ProductName = this.ProductName;
prms.Producer = this.Producer;
prms.DN = this.DN;
prms.L = this.L;
prms.Mounting = this.Mounting;
prms.Q4 = this.Q4;
prms.Qn = this.Qn;
prms.Q2 = this.Q2;
prms.Q1 = this.Q1;
prms.MetrologicalClass = this.MetrologicalClass;
prms.TemperatureClass = this.TemperatureClass;
prms.PressureLossClass = this.PressureLossClass;
prms.MaxAdmissiblePressure = this.MaxAdmissiblePressure;
prms.FlowProfileSensitivityClass = this.FlowProfileSensitivityClass;
prms.ApprovalInfo = this.ApprovalInfo;
prms.Certificate = this.Certificate;
prms.PulsesPerLtr = this.PulsesPerLtr;
prms.Text1 = this.Text1;
prms.Text2 = this.Text2;
prms.Text3 = this.Text3;
prms.Text4 = this.Text4;
prms.Text5 = this.Text5;
prms.MeterType = this.MeterType;
#if ORACLE_DB
prms.WMType_ID = this.WMType_ID;
prms.WMType_Rev = this.WMType_Rev;
#endif
prms.FactorLimitLo = this.FactorLimitLo;
prms.FactorLimitHi = this.FactorLimitHi;
}
public IParamsProvider Clone()
{
ProcParams pars = new ProcParams();
CopyContentTo(pars);
return pars;
}
public override void UpdateProcedureParams(ComponentProcedure dbEntity)
{
if (dbEntity == null) return;
try
{
ProcParams tmp = (ProcParams)(new XmlSerializer(typeof(ProcParams)))
.Deserialize(new StringReader(dbEntity.Parameters));
procedureParamsEntity = dbEntity;
componentName = dbEntity.CmpntName;
procedure = dbEntity.Procedure;
tmp.CopyContentTo(this);
}
catch
{
}
}
public ProcParams()
{
}
public ProcParams(bool initialize)
{
if (initialize) InitializeAll();
}
public ProcParams(ComponentProcedure procParamsEntity, string componentName, Procedure procedure)
{
this.procedureParamsEntity = procParamsEntity;
this.componentName = componentName;
this.procedure = procedure;
}
}
}

View File

@ -1,26 +0,0 @@
///
/// Copyright (c) 2015-2016 Sensus Metering Systems
///
using System.Collections.Generic;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.WaterMeters.iPerl
{
public class WaterMeterFactory : IComponentFactory
{
public string ClassName { get { return "iPerl"; } }
public void ResetStaticProperties() { WaterMeter.ResetStaticProperties(); }
public IComponent DummyComponent() { return new WaterMeter(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new WaterMeter(cfg); }
public IComponentCfg DefaultConfig() { return new WaterMeterCfg(this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(typeof(WaterMeterCfg), component, this);
}
}
}

View File

@ -833,6 +833,22 @@
<Compile Include="BenchControl\TestMethods\iPerlCommunication\iPerlCommunicationForm.designer.cs">
<DependentUpon>iPerlCommunicationForm.cs</DependentUpon>
</Compile>
<Compile Include="BenchControl\TestMethods\iPerlCommunication\iPerlHead\CalibrationStruct.cs" />
<Compile Include="BenchControl\TestMethods\iPerlCommunication\iPerlHead\ConfigStruct.cs" />
<Compile Include="BenchControl\TestMethods\iPerlCommunication\iPerlHead\Enums.cs" />
<Compile Include="BenchControl\TestMethods\iPerlCommunication\iPerlHead\Factory.cs" />
<Compile Include="BenchControl\TestMethods\iPerlCommunication\iPerlHead\IperlHead.cs" />
<Compile Include="BenchControl\TestMethods\iPerlCommunication\iPerlHead\IperlHeadCfg.cs" />
<Compile Include="BenchControl\TestMethods\iPerlCommunication\iPerlHead\IperlHeadCfgCtrl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="BenchControl\TestMethods\iPerlCommunication\iPerlHead\IperlHeadCfgCtrl.designer.cs">
<DependentUpon>IperlHeadCfgCtrl.cs</DependentUpon>
</Compile>
<Compile Include="BenchControl\TestMethods\iPerlCommunication\iPerlHead\OptoReceivedEventArgs.cs" />
<Compile Include="BenchControl\TestMethods\iPerlCommunication\iPerlHead\OptoTelegramRaw.cs" />
<Compile Include="BenchControl\TestMethods\iPerlCommunication\iPerlHead\ProcParams.cs" />
<Compile Include="BenchControl\TestMethods\iPerlCommunication\iPerlHead\StatusStruct.cs" />
<Compile Include="BenchControl\TestMethods\iPerlCommunication\TestMethod.cs" />
<Compile Include="BenchControl\TestMethods\iPerlCommunication\TestMethodCfg.cs" />
<Compile Include="BenchControl\TestMethods\iPerlCommunication\TestMethodCfgCtrl.cs">
@ -856,22 +872,6 @@
<Compile Include="BenchControl\TestMethods\OuterLoop\End\Factory.cs" />
<Compile Include="BenchControl\TestMethods\OuterLoop\Start\Component.cs" />
<Compile Include="BenchControl\TestMethods\OuterLoop\Start\Factory.cs" />
<Compile Include="BenchControl\WaterMeters\iPerl\CalibrationStruct.cs" />
<Compile Include="BenchControl\WaterMeters\iPerl\ConfigStruct.cs" />
<Compile Include="BenchControl\WaterMeters\iPerl\Enums.cs" />
<Compile Include="BenchControl\WaterMeters\iPerl\OptoReceivedEventArgs.cs" />
<Compile Include="BenchControl\WaterMeters\iPerl\OptoTelegramRaw.cs" />
<Compile Include="BenchControl\WaterMeters\iPerl\ProcParams.cs" />
<Compile Include="BenchControl\WaterMeters\iPerl\StatusStruct.cs" />
<Compile Include="BenchControl\WaterMeters\iPerl\WaterMeter.cs" />
<Compile Include="BenchControl\WaterMeters\iPerl\WaterMeterCfg.cs" />
<Compile Include="BenchControl\WaterMeters\iPerl\WaterMeterCfgCtrl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="BenchControl\WaterMeters\iPerl\WaterMeterCfgCtrl.designer.cs">
<DependentUpon>WaterMeterCfgCtrl.cs</DependentUpon>
</Compile>
<Compile Include="BenchControl\WaterMeters\iPerl\WaterMeterFactory.cs" />
<Compile Include="BenchControl\WaterMeters\Munich\ProcParams.cs" />
<Compile Include="BenchControl\WaterMeters\Munich\WaterMeter.cs" />
<Compile Include="BenchControl\WaterMeters\Munich\WaterMeterCfg.cs" />
@ -2042,6 +2042,9 @@
<EmbeddedResource Include="BenchControl\TestMethods\Endurance\CycleDlg.ru.resx">
<DependentUpon>CycleDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="BenchControl\TestMethods\iPerlCommunication\iPerlHead\IperlHeadCfgCtrl.resx">
<DependentUpon>IperlHeadCfgCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="BenchControl\TestMethods\LiveStream\CfgCtrl.resx">
<DependentUpon>CfgCtrl.cs</DependentUpon>
</EmbeddedResource>
@ -2084,9 +2087,6 @@
<EmbeddedResource Include="BenchControl\TestMethods\PMaxTest\TestMethodCfgCtrl.resx">
<DependentUpon>TestMethodCfgCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="BenchControl\WaterMeters\iPerl\WaterMeterCfgCtrl.resx">
<DependentUpon>WaterMeterCfgCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="BenchControl\WaterMeters\Munich\WaterMeterCfgCtrl.resx">
<DependentUpon>WaterMeterCfgCtrl.cs</DependentUpon>
</EmbeddedResource>