iPerlST : Modification in writing calibration factors via RFID.

This commit is contained in:
Milan Hanajik 2016-11-10 14:07:11 +01:00
parent 3e6243a8b7
commit b649c282e8

View File

@ -27,6 +27,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
OpenPort,
Read,
Write,
ReadAfterWrite,
CmdActive,
CmdTest,
Verify,
@ -974,9 +975,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
if (OpenPort(wm) != 0) return CommErr.OpenPort; /// Open RFID port
CommErr error = CommErr.Write;
///
/// Parse calibration factor (1 argument) or calibration factor limits (2 arguments)
///
UInt16 newCalibFactor = 0;
if (multiTestParams[currentActivityStep].Activity.Length > WriteCalibrationFactorStr.Length)
{
@ -1007,35 +1008,41 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
newCalibFactor = wm.CalculateNewCalibFactor(wm.CalibrationFactor, 2400, 2700); /// Default factor limits for DN15
}
///
/// Start communication with iPerl
///
CommErr error;
byte[] data = new byte[2] { (byte)(newCalibFactor & 0x00FF), (byte)((newCalibFactor >> 8) & 0x00FF) };
for (int j = 0; j < cfg.MaxCommRetries; j++)
int writeAndVerifyRetries = 0;
do
{
///
/// Write the new calibration factor (up to cfg.MaxCommRetries tims)
///
error = CommErr.Write;
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++)
{
///
/// 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))
{
error = CommErr.None;
wm.CalibrationStruct.Update(calib_2_3, 2);
resultStr = wm.CalibrationStruct.ToString();
break;
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();
break;
}
}
}
wm.CalibrationStruct.Update(data, 2);
}
while (++writeAndVerifyRetries <= cfg.MaxCommRetries);
ClosePort(wm); /// Close RFID port