Genesis: - RequestProtocol: - CommandToMeter :Rewound to version from 06.09.2023 14:44:33 before Commit 8c9d7704
This commit is contained in:
@@ -155,7 +155,7 @@
|
||||
</site>
|
||||
<site name="MeterProcessState" id="2">
|
||||
<application path="/" applicationPool="Clr4IntegratedAppPool">
|
||||
<virtualDirectory path="/" physicalPath="C:\Users\drabesch_ro\Repo\lab\la_operations\laa_production\Common\Service\MeterProcessState" />
|
||||
<virtualDirectory path="/" physicalPath="D:\Projekte\SENSUS_GitLab\LAA_PRODUCTION\Common\Service\MeterProcessState" />
|
||||
</application>
|
||||
<bindings>
|
||||
<binding protocol="http" bindingInformation="*:56011:localhost" />
|
||||
|
||||
@@ -607,19 +607,23 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.RequestProtocol
|
||||
/// <remarks date="2024-Apr-11" author="T.Wiedebusch">
|
||||
/// - Exit multiple read date if retries exceeded increased to <see cref="CommunicationConfig.MaxRequestRetries"/>.
|
||||
/// </remarks>
|
||||
/// <remarks date="2024-Apr-11 Version 2" author="T.Wiedebusch">
|
||||
/// - Rewound to version from 06.09.2023 14:44:33 before Commit 8c9d7704.
|
||||
/// </remarks>
|
||||
public RequestRecord CommandToMeter(Byte command, RegisterDefinition meterRegister = null,
|
||||
Byte[] payload = null, Int32 expectedLength = 4, Boolean hideDataInLog = false,
|
||||
Byte[] payload = null, Int32? expectedLength = null, Boolean hideDataInLog = false,
|
||||
UInt16 skipRetryErrorCode = CommunicationConfig.SkipRetryErrorCode)
|
||||
{
|
||||
if (command == Commands.MultipleReadData && meterRegister != null && meterRegister.DataType == typeof(String))
|
||||
{
|
||||
var completeResponse = new List<Byte>();
|
||||
while (!completeResponse.Contains(0) && _recordInProcess.RetryCtr <= CommunicationConfig.MaxRequestRetries)
|
||||
//TODO THW check this including the recursive call CommandToMeter
|
||||
while (true)
|
||||
{
|
||||
var cRecord = CommandToMeter(Commands.ReadData, meterRegister, payload, 4, hideDataInLog,
|
||||
skipRetryErrorCode);
|
||||
var cRecord = CommandToMeter(Commands.ReadData, meterRegister, payload, expectedLength,
|
||||
hideDataInLog, skipRetryErrorCode);
|
||||
var rest = ProcessRecordList();
|
||||
if (rest == RequestAcknowledgeState.Ok && cRecord?.ResponsePayload != null)
|
||||
if (rest == RequestAcknowledgeState.Ok && cRecord != null && cRecord.ResponsePayload != null)
|
||||
{
|
||||
completeResponse.AddRange(cRecord.ResponsePayload);
|
||||
if (cRecord.ResponsePayload.Contains(0))
|
||||
@@ -627,11 +631,68 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.RequestProtocol
|
||||
cRecord.ResponsePayload = completeResponse;
|
||||
OnMeterRegisterUpdated?.Invoke(this,
|
||||
new RegisterUpdatedEventArgs(meterRegister, completeResponse.ToArray()));
|
||||
if (expectedLength.HasValue && completeResponse.Count < expectedLength.Value)
|
||||
{
|
||||
_logger.Debug("Too Short. Payload contains zero");
|
||||
}
|
||||
|
||||
return cRecord;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (expectedLength.HasValue && completeResponse.Any() &&
|
||||
completeResponse.Count < expectedLength.Value)
|
||||
{
|
||||
if (rest != RequestAcknowledgeState.Ok)
|
||||
{
|
||||
_logger.Debug($"Too Short.Request Acknowledge State is {rest}");
|
||||
}
|
||||
else if (cRecord == null)
|
||||
{
|
||||
_logger.Debug("Too Short.Record is empty or null");
|
||||
}
|
||||
else if (cRecord.ResponsePayload == null)
|
||||
{
|
||||
_logger.Debug("Too Short.ResponsePayload is empty or null");
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Debug("Too Short.Unkown reason");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return cRecord;
|
||||
}
|
||||
}
|
||||
}
|
||||
//if (command == Commands.MultipleReadData && meterRegister != null && meterRegister.DataType == typeof(String))
|
||||
//{
|
||||
// var completeResponse = new List<Byte>();
|
||||
// while (!completeResponse.Contains(0) && _recordInProcess.RetryCtr <= CommunicationConfig.MaxRequestRetries)
|
||||
// {
|
||||
// var cRecord = CommandToMeter(Commands.ReadData, meterRegister, payload, 4, hideDataInLog,
|
||||
// skipRetryErrorCode);
|
||||
// var rest = ProcessRecordList();
|
||||
// if (rest == RequestAcknowledgeState.Ok && cRecord?.ResponsePayload != null)
|
||||
// {
|
||||
// completeResponse.AddRange(cRecord.ResponsePayload);
|
||||
// if (cRecord.ResponsePayload.Contains(0))
|
||||
// {
|
||||
// cRecord.ResponsePayload = completeResponse;
|
||||
// OnMeterRegisterUpdated?.Invoke(this,
|
||||
// new RegisterUpdatedEventArgs(meterRegister, completeResponse.ToArray()));
|
||||
// return cRecord;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (cRecord?.ResponsePayload == null)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//the minimum payload is one 4 byte chunk
|
||||
var chunkSize = RegisterDefinition.ChunkSize;
|
||||
if (payload == null)
|
||||
@@ -674,7 +735,20 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.RequestProtocol
|
||||
|
||||
if (command == Commands.MultipleReadData)
|
||||
{
|
||||
var numberOfChunks = (UInt16)(expectedLength / chunkSize);
|
||||
//TODO THW create expected size out of meterRegister.DataType
|
||||
if (!expectedLength.HasValue)
|
||||
{
|
||||
if ((meterRegister.DataType == typeof(UInt64) || meterRegister.DataType == typeof(Int64)))
|
||||
{
|
||||
expectedLength = 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
expectedLength = 24;
|
||||
}
|
||||
}
|
||||
|
||||
var numberOfChunks = (UInt16)(expectedLength.Value / chunkSize);
|
||||
if (expectedLength % chunkSize != 0)
|
||||
numberOfChunks++;
|
||||
requestProtocol.Add((Byte)(numberOfChunks & 0xFF));
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
c43c40a030005a8f189e6179faf40a6d42bfef5c
|
||||
8fbe991b217e7692af4817ad205b768685aa5a72
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
65d75c3322f8a137c69963cfdc0cb6f1ffacf62a
|
||||
1babc7d629fd8c486aff20f4990c117c2e58a68f
|
||||
|
||||
Reference in New Issue
Block a user