From 6d79c039096c5321cfe074bcae331f60d2e2dea5 Mon Sep 17 00:00:00 2001 From: Thomas Wiedebusch Date: Sat, 10 Jan 2026 17:13:47 +0100 Subject: [PATCH] SiUnits: - initial --- .../FM2014/FM2014Core/Consts/FM2014CmdDef.cs | 11 +- .../Metrology/Measurements/Consts/SiUnits.cs | 161 ++++++++++++++++++ .../Measurements/Measurements.csproj | 1 + MiniPrf/MiniPrf.sln | 9 + 4 files changed, 180 insertions(+), 2 deletions(-) create mode 100644 Common/Metrology/Measurements/Consts/SiUnits.cs diff --git a/Common/Hardware/WaterMeter/MechanicalMeter/FM2014/FM2014Core/Consts/FM2014CmdDef.cs b/Common/Hardware/WaterMeter/MechanicalMeter/FM2014/FM2014Core/Consts/FM2014CmdDef.cs index f7342a91..7d5ef897 100644 --- a/Common/Hardware/WaterMeter/MechanicalMeter/FM2014/FM2014Core/Consts/FM2014CmdDef.cs +++ b/Common/Hardware/WaterMeter/MechanicalMeter/FM2014/FM2014Core/Consts/FM2014CmdDef.cs @@ -39,7 +39,7 @@ using Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core.Proper namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core.Consts { /// - /// + /// Command definitions for FM2014 /// public static class FM2014CmdDef { @@ -342,15 +342,22 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core.Co /// public Double? DoubleValue { get; private set; } + /// + /// Measurement SI unit + /// + public String SiUnit { get; private set; } + /// /// Ctor /// - public CmdResponse(CmdDef cmdId, String answerStr, Int32? intValue = null, Double? doubleValue = null) + public CmdResponse(CmdDef cmdId, String answerStr, Int32? intValue = null, Double? doubleValue = null, + String siUnit = "") { CmdId = cmdId; AnswerStr = answerStr; IntValue = intValue; DoubleValue = doubleValue; + SiUnit = siUnit; } } diff --git a/Common/Metrology/Measurements/Consts/SiUnits.cs b/Common/Metrology/Measurements/Consts/SiUnits.cs new file mode 100644 index 00000000..e0efd21d --- /dev/null +++ b/Common/Metrology/Measurements/Consts/SiUnits.cs @@ -0,0 +1,161 @@ +/****************************************************************************************/ +/*!@file FM2014Commands.cs + * @brief Command list of the FM2014. + * + *=======================================================================================\n + * @copyright + * + *_______________________________________________________________________________________\n + * Copyright (c) 2026 SENSUS GmbH.\n + * All Rights Reserved.\n + * \n + * Confidential property of\n + * SENSUS GmbH,\n + * Meineckestr. 10, 30880 LAATZEN, GERMANY\n + * \n + *=======================================================================================\n + * @authors + * + *_______________________________________________________________________________________\n + * Thomas Wiedebusch\n + * + * + *=======================================================================================\n + * @version + * + *_______________________________________________________________________________________\n + * V1.00 10-Jan-2026 by Thomas Wiedebusch\n + * - Initial. + * + * + *=======================================================================================\n + */ + +using System; +using System.Linq; + +namespace Xylem.Common.Metrology.Measurements.Consts +{ + + /// + /// SI Units + /// + public static class SiUnits + { + /// + /// Unit definitions based on SI or derived SI or NON SI + /// + public enum SiUnit + { + /// + /// + /// + UNITLESS_NON_SI, + + /// + /// + /// + PERCENTAGE_NON_SI, + + /// + /// + /// + VOLTAGE, + + /// + /// + /// + CURRENT, + + /// + /// + /// + ELECTRICAL_POWER, + + /// + /// + /// + ELECTRICAL_LOAD, + + /// + /// + /// + DISTANCE, + + /// + /// + /// + FLOW_RATE, + + /// + /// + /// + TEMPERATURE, + + /// + /// + /// + PRESSURE + + } + + /// + /// Combine SI unit names with string value + /// + public struct SiUnitDef + { + /// + /// Hard coded return string from FM2014 + /// + public readonly SiUnit SiUnit; + + /// + /// SI unit string + /// + public readonly String SiUnitStr; + + /// + /// Ctor + /// + /// + /// + public SiUnitDef(SiUnit siUnit, String siUnitStr) + { + SiUnit = siUnit; + SiUnitStr = siUnitStr; + } + } + + /// + /// Table of SI units + /// + public static readonly SiUnitDef[] SiUnitTbl = + { + new SiUnitDef(SiUnit.UNITLESS_NON_SI, ""), + new SiUnitDef(SiUnit.PERCENTAGE_NON_SI, "%"), + new SiUnitDef(SiUnit.VOLTAGE, "V"), + new SiUnitDef(SiUnit.CURRENT, "A"), + new SiUnitDef(SiUnit.ELECTRICAL_POWER, "W"), + new SiUnitDef(SiUnit.ELECTRICAL_LOAD, "Ah"), + new SiUnitDef(SiUnit.DISTANCE, "m"), + new SiUnitDef(SiUnit.FLOW_RATE, "m³/h"), + new SiUnitDef(SiUnit.TEMPERATURE, "°C"), + new SiUnitDef(SiUnit.PRESSURE, "Pa"), + }; + + /// + /// Get the information string + /// + /// + /// Unit string + /// + /// - Initial. + /// + public static String GetInfo(SiUnit siUnit) + { + return (from sit in SiUnitTbl + where sit.SiUnit == siUnit + select sit.SiUnitStr).FirstOrDefault(); + } + } +} diff --git a/Common/Metrology/Measurements/Measurements.csproj b/Common/Metrology/Measurements/Measurements.csproj index a119384d..3e0ead2c 100644 --- a/Common/Metrology/Measurements/Measurements.csproj +++ b/Common/Metrology/Measurements/Measurements.csproj @@ -212,6 +212,7 @@ + diff --git a/MiniPrf/MiniPrf.sln b/MiniPrf/MiniPrf.sln index 5eabe8b7..c3abc473 100644 --- a/MiniPrf/MiniPrf.sln +++ b/MiniPrf/MiniPrf.sln @@ -48,6 +48,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Utils", "Utils", "{DBC8FF8D EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProcessExec", "..\Common\Utils\ProcessExec\ProcessExec.csproj", "{2FD60CF1-45CD-4060-B8E5-4F39FBA7F1CB}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Metrology", "Metrology", "{6695522E-E681-434C-8006-5A92AABB9807}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Measurements", "..\Common\Metrology\Measurements\Measurements.csproj", "{6CCDB656-C676-4360-BABA-C4596AAD175D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -82,6 +86,10 @@ Global {2FD60CF1-45CD-4060-B8E5-4F39FBA7F1CB}.Debug|Any CPU.Build.0 = Debug|Any CPU {2FD60CF1-45CD-4060-B8E5-4F39FBA7F1CB}.Release|Any CPU.ActiveCfg = Release|Any CPU {2FD60CF1-45CD-4060-B8E5-4F39FBA7F1CB}.Release|Any CPU.Build.0 = Release|Any CPU + {6CCDB656-C676-4360-BABA-C4596AAD175D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6CCDB656-C676-4360-BABA-C4596AAD175D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6CCDB656-C676-4360-BABA-C4596AAD175D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6CCDB656-C676-4360-BABA-C4596AAD175D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -103,6 +111,7 @@ Global {4E27EA04-8B52-4681-BB5E-4658BC3FF9A6} = {14FE7B6A-2029-4DCD-AD07-2BDF77D42D94} {2E139F63-B6FE-4EA9-A098-85364FE9B26C} = {83A52B6E-DB81-4B43-B5C1-F9B637D135BE} {2FD60CF1-45CD-4060-B8E5-4F39FBA7F1CB} = {DBC8FF8D-D0A2-4C55-B7D5-F7D17CCEE01F} + {6CCDB656-C676-4360-BABA-C4596AAD175D} = {6695522E-E681-434C-8006-5A92AABB9807} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {B72A8444-29F9-4FA4-82BE-B6E230750911}