Mexico - read additional parameters and store to DB, ver. 3.9.3135.0

Add support for reading and handling additional common parameters in OptoHeadTest. Extend RadioService and related classes with enhanced parsing and validation logic. Update UI and constants for functionality integration.
This commit is contained in:
2026-08-12 16:20:16 +02:00
parent 126322584f
commit 55d2381e8a
12 changed files with 291 additions and 152 deletions
@@ -717,7 +717,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
else if (currentActivity.ToLower().Equals(SetActiveModeStr.ToLower())) error = SetActiveMode(threadID, ihead, ref resultStr);
else if (currentActivity.ToLower().Equals(SetIdleModeStr.ToLower())) error = SetIdleMode(threadID, ihead, ref resultStr);
else if (currentActivity.ToLower().Contains(ReadConfigurationStr.ToLower())) error = ReadConfiguration(ihead, wm, ref resultStr);
else if (currentActivity.ToLower().Contains( iPerlCommunicationConstants.ReadAdditionalCommonParametersStr.ToLower())) error = ReadAdditionalCommonParameters( ihead, ref resultStr);
else if (currentActivity.ToLower().Contains( iPerlCommunicationConstants.ReadAdditionalCommonParametersStr.ToLower())) error = ReadAdditionalCommonParameters( ihead,wm, ref resultStr);
///
/// RFID communication functions below require a reference to water meter entity (wm != null)
///
@@ -890,7 +890,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
if (ihead.CommFailed) return CommErr.CommFailed;
//zeroing
ihead.ConfigStruct = null; /// Clear previous ConfigStruct, avoid reuse of (not anymore valid) PCB Number
//ihead.ConfigStruct = null; /// Clear previous ConfigStruct, avoid reuse of (not anymore valid) PCB Number
CommErr error = CommErr.Read;
int readRetVal = 0;
@@ -1018,20 +1018,24 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
/// <summary>
/// Reads additional common parameters through the optical head.
/// </summary>
private static CommErr ReadAdditionalCommonParameters( IperlHead ihead, ref string resultStr)
private static CommErr ReadAdditionalCommonParameters( IperlHead ihead, WaterMeter wm, ref string resultStr)
{
if (ihead == null)
{
resultStr = "Read additional common parameters: iPerl head is null.";
return CommErr.CommFailed;
}
if (ihead.CommFailed)
if (wm == null)
{
resultStr = "Read additional common parameters: previous communication failed.";
resultStr =
"Read additional common parameters: WaterMeter is null.";
return CommErr.CommFailed;
}
ihead.CommFailed = false;
if (ihead.OptoHeadTest == null)
{
resultStr = "Read additional common parameters: OptoHeadTest is not available.";
@@ -1040,8 +1044,72 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
try
{
bool successful = ihead.OptoHeadTest.ReadAdditionalCommonParameters( out resultStr);
return successful ? CommErr.None : CommErr.Read;
log.DebugFormat( "ReadAdditionalCommonParameters started: Head={0}", ihead);
bool successful = ihead.OptoHeadTest.ReadAdditionalCommonParameters( out resultStr, false);
log.DebugFormat( "ReadAdditionalCommonParameters finished: Head={0}, successful={1}, result={2}",
ihead, successful, resultStr);
if (successful)
{
ConfigStruct config = ihead.ConfigStruct;
if (config != null)
{
if (config.VersionType != null)
{
wm.FWVersion = string.Format(
"{0} {1} {2}",
config.VersionType.TouchReadVersion,
config.VersionType.MeterDeviceType,
config.VersionType.MeterFirmwareVersion);
}
if (config.ReadingUnits.HasValue)
{
wm.SerialNrAux =
config.ReadingUnits.Value.ToString();
}
if (config.FlipMode.HasValue)
{
wm.RadioAddress =
config.FlipMode.Value.ToString();
}
if (config.Calibration != null)
{
wm.CalibFactor =
config.Calibration.RawValue;
}
log.DebugFormat(
"Additional common parameters copied to WaterMeter: " +
"FWVersion={0}, ReadingUnits={1}, FlipMode={2}, CalibFactor={3}",
wm.FWVersion,
wm.SerialNrAux,
wm.RadioAddress,
wm.CalibFactor);
}
else
{
log.WarnFormat(
"Additional common parameters were read, but ConfigStruct is null: Head={0}",
ihead);
}
return CommErr.None;
}
if (string.IsNullOrWhiteSpace(resultStr))
{
resultStr = "Failed to read additional common parameters.";
}
log.ErrorFormat( "ReadAdditionalCommonParameters failed: Head={0}, result={1}", ihead, resultStr);
return CommErr.Read;
}
catch (Exception ex)
{
@@ -2765,7 +2833,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
break;
}
success = iHead.OptoHeadTest .ReadAdditionalCommonParameters( out txt);
success = iHead.OptoHeadTest .ReadAdditionalCommonParameters( out txt, false);
if (!success && string.IsNullOrWhiteSpace(txt))
{