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:
parent
126322584f
commit
55d2381e8a
@ -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")]
|
||||
|
||||
@ -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<string>();
|
||||
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));
|
||||
|
||||
@ -47,6 +47,7 @@ namespace TBF.Rig.TestMethods.SmartMeterFlyingStartMassCollection
|
||||
{
|
||||
var retVal = new List<string>();
|
||||
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);
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
@ -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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="resultStr">
|
||||
/// Result intended for GUI and test-process output.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// True when all parameters were read successfully.
|
||||
/// </returns>
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -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<FlipMode>(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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ----------------------
|
||||
|
||||
|
||||
|
||||
@ -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))
|
||||
{
|
||||
|
||||
@ -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<string>();
|
||||
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));
|
||||
|
||||
@ -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()
|
||||
{
|
||||
|
||||
@ -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<ListItem> additionalItems = new List<ListItem>();
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user