diff --git a/.gitignore b/.gitignore
index 579ca871..34fe99d5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,7 +18,6 @@
mono_crash.*
# Build results
-bin/
[Aa]pp_[Dd]ata/
[Dd]ebug/
[Dd]ebugPublic/
diff --git a/Common/Common.sln b/Common/Common.sln
index 61d38cec..4f7efe21 100644
--- a/Common/Common.sln
+++ b/Common/Common.sln
@@ -27,6 +27,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataPackages", "Hardware\Wa
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".Shared", ".Shared", "{26EB462B-1FAC-4CEA-A9B9-DB96CA9CC864}"
ProjectSection(SolutionItems) = preProject
+ ..\.gitignore = ..\.gitignore
Hardware\WaterMeter\Genesis\GenesisCore\configuration.json = Hardware\WaterMeter\Genesis\GenesisCore\configuration.json
.shared\NlogConfig.xml = .shared\NlogConfig.xml
.shared\SharedAssemblyInfo.cs = .shared\SharedAssemblyInfo.cs
diff --git a/Common/Common.sln.DotSettings.user b/Common/Common.sln.DotSettings.user
index 9368210b..080ddbbc 100644
--- a/Common/Common.sln.DotSettings.user
+++ b/Common/Common.sln.DotSettings.user
@@ -28,6 +28,7 @@
True
NewVersion
True
+ C:\Users\Thomas\AppData\Local\Temp\JetBrains\ReSharperPlatformVs15\vAny_33007af5\CoverageData\_Common.-1885154465\Snapshot\snapshot.utdcvr
diff --git a/Common/Hardware/WaterMeter/Genesis/DataPackages/DataPackages.csproj b/Common/Hardware/WaterMeter/Genesis/DataPackages/DataPackages.csproj
index 9105a180..e4a2b04d 100644
--- a/Common/Hardware/WaterMeter/Genesis/DataPackages/DataPackages.csproj
+++ b/Common/Hardware/WaterMeter/Genesis/DataPackages/DataPackages.csproj
@@ -216,9 +216,11 @@
Properties\SharedAssemblyInfo.cs
+
+
diff --git a/Common/Hardware/WaterMeter/Genesis/DataPackages/EventArguments/BendDetectDataEventArgs.cs b/Common/Hardware/WaterMeter/Genesis/DataPackages/EventArguments/BendDetectDataEventArgs.cs
new file mode 100644
index 00000000..e9fec4c2
--- /dev/null
+++ b/Common/Hardware/WaterMeter/Genesis/DataPackages/EventArguments/BendDetectDataEventArgs.cs
@@ -0,0 +1,22 @@
+using System;
+using Xylem.Common.Hardware.Interfaces.Protocols.ProtocolCore.EventArguments;
+using Xylem.Common.Hardware.WaterMeter.Genesis.DataPackages.MeasurementRecords;
+
+
+namespace Xylem.Common.Hardware.WaterMeter.Genesis.DataPackages.EventArguments
+{
+ ///
+ public class BendDetectDataEventArgs : BaseDataEventArgs
+ {
+ ///
+ /// new record from Stream
+ ///
+ public BendDetectionRecord NewData;
+
+ ///
+ public override Object GetEventData()
+ {
+ return NewData;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Common/Hardware/WaterMeter/Genesis/DataPackages/MeasurementRecords/BendDetectionRecord.cs b/Common/Hardware/WaterMeter/Genesis/DataPackages/MeasurementRecords/BendDetectionRecord.cs
new file mode 100644
index 00000000..e52ca876
--- /dev/null
+++ b/Common/Hardware/WaterMeter/Genesis/DataPackages/MeasurementRecords/BendDetectionRecord.cs
@@ -0,0 +1,114 @@
+using System;
+using System.Text;
+using Xylem.Common.Metrology.Measurements;
+
+namespace Xylem.Common.Hardware.WaterMeter.Genesis.DataPackages.MeasurementRecords
+{
+ ///
+ ///
+ /// Streaming record for protocol M (information about bend detection and correction)
+ ///
+ public class BendDetectionRecord : MeasurementRecord
+ {
+
+ ///
+ /// The status of the U0 detection for this measurement
+ ///
+ public enum StatusBendU0Enum
+ {
+ ///
+ /// Status okay
+ ///
+ OKAY = 0,
+ ///
+ /// Error code as defined by field name
+ ///
+ ERROR_GENESISFLOW_INSTALLATION_HIGH_TIME_DIFF = 0x0F41,
+ ///
+ /// Error code as defined by field name
+ ///
+ ERROR_GENESISFLOW_INSTALLATION_LOW_FLOW_IGNORE = 0x0F42,
+ ///
+ /// Error code as defined by field name
+ ///
+ ERROR_GENESISFLOW_INSTALLATION_BAD_CHANNELS = 0x0F43,
+ ///
+ /// Error code as defined by field name
+ ///
+ ERROR_GENESISFLOW_INSTALLATION_FIXED = 0x0F44
+ }
+
+ ///
+ /// An enum describing the installation type detected
+ ///
+ public enum InstallationTypeEnum
+ {
+ ///
+ /// Installation type code as defined by field name
+ ///
+ INSTALLATION_U0_180_360 = 0,
+ ///
+ /// Installation type code as defined by field name
+ ///
+ INSTALLATION_U0_90_270 = 1,
+ ///
+ /// Installation type code as defined by field name
+ ///
+ INSTALLATION_UNDISTURBED = 2
+ }
+
+ ///
+ /// Status of U0 Bend detection
+ ///
+ public StatusBendU0Enum StatusBendU0;
+
+ ///
+ /// Installation type code
+ ///
+ public InstallationTypeEnum InstallationType;
+
+ ///
+ /// The proportion of the installation correction to apply based on the detected
+ /// installation. 100% == 0x8000
+ ///
+ public Double CorrectionFactor_percent;
+
+ ///
+ /// The default proportion of the installation correction to apply based on the
+ /// detected installation. 100% == 0x8000
+ ///
+ private const UInt32 DefaultCorrectionFactor = 0x8000;
+
+ ///
+ /// Scale for correction factor to apply to convert it to percentage value 100% == 0x8000
+ ///
+ public const Double CorrectionFactorScale = 100.0 / DefaultCorrectionFactor;
+
+ ///
+ /// The volume in internal units before correction applied
+ ///
+ public Double PreCorrectionVolumeRaw;
+
+ ///
+ /// The volume in internal units after correction applied
+ ///
+ public Double PostCorrectionVolumeRaw;
+
+
+ ///
+ /// Get result as string
+ ///
+ ///
+ public override String ToString()
+ {
+ var sb = new StringBuilder();
+ sb.Append($"Status={StatusBendU0}").Append(",")
+ .Append($"Installation={InstallationType}").Append(",")
+ .Append($"Factor={CorrectionFactor_percent}").Append(",")
+ .Append($"PreVolume={PreCorrectionVolumeRaw}").Append(",")
+ .Append($"PostVolume={PostCorrectionVolumeRaw}");
+
+ return sb.ToString();
+ }
+ }
+}
diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisCore/Consts/LedMode.cs b/Common/Hardware/WaterMeter/Genesis/GenesisCore/Consts/LedMode.cs
index cb67ee9c..35468825 100644
--- a/Common/Hardware/WaterMeter/Genesis/GenesisCore/Consts/LedMode.cs
+++ b/Common/Hardware/WaterMeter/Genesis/GenesisCore/Consts/LedMode.cs
@@ -8,6 +8,13 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.Consts
///
public enum LedMode
{
+ ///
+ /// Test mode with raw record to log.
+ /// Should give one
+ /// 3 times and
+ /// one
+ ///
+ FlowTestAndCalibDataAndBendCorrect = 7,
///
/// Test mode with raw record to log. Should give one
/// 3 times and repeat this till led mode is switch
diff --git a/Common/Hardware/WaterMeter/Genesis/Protocols/StreamingProtocol/StreamingDecoder.cs b/Common/Hardware/WaterMeter/Genesis/Protocols/StreamingProtocol/StreamingDecoder.cs
index 29fe033f..049d1f8c 100644
--- a/Common/Hardware/WaterMeter/Genesis/Protocols/StreamingProtocol/StreamingDecoder.cs
+++ b/Common/Hardware/WaterMeter/Genesis/Protocols/StreamingProtocol/StreamingDecoder.cs
@@ -29,6 +29,22 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol
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
+ ///
+ /// Default data for bend detection tests of Genesis
+ ///
+ private readonly BendDetectionRecord _bendDetectionDefault = new BendDetectionRecord
+ {
+ StatusBendU0 = BendDetectionRecord.StatusBendU0Enum.OKAY,
+ InstallationType = BendDetectionRecord.InstallationTypeEnum.INSTALLATION_UNDISTURBED,
+ CorrectionFactor_percent = 0.0,
+ PreCorrectionVolumeRaw = 0.0,
+ PostCorrectionVolumeRaw = 0.0,
+ TimeS = 0.0,
+ OverflowTimeS = CpuTimeOverflowS,
+ Crc = 0xFFFF,
+ IsValid = false
+ };
+
///
/// Default data for flow tests of Genesis
///
@@ -76,6 +92,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol
private CalibrationRecord _dataCalibRec;
private FlowTestRecord _dataFlowTestRec;
+ private BendDetectionRecord _dataBendDetectRec;
private readonly Boolean _ignoreCorruptedData;
///
@@ -85,6 +102,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol
{
_dataFlowTestRec = _dataDefault;
_dataCalibRec = _rawDataDefault;
+ _dataBendDetectRec = _bendDetectionDefault;
_ignoreCorruptedData = ignoreCorruptedData;
}
@@ -104,6 +122,14 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol
get; private set;
}
+ ///
+ /// Bend detection test data
+ ///
+ public BendDetectionRecord DataBendDetectTest
+ {
+ get; private set;
+ }
+
///
/// Decoding the raw message
///
@@ -170,7 +196,16 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol
switch (rawMsgFields[0])
{
- case "@f":
+ case "@m":
+ _dataBendDetectRec.IsValid = rawRecordIsValid;
+ if (rawRecordIsValid || !_ignoreCorruptedData)
+ {
+ DecodeProtocolM(ref _dataBendDetectRec, rawMsgFields);
+ DataBendDetectTest = _dataBendDetectRec;
+ }
+ break;
+
+ case "@f":
_dataFlowTestRec.IsValid = rawRecordIsValid;
if (rawRecordIsValid || !_ignoreCorruptedData)
{
@@ -205,6 +240,44 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol
return rawRecordIsValid;
}
+ ///
+ /// Extracting message from string fields for protocol 'm'
+ ///
+ /// reference to bend detection test record
+ /// Separated fields containing the measurement as string
+ ///
+ ///
+ /// - Modified using common CRC check in advance.
+ ///
+ private static void DecodeProtocolM(ref BendDetectionRecord dataBendTestRec, IList fields)
+ {
+ // time stamp attachment
+ dataBendTestRec.DecodedTime = DateTimeOffset.UtcNow;
+
+ // extract received CRC
+ dataBendTestRec.Crc = ushort.Parse(fields[(Int32)ProtMsubString.Crc],
+ NumberStyles.HexNumber);
+ // extract the status
+ dataBendTestRec.StatusBendU0 =
+ (BendDetectionRecord.StatusBendU0Enum)UInt32.Parse(fields[(Int32)ProtMsubString.Status],
+ NumberStyles.AllowHexSpecifier);
+ // extract the installation type
+ dataBendTestRec.InstallationType =
+ (BendDetectionRecord.InstallationTypeEnum)UInt32.Parse(fields[(Int32)ProtMsubString.Installation],
+ NumberStyles.AllowHexSpecifier);
+ // extract the correction factor in percent
+ dataBendTestRec.CorrectionFactor_percent =
+ UInt32.Parse(fields[(Int32)ProtMsubString.Factor],
+ NumberStyles.AllowHexSpecifier) * BendDetectionRecord.CorrectionFactorScale;
+
+ // build result values, the volume before and after correction can be positive or negative!
+ dataBendTestRec.PreCorrectionVolumeRaw = Int32.Parse(fields[(Int32)ProtMsubString.PreVolume],
+ NumberStyles.AllowHexSpecifier);
+ // build result values, the volume before and after correction can be positive or negative!
+ dataBendTestRec.PostCorrectionVolumeRaw = Int32.Parse(fields[(Int32)ProtMsubString.PostVolume],
+ NumberStyles.AllowHexSpecifier);
+ }
+
///
/// Extracting message from string fields for protocol 'f'
///
@@ -413,6 +486,18 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol
CpuTime,
Crc
}
+ /// field position in protocol 'm'
+ private enum ProtMsubString
+ {
+ //do not remove this needed for position in record
+ ProtType,
+ Status,
+ Installation,
+ Factor,
+ PreVolume,
+ PostVolume,
+ Crc
+ }
/// field position in protocol 'g'
private enum ProtGsubString
diff --git a/Common/Hardware/WaterMeter/Genesis/Protocols/StreamingProtocol/StreamingProtocol.cs b/Common/Hardware/WaterMeter/Genesis/Protocols/StreamingProtocol/StreamingProtocol.cs
index 4e05511f..bb200644 100644
--- a/Common/Hardware/WaterMeter/Genesis/Protocols/StreamingProtocol/StreamingProtocol.cs
+++ b/Common/Hardware/WaterMeter/Genesis/Protocols/StreamingProtocol/StreamingProtocol.cs
@@ -73,6 +73,27 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol
}
}
+ else if (_streamingDecode.DataBendDetectTest != null)
+ {
+ _streamingDecode.DataBendDetectTest.SyncMarkRecord = dataArgs.GetSyncMarkRecord();
+ _streamingDecode.DataBendDetectTest.ReceivedTime = dataArgs.GetReceivedTime();
+ if (_streamingDecode.DataBendDetectTest.IsValid)
+ {
+ OnRecordIsDecoded?.Invoke(this, new BendDetectDataEventArgs
+ {
+ NewData = _streamingDecode.DataBendDetectTest,
+ RawData = data
+ });
+ }
+ else if (!_ignoreCorruptedData)
+ {
+ OnRecordIsDecoded?.Invoke(this, new BendDetectDataEventArgs
+ {
+ NewData = _streamingDecode.DataBendDetectTest,
+ RawData = data
+ });
+ }
+ }
//toDo: handle trashy telegrams
}
diff --git a/Common/Ui/GenesisToolBox/FrmStreamingQuality.cs b/Common/Ui/GenesisToolBox/FrmStreamingQuality.cs
index 1c354d91..f5797e14 100644
--- a/Common/Ui/GenesisToolBox/FrmStreamingQuality.cs
+++ b/Common/Ui/GenesisToolBox/FrmStreamingQuality.cs
@@ -129,7 +129,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
WriteValue(Register.Genesisflow.SampleRate, SampleRateHz);
_channels = 4;
- WriteValue(Register.Genesisflow.LedMode, (Byte)LedMode.FlowTestAndCalibData);
+ WriteValue(Register.Genesisflow.LedMode, (Byte)LedMode.FlowTestAndCalibDataAndBendCorrect);
if (_currentGenesis.IsLoggedOn)
{
diff --git a/Docu/Hardware/Genesis/2023-04-20 Genesis Firmware Specification.docx b/Docu/Hardware/Genesis/2023-04-20 Genesis Firmware Specification.docx
new file mode 100644
index 00000000..88e90675
Binary files /dev/null and b/Docu/Hardware/Genesis/2023-04-20 Genesis Firmware Specification.docx differ
diff --git a/Docu/Hardware/Genesis/2023-09-21 Genesis Debug Serial Output.docx b/Docu/Hardware/Genesis/2023-09-21 Genesis Debug Serial Output.docx
new file mode 100644
index 00000000..a40ff382
Binary files /dev/null and b/Docu/Hardware/Genesis/2023-09-21 Genesis Debug Serial Output.docx differ
diff --git a/Docu/Hardware/Genesis/2023-11-24 Genesis Firmware Specification.docx b/Docu/Hardware/Genesis/2023-11-24 Genesis Firmware Specification.docx
new file mode 100644
index 00000000..a52a90bb
Binary files /dev/null and b/Docu/Hardware/Genesis/2023-11-24 Genesis Firmware Specification.docx differ