StreamingDecoder: - MagFlux overflow volume changed from32 to 64 bits
This commit is contained in:
+26
-19
@@ -14,19 +14,24 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol
|
||||
/// </summary>
|
||||
public class StreamingDecoder
|
||||
{
|
||||
private const Double MilliLitersToQmFactor = 1.0E-6;
|
||||
private const Double DefaultVolumeScaleRawPerMl = 1024.0;
|
||||
private const Double DefaultVolumeFactorRawToQm = MilliLitersToQmFactor / DefaultVolumeScaleRawPerMl;
|
||||
private const Double MaxAccuVolumeRaw = 0x100000000; //2^32
|
||||
private const Double DefaultAccuDutOverflowVolumeCm = MaxAccuVolumeRaw * DefaultVolumeFactorRawToQm;
|
||||
private const Double MilliLitersToCmFactor = 1.0E-6;
|
||||
private const Double CpuTimeToSecondsFactor = 1.0 / 0x10000;
|
||||
private const Double CpuTimeOverflowS = 0x100000000 * CpuTimeToSecondsFactor;
|
||||
private const Double DisplayMlSetupDutOverflowVolumeCm = 1000.0; //overflow of LCD if set to ml
|
||||
private const Double TofToSecondsFactor38Bit = 1.0 / 0x4000000000; // 2^38
|
||||
private const Double AmplitudeToVoltFactor = 1.0 / 0x400000 / 1000.0; // 2^22
|
||||
private const Double PulseWidthToRelFactor = 1.0 / 0x100; // 2^8
|
||||
private const Double LitersPerSecondToCmPerHourFactor = 3600.0 / 1000.0;
|
||||
|
||||
private const Double DefaultVolumeScaleRawPerMl = 1024.0;
|
||||
private const Double DefaultVolumeFactorRawToCm = MilliLitersToCmFactor / DefaultVolumeScaleRawPerMl;
|
||||
private const Double MaxGenesisAccuVolumeRaw = UInt32.MaxValue; //0x100000000; //2^32
|
||||
private const Double DefaultAccuDutOverflowVolumeCm = MaxGenesisAccuVolumeRaw * DefaultVolumeFactorRawToCm;
|
||||
|
||||
private const Double DisplayMlSetupDutOverflowVolumeCm = 1000.0; //overflow of LCD if set to ml
|
||||
private const Double TofToSecondsFactor38Bit = 1.0 / 0x4000000000; // 2^38
|
||||
private const Double AmplitudeToVoltFactor = 1.0 / 0x400000 / 1000.0; // 2^22 100 0000 0000 0000 0000 0000b
|
||||
private const Double PulseWidthToRelFactor = 1.0 / 0x100; // 2^8
|
||||
|
||||
// protocol 'l' MagFlux
|
||||
private const Double MaxMagFluxVolumeRaw = UInt64.MaxValue;//0x10000000000000000; //2^64
|
||||
private const Double DefaultMagFluxOverflowVolumeCm = MaxMagFluxVolumeRaw / MilliLitersToCmFactor;
|
||||
/// <summary>
|
||||
/// Default data for
|
||||
/// </summary>
|
||||
@@ -39,7 +44,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol
|
||||
UniqueId = "?",
|
||||
SensorId = "?",
|
||||
Crc = 0xFFFF,
|
||||
OverflowVolumeCm = DisplayMlSetupDutOverflowVolumeCm, //TODO THW it is a UInt64 overflow, please change
|
||||
OverflowVolumeCm = DefaultMagFluxOverflowVolumeCm,
|
||||
OverflowTimeS = CpuTimeOverflowS,
|
||||
IsValid = false
|
||||
};
|
||||
@@ -65,7 +70,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol
|
||||
DeltaTimeOfFlightS = 0.0,
|
||||
|
||||
VolumeScaleRawPerMl = DefaultVolumeScaleRawPerMl,
|
||||
VolumeFactorRawToQm = DefaultVolumeFactorRawToQm,
|
||||
VolumeFactorRawToQm = DefaultVolumeFactorRawToCm,
|
||||
DeltaVolumeRaw = 0.0,
|
||||
DeltaVolumeQm = 0.0,
|
||||
AccuVolumeRaw = 0.0,
|
||||
@@ -143,8 +148,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol
|
||||
//_rawMsgForCrc = rawMsg;
|
||||
// extract message and split it to fields
|
||||
|
||||
//MagFlux test string from Jan Bennett 2023-03-09
|
||||
//rawMsg = "@l 34c21 e6e56 3c40f883 0 3c005d5232500120373235 0 5790"
|
||||
//MagFlux test string from Jan Bennett 2023-03-14_16-16-31_fromTO.log
|
||||
//rawMsg = "@l 1bd911f 95b8d4 40cf9b5c 0 26004f5232500120373235 0 5863"
|
||||
//DUT:Debug version,DUT:Vol FWD [mL],DUT:Time [s],DUT:Flow_LPS,DUT:StatusBitsHex,DUT:UniqueId,DUT:SensorId,DUT:CRC
|
||||
//dec_AT_l, 29200671, 149.7219849, 6.487714767, 0, 4.59406E+25, 0, 22627
|
||||
|
||||
//DN50
|
||||
//2022-07-21 07:22:06.9871 | @f 8497D 062E4216 9B2A
|
||||
@@ -257,7 +264,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol
|
||||
|
||||
// build result values, the display volume can be positive or negative!
|
||||
dataMagFluxRec.VolumeCm = UInt64.Parse(fields[(Int32)ProtLsubString.DisplayVolume],
|
||||
NumberStyles.AllowHexSpecifier) * MilliLitersToQmFactor;
|
||||
NumberStyles.AllowHexSpecifier) * MilliLitersToCmFactor;
|
||||
dataMagFluxRec.TimeS = UInt32.Parse(fields[(Int32)ProtLsubString.CpuTime],
|
||||
NumberStyles.AllowHexSpecifier) * CpuTimeToSecondsFactor;
|
||||
|
||||
@@ -293,7 +300,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol
|
||||
NumberStyles.HexNumber);
|
||||
// build result values, the display volume can be positive or negative!
|
||||
dataFlowTestRec.VolumeCm = int.Parse(fields[(Int32)ProtFsubString.DisplayVolume],
|
||||
NumberStyles.AllowHexSpecifier) * MilliLitersToQmFactor;
|
||||
NumberStyles.AllowHexSpecifier) * MilliLitersToCmFactor;
|
||||
dataFlowTestRec.TimeS = uint.Parse(fields[(Int32)ProtFsubString.CpuTime],
|
||||
NumberStyles.AllowHexSpecifier) * CpuTimeToSecondsFactor;
|
||||
}
|
||||
@@ -337,8 +344,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol
|
||||
NumberStyles.AllowHexSpecifier);
|
||||
|
||||
dataProtGRec.VolumeScaleRawPerMl = volumeRawScale != 0 ? volumeRawScale : DefaultVolumeScaleRawPerMl;
|
||||
dataProtGRec.VolumeFactorRawToQm = MilliLitersToQmFactor / dataProtGRec.VolumeScaleRawPerMl;
|
||||
dataProtGRec.OverflowVolumeCm = MaxAccuVolumeRaw * dataProtGRec.VolumeFactorRawToQm;
|
||||
dataProtGRec.VolumeFactorRawToQm = MilliLitersToCmFactor / dataProtGRec.VolumeScaleRawPerMl;
|
||||
dataProtGRec.OverflowVolumeCm = MaxGenesisAccuVolumeRaw * dataProtGRec.VolumeFactorRawToQm;
|
||||
|
||||
// Calculate volume in cubic meters out of the raw volume
|
||||
dataProtGRec.DeltaVolumeQm = dataProtGRec.DeltaVolumeRaw * dataProtGRec.VolumeFactorRawToQm;
|
||||
@@ -432,8 +439,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol
|
||||
NumberStyles.AllowHexSpecifier);
|
||||
|
||||
dataProtHRec.VolumeScaleRawPerMl = volumeRawScale != 0 ? volumeRawScale : DefaultVolumeScaleRawPerMl;
|
||||
dataProtHRec.VolumeFactorRawToQm = MilliLitersToQmFactor / dataProtHRec.VolumeScaleRawPerMl;
|
||||
dataProtHRec.OverflowVolumeCm = MaxAccuVolumeRaw * dataProtHRec.VolumeFactorRawToQm;
|
||||
dataProtHRec.VolumeFactorRawToQm = MilliLitersToCmFactor / dataProtHRec.VolumeScaleRawPerMl;
|
||||
dataProtHRec.OverflowVolumeCm = MaxGenesisAccuVolumeRaw * dataProtHRec.VolumeFactorRawToQm;
|
||||
|
||||
// Calculate volume in cubic meters out of the raw volume
|
||||
dataProtHRec.DeltaVolumeQm = dataProtHRec.DeltaVolumeRaw * dataProtHRec.VolumeFactorRawToQm;
|
||||
|
||||
Reference in New Issue
Block a user