FM2014: -verbose output on read
This commit is contained in:
parent
c836eb181a
commit
487ceee7b4
@ -482,7 +482,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
cmdName = CmdName.CMD_REF_GET_PLS_CTR;
|
||||
if (CyclicReceiveTaskLoopIsActive && refCtrOn && Write(cmdName))
|
||||
{
|
||||
if (StatusReturn.Okay == Read(cmdName, out var responseStr) &&
|
||||
if (Read(cmdName, out var responseStr) &&
|
||||
int.TryParse(responseStr, NumberStyles.HexNumber, new CultureInfo("en"), out var intValue))
|
||||
{
|
||||
var response = new CmdResponse(cmdName, infoRef, intValue);
|
||||
@ -496,7 +496,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
if (CyclicReceiveTaskLoopIsActive && dutCtrOn && Write(cmdName))
|
||||
{
|
||||
|
||||
if (StatusReturn.Okay == Read(cmdName, out var responseStr) &&
|
||||
if (Read(cmdName, out var responseStr) &&
|
||||
int.TryParse(responseStr, NumberStyles.HexNumber, new CultureInfo("en"), out var intValue))
|
||||
{
|
||||
var response = new CmdResponse(cmdName, infoDut, intValue);
|
||||
@ -600,7 +600,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
var info = GetCmdInfo(cmdName);
|
||||
if (CyclicReceiveTaskLoopIsActive && Write(cmdName))
|
||||
{
|
||||
if (StatusReturn.Okay == Read(cmdName, out responseStr))
|
||||
if (Read(cmdName, out responseStr))
|
||||
{
|
||||
// The response contains a sign!
|
||||
var signMultiplier = responseStr.Contains("+") ? 1.0f : -1.0f;
|
||||
@ -623,7 +623,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
info = GetCmdInfo(cmdName);
|
||||
if (RequestDebugInformation && CyclicReceiveTaskLoopIsActive && Write(cmdName))
|
||||
{
|
||||
if (StatusReturn.Okay == Read(cmdName, out responseStr) &&
|
||||
if (Read(cmdName, out responseStr) &&
|
||||
int.TryParse(responseStr, NumberStyles.HexNumber, new CultureInfo("en"), out var period))
|
||||
{
|
||||
// Publish the period [ms]
|
||||
@ -663,7 +663,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
info = GetCmdInfo(cmdName);
|
||||
if (RequestDebugInformation && CyclicReceiveTaskLoopIsActive && Write(cmdName))
|
||||
{
|
||||
if (StatusReturn.Okay == Read(cmdName, out responseStr) &&
|
||||
if (Read(cmdName, out responseStr) &&
|
||||
int.TryParse(responseStr, NumberStyles.HexNumber, new CultureInfo("en"), out var period))
|
||||
{
|
||||
// Publish the period [ms]
|
||||
@ -703,7 +703,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
info = GetCmdInfo(cmdName);
|
||||
if (CyclicReceiveTaskLoopIsActive && Write(cmdName))
|
||||
{
|
||||
if (StatusReturn.Okay == Read(cmdName, out responseStr) &&
|
||||
if (Read(cmdName, out responseStr) &&
|
||||
int.TryParse(responseStr, NumberStyles.HexNumber, new CultureInfo("en"), out var refFrequency))
|
||||
{
|
||||
// Publish the frequency in [Hz]
|
||||
@ -833,7 +833,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
var loopCtr = 4;
|
||||
do
|
||||
{
|
||||
if (StatusReturn.Okay == Read(cmdName, out var responseStr))
|
||||
if (Read(cmdName, out var responseStr))
|
||||
responseStrs.Add(responseStr);
|
||||
} while (loopCtr-- > 0);
|
||||
}
|
||||
@ -843,7 +843,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
var loopCtr = 5;
|
||||
do
|
||||
{
|
||||
if (StatusReturn.Okay == Read(cmdName, out var responseStr))
|
||||
if (Read(cmdName, out var responseStr))
|
||||
responseStrs.Add(responseStr);
|
||||
} while (loopCtr-- > 0);
|
||||
}
|
||||
@ -953,7 +953,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
return false;
|
||||
}
|
||||
|
||||
if (StatusReturn.Okay == Read(cmdName, out var responseStr))
|
||||
if (Read(cmdName, out var responseStr))
|
||||
SerialNumber = responseStr;
|
||||
|
||||
if (!string.IsNullOrEmpty(SerialNumber))
|
||||
@ -1128,30 +1128,41 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
/// <remarks date="2026-Jan-23" author="Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </remarks>
|
||||
private StatusReturn Read(CmdName cmdName, out String responseStr)
|
||||
private Boolean Read(CmdName cmdName, out String responseStr)
|
||||
{
|
||||
responseStr = "";
|
||||
var retVal = StatusReturn.Failed;
|
||||
var cmdCodeStr = GetCmdStr(cmdName);
|
||||
var info = $"{Resources.StrCommResponse}: {GetCmdInfo(cmdName)}";
|
||||
var statusReturn = StatusReturn.Failed;
|
||||
|
||||
// Check for individual command without response
|
||||
if (CmdType.INDIVIDUAL_UNRESPONSIVE == CmdTypeReminderLastCmd &&
|
||||
CmdType.INDIVIDUAL_UNRESPONSIVE == GetCmdCmdType(cmdName))
|
||||
{
|
||||
retVal = StatusReturn.Skipped;
|
||||
statusReturn = StatusReturn.Skipped;
|
||||
}
|
||||
|
||||
else if (CmdType.INDIVIDUAL == CmdTypeReminderLastCmd &&
|
||||
CmdType.INDIVIDUAL == GetCmdCmdType(cmdName))
|
||||
{
|
||||
// Read or timeout with a TimeoutException
|
||||
var answerStr = SerialPort.ReadTo(END_OF_STR);
|
||||
if (string.IsNullOrEmpty(answerStr))
|
||||
return retVal;
|
||||
|
||||
responseStr = answerStr;
|
||||
retVal = StatusReturn.Okay;
|
||||
{
|
||||
statusReturn = StatusReturn.Failed;
|
||||
}
|
||||
else
|
||||
{
|
||||
statusReturn = StatusReturn.Okay;
|
||||
responseStr = answerStr;
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
var isErrorStr = StatusReturn.Failed == statusReturn ? Resources.StrError + ": " : "";
|
||||
var response = new CmdResponse(cmdName, $"{isErrorStr}{info} {responseStr}");
|
||||
OnRawRecordReceived?.Invoke(this, new ProcessExecEventArgs("", specificInfoObj: response,
|
||||
statusReturn: statusReturn));
|
||||
|
||||
return StatusReturn.Failed != statusReturn;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -1172,7 +1183,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
/// </remarks>
|
||||
private Boolean Write(CmdName cmdName, Object dataObj = null)
|
||||
{
|
||||
if (SerialPort == null)//|| !SerialPort.IsOpen)
|
||||
if (SerialPort == null)
|
||||
{
|
||||
CmdTypeReminderLastCmd = CmdType.NOT_INITIALIZED;
|
||||
IsLoggedOn = false;
|
||||
|
||||
@ -619,6 +619,15 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core.Pr
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Response.
|
||||
/// </summary>
|
||||
internal static string StrCommResponse {
|
||||
get {
|
||||
return ResourceManager.GetString("StrCommResponse", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to ERROR.
|
||||
/// </summary>
|
||||
|
||||
@ -321,4 +321,7 @@
|
||||
<data name="StrCmdRespErrorPramTypeNotSupported" xml:space="preserve">
|
||||
<value>Parametertyp wird nicht unterstützt</value>
|
||||
</data>
|
||||
<data name="StrCommResponse" xml:space="preserve">
|
||||
<value>Antwort</value>
|
||||
</data>
|
||||
</root>
|
||||
@ -321,4 +321,7 @@
|
||||
<data name="StrCmdRespErrorPramTypeNotSupported" xml:space="preserve">
|
||||
<value>Parameter type not supported</value>
|
||||
</data>
|
||||
<data name="StrCommResponse" xml:space="preserve">
|
||||
<value>Response</value>
|
||||
</data>
|
||||
</root>
|
||||
Loading…
Reference in New Issue
Block a user