iPerlCommunication : "Normalize calibration factor" activity added.
This commit is contained in:
+76
-1
@@ -232,6 +232,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
|||||||
const string SetActiveModeStr = "Set Active mode";
|
const string SetActiveModeStr = "Set Active mode";
|
||||||
const string ReadCalibrationStr = "Read calibration";
|
const string ReadCalibrationStr = "Read calibration";
|
||||||
const string WriteCalibrationFactorStr = "Write calibration factor";
|
const string WriteCalibrationFactorStr = "Write calibration factor";
|
||||||
|
const string NormalizeCalibrationFactorStr = "Normalize calibration factor";
|
||||||
const string ResetQ2CorrectionStr = "Reset Q2 correction";
|
const string ResetQ2CorrectionStr = "Reset Q2 correction";
|
||||||
const string WriteQ2CorrectionStr = "Write Q2 correction";
|
const string WriteQ2CorrectionStr = "Write Q2 correction";
|
||||||
const string Reset2HzCorrectionStr = "Reset 2Hz correction";
|
const string Reset2HzCorrectionStr = "Reset 2Hz correction";
|
||||||
@@ -662,7 +663,8 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
|||||||
else if (activity.ToLower().Equals(SetActiveModeStr.ToLower())) error = SetActiveMode(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().Equals(ReadCalibrationStr.ToLower())) error = ReadCalibration(wm, ref resultStr);
|
||||||
else if (activity.ToLower().Contains(WriteCalibrationFactorStr.ToLower())) error = WriteCalibrationFactor(wm, ref resultStr);
|
else if (activity.ToLower().Contains(WriteCalibrationFactorStr.ToLower())) error = WriteCalibrationFactor(wm, ref resultStr);
|
||||||
else if (activity.ToLower().Equals(ResetQ2CorrectionStr.ToLower())) error = ResetQ2Correction(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);
|
else if (activity.ToLower().Equals(WriteQ2CorrectionStr.ToLower())) error = WriteQ2Correction(wm, ref resultStr);
|
||||||
else if (activity.ToLower().Equals(Reset2HzCorrectionStr.ToLower())) error = Reset2HzCorrection(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 if (activity.ToLower().Equals(Write2HzCorrectionStr.ToLower())) error = Write2HzCorrection(wm, ref resultStr);
|
||||||
@@ -1040,6 +1042,79 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Normalize calibration factor in case ti is close to value 8000.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="wm">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)
|
||||||
|
{
|
||||||
|
if (wm.CommFailed) return CommErr.CommFailed;
|
||||||
|
|
||||||
|
if (wm.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
|
||||||
|
|
||||||
|
CommErr error = CommErr.Write;
|
||||||
|
|
||||||
|
/// Determine the new calibration factor
|
||||||
|
UInt16 newCalibFactor = 0;
|
||||||
|
switch (wm.CalibrationStruct.MeterType)
|
||||||
|
{
|
||||||
|
case MeterType.DN15: newCalibFactor = 2650; break;
|
||||||
|
case MeterType.DN20: newCalibFactor = 3746; break;
|
||||||
|
case MeterType.DN25: newCalibFactor = 3300; break;
|
||||||
|
case MeterType.DN32: newCalibFactor = 2500; break;
|
||||||
|
case MeterType.DN40: newCalibFactor = 3000; break;
|
||||||
|
|
||||||
|
case MeterType.DN26:
|
||||||
|
case MeterType.CoaxManifold:
|
||||||
|
default:
|
||||||
|
newCalibFactor = 3040;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
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))
|
||||||
|
{
|
||||||
|
error = CommErr.None;
|
||||||
|
wm.CalibrationStruct.Update(data, 2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error == CommErr.None)
|
||||||
|
{
|
||||||
|
error = CommErr.Verify;
|
||||||
|
|
||||||
|
/// Read calibration
|
||||||
|
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))
|
||||||
|
{
|
||||||
|
error = CommErr.None;
|
||||||
|
wm.CalibrationStruct.Update(calib_2_3, 2);
|
||||||
|
resultStr = wm.CalibrationStruct.ToString();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ClosePort(wm); /// Close RFID port
|
||||||
|
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const int Hz2CorrFactorsAddr = 0x1875; /// Used by Reset2HzCorrection(...) and Write2HzCorrection(...)
|
const int Hz2CorrFactorsAddr = 0x1875; /// Used by Reset2HzCorrection(...) and Write2HzCorrection(...)
|
||||||
const int Q2CorrFactorsAddr = 0x1878; /// Used by ResetQ2Correction(...) and WriteQ2Correction(...)
|
const int Q2CorrFactorsAddr = 0x1878; /// Used by ResetQ2Correction(...) and WriteQ2Correction(...)
|
||||||
|
|
||||||
|
|||||||
@@ -1117,7 +1117,7 @@
|
|||||||
<value>Sériová čísla vodoměru a stavy</value>
|
<value>Sériová čísla vodoměru a stavy</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Water_Meter_States" xml:space="preserve">
|
<data name="Water_Meter_States" xml:space="preserve">
|
||||||
<value>Stav vodoměru</value>
|
<value>Stav vodoměrů</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Water_meter_types" xml:space="preserve">
|
<data name="Water_meter_types" xml:space="preserve">
|
||||||
<value>Typy vodoměrů</value>
|
<value>Typy vodoměrů</value>
|
||||||
|
|||||||
Reference in New Issue
Block a user