Merge branch 'main' of https://slm.sms-esaap.com/la_operations/laa_production
This commit is contained in:
@@ -111,6 +111,21 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol
|
||||
// save the raw message for CRC calculation before separation to fields
|
||||
_rawMsgForCrc = rawMsg;
|
||||
// extract message and split it to fields
|
||||
|
||||
|
||||
//Dn 50
|
||||
//2022-07-21 07:22:06.9871 | @f 8497D 062E4216 9B2A
|
||||
//2022-07-21 07:22:06.9871 | @h 1 0 0A1F59C4 00017A43 00115C45 72E1596B 00000400 00001998 7D91B652 7D4F37E6 000191E6 0C 062E4A9C 5331
|
||||
//2022-07-21 07:22:07.0171 | @h 2 0 0A1B1FE8 00017B7F 00116B56 72B77427 00000400 0000199A 7DC09688 7B570006 000191E6 0C 062E5326 95BD
|
||||
//rawMsg = "@h 3 0 0A1DF1D5 00017EA8 00118037 741F80F3 00000400 00001998 7E58A62E 7CC2C606 000191E6 0C 062E5BAE D40E";
|
||||
//DN80
|
||||
// 2022-04-28 15:19:54.9167 | @f AA754B 4D0CEE78 5D89
|
||||
//2022-04-28 15:19:54.9337 | @h 1 0 0EF4A130 0002AAB8 000DAC8C 02B98FBD 00000200 00000FFC 643BCF30 63C9CFF6 00015096 0C 4D0CF3CC 3E87
|
||||
//2022-04-28 15:19:54.9497 | @h 2 0 0EFA3000 000283E7 000CE580 E3D5EFFA 00000200 00001000 6DC0A84E 6CD462C2 00015096 0C 4D0CF922 1646
|
||||
//2022-04-28 15:19:54.9627 | @h 3 0 0EFF7F91 0002AC39 000DB43D FE1C0254 00000200 00000FFE 6C932DE6 6D20005D 00015096 0C 4D0CFE76 868A
|
||||
//2022-04-28 15:19:54.9787 | @f AA7C01 4D0CFE76 B08F
|
||||
// rawMsg = "@h 3 0 0EFF7F91 0002AC39 000DB43D FE1C0254 00000200 00000FFE 6C932DE6 6D20005D 00015096 0C 4D0CFE76 868A ";
|
||||
|
||||
rawMsg = rawMsg.Replace('\n', ' ');
|
||||
var field = rawMsg.Split(' ');
|
||||
|
||||
@@ -119,20 +134,31 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol
|
||||
case "@f":
|
||||
isSuccessfulDecoded = DecodeProtocolF(field);
|
||||
if (isSuccessfulDecoded || !_ignoreCorruptedData)
|
||||
{
|
||||
DataFlowTest = _dataFlowTestRec;
|
||||
}
|
||||
|
||||
break;
|
||||
case "@g":
|
||||
{
|
||||
isSuccessfulDecoded = DecodeProtocolG(ref _dataCalibRec, field);
|
||||
if (isSuccessfulDecoded || !_ignoreCorruptedData)
|
||||
{
|
||||
DataCalib = _dataCalibRec;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case "@h":
|
||||
{
|
||||
|
||||
|
||||
isSuccessfulDecoded = DecodeProtocolH(ref _dataCalibRec, field);
|
||||
if (isSuccessfulDecoded || !_ignoreCorruptedData)
|
||||
{
|
||||
DataCalib = _dataCalibRec;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -157,7 +183,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol
|
||||
var byteArraySize = _rawMsgForCrc.Length - 4;
|
||||
var byteArray = new Byte[byteArraySize];
|
||||
for (var i = 0; i < byteArraySize; i++)
|
||||
{
|
||||
byteArray[i] = (Byte)_rawMsgForCrc[i];
|
||||
}
|
||||
|
||||
_rawMsgForCrc = null;
|
||||
var calculatedCrc = Crc16Ccitt.CalculateMsb1021(byteArray);
|
||||
|
||||
@@ -197,7 +226,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol
|
||||
var byteArraySize = _rawMsgForCrc.Length - 4;
|
||||
var byteArray = new Byte[byteArraySize];
|
||||
for (var i = 0; i < byteArraySize; i++)
|
||||
{
|
||||
byteArray[i] = (Byte)_rawMsgForCrc[i];
|
||||
}
|
||||
|
||||
_rawMsgForCrc = null;
|
||||
var calculatedCrc = Crc16Ccitt.CalculateMsb1021(byteArray);
|
||||
|
||||
@@ -212,7 +244,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol
|
||||
|
||||
//compare received with calculated CRC
|
||||
if (calculatedCrc != dataProtGRec.Crc || IsValidProtG != dataProtGRec.Validation)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//decode rest of message only if CRC and mode are valid
|
||||
dataProtGRec.IsValid = true;
|
||||
@@ -292,7 +326,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol
|
||||
private Boolean DecodeProtocolH(ref CalibrationRecord dataProtHRec, IList<String> field)
|
||||
{
|
||||
|
||||
|
||||
|
||||
dataProtHRec.DecodedTime = DateTimeOffset.UtcNow;
|
||||
dataProtHRec.IsValid = false;
|
||||
|
||||
@@ -300,7 +334,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol
|
||||
var byteArraySize = _rawMsgForCrc.Length - 4;
|
||||
var byteArray = new Byte[byteArraySize];
|
||||
for (var i = 0; i < byteArraySize; i++)
|
||||
{
|
||||
byteArray[i] = (Byte)_rawMsgForCrc[i];
|
||||
}
|
||||
|
||||
_rawMsgForCrc = null;
|
||||
var calculatedCrc = Crc16Ccitt.CalculateMsb1021(byteArray);
|
||||
|
||||
@@ -322,7 +359,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol
|
||||
}
|
||||
// decode rest of message only if CRC and mode are valid
|
||||
dataProtHRec.IsValid = true;
|
||||
|
||||
|
||||
|
||||
// Total time of flight
|
||||
dataProtHRec.TotalTimeOfFlightS = int.Parse(field[(Int32)ProtHsubString.Ttof],
|
||||
@@ -335,10 +372,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol
|
||||
|
||||
|
||||
dataProtHRec.RAWTotalTimeOfFlight =
|
||||
int.Parse(field[(Int32) ProtHsubString.Ttof], NumberStyles.AllowHexSpecifier);
|
||||
dataProtHRec.RAWDeltaTimeOfFlight = int.Parse(field[(Int32) ProtHsubString.Dtof], NumberStyles.AllowHexSpecifier);
|
||||
int.Parse(field[(Int32)ProtHsubString.Ttof], NumberStyles.AllowHexSpecifier);
|
||||
dataProtHRec.RAWDeltaTimeOfFlight = int.Parse(field[(Int32)ProtHsubString.Dtof], NumberStyles.AllowHexSpecifier);
|
||||
|
||||
//Delta raw volume between two samples
|
||||
//Delta raw volume between two samples
|
||||
dataProtHRec.DeltaVolumeRaw = uint.Parse(field[(Int32)ProtHsubString.RawDVolume],
|
||||
NumberStyles.AllowHexSpecifier);
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ namespace Xylem.Common.Hardware.WaterMeter.WaterMeterCore
|
||||
}
|
||||
|
||||
_listOfMeters.Add(meterToAdd);
|
||||
|
||||
meterToAdd.ConnectMeter();
|
||||
}
|
||||
|
||||
@@ -67,6 +68,7 @@ namespace Xylem.Common.Hardware.WaterMeter.WaterMeterCore
|
||||
|
||||
|
||||
meterToAdd.LoadConfiguration(!string.IsNullOrEmpty(_sourceLocation) ? _sourceLocation : Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
1a3d4919c9c702245832d925951f2b7cb72fc333
|
||||
5ed75d99ee45ff67821090f1b3dbb001dd9e4fe3
|
||||
|
||||
Reference in New Issue
Block a user