MagFlux: - Introduced reverse flow

This commit is contained in:
Thomas Wiedebusch
2023-05-25 15:31:43 +02:00
parent 3d6566e5d7
commit 492761f236
6 changed files with 144 additions and 111 deletions
@@ -11,6 +11,11 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.DataPackages.MeasurementRecor
public class MagFluxRecord : MeasurementRecord
{
/// <summary>
/// Reverse volume in cubic meters
/// </summary>
public Double RevVolumeCm;
/// <summary>
/// Flow rate in cubic meters per hour
/// </summary>
@@ -44,18 +49,19 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.DataPackages.MeasurementRecor
{
var sb = new StringBuilder();
sb = sb.Append($"Volume [m³]: {VolumeCm}").Append(StringDelimiter)
.Append($"CPU Time [s]: {TimeS}").Append(StringDelimiter)
.Append($"FlowRate [m³/h]: {FlowRateCmPh}").Append(StringDelimiter)
.Append($"Status: 0x{StatusBits:X8}").Append(StringDelimiter)
.Append($"UniqueId: {UniqueId}").Append(StringDelimiter)
.Append($"SensorId: {SensorId}").Append(StringDelimiter)
.Append($"CRC: 0x{Crc:X4}").Append(StringDelimiter)
.Append($"OverflowVolume [m³]: {OverflowVolumeCm}").Append(StringDelimiter)
.Append($"OverflowTime [s]: {OverflowTimeS}").Append(StringDelimiter)
.Append($"IsValid: {IsValid}").Append(StringDelimiter)
.Append($"ReceivedTime [UTC]: {ReceivedTime}").Append(StringDelimiter)
.Append($"DecodedTime [UTC]: {DecodedTime}").Append(StringDelimiter)
.Append($"SyncMarkRecord: {SyncMarkRecord}");
.Append($"Reverse Volume [m³]: {RevVolumeCm}").Append(StringDelimiter)
.Append($"CPU Time [s]: {TimeS}").Append(StringDelimiter)
.Append($"FlowRate [m³/h]: {FlowRateCmPh}").Append(StringDelimiter)
.Append($"Status: 0x{StatusBits:X8}").Append(StringDelimiter)
.Append($"UniqueId: {UniqueId}").Append(StringDelimiter)
.Append($"SensorId: {SensorId}").Append(StringDelimiter)
.Append($"CRC: 0x{Crc:X4}").Append(StringDelimiter)
.Append($"OverflowVolume [m³]: {OverflowVolumeCm}").Append(StringDelimiter)
.Append($"OverflowTime [s]: {OverflowTimeS}").Append(StringDelimiter)
.Append($"IsValid: {IsValid}").Append(StringDelimiter)
.Append($"ReceivedTime [UTC]: {ReceivedTime}").Append(StringDelimiter)
.Append($"DecodedTime [UTC]: {DecodedTime}").Append(StringDelimiter)
.Append($"SyncMarkRecord: {SyncMarkRecord}");
return sb.ToString();
}
}
@@ -5,7 +5,6 @@ using System.IO;
using System.Linq;
using System.Threading;
using Newtonsoft.Json;
using NLog.LayoutRenderers;
using Xylem.Common.CommonCore.Consts;
using Xylem.Common.Hardware.Interfaces.Ports.PortCore;
using Xylem.Common.Hardware.Interfaces.Ports.PortCore.EventArguments;
@@ -23,7 +22,6 @@ using Xylem.Common.Hardware.WaterMeter.WaterMeterCore.Consts;
using Xylem.Common.Metrology.Measurements;
using Xylem.Common.Metrology.Measurements.Consts;
using Xylem.Common.Utils.Logging;
using Timer = System.Timers.Timer;
namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
@@ -34,7 +34,8 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.StreamingProtocol
/// </summary>
private readonly MagFluxRecord _dataMagFluxDefault = new MagFluxRecord
{
VolumeCm = 0.0,
VolumeCm = 0.0,
RevVolumeCm = 0.0,
TimeS = 0.0,
FlowRateCmPh = 0.0,
StatusBits = 0,
@@ -74,19 +75,20 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.StreamingProtocol
/// <remarks date="2023-Mar-09" author="T.Wiedebusch">
/// - Modified using common CRC check before branching to the protocol specific decoder.
/// </remarks>
/// <remarks date="2023-May-25" author="T.Wiedebusch">
/// - Introduced reverse volume.
/// </remarks>
public Boolean DecodeMsg(String rawMsg)
{
var rawRecordIsValid = false;
try
{
// save the raw message for CRC calculation before separation to fields
//_rawMsgForCrc = rawMsg;
// extract message and split it to fields
//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 (0x5863)
//MagFlux test string:
//rawMsg = "@l 1bd911f 0 95b8d4 40cf9b5c 0 26004f5232500120373235 0 5863"
//Protocol version, DUT:Vol FWD [mL], DUT: Vol REV [ml], DUT:Time [s], DUT:Flow_LPS, DUT:StatusBitsHex,
//l, 29200671, 0, 149.7219849, 6.487714767, 0,
//DUT:UniqueId, DUT:SensorId, DUT:CRC
//4.59406E+25, 0, 22627 (0x5863)
// The received message is a string with a line delimiter.
rawMsg = rawMsg.Replace('\n', ' ');
@@ -157,8 +159,10 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.StreamingProtocol
// extract received CRC
dataMagFluxRec.Crc = UInt16.Parse(fields[(Int32)ProtLsubString.Crc], NumberStyles.HexNumber);
// build result values, the display volume can be positive or negative!
dataMagFluxRec.VolumeCm = UInt64.Parse(fields[(Int32)ProtLsubString.DisplayVolume],
// build result values
dataMagFluxRec.VolumeCm = UInt64.Parse(fields[(Int32)ProtLsubString.FwdVolume],
NumberStyles.AllowHexSpecifier) * MilliLitersToCmFactor;
dataMagFluxRec.RevVolumeCm = UInt64.Parse(fields[(Int32)ProtLsubString.RevVolume],
NumberStyles.AllowHexSpecifier) * MilliLitersToCmFactor;
dataMagFluxRec.TimeS = UInt32.Parse(fields[(Int32)ProtLsubString.CpuTime],
NumberStyles.AllowHexSpecifier) * CpuTimeToSecondsFactor;
@@ -185,7 +189,8 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.StreamingProtocol
{
//do not remove this needed for position in record
ProtType,
DisplayVolume,
FwdVolume,
RevVolume,
CpuTime,
FlowRate,
StatusBits,
+106 -83
View File
@@ -49,6 +49,8 @@
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.picLogo = new System.Windows.Forms.PictureBox();
this.grpMeasurements = new System.Windows.Forms.GroupBox();
this.tbxStatus = new System.Windows.Forms.TextBox();
this.lblStatus = new System.Windows.Forms.Label();
this.tbxVolume = new System.Windows.Forms.TextBox();
this.tbxFlowRate = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
@@ -56,17 +58,17 @@
this.tbxUniqueId = new System.Windows.Forms.TextBox();
this.lblUniqueId = new System.Windows.Forms.Label();
this.grpInfo = new System.Windows.Forms.GroupBox();
this.lblSensorId = new System.Windows.Forms.Label();
this.tbxStatus = new System.Windows.Forms.TextBox();
this.lblStatus = new System.Windows.Forms.Label();
this.lblFwVersion = new System.Windows.Forms.Label();
this.tbxFwVersion = new System.Windows.Forms.TextBox();
this.lblFwBuildDate = new System.Windows.Forms.Label();
this.tbxFwBuildDate = new System.Windows.Forms.TextBox();
this.lblFwGitHash = new System.Windows.Forms.Label();
this.tbxFwGitHash = new System.Windows.Forms.TextBox();
this.lblMeterSize = new System.Windows.Forms.Label();
this.tbxMeterSize = new System.Windows.Forms.TextBox();
this.lblFwGitHash = new System.Windows.Forms.Label();
this.tbxFwGitHash = new System.Windows.Forms.TextBox();
this.lblFwBuildDate = new System.Windows.Forms.Label();
this.tbxFwBuildDate = new System.Windows.Forms.TextBox();
this.lblFwVersion = new System.Windows.Forms.Label();
this.tbxFwVersion = new System.Windows.Forms.TextBox();
this.lblSensorId = new System.Windows.Forms.Label();
this.tbxRevVolume = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.grpSetup.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.picLogo)).BeginInit();
@@ -262,6 +264,8 @@
//
// grpMeasurements
//
this.grpMeasurements.Controls.Add(this.tbxRevVolume);
this.grpMeasurements.Controls.Add(this.label1);
this.grpMeasurements.Controls.Add(this.tbxStatus);
this.grpMeasurements.Controls.Add(this.lblStatus);
this.grpMeasurements.Controls.Add(this.tbxVolume);
@@ -270,14 +274,31 @@
this.grpMeasurements.Controls.Add(this.label11);
this.grpMeasurements.Location = new System.Drawing.Point(320, -1);
this.grpMeasurements.Name = "grpMeasurements";
this.grpMeasurements.Size = new System.Drawing.Size(203, 102);
this.grpMeasurements.Size = new System.Drawing.Size(203, 157);
this.grpMeasurements.TabIndex = 37;
this.grpMeasurements.TabStop = false;
this.grpMeasurements.Text = "Measurements";
//
// tbxStatus
//
this.tbxStatus.Location = new System.Drawing.Point(114, 95);
this.tbxStatus.Name = "tbxStatus";
this.tbxStatus.ReadOnly = true;
this.tbxStatus.Size = new System.Drawing.Size(68, 20);
this.tbxStatus.TabIndex = 33;
//
// lblStatus
//
this.lblStatus.AutoSize = true;
this.lblStatus.Location = new System.Drawing.Point(6, 98);
this.lblStatus.Name = "lblStatus";
this.lblStatus.Size = new System.Drawing.Size(40, 13);
this.lblStatus.TabIndex = 32;
this.lblStatus.Text = "Status:";
//
// tbxVolume
//
this.tbxVolume.Location = new System.Drawing.Point(114, 17);
this.tbxVolume.Location = new System.Drawing.Point(114, 20);
this.tbxVolume.Name = "tbxVolume";
this.tbxVolume.ReadOnly = true;
this.tbxVolume.Size = new System.Drawing.Size(68, 20);
@@ -285,7 +306,7 @@
//
// tbxFlowRate
//
this.tbxFlowRate.Location = new System.Drawing.Point(114, 47);
this.tbxFlowRate.Location = new System.Drawing.Point(114, 70);
this.tbxFlowRate.Name = "tbxFlowRate";
this.tbxFlowRate.ReadOnly = true;
this.tbxFlowRate.Size = new System.Drawing.Size(68, 20);
@@ -294,7 +315,7 @@
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(6, 50);
this.label7.Location = new System.Drawing.Point(6, 73);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(89, 13);
this.label7.TabIndex = 27;
@@ -303,7 +324,7 @@
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(6, 20);
this.label11.Location = new System.Drawing.Point(6, 23);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(65, 13);
this.label11.TabIndex = 25;
@@ -347,65 +368,22 @@
this.grpInfo.TabStop = false;
this.grpInfo.Text = "Info";
//
// lblSensorId
// lblMeterSize
//
this.lblSensorId.AutoSize = true;
this.lblSensorId.Location = new System.Drawing.Point(4, 48);
this.lblSensorId.Name = "lblSensorId";
this.lblSensorId.Size = new System.Drawing.Size(57, 13);
this.lblSensorId.TabIndex = 36;
this.lblSensorId.Text = "Sensor ID:";
this.lblMeterSize.AutoSize = true;
this.lblMeterSize.Location = new System.Drawing.Point(4, 148);
this.lblMeterSize.Name = "lblMeterSize";
this.lblMeterSize.Size = new System.Drawing.Size(85, 13);
this.lblMeterSize.TabIndex = 44;
this.lblMeterSize.Text = "Meter Size [DN]:";
//
// tbxStatus
// tbxMeterSize
//
this.tbxStatus.Location = new System.Drawing.Point(114, 74);
this.tbxStatus.Name = "tbxStatus";
this.tbxStatus.ReadOnly = true;
this.tbxStatus.Size = new System.Drawing.Size(68, 20);
this.tbxStatus.TabIndex = 33;
//
// lblStatus
//
this.lblStatus.AutoSize = true;
this.lblStatus.Location = new System.Drawing.Point(6, 77);
this.lblStatus.Name = "lblStatus";
this.lblStatus.Size = new System.Drawing.Size(40, 13);
this.lblStatus.TabIndex = 32;
this.lblStatus.Text = "Status:";
//
// lblFwVersion
//
this.lblFwVersion.AutoSize = true;
this.lblFwVersion.Location = new System.Drawing.Point(4, 73);
this.lblFwVersion.Name = "lblFwVersion";
this.lblFwVersion.Size = new System.Drawing.Size(65, 13);
this.lblFwVersion.TabIndex = 38;
this.lblFwVersion.Text = "FW Version:";
//
// tbxFwVersion
//
this.tbxFwVersion.Location = new System.Drawing.Point(103, 70);
this.tbxFwVersion.Name = "tbxFwVersion";
this.tbxFwVersion.ReadOnly = true;
this.tbxFwVersion.Size = new System.Drawing.Size(116, 20);
this.tbxFwVersion.TabIndex = 37;
//
// lblFwBuildDate
//
this.lblFwBuildDate.AutoSize = true;
this.lblFwBuildDate.Location = new System.Drawing.Point(4, 98);
this.lblFwBuildDate.Name = "lblFwBuildDate";
this.lblFwBuildDate.Size = new System.Drawing.Size(79, 13);
this.lblFwBuildDate.TabIndex = 40;
this.lblFwBuildDate.Text = "FW Build Date:";
//
// tbxFwBuildDate
//
this.tbxFwBuildDate.Location = new System.Drawing.Point(103, 95);
this.tbxFwBuildDate.Name = "tbxFwBuildDate";
this.tbxFwBuildDate.ReadOnly = true;
this.tbxFwBuildDate.Size = new System.Drawing.Size(116, 20);
this.tbxFwBuildDate.TabIndex = 39;
this.tbxMeterSize.Location = new System.Drawing.Point(103, 145);
this.tbxMeterSize.Name = "tbxMeterSize";
this.tbxMeterSize.ReadOnly = true;
this.tbxMeterSize.Size = new System.Drawing.Size(116, 20);
this.tbxMeterSize.TabIndex = 43;
//
// lblFwGitHash
//
@@ -424,22 +402,65 @@
this.tbxFwGitHash.Size = new System.Drawing.Size(116, 20);
this.tbxFwGitHash.TabIndex = 41;
//
// lblMeterSize
// lblFwBuildDate
//
this.lblMeterSize.AutoSize = true;
this.lblMeterSize.Location = new System.Drawing.Point(4, 148);
this.lblMeterSize.Name = "lblMeterSize";
this.lblMeterSize.Size = new System.Drawing.Size(85, 13);
this.lblMeterSize.TabIndex = 44;
this.lblMeterSize.Text = "Meter Size [DN]:";
this.lblFwBuildDate.AutoSize = true;
this.lblFwBuildDate.Location = new System.Drawing.Point(4, 98);
this.lblFwBuildDate.Name = "lblFwBuildDate";
this.lblFwBuildDate.Size = new System.Drawing.Size(79, 13);
this.lblFwBuildDate.TabIndex = 40;
this.lblFwBuildDate.Text = "FW Build Date:";
//
// tbxMeterSize
// tbxFwBuildDate
//
this.tbxMeterSize.Location = new System.Drawing.Point(103, 145);
this.tbxMeterSize.Name = "tbxMeterSize";
this.tbxMeterSize.ReadOnly = true;
this.tbxMeterSize.Size = new System.Drawing.Size(116, 20);
this.tbxMeterSize.TabIndex = 43;
this.tbxFwBuildDate.Location = new System.Drawing.Point(103, 95);
this.tbxFwBuildDate.Name = "tbxFwBuildDate";
this.tbxFwBuildDate.ReadOnly = true;
this.tbxFwBuildDate.Size = new System.Drawing.Size(116, 20);
this.tbxFwBuildDate.TabIndex = 39;
//
// lblFwVersion
//
this.lblFwVersion.AutoSize = true;
this.lblFwVersion.Location = new System.Drawing.Point(4, 73);
this.lblFwVersion.Name = "lblFwVersion";
this.lblFwVersion.Size = new System.Drawing.Size(65, 13);
this.lblFwVersion.TabIndex = 38;
this.lblFwVersion.Text = "FW Version:";
//
// tbxFwVersion
//
this.tbxFwVersion.Location = new System.Drawing.Point(103, 70);
this.tbxFwVersion.Name = "tbxFwVersion";
this.tbxFwVersion.ReadOnly = true;
this.tbxFwVersion.Size = new System.Drawing.Size(116, 20);
this.tbxFwVersion.TabIndex = 37;
//
// lblSensorId
//
this.lblSensorId.AutoSize = true;
this.lblSensorId.Location = new System.Drawing.Point(4, 48);
this.lblSensorId.Name = "lblSensorId";
this.lblSensorId.Size = new System.Drawing.Size(57, 13);
this.lblSensorId.TabIndex = 36;
this.lblSensorId.Text = "Sensor ID:";
//
// tbxRevVolume
//
this.tbxRevVolume.Location = new System.Drawing.Point(114, 45);
this.tbxRevVolume.Name = "tbxRevVolume";
this.tbxRevVolume.ReadOnly = true;
this.tbxRevVolume.Size = new System.Drawing.Size(68, 20);
this.tbxRevVolume.TabIndex = 35;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(6, 48);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(108, 13);
this.label1.TabIndex = 34;
this.label1.Text = "Reverse Volume [m²]:";
//
// FrmTest
//
@@ -521,5 +542,7 @@
private System.Windows.Forms.TextBox tbxFwBuildDate;
private System.Windows.Forms.Label lblFwVersion;
private System.Windows.Forms.TextBox tbxFwVersion;
private System.Windows.Forms.TextBox tbxRevVolume;
private System.Windows.Forms.Label label1;
}
}
+1
View File
@@ -147,6 +147,7 @@ namespace Xylem.Common.Ui.MagFluxToolBox
Invoke(new Action(() =>
{
tbxVolume.Text = $@"{e.NewData.VolumeCm:F3}";
tbxRevVolume.Text = $@"{e.NewData.RevVolumeCm:F3}";
tbxFlowRate.Text = $@"{e.NewData.FlowRateCmPh:F3}";
tbxStatus.Text = $@"0x{e.NewData.StatusBits:X8}";
}));
@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]