158 lines
4.5 KiB
C#
158 lines
4.5 KiB
C#
/*********************************************************************************************************************/
|
|
/*! @file Unit.cs
|
|
* @brief <i>Units for measurements</i>
|
|
*
|
|
* @author Thomas Wiedebusch
|
|
* @date 2026-Jan-08
|
|
*
|
|
* @details <i>Implements the command table and interprocess-communication structs for the FM2014.</i>
|
|
*
|
|
* @copyright © SENSUS GmbH 2026. All rights reserved.
|
|
*********************************************************************************************************************/
|
|
using System;
|
|
using System.Linq;
|
|
|
|
namespace Xylem.Common.Metrology.Measurements.Consts
|
|
{
|
|
|
|
/// <summary>
|
|
/// SI Units
|
|
/// </summary>
|
|
public static class Units
|
|
{
|
|
/// <summary>
|
|
/// Unit definitions based on SI or derived SI or NON SI
|
|
/// </summary>
|
|
public enum Name
|
|
{
|
|
/// <summary>
|
|
/// Value without any attachable unit []
|
|
/// </summary>
|
|
UNITLESS,
|
|
|
|
/// <summary>
|
|
/// Normalized to +/- 1.000 [norm]
|
|
/// </summary>
|
|
NORMALIZED,
|
|
|
|
/// <summary>
|
|
/// Percent [%]
|
|
/// </summary>
|
|
PERCENT,
|
|
|
|
/// <summary>
|
|
/// Voltage in Volts [V]
|
|
/// </summary>
|
|
VOLTAGE_V,
|
|
|
|
/// <summary>
|
|
/// Current in Amperes [A]
|
|
/// </summary>
|
|
CURRENT_A,
|
|
|
|
/// <summary>
|
|
/// Electrical Power in Watts [W]
|
|
/// </summary>
|
|
ELECTRICAL_POWER_W,
|
|
|
|
/// <summary>
|
|
/// Electrical Load in Ampere hours [Ah]
|
|
/// </summary>
|
|
ELECTRICAL_LOAD_Ah,
|
|
|
|
/// <summary>
|
|
/// Distance in Meters [m]
|
|
/// </summary>
|
|
DISTANCE_m,
|
|
|
|
/// <summary>
|
|
/// Flow rate in cubic-meters per hour [m³/h]
|
|
/// </summary>
|
|
FLOW_RATE_cm_per_h,
|
|
|
|
/// <summary>
|
|
/// Temperature in degree Celsius [°C]
|
|
/// </summary>
|
|
TEMPERATURE_degC,
|
|
|
|
/// <summary>
|
|
/// Time in seconds [s]
|
|
/// </summary>
|
|
TIME_s,
|
|
|
|
/// <summary>
|
|
/// Pressure in Pascal [Pa]
|
|
/// </summary>
|
|
PRESSURE_Pa,
|
|
|
|
/// <summary>
|
|
/// Frequency in Hertz [Hz]
|
|
/// </summary>
|
|
FREQUENCY_Hz
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Combine SI unit names with string value
|
|
/// </summary>
|
|
public struct SiUnit
|
|
{
|
|
/// <summary>
|
|
/// Hard coded return string from FM2014
|
|
/// </summary>
|
|
public readonly Name Name;
|
|
|
|
/// <summary>
|
|
/// SI unit string
|
|
/// </summary>
|
|
public readonly String AbbreviationStr;
|
|
|
|
/// <summary>
|
|
/// Ctor
|
|
/// </summary>
|
|
/// <param name="name"></param>
|
|
/// <param name="abbreviationStr"></param>
|
|
public SiUnit(Name name, String abbreviationStr)
|
|
{
|
|
Name = name;
|
|
AbbreviationStr = abbreviationStr;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Table of SI and NON-SI units
|
|
/// </summary>
|
|
public static readonly SiUnit[] SiUnitTbl =
|
|
{
|
|
new SiUnit(Name.UNITLESS, ""),
|
|
new SiUnit(Name.NORMALIZED, "norm"),
|
|
new SiUnit(Name.PERCENT, "%"),
|
|
new SiUnit(Name.VOLTAGE_V, "V"),
|
|
new SiUnit(Name.CURRENT_A, "A"),
|
|
new SiUnit(Name.ELECTRICAL_POWER_W, "W"),
|
|
new SiUnit(Name.ELECTRICAL_LOAD_Ah, "Ah"),
|
|
new SiUnit(Name.DISTANCE_m, "m"),
|
|
new SiUnit(Name.FLOW_RATE_cm_per_h, "m³/h"),
|
|
new SiUnit(Name.TEMPERATURE_degC, "°C"),
|
|
new SiUnit(Name.TIME_s, "s"),
|
|
new SiUnit(Name.PRESSURE_Pa, "Pa"),
|
|
new SiUnit(Name.FREQUENCY_Hz, "Hz"),
|
|
};
|
|
|
|
/// <summary>
|
|
/// Get the information string
|
|
/// </summary>
|
|
/// <param name="name"></param>
|
|
/// <returns>Unit string</returns>
|
|
/// <remarks date="2026-Jan-10" author="Thomas Wiedebusch">
|
|
/// - Initial.
|
|
/// </remarks>
|
|
public static String GetInfo(Name name)
|
|
{
|
|
return (from sit in SiUnitTbl
|
|
where sit.Name == name
|
|
select sit.AbbreviationStr).FirstOrDefault();
|
|
}
|
|
}
|
|
}
|