Commit 4fced962 authored by Michael Ott's avatar Michael Ott
Browse files

Add units for flow, pressure, percent

parent a79dd972
......@@ -56,10 +56,15 @@ typedef enum {
Unit_Hertz,
Unit_Joules,
Unit_WattHours,
Unit_CubicMetersPerSecond,
Unit_CubicMetersPerHour,
Unit_Bar,
Unit_Pascal,
/* Others */
Unit_Celsius,
Unit_Fahrenheit,
Unit_Percent,
/* 1e3 */
Unit_KiloHertz,
......@@ -89,8 +94,12 @@ typedef enum {
Unit_MilliAmpere,
Unit_MilliKelvin,
Unit_MilliWatt,
Unit_MilliJoules,
Unit_MilliVolt,
Unit_LitersPerSecond,
Unit_LitersPerHour,
Unit_MilliCelsius,
Unit_MilliBar,
/* 1e-6 */
Unit_MicroMeter,
......@@ -98,6 +107,7 @@ typedef enum {
Unit_MicroAmpere,
Unit_MicroKelvin,
Unit_MicroWatt,
Unit_MicroJoules,
Unit_MicroVolt,
Unit_MicroCelsius,
} Unit;
......
......@@ -83,43 +83,53 @@ typedef struct {
* the first entry (index 0) in the table must be an identity conversion.
*/
ConversionTableEntry conversionTable[] = {
/* 0 */ { Unit_None, "none", Unit_None, 1, 0},
/* 1 */ { Unit_Meter, "m", Unit_Meter, 1, 0 },
/* 2 */ { Unit_CentiMeter, "cm", Unit_Meter, -100, 0},
/* 3 */ { Unit_MilliMeter, "mm", Unit_Meter, -1000, 0 },
/* 4 */ { Unit_MicroMeter, "um", Unit_Meter, -1000000, 0 },
/* 5 */ { Unit_Second, "s", Unit_Second, 1, 0 },
/* 6 */ { Unit_MilliSecond, "ms", Unit_Second, -1000, 0 },
/* 7 */ { Unit_MicroSecond, "us", Unit_Second, -1000000, 0 },
/* 8 */ { Unit_Ampere, "A", Unit_Ampere, 1, 0 },
/* 9 */ { Unit_MilliAmpere, "mA", Unit_Ampere, -1000, 0 },
/* 10 */ { Unit_MicroAmpere, "uA", Unit_Ampere, -1000000, 0 },
/* 11 */ { Unit_Kelvin, "K", Unit_Kelvin, 1, 0 },
/* 12 */ { Unit_MilliKelvin, "mK", Unit_Kelvin, -1000, 0 },
/* 13 */ { Unit_MicroKelvin, "uK", Unit_Kelvin, -1000000, 0 },
/* 14 */ { Unit_Watt, "W", Unit_Watt, 1, 0 },
/* 15 */ { Unit_MilliWatt, "mW", Unit_Watt, -1000, 0 },
/* 16 */ { Unit_MicroWatt, "uW", Unit_Watt, -1000000, 0 },
/* 17 */ { Unit_KiloWatt, "kW", Unit_Watt, 1000, 0 },
/* 18 */ { Unit_MegaWatt, "MW", Unit_Watt, 1000000, 0 },
/* 19 */ { Unit_Volt, "V", Unit_Volt, 1, 0 },
/* 20 */ { Unit_MilliVolt, "mV", Unit_Volt, -1000, 0 },
/* 21 */ { Unit_MicroVolt, "uV", Unit_Volt, -1000000, 0 },
/* 22 */ { Unit_Celsius, "C", Unit_MilliKelvin, 1000, 273150 },
/* 23 */ { Unit_DeciCelsius, "dC", Unit_Celsius, -10, 0 },
/* 24 */ { Unit_CentiCelsius, "cC", Unit_Celsius, -100, 0},
/* 25 */ { Unit_MilliCelsius, "mC", Unit_Celsius, -1000, 0 },
/* 26 */ { Unit_MicroCelsius, "uC", Unit_Celsius, -1000000, 0},
/* 27 */ { Unit_Fahrenheit, "F", Unit_MilliKelvin, 555, 255116 },
/* 28 */ { Unit_Hertz, "Hz", Unit_Hertz, 1, 0},
/* 29 */ { Unit_KiloHertz, "kHz", Unit_Hertz, 1000, 0},
/* 30 */ { Unit_MegaHertz,"MHz", Unit_Hertz, 1000000, 0},
/* 31 */ { Unit_Joules, "J", Unit_Joules, 3600, 0},
/* 32 */ { Unit_KiloJoules, "kJ", Unit_Joules, 1000, 0},
/* 33 */ { Unit_MegaJoules, "MJ", Unit_Joules, 1000000, 0},
/* 34 */ { Unit_WattHours, "Wh", Unit_Joules, 3600, 0},
/* 35 */ { Unit_KiloWattHours, "kWh", Unit_WattHours, 1000, 0},
/* 36 */ { Unit_MegaWattHours, "MWh", Unit_WattHours, 1000000, 0},
{ Unit_None, "none", Unit_None, 1, 0},
{ Unit_Meter, "m", Unit_Meter, 1, 0 },
{ Unit_CentiMeter, "cm", Unit_Meter, -100, 0},
{ Unit_MilliMeter, "mm", Unit_Meter, -1000, 0 },
{ Unit_MicroMeter, "um", Unit_Meter, -1000000, 0 },
{ Unit_Second, "s", Unit_Second, 1, 0 },
{ Unit_MilliSecond, "ms", Unit_Second, -1000, 0 },
{ Unit_MicroSecond, "us", Unit_Second, -1000000, 0 },
{ Unit_Ampere, "A", Unit_Ampere, 1, 0 },
{ Unit_MilliAmpere, "mA", Unit_Ampere, -1000, 0 },
{ Unit_MicroAmpere, "uA", Unit_Ampere, -1000000, 0 },
{ Unit_Kelvin, "K", Unit_Kelvin, 1, 0 },
{ Unit_MilliKelvin, "mK", Unit_Kelvin, -1000, 0 },
{ Unit_MicroKelvin, "uK", Unit_Kelvin, -1000000, 0 },
{ Unit_Watt, "W", Unit_Watt, 1, 0 },
{ Unit_MilliWatt, "mW", Unit_Watt, -1000, 0 },
{ Unit_MicroWatt, "uW", Unit_Watt, -1000000, 0 },
{ Unit_KiloWatt, "kW", Unit_Watt, 1000, 0 },
{ Unit_MegaWatt, "MW", Unit_Watt, 1000000, 0 },
{ Unit_Volt, "V", Unit_Volt, 1, 0 },
{ Unit_MilliVolt, "mV", Unit_Volt, -1000, 0 },
{ Unit_MicroVolt, "uV", Unit_Volt, -1000000, 0 },
{ Unit_Celsius, "C", Unit_MilliKelvin, 1000, 273150 },
{ Unit_DeciCelsius, "dC", Unit_Celsius, -10, 0 },
{ Unit_CentiCelsius, "cC", Unit_Celsius, -100, 0},
{ Unit_MilliCelsius, "mC", Unit_Celsius, -1000, 0 },
{ Unit_MicroCelsius, "uC", Unit_Celsius, -1000000, 0},
{ Unit_Fahrenheit, "F", Unit_MilliKelvin, 555, 255116 },
{ Unit_Hertz, "Hz", Unit_Hertz, 1, 0},
{ Unit_KiloHertz, "kHz", Unit_Hertz, 1000, 0},
{ Unit_MegaHertz,"MHz", Unit_Hertz, 1000000, 0},
{ Unit_Joules, "J", Unit_Joules, 1, 0},
{ Unit_MilliJoules, "mJ", Unit_Joules, -1000, 0},
{ Unit_MicroJoules, "uJ", Unit_Joules, -1000000, 0},
{ Unit_KiloJoules, "kJ", Unit_Joules, 1000, 0},
{ Unit_MegaJoules, "MJ", Unit_Joules, 1000000, 0},
{ Unit_WattHours, "Wh", Unit_Joules, 3600, 0},
{ Unit_KiloWattHours, "kWh", Unit_WattHours, 1000, 0},
{ Unit_MegaWattHours, "MWh", Unit_WattHours, 1000000, 0},
{ Unit_CubicMetersPerSecond, "m3/s", Unit_CubicMetersPerHour, 3600, 0},
{ Unit_CubicMetersPerHour, "m3/h", Unit_LitersPerHour, 1000, 0},
{ Unit_LitersPerSecond, "l/s", Unit_LitersPerHour, 3600, 0},
{ Unit_LitersPerHour, "l/h", Unit_LitersPerHour, 1, 0},
{ Unit_Bar, "Bar", Unit_Bar, 1, 0},
{ Unit_MilliBar, "mBar", Unit_Bar, -1000, 0},
{ Unit_Pascal, "Pa", Unit_Bar, -10000, 0},
{ Unit_Percent, "%", Unit_Percent, 1, 0},
};
#define ConversionTableSize ((int)(sizeof(conversionTable)/sizeof(ConversionTableEntry)))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment