diff --git a/TestBenchFramework/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs b/TestBenchFramework/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs
index 9beae8296..0e3661ab1 100644
--- a/TestBenchFramework/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs
+++ b/TestBenchFramework/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs
@@ -1,5 +1,5 @@
///
-/// Copyright (c) 2015-2016 Sensus Metering Systems
+/// Copyright (c) 2015-2017 Sensus Metering Systems
///
//#define VERIFY_ACTIVE_MODE
//#define VERIFY_Q2_CORR_RESET
@@ -236,6 +236,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
const string NormalizeCalibrationFactorStr = "Normalize calibration factor";
const string ResetQ2CorrectionStr = "Reset Q2 correction";
const string WriteQ2CorrectionStr = "Write Q2 correction";
+ const string WriteQ2CorrectionAltStr = "Write Q2 correction Alt";
const string Reset2HzCorrectionStr = "Reset 2Hz correction";
const string Write2HzCorrectionStr = "Write 2Hz correction";
@@ -675,6 +676,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
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);
+ else if (activity.ToLower().Equals(WriteQ2CorrectionAltStr.ToLower())) error = WriteQ2CorrectionAlt(wm, ref resultStr);
else if (activity.ToLower().Equals(Reset2HzCorrectionStr.ToLower())) error = Reset2HzCorrection(wm, ref resultStr);
else if (activity.ToLower().Equals(Write2HzCorrectionStr.ToLower())) error = Write2HzCorrection(wm, ref resultStr);
else
@@ -1341,6 +1343,86 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
}
+ ///
+ /// Write the calculated Q2 correction factors to the memory.
+ /// Read them back to verify factors were written correctly.
+ ///
+ /// Water meter object
+ /// String passed to caller
+ /// true on success
+ static CommErr WriteQ2CorrectionAlt(WaterMeters.iPerl.WaterMeter wm, ref string resultStr)
+ {
+ if (wm.CommFailed) return CommErr.CommFailed;
+
+ wm.Q2ErrorWOCorrection = wm.LastTestResult.Error;
+ wm.Q2CorrectionDone = false;
+
+ double q2CorrectionFactor;
+ bool wmOK = wm.CalculateQ2CorrectionFactor(wm.LastTestResult, out q2CorrectionFactor);
+
+ if (q2CorrectionFactor == 0)
+ {
+ resultStr = string.Format("Q2 correction = 0 (writing bypassed)");
+ return CommErr.None;
+ }
+
+ if (OpenPort(wm) != 0) return CommErr.OpenPort; /// Open RFID port
+
+ CommErr error = CommErr.Write;
+
+ Byte q2CorrRFlow = (byte)((int)Math.Round(q2CorrectionFactor) & 0x000000FF);
+ Byte q2CorrLFlow = (byte)((int)Math.Round(q2CorrectionFactor) & 0x000000FF);
+ byte[] wrData = new byte[2] { q2CorrRFlow, q2CorrLFlow };
+ ///
+ for (int j = 0; j < cfg.MaxCommRetries; j++)
+ {
+ if (0 == WriteRequestPort(wm, MessageID.MetrologyMemory, Q2CorrFactorsAddr, wrData.Length, wrData, cfg.CommTimeout))
+ {
+ error = CommErr.None;
+ break;
+ }
+ }
+
+ ///
+ /// Verification disabled on 16.02.2016
+ ///
+#if false
+ if (error == CommErr.None)
+ {
+ error = CommErr.Verify;
+
+ /// Read calibration
+ byte[] rdData = null;
+ for (int j = 0; j < cfg.MaxCommRetries; j++)
+ {
+ if ((0 == ReadRequestPort(wm, MessageID.MetrologyMemory, Q2CorrFactorsAddr, 2, out rdData, cfg.CommTimeout)) &&
+ (rdData != null) && (rdData.Length == 2) && (rdData[0] == q2CorrRFlow) && (rdData[1] == q2CorrLFlow))
+ {
+ error = CommErr.None;
+ 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;
+ break;
+ }
+ }
+ }
+#else
+ 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.Q2CorrectionFactor = q2CorrectionFactor;
+ }
+#endif
+
+ ClosePort(wm); /// Close RFID port
+
+ return error;
+ }
+
+
///
/// Write the calculated 2Hz correction factor to the memory.
///