SiUnits: - initial

This commit is contained in:
Thomas Wiedebusch 2026-01-10 17:13:47 +01:00
parent 567c04d98f
commit 6d79c03909
4 changed files with 180 additions and 2 deletions

View File

@ -39,7 +39,7 @@ using Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core.Proper
namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core.Consts
{
/// <summary>
///
/// Command definitions for FM2014
/// </summary>
public static class FM2014CmdDef
{
@ -342,15 +342,22 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core.Co
/// </summary>
public Double? DoubleValue { get; private set; }
/// <summary>
/// Measurement SI unit
/// </summary>
public String SiUnit { get; private set; }
/// <summary>
/// Ctor
/// </summary>
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;
}
}

View File

@ -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
{
/// <summary>
/// SI Units
/// </summary>
public static class SiUnits
{
/// <summary>
/// Unit definitions based on SI or derived SI or NON SI
/// </summary>
public enum SiUnit
{
/// <summary>
///
/// </summary>
UNITLESS_NON_SI,
/// <summary>
///
/// </summary>
PERCENTAGE_NON_SI,
/// <summary>
///
/// </summary>
VOLTAGE,
/// <summary>
///
/// </summary>
CURRENT,
/// <summary>
///
/// </summary>
ELECTRICAL_POWER,
/// <summary>
///
/// </summary>
ELECTRICAL_LOAD,
/// <summary>
///
/// </summary>
DISTANCE,
/// <summary>
///
/// </summary>
FLOW_RATE,
/// <summary>
///
/// </summary>
TEMPERATURE,
/// <summary>
///
/// </summary>
PRESSURE
}
/// <summary>
/// Combine SI unit names with string value
/// </summary>
public struct SiUnitDef
{
/// <summary>
/// Hard coded return string from FM2014
/// </summary>
public readonly SiUnit SiUnit;
/// <summary>
/// SI unit string
/// </summary>
public readonly String SiUnitStr;
/// <summary>
/// Ctor
/// </summary>
/// <param name="siUnit"></param>
/// <param name="siUnitStr"></param>
public SiUnitDef(SiUnit siUnit, String siUnitStr)
{
SiUnit = siUnit;
SiUnitStr = siUnitStr;
}
}
/// <summary>
/// Table of SI units
/// </summary>
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"),
};
/// <summary>
/// Get the information string
/// </summary>
/// <param name="siUnit"></param>
/// <returns>Unit string</returns>
/// <remarks date="2026-Jan-10" author="Thomas Wiedebusch">
/// - Initial.
/// </remarks>
public static String GetInfo(SiUnit siUnit)
{
return (from sit in SiUnitTbl
where sit.SiUnit == siUnit
select sit.SiUnitStr).FirstOrDefault();
}
}
}

View File

@ -212,6 +212,7 @@
<Compile Include="Consts\MeasurementResultsStates.cs" />
<Compile Include="Consts\MeasurementStates.cs" />
<Compile Include="Consts\ProcessStates.cs" />
<Compile Include="Consts\SiUnits.cs" />
<Compile Include="IMeasurement.cs" />
<Compile Include="IMeasurementRecord.cs" />
<Compile Include="MeasurementRecord.cs" />

View File

@ -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}