From 55d2381e8a2f7d69a37f1047e4798683669cc203 Mon Sep 17 00:00:00 2001 From: Michal Buzik Date: Wed, 12 Aug 2026 16:20:16 +0200 Subject: [PATCH] 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. --- TBF/Properties/AssemblyInfo.cs | 4 +- .../iPerlCommunicationParams.cs | 2 + .../SmartCommunicationParams.cs | 1 + .../C4/protocolCommons/ReadingUnits.cs | 19 +- .../communication/OptoHeadTest.cs | 196 +++++++++--------- .../communication/RadioService.cs | 80 +++---- .../iPerlCommunicationForm.cs | 86 +++++++- .../iPerlCommunicationParams.cs | 2 + .../iPerlHead/ConfigStruct.cs | 5 + .../iPerlHead/IperlHeadTestCtrl.cs | 45 ++++ .../IperlHatIntegrationTests.cs | 1 - .../communication/RadioServiceTest.cs | 2 - 12 files changed, 291 insertions(+), 152 deletions(-) diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index 7fd036103..d21bd023d 100644 --- a/TBF/Properties/AssemblyInfo.cs +++ b/TBF/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("3.9.3134.112")] -[assembly: AssemblyFileVersion("3.9.3134.112")] +[assembly: AssemblyVersion("3.9.3135.0")] +[assembly: AssemblyFileVersion("3.9.3135.0")] diff --git a/TBF/Rig/TestMethods/GenesisCommunication/iPerlCommunicationParams.cs b/TBF/Rig/TestMethods/GenesisCommunication/iPerlCommunicationParams.cs index e995c359a..82fa52edb 100644 --- a/TBF/Rig/TestMethods/GenesisCommunication/iPerlCommunicationParams.cs +++ b/TBF/Rig/TestMethods/GenesisCommunication/iPerlCommunicationParams.cs @@ -10,6 +10,7 @@ using Config.Entities; using TBF.Resources; using TBF.Rig.Generic; using TBF.Rig.TestMethods.iPerlCommunication; +using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication; namespace TBF.Rig.TestMethods.GenesisCommunication { @@ -51,6 +52,7 @@ namespace TBF.Rig.TestMethods.GenesisCommunication { var retVal = new List(); retVal.Add(iPerlCommunicationForm.ReadConfigurationStr); + retVal.Add(iPerlCommunicationConstants.ReadAdditionalCommonParametersStr); retVal.Add(iPerlCommunicationForm.ReadSerialNrStr); retVal.Add(string.Format("{0} A0", iPerlCommunicationForm.SetTestModeStr)); retVal.Add(string.Format("{0} A4", iPerlCommunicationForm.SetTestModeStr)); diff --git a/TBF/Rig/TestMethods/SmartMeterFlyingStartMassCollection/SmartCommunicationParams.cs b/TBF/Rig/TestMethods/SmartMeterFlyingStartMassCollection/SmartCommunicationParams.cs index eeb91f8c7..774f528ee 100644 --- a/TBF/Rig/TestMethods/SmartMeterFlyingStartMassCollection/SmartCommunicationParams.cs +++ b/TBF/Rig/TestMethods/SmartMeterFlyingStartMassCollection/SmartCommunicationParams.cs @@ -47,6 +47,7 @@ namespace TBF.Rig.TestMethods.SmartMeterFlyingStartMassCollection { var retVal = new List(); retVal.Add(iPerlCommunicationConstants.ReadConfigurationStr); + retVal.Add(iPerlCommunicationConstants.ReadAdditionalCommonParametersStr); retVal.Add(string.Format("{0} A0", iPerlCommunicationConstants.SetTestModeStr)); retVal.Add(string.Format("{0} A4", iPerlCommunicationConstants.SetTestModeStr)); retVal.Add(iPerlCommunicationConstants.ReadCalibrationStr); diff --git a/TBF/Rig/TestMethods/iPerlCommunication/communication/C4/protocolCommons/ReadingUnits.cs b/TBF/Rig/TestMethods/iPerlCommunication/communication/C4/protocolCommons/ReadingUnits.cs index 9cbcfa563..49cd0ff79 100644 --- a/TBF/Rig/TestMethods/iPerlCommunication/communication/C4/protocolCommons/ReadingUnits.cs +++ b/TBF/Rig/TestMethods/iPerlCommunication/communication/C4/protocolCommons/ReadingUnits.cs @@ -4,9 +4,20 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.communication.C4.protocolCommon { CubicMeters = 0x00, CubicFeet = 0x01, - UsGallons = 0x02, - UsGallons1 = 0x04, - UsGallons2 = 0x08, - UsGallons3 = 0x10, + Unknown_0x02 = 0x02, + Unknown_0x03 = 0x03, + UsGallons = 0x04, + Unknown_0x05 = 0x05, + Unknown_0x06 = 0x06, + Unknown_0x07 = 0x07, + Unknown_0x08 = 0x08, + Unknown_0x09 = 0x09, + Unknown_0x0A = 0x0A, + Unknown_0x0B = 0x0B, + Unknown_0x0C = 0x0C, + Unknown_0x0D = 0x0D, + Unknown_0x0E = 0x0E, + Unknown_0x0F = 0x0F, + Unknown_0x10 = 0x10 } } \ No newline at end of file diff --git a/TBF/Rig/TestMethods/iPerlCommunication/communication/OptoHeadTest.cs b/TBF/Rig/TestMethods/iPerlCommunication/communication/OptoHeadTest.cs index 5ecd3ffac..5da359cd4 100644 --- a/TBF/Rig/TestMethods/iPerlCommunication/communication/OptoHeadTest.cs +++ b/TBF/Rig/TestMethods/iPerlCommunication/communication/OptoHeadTest.cs @@ -332,7 +332,10 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.communication if (iperlHead != null) { - iperlHead.ConfigStruct = new ConfigStruct(); + if (iperlHead.ConfigStruct == null) + { + iperlHead.ConfigStruct = new ConfigStruct(); + } if (serialDriver == null) serialDriver = BuildConnection(iperlHead); @@ -691,39 +694,43 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.communication } /// - /// Reads additional common parameters: - /// version and type, reading units, flip mode - /// and calibration factor. + /// Reads additional common parameters and stores them + /// in the current iPerl ConfigStruct. /// - /// - /// Result intended for GUI and test-process output. - /// - /// - /// True when all parameters were read successfully. - /// - public bool ReadAdditionalCommonParameters( - out string resultStr) + public bool ReadAdditionalCommonParameters( out string resultStr, bool prettyText) { resultStr = string.Empty; if (iperlHead == null) { - resultStr = - "Read additional common parameters: iPerl head is null."; - + resultStr = "Read additional common parameters: iPerl head is null."; log.Warn(resultStr); - return false; } + if (iperlHead.ConfigStruct == null) + { + iperlHead.ConfigStruct = new ConfigStruct(); + } + if (iperlHead.DebugLevel == DebugMode.Simulate) { - resultStr = - "Version/type: SIMULATED; " + - "Reading units: CubicMeters; " + - "Flip mode: 0x00; " + - "Calibration: 4096 (100.0000 %, correction 0.0000 %)"; + iperlHead.ConfigStruct.VersionType = new VersionTypeResult + { + TouchReadVersion = "SIMULATED", + MeterDeviceType = "SIMULATED", + MeterFirmwareVersion = "SIMULATED" + }; + iperlHead.ConfigStruct.ReadingUnits = ReadingUnits.CubicMeters; + iperlHead.ConfigStruct.FlipMode = (FlipMode)0x00; + iperlHead.ConfigStruct.Calibration = new CalibrationFactorResult { + RawValue = 4096, + Percentage = 100.0, + CorrectionPercentage = 0.0 + }; + + resultStr = BuildAdditionalCommonParametersString( iperlHead.ConfigStruct, false); return true; } @@ -735,97 +742,96 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.communication BuildConnection(iperlHead); } - var headService = - new RadioService(serialDriver); + var headService = new RadioService(serialDriver); + VersionTypeResult versionType = headService.SetViewVersionAndType( iperlHead); + ReadingUnits? readingUnits = headService.ViewReadingUnits( iperlHead); + FlipMode? flipMode = headService.ViewFlipMode( iperlHead); + CalibrationFactorResult calibration = headService.ViewCalibration( iperlHead); - VersionTypeResult versionType = - headService.SetViewVersionAndType(iperlHead); + /* + * Save received values into ConfigStruct. + * Null values replace old values after an unsuccessful read. + */ + iperlHead.ConfigStruct.VersionType = versionType; + iperlHead.ConfigStruct.ReadingUnits = readingUnits; + iperlHead.ConfigStruct.FlipMode = flipMode; + iperlHead.ConfigStruct.Calibration = calibration; - ReadingUnits? readingUnits = - headService.ViewReadingUnits(iperlHead); - - FlipMode? flipMode = - headService.ViewFlipMode(iperlHead); - - CalibrationFactorResult calibration = - headService.ViewCalibration(iperlHead); - - bool successful = - versionType != null && - readingUnits.HasValue && - flipMode.HasValue && - calibration != null; - - string versionTypeText = - versionType == null - ? "FAILED" - : versionType.ToString(); - - string readingUnitsText = - readingUnits.HasValue - ? string.Format( - "{0} (0x{1:X2})", - readingUnits.Value, - Convert.ToByte(readingUnits.Value)) - : "FAILED"; - - string flipModeText = - flipMode.HasValue - ? string.Format( - "{0} (0x{1:X2})", - flipMode.Value, - Convert.ToByte(flipMode.Value)) - : "FAILED"; - - string calibrationText; - - if (calibration == null) - { - calibrationText = "FAILED"; - } - else - { - calibrationText = string.Format( - "{0} ({1:F4} %, correction {2:+0.0000;-0.0000;0.0000} %)", - calibration.RawValue, - calibration.Percentage, - calibration.CorrectionPercentage); - } - - resultStr = - "Version/type: " + versionTypeText + - "; Reading units: " + readingUnitsText + - "; Flip mode: " + flipModeText + - "; Calibration: " + calibrationText; + bool successful = versionType != null && readingUnits.HasValue && flipMode.HasValue && calibration != null; + resultStr = BuildAdditionalCommonParametersString( iperlHead.ConfigStruct, prettyText); if (successful) { - log.Info( - "ReadAdditionalCommonParameters: " + - resultStr); + log.Info( "ReadAdditionalCommonParameters: " + resultStr); } else { - log.Warn( - "ReadAdditionalCommonParameters failed: " + - resultStr); + log.Warn( "ReadAdditionalCommonParameters failed: " + resultStr); } return successful; } catch (Exception ex) { - resultStr = - "Read additional common parameters failed: " + - ex.Message; - - log.Error( - "ReadAdditionalCommonParameters failed.", - ex); - + resultStr = "Read additional common parameters failed: " + ex.Message; + log.Error( "ReadAdditionalCommonParameters failed.", ex); return false; } } + + private static string BuildAdditionalCommonParametersString( + ConfigStruct config, bool prettyText) + { + if (config == null) + { + return "Additional common parameters are not available."; + } + + string versionTypeText = config.VersionType == null ? "Not available" : config.VersionType.ToString(); + string readingUnitsText = config.ReadingUnits.HasValue ? + string.Format( "{0} (0x{1:X2})", config.ReadingUnits.Value, Convert.ToByte( config.ReadingUnits.Value)) + : "Not available"; + + string flipModeText = config.FlipMode.HasValue ? + string.Format( "{0} (0x{1:X2})", config.FlipMode.Value, Convert.ToByte( config.FlipMode.Value)) + : "Not available"; + + string calibrationText; + + if (config.Calibration == null) + { + calibrationText = "Not available"; + } + else + { + calibrationText = + string.Format( "{0} ({1:F4} %, correction " + "{2:+0.0000;-0.0000;0.0000} %)", + config.Calibration.RawValue, + config.Calibration.Percentage, + config.Calibration.CorrectionPercentage); + } + + if (prettyText) + { + return string.Format( + "Version/type: {0}{4}" + + "Reading units: {1}{4}" + + "Flip mode: {2}{4}" + + "Calibration: {3}", + versionTypeText, + readingUnitsText, + flipModeText, + calibrationText, + Environment.NewLine); + } + + + return + "Version/type: " + versionTypeText + + "; Reading units: " + readingUnitsText + + "; Flip mode: " + flipModeText + + "; Calibration: " + calibrationText; + } } } \ No newline at end of file diff --git a/TBF/Rig/TestMethods/iPerlCommunication/communication/RadioService.cs b/TBF/Rig/TestMethods/iPerlCommunication/communication/RadioService.cs index f0b8a40f2..2d07642b9 100644 --- a/TBF/Rig/TestMethods/iPerlCommunication/communication/RadioService.cs +++ b/TBF/Rig/TestMethods/iPerlCommunication/communication/RadioService.cs @@ -294,7 +294,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.communication return null; } } - + public FlipMode? ViewFlipMode(IperlHead iHead) { if (!serialDriver.IsOpen()) @@ -302,7 +302,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.communication serialDriver.Open(); } - byte[] request = new TouchReadFrameBuilder() + byte[] request = new IperlHatFrameBuilder() .RequestResponse(true) .AddDeviceCommand(ProtocolDeviceSubCommand.ViewFlipMode) .BuildBytes(); @@ -311,71 +311,73 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.communication if (rawData == null || rawData.Length == 0) { - log.Warn("ViewFlipMode: No response received."); + log.Warn( "ViewFlipMode: No response received."); return null; } try { var parser = new IperlHatFrameParser(); + IperlHatResponse decoded = parser.Parse(rawData); - log.Debug("ViewFlipMode isOK: " + decoded.IsOk); + log.Debug( "ViewFlipMode isOK: " + decoded.IsOk); if (!decoded.IsOk) { - log.Warn("ViewFlipMode: Device returned NOK response."); + log.Warn( "ViewFlipMode: Device returned NOK response."); return null; } - FlipMode flipMode = - decoded.GetResponse(out bool responseOk); - - if (!responseOk) + if (decoded.Payload == null || decoded.Payload.Length != 1) { - log.Warn( - "ViewFlipMode: Invalid payload. Expected one byte " + - "with value 0x00 or 0x01. Payload=" + - BitConverter.ToString(decoded.Payload)); - + log.Warn( "ViewFlipMode: Invalid payload. Expected exactly one byte. Payload=" + + BitConverter.ToString( decoded.Payload ?? new byte[0])); return null; } - log.Debug( - $"ViewFlipMode: {flipMode} " + - $"(0x{(byte)flipMode:X2})"); + byte rawValue = decoded.Payload[0]; + if (!Enum.IsDefined( typeof(FlipMode), rawValue)) + { + log.Warn( $"ViewFlipMode: Unknown value. Value=0x{rawValue:X2}"); + return null; + } + + FlipMode flipMode = (FlipMode)rawValue; + + log.Debug( $"ViewFlipMode: {flipMode} " + $"(0x{rawValue:X2})"); return flipMode; } catch (FormatException ex) { - log.Error("ViewFlipMode: Invalid response frame.", ex); + log.Error( "ViewFlipMode: Invalid response frame.", ex); return null; } catch (Exception ex) { - log.Error("ViewFlipMode failed.", ex); + log.Error( "ViewFlipMode failed.", ex); return null; } } - - public CalibrationFactorResult ViewCalibration(IperlHead iHead) + + public CalibrationFactorResult ViewCalibration( IperlHead iHead) { if (!serialDriver.IsOpen()) { serialDriver.Open(); } - byte[] request = new TouchReadFrameBuilder() + byte[] request = new IperlHatFrameBuilder() .RequestResponse(true) - .AddDeviceCommand(ProtocolDeviceSubCommand.ViewCalibration) + .AddDeviceCommand( ProtocolDeviceSubCommand.ViewCalibration) .BuildBytes(); byte[] rawData = serialDriver.SendAndWait(request, 5000); if (rawData == null || rawData.Length == 0) { - log.Warn("ViewCalibration: No response received."); + log.Warn( "ViewCalibration: No response received."); return null; } @@ -384,38 +386,38 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.communication var parser = new IperlHatFrameParser(); IperlHatResponse decoded = parser.Parse(rawData); - log.Debug("ViewCalibration isOK: " + decoded.IsOk); + log.Debug( "ViewCalibration isOK: " + decoded.IsOk); if (!decoded.IsOk) { - log.Warn("ViewCalibration: Device returned NOK response."); + log.Warn( "ViewCalibration: Device returned NOK response."); return null; } - ushort calibrationFactor = decoded.GetUInt16LittleEndian(out bool responseOk); - - if (!responseOk) + if (decoded.Payload == null || decoded.Payload.Length != 2) { - log.Warn( "ViewCalibration: Invalid payload. Expected uint16 little-endian value. Payload=" + BitConverter.ToString(decoded.Payload)); + log.Warn( "ViewCalibration: Invalid payload. Expected two-byte little-endian value. Payload=" + + BitConverter.ToString( decoded.Payload ?? new byte[0])); return null; } + ushort calibrationFactor = (ushort)( decoded.Payload[0] | (decoded.Payload[1] << 8)); + double percentage = calibrationFactor * 100.0 / 4096.0; var result = new CalibrationFactorResult - { - RawValue = calibrationFactor, - Percentage = percentage, - CorrectionPercentage = percentage - 100.0 - }; - - log.Debug("ViewCalibration result: " + result); + { + RawValue = calibrationFactor, + Percentage = percentage, + CorrectionPercentage = percentage - 100.0 + }; + log.Debug( "ViewCalibration result: " + result); return result; } catch (FormatException ex) { - log.Error("ViewCalibration: Invalid response frame.", ex); + log.Error( "ViewCalibration: Invalid response frame.", ex); return null; } catch (Exception ex) @@ -424,7 +426,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.communication return null; } } - + // ---------------------- diff --git a/TBF/Rig/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs b/TBF/Rig/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs index 1d1cefd29..fb7e991c6 100644 --- a/TBF/Rig/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs +++ b/TBF/Rig/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs @@ -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 /// /// Reads additional common parameters through the optical head. /// - 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)) { diff --git a/TBF/Rig/TestMethods/iPerlCommunication/iPerlCommunicationParams.cs b/TBF/Rig/TestMethods/iPerlCommunication/iPerlCommunicationParams.cs index 0e7e78352..820662e9c 100644 --- a/TBF/Rig/TestMethods/iPerlCommunication/iPerlCommunicationParams.cs +++ b/TBF/Rig/TestMethods/iPerlCommunication/iPerlCommunicationParams.cs @@ -10,6 +10,7 @@ using Config.Entities; using TBF.Rig.Generic; using TBF.Resources; using System.Collections.Generic; +using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication; namespace TBF.Rig.TestMethods.iPerlCommunication { @@ -51,6 +52,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication { var retVal = new List(); retVal.Add(iPerlCommunicationForm.ReadConfigurationStr); + retVal.Add(iPerlCommunicationConstants.ReadAdditionalCommonParametersStr); retVal.Add(iPerlCommunicationForm.ReadSerialNrStr); retVal.Add(string.Format("{0} A0", iPerlCommunicationForm.SetTestModeStr)); retVal.Add(string.Format("{0} A4", iPerlCommunicationForm.SetTestModeStr)); diff --git a/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/ConfigStruct.cs b/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/ConfigStruct.cs index 71b928a7f..36acb5525 100644 --- a/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/ConfigStruct.cs +++ b/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/ConfigStruct.cs @@ -20,6 +20,11 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead public string Unit; //dynamic public string Version; // dynamic + public VersionTypeResult VersionType { get; set; } + public ReadingUnits? ReadingUnits { get; set; } + public FlipMode? FlipMode { get; set; } + public CalibrationFactorResult Calibration { get; set; } + public ConfigStruct() { diff --git a/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHeadTestCtrl.cs b/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHeadTestCtrl.cs index f65c32ade..7d4f0052e 100644 --- a/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHeadTestCtrl.cs +++ b/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHeadTestCtrl.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Threading; using System.Web.UI.WebControls; using System.Windows.Forms; @@ -34,6 +35,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead var items = new[] { new {Name = "Read PCB", Value = "ReadPCB" }, + new {Name = "Read Additional Common Parameters", Value = "ReadAdditionalCommonParameters" }, new {Name = "Set Test Mode", Value = "SetTestMode" }, new {Name = "Set Active Mode", Value = "SetActiveMode" }, #if DEBUG @@ -80,12 +82,50 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead ListItem rfidListItem = new ListItem(); rfidListItem.Attributes.Add("style", "font-volume:bold"); //rfidListItem.Attributes.Add("style", "font-weight:bold"); + + List additionalItems = new List(); + bool isTestModeSuccessful = false; switch (rfidCommandComboBox.SelectedValue) { case "ReadPCB": rfidListItem.Text = $"PCB: {iPerlHead.OptoHeadTest.ReadRequest_PCB()}"; break; + case "ReadAdditionalCommonParameters": + { + if (iPerlHead == null) + { + rfidListItem.Text = "FAILED: iPerl head is not available."; + break; + } + + if (iPerlHead.OptoHeadTest == null) + { + rfidListItem.Text = "FAILED: OptoHeadTest is not available."; + break; + } + + bool successful = iPerlHead.OptoHeadTest.ReadAdditionalCommonParameters( out string result, true); + + if (!successful) + { + rfidListItem.Text = "FAILED: " + result; + break; + } + + rfidListItem.Text = "Additional common parameters:"; + + string[] resultLines = result.Split( + new[] { "\r\n", "\n", "\r" }, + StringSplitOptions.RemoveEmptyEntries); + + foreach (string line in resultLines) + { + additionalItems.Add( new ListItem(" " + line.Trim())); + } + + break; + } case "SetTestMode": rfidListItem.Text = iPerlHead.OptoHeadTest.SetTestMode(ref isTestModeSuccessful); optoListBox.Items.Clear(); @@ -133,6 +173,11 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead break; } rfidOutputListBox.Items.Add(rfidListItem); + foreach (ListItem item in additionalItems) + { + rfidOutputListBox.Items.Add(item); + } + rfidOutputListBox.Items.AddRange(logChecker.Messages.ToArray()); } } diff --git a/TBFTests/Rig/RegisterReaders/iPerlASICReader/communication/C4/IperlHatProtocol/IperlHatIntegrationTests.cs b/TBFTests/Rig/RegisterReaders/iPerlASICReader/communication/C4/IperlHatProtocol/IperlHatIntegrationTests.cs index 7475c2bd7..bda845ba5 100644 --- a/TBFTests/Rig/RegisterReaders/iPerlASICReader/communication/C4/IperlHatProtocol/IperlHatIntegrationTests.cs +++ b/TBFTests/Rig/RegisterReaders/iPerlASICReader/communication/C4/IperlHatProtocol/IperlHatIntegrationTests.cs @@ -9,7 +9,6 @@ using TBF.Rig.TestMethods.iPerlCommunication.communication.C4.diagnosticLed.pars using TBF.Rig.TestMethods.iPerlCommunication.communication.C4.hexLogger; using TBF.Rig.TestMethods.iPerlCommunication.communication.C4.IperlHatProtocol; using TBF.Rig.TestMethods.iPerlCommunication.communication.C4.protocolCommons; -using TBF.Rig.TestMethods.iPerlCommunication.communication.C4.protocolCommons.TBF.Rig.TestMethods.iPerlCommunication.communication.C4.IperlHatProtocol; namespace TBFTests.Rig.RegisterReaders.iPerlASICReader.communication.C4.IperlHatProtocol diff --git a/TBFTests/Rig/TestMethods/iPerlCommunication/communication/RadioServiceTest.cs b/TBFTests/Rig/TestMethods/iPerlCommunication/communication/RadioServiceTest.cs index a14e56136..70224daec 100644 --- a/TBFTests/Rig/TestMethods/iPerlCommunication/communication/RadioServiceTest.cs +++ b/TBFTests/Rig/TestMethods/iPerlCommunication/communication/RadioServiceTest.cs @@ -2,10 +2,8 @@ using System; using Microsoft.VisualStudio.TestTools.UnitTesting; using JetBrains.Annotations; using TBF.Rig.TestMethods.iPerlCommunication.communication; -using TBF.Rig.TestMethods.iPerlCommunication.communication.C4; using TBF.Rig.TestMethods.iPerlCommunication.communication.C4.IperlHatProtocol; using TBF.Rig.TestMethods.iPerlCommunication.communication.C4.protocolCommons; -using TBF.Rig.TestMethods.iPerlCommunication.communication.C4.protocolCommons.TBF.Rig.TestMethods.iPerlCommunication.communication.C4.IperlHatProtocol; using TBF.Rig.TestMethods.iPerlCommunication.communication.C4.wiredProtocol; using TBF.Rig.TestMethods.iPerlCommunication.iPerlHead;