From f75f1d632139a6c415c298af69b16b159541c72f Mon Sep 17 00:00:00 2001 From: jpawlowski Date: Mon, 7 Nov 2016 06:19:04 +0000 Subject: [PATCH] Unit.pm: first part to integration dimensions git-svn-id: https://svn.fhem.de/fhem/trunk@12517 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/Unit.pm | 3076 ++++++++++++++++++++++++++------------------- 1 file changed, 1782 insertions(+), 1294 deletions(-) diff --git a/fhem/FHEM/Unit.pm b/fhem/FHEM/Unit.pm index fbe619f3b..d109a29ba 100644 --- a/fhem/FHEM/Unit.pm +++ b/fhem/FHEM/Unit.pm @@ -37,11 +37,13 @@ sub ReadingsUnit($$@) { $ud = Unit::GetDetailsFromReadingname( $n, $lang ); } - return $ud->{"unit"} if ( !$format && defined( $ud->{"unit"} ) ); - return $ud->{"unit_long"} - if ( $format && $format eq "1" && defined( $ud->{"unit_long"} ) ); - return $ud->{"unit_abbr"} - if ( $format && $format eq "2" && defined( $ud->{"unit_abbr"} ) ); + return $ud->{unit_symbol} + if ( !$format && defined( $ud->{unit_symbol} ) ); + return $ud->{unit} if ( !$format && defined( $ud->{unit} ) ); + return $ud->{unit_long} + if ( $format && $format eq "1" && defined( $ud->{unit_long} ) ); + return $ud->{unit_abbr} + if ( $format && $format eq "2" && defined( $ud->{unit_abbr} ) ); return $default; } @@ -420,1560 +422,2018 @@ sub CommandDeleteunit($$$) { package Unit; -my %unit_types = ( - 0 => "mathematics", - 1 => "temperature", - 2 => "pressure", - 3 => "currency", - 4 => "length", - 5 => "time", - 6 => "speed", - 7 => "weight", - 8 => "solar", - 9 => "volume", - 10 => "energy", +my %autoscale = ( + '0' => { format => '%i', scale => 1000, }, + '0.001' => { format => '%i', scale => 1000, }, + '0.1' => { format => '%.1f', scale => 1, }, + '10' => { format => '%i', scale => 1, }, + '1.0e3' => { format => '%.1f', scale => 0.001, }, + '2.0e3' => { format => '%i', scale => 0.001, }, + '1.0e6' => { format => '%.1f', scale => 0.001, }, + '2.0e6' => { format => '%i', scale => 0.001, }, ); -my %unitsDB = ( - - #TODO really translate all languages - - # math - "deg" => { - "unit_type" => 0, - "unit" => "°", - "unit_long" => { - "de" => "Grad", - "en" => "degree", - "fr" => "degree", - "nl" => "degree", - "pl" => "degree", +my %scales_m = ( + '1.0e-12' => { + 'scale' => 'p', + 'scale_long' => { + de => 'Piko', + en => 'pico', + fr => 'pico', + nl => 'pico', + pl => 'pico', }, }, - "pct" => { - "unit_type" => 0, - "unit" => "%", - "unit_long" => { - "de" => "Prozent", - "en" => "percent", - "fr" => "percent", - "nl" => "percent", - "pl" => "percent", + '1.0e-9' => { + 'scale' => 'n', + 'scale_long' => { + de => 'Nano', + en => 'nano', + fr => 'nano', + nl => 'nano', + pl => 'nano', + }, + }, + + '1.0e-6' => { + 'scale' => 'μ', + 'scale_long' => { + de => 'Mikro', + en => 'micro', + fr => 'micro', + nl => 'micro', + pl => 'micro', + }, + }, + + '1.0e-3' => { + 'scale' => 'm', + 'scale_long' => { + de => 'Milli', + en => 'mili', + fr => 'mili', + nl => 'mili', + pl => 'mili', + }, + }, + + '1.0e-2' => { + 'scale' => 'c', + 'scale_long' => { + de => 'Zenti', + en => 'centi', + fr => 'centi', + nl => 'centi', + pl => 'centi', + }, + }, + + '1.0e-1' => { + 'scale' => 'd', + 'scale_long' => { + de => 'Dezi', + en => 'deci', + fr => 'deci', + nl => 'deci', + pl => 'deci', + }, + }, + + '1.0e0' => { + 'scale' => '', + 'scale_long' => '', + }, + + '1.0e1' => { + 'scale' => 'da', + 'scale_long' => { + de => 'Deka', + en => 'deca', + fr => 'deca', + nl => 'deca', + pl => 'deca', + }, + }, + + '1.0e2' => { + 'scale' => 'h', + 'scale_long' => { + de => 'Hekto', + en => 'hecto', + fr => 'hecto', + nl => 'hecto', + pl => 'hecto', + }, + }, + + '1.0e3' => { + 'scale' => 'k', + 'scale_long' => { + de => 'Kilo', + en => 'kilo', + fr => 'kilo', + nl => 'kilo', + pl => 'kilo', + }, + }, + + '1.0e6' => { + 'scale' => 'M', + 'scale_long' => { + de => 'Mega', + en => 'mega', + fr => 'mega', + nl => 'mega', + pl => 'mega', + }, + }, +); + +my %scales_sq = ( + 'scale' => '2', + 'scale_long' => { + de => 'Quadrat', + en => 'square', + fr => 'square', + nl => 'square', + pl => 'square', + }, +); + +my %scales_cu = ( + 'scale' => '3', + 'scale_long' => { + de => 'Kubik', + en => 'cubic', + fr => 'cubic', + nl => 'cubic', + pl => 'cubic', + }, +); + +my %unit_base = ( + + # based on https://de.wikipedia.org/wiki/Liste_physikalischer_Gr%C3%B6%C3%9Fen + + 0 => { + dimension => 'L', + formula_symbol => 'l', + base_unit => 'm', + base_parameter => { + de => 'Länge', + en => 'length', + fr => 'length', + nl => 'length', + pl => 'length', + }, + }, + + 1 => { + dimension => 'M', + formula_symbol => 'm', + base_unit => 'kg', + base_parameter => { + de => 'Masse', + en => 'mass', + fr => 'mass', + nl => 'mass', + pl => 'mass', + }, + }, + + 2 => { + dimension => 'T', + formula_symbol => 't', + base_unit => 's', + base_parameter => { + de => 'Zeit', + en => 'time', + fr => 'time', + nl => 'time', + pl => 'time', + }, + }, + + 3 => { + dimension => 'I', + formula_symbol => 'i', + base_unit => 'a', + base_parameter => { + de => 'elektrische Stromstärke', + en => 'electric current', + fr => 'electric current', + nl => 'electric current', + pl => 'electric current', + }, + }, + + 4 => { + dimension => 'θ', + formula_symbol => 'T', + base_unit => 'k', + base_parameter => { + de => 'absolute Temperatur', + en => 'absolute temperature', + fr => 'absolute temperature', + nl => 'absolute temperature', + pl => 'absolute temperature', + }, + }, + + 5 => { + dimension => 'N', + formula_symbol => 'n', + base_unit => 'mol', + base_parameter => { + de => 'Stoffmenge', + en => 'amount of substance', + fr => 'amount of substance', + nl => 'amount of substance', + pl => 'amount of substance', + }, + }, + + 6 => { + dimension => 'J', + formula_symbol => 'Iv', + base_unit => 'cd', + base_parameter => { + de => 'Lichtstärke', + en => 'luminous intensity', + fr => 'luminous intensity', + nl => 'luminous intensity', + pl => 'luminous intensity', + }, + }, + + 7 => { + dimension => 'M L^2 T^−2', + formula_symbol => 'E', + base_unit => 'j', + base_parameter => { + de => 'Energie', + en => 'energy', + fr => 'energy', + nl => 'energy', + pl => 'energy', + }, + }, + + 8 => { + dimension => 'T^−1', + formula_symbol => 'f', + base_unit => 'hz', + base_parameter => { + de => 'Frequenz', + en => 'frequency', + fr => 'frequency', + nl => 'frequency', + pl => 'frequency', + }, + }, + + 9 => { + dimension => 'M L^2 T^−3', + formula_symbol => 'P', + base_unit => 'w', + base_parameter => { + de => 'Leistung', + en => 'power', + fr => 'power', + nl => 'power', + pl => 'power', + }, + }, + + 10 => { + dimension => 'M L^−1 T^−2', + formula_symbol => 'p', + base_unit => 'pa', + base_parameter => { + de => 'Druck', + en => 'pressure', + fr => 'pressure', + nl => 'pressure', + pl => 'pressure', + }, + }, + + 11 => { + dimension => 'M L^−1 T^−2', + formula_symbol => 'pabs', + base_unit => 'pabs', + base_parameter => { + de => 'absoluter Druck', + en => 'absolute pressure', + fr => 'absolute pressure', + nl => 'absolute pressure', + pl => 'absolute pressure', + }, + }, + + 12 => { + dimension => 'M L^−1 T^−2', + formula_symbol => 'pamb', + base_unit => 'pamb', + base_parameter => { + de => 'Luftdruck', + en => 'air pressure', + fr => 'air pressure', + nl => 'air pressure', + pl => 'air pressure', + }, + }, + + 13 => { + dimension => 'M L^2 T^−3 I^−1', + formula_symbol => 'U', + base_unit => 'v', + base_parameter => { + de => 'elektrische Spannung', + en => 'electric voltage', + fr => 'electric voltage', + nl => 'electric voltage', + pl => 'electric voltage', + }, + }, + + 14 => { + dimension => '1', + formula_symbol => '', + base_unit => 'rad', + base_parameter => { + de => 'ebener Winkel', + en => 'plane angular', + fr => 'plane angular', + nl => 'plane angular', + pl => 'plane angular', + }, + }, + + 15 => { + dimension => 'L T^−1', + formula_symbol => 'v', + base_unit => 'kmh', + base_parameter => { + de => 'Geschwindigkeit', + en => 'speed', + fr => 'speed', + nl => 'speed', + pl => 'speed', + }, + }, + + 16 => { + dimension => 'L^−2 J', + formula_symbol => 'Ev', + base_unit => 'lx', + base_parameter => { + de => 'Beleuchtungsstärke', + en => 'illumination intensity', + fr => 'illumination intensity', + nl => 'illumination intensity', + pl => 'illumination intensity', + }, + }, + + 17 => { + dimension => 'J', + formula_symbol => 'F', + base_unit => 'lm', + base_parameter => { + de => 'Lichtstrom', + en => 'luminous flux', + fr => 'luminous flux', + nl => 'luminous flux', + pl => 'luminous flux', + }, + }, + + 18 => { + dimension => 'L^3', + formula_symbol => 'V', + base_unit => 'm3', + base_parameter => { + de => 'Volumen', + en => 'volume', + fr => 'volume', + nl => 'volume', + pl => 'volume', + }, + }, + + 19 => { + dimension => '1', + formula_symbol => 'B', + base_unit => 'b', + base_parameter => { + de => 'Logarithmische Größe', + en => 'logarithmic level', + fr => 'logarithmic level', + nl => 'logarithmic level', + pl => 'logarithmic level', + }, + }, + + 20 => { + dimension => 'I T', + formula_symbol => 'C', + base_unit => 'coul', + base_parameter => { + de => 'elektrische Ladung', + en => 'electric charge', + fr => 'electric charge', + nl => 'electric charge', + pl => 'electric charge', + }, + }, + + 21 => { + dimension => '', + formula_symbol => 'F', + base_unit => 'far', + base_parameter => { + de => 'elektrische Kapazität', + en => 'electric capacity', + fr => 'electric capacity', + nl => 'electric capacity', + pl => 'electric capacity', + }, + }, + + 22 => { + dimension => '', + formula_symbol => 'F', + base_unit => 'far', + base_parameter => { + de => 'elektrische Widerstand', + en => 'electric resistance', + fr => 'electric resistance', + nl => 'electric resistance', + pl => 'electric resistance', + }, + }, +); + +#TODO really translate all languages +my %unitsDB = ( + + pct => { + + unit_symbol => '%', + unit_long => { + de => 'Prozent', + en => 'percent', + fr => 'percent', + nl => 'percent', + pl => 'percent', + }, + + txt_format => '%value% %unit_symbol%', + }, + + gon => { + + base_ref => 14, + unit_symbol => '°', + unit => 'gon', + unit_long => { + de => 'Grad', + en => 'gradians', + fr => 'gradians', + nl => 'gradians', + pl => 'gradians', + }, + txt_format => '%value%%unit_symbol%', + }, + + rad => { + base_ref => 14, + unit => 'rad', + unit_long => { + de => 'Radiant', + en => 'radiant', + fr => 'radiant', + nl => 'radiant', + pl => 'radiant', }, }, # temperature - "c" => { - "unit_type" => 1, - "unit" => "°C", - "unit_long" => { - "de" => "Grad Celsius", - "en" => "Degree Celsius", - "fr" => "Degree Celsius", - "nl" => "Degree Celsius", - "pl" => "Degree Celsius", + c => { + base_ref => 2, + unit_symbol => chr(0xC2) . chr(0xB0) . 'C', + unit => 'C', + unit_long => { + de => 'Grad Celsius', + en => 'Degrees Celsius', + fr => 'Degrees Celsius', + nl => 'Degrees Celsius', + pl => 'Degrees Celsius', }, + txt_format => '%value%%unit_symbol%', }, - "f" => { - "unit_type" => 1, - "unit" => "°F", - "unit_long" => { - "de" => "Grad Fahrenheit", - "en" => "Degree Fahrenheit", - "fr" => "Degree Fahrenheit", - "nl" => "Degree Fahrenheit", - "pl" => "Degree Fahrenheit", + f => { + base_ref => 2, + unit_symbol => chr(0xC2) . chr(0xB0) . 'F', + unit => 'F', + unit_long => { + de => 'Grad Fahrenheit', + en => 'Degree Fahrenheit', + fr => 'Degree Fahrenheit', + nl => 'Degree Fahrenheit', + pl => 'Degree Fahrenheit', }, + txt_format => '%value% %unit_symbol%', }, - "k" => { - "unit_type" => 1, - "unit" => "K", - "unit_long" => { - "de" => "Kelvin", - "en" => "Kelvin", - "fr" => "Kelvin", - "nl" => "Kelvin", - "pl" => "Kelvin", + k => { + base_ref => 2, + unit => 'K', + unit_long => { + de => 'Kelvin', + en => 'Kelvin', + fr => 'Kelvin', + nl => 'Kelvin', + pl => 'Kelvin', }, }, # pressure - "bar" => { - "unit_type" => 3, - "unit" => "bar", - "unit_long" => { - "de" => "Bar", - "en" => "Bar", - "fr" => "Bar", - "nl" => "Bar", - "pl" => "Bar", + bar => { + base_ref => 10, + unit_scale_m => '1.0e0', + unit => 'bar', + unit_long => { + de => 'Bar', + en => 'Bar', + fr => 'Bar', + nl => 'Bar', + pl => 'Bar', }, }, - "pa" => { - "unit_type" => 3, - "unit" => "Pa", - "unit_long" => { - "de" => "Pascal", - "en" => "Pascal", - "fr" => "Pascal", - "nl" => "Pascal", - "pl" => "Pascal", + mbar => { + unit_ref => 'bar', + unit_scale_m => '1.0e-3', + }, + + pa => { + base_ref => 10, + unit_scale_m => '1.0e0', + unit => 'Pa', + unit_long => { + de => 'Pascal', + en => 'Pascal', + fr => 'Pascal', + nl => 'Pascal', + pl => 'Pascal', }, }, - "hpa" => { - "unit_type" => 3, - "unit" => "hPa", - "unit_long" => { - "de" => "Hecto Pascal", - "en" => "Hecto Pascal", - "fr" => "Hecto Pascal", - "nl" => "Hecto Pascal", - "pl" => "Hecto Pascal", + hpa => { + unit_ref => 'pa', + unit_scale_m => '1.0e2', + }, + + pamb => { + base_ref => 12, + unit_scale_m => '1.0e0', + unit => 'Pa', + unit_long => { + de => 'Pascal', + en => 'Pascal', + fr => 'Pascal', + nl => 'Pascal', + pl => 'Pascal', }, }, - "inhg" => { - "unit_type" => 3, - "unit" => "inHg", - "unit_long" => { - "de" => "Zoll Quecksilbersäule", - "en" => "Inches of Mercury", - "fr" => "Inches of Mercury", - "nl" => "Inches of Mercury", - "pl" => "Inches of Mercury", + hpamb => { + unit_ref => 'pamb', + unit_scale_m => '1.0e2', + }, + + inhg => { + base_ref => 12, + unit => 'inHg', + unit_long => { + de => 'Zoll Quecksilbersäule', + en => 'Inches of Mercury', + fr => 'Inches of Mercury', + nl => 'Inches of Mercury', + pl => 'Inches of Mercury', }, }, - "mmhg" => { - "unit_type" => 3, - "unit" => "mmHg", - "unit_long" => { - "de" => "Millimeter Quecksilbersäule", - "en" => "Milimeter of Mercury", - "fr" => "Milimeter of Mercury", - "nl" => "Milimeter of Mercury", - "pl" => "Milimeter of Mercury", - }, - }, - - "torr" => { - "unit_type" => 3, - "unit" => "Torr", - }, - - "psi" => { - "unit_type" => 3, - "unit" => "psi", - "unit_long" => { - "de" => "Pfund pro Quadratzoll", - "en" => "Pound-force per square inch", - "fr" => "Pound-force per square inch", - "nl" => "Pound-force per square inch", - "pl" => "Pound-force per square inch", - }, - }, - - "psia" => { - "unit_type" => 3, - "unit" => "psia", - "unit_long" => { - "de" => "Pfund pro Quadratzoll absolut", - "en" => "pound-force per square inch absolute", - "fr" => "pound-force per square inch absolute", - "nl" => "pound-force per square inch absolute", - "pl" => "pound-force per square inch absolute", - }, - }, - - "psig" => { - "unit_type" => 3, - "unit" => "psig", - "unit_long" => { - "de" => "Pfund pro Quadratzoll relativ", - "en" => "pounds-force per square inch gauge", - "fr" => "pounds-force per square inch gauge", - "nl" => "pounds-force per square inch gauge", - "pl" => "pounds-force per square inch gauge", + mmhg => { + base_ref => 12, + unit => 'mmHg', + unit_long => { + de => 'Millimeter Quecksilbersäule', + en => 'Milimeter of Mercury', + fr => 'Milimeter of Mercury', + nl => 'Milimeter of Mercury', + pl => 'Milimeter of Mercury', }, }, # length - "km" => { - "unit_type" => 4, - "unit" => "km", - "unit_long" => { - "de" => "Kilometer", - "en" => "kilometer", - "fr" => "kilometer", - "nl" => "kilometer", - "pl" => "kilometer", + km => { + unit_ref => 'm', + unit_scale_m => '1.0e3', + }, + + hm => { + unit_ref => 'm', + unit_scale_m => '1.0e2', + }, + + dam => { + unit_ref => 'm', + unit_scale_m => '1.0e1', + }, + + m => { + base_ref => 0, + unit_scale_m => '1.0e0', + unit => 'm', + unit_long => { + de => 'Meter', + en => 'meter', + fr => 'meter', + nl => 'meter', + pl => 'meter', }, }, - "m" => { - "unit_type" => 4, - "unit" => "m", - "unit_long" => { - "de" => "Meter", - "en" => "meter", - "fr" => "meter", - "nl" => "meter", - "pl" => "meter", + dm => { + unit_ref => 'm', + unit_scale_m => '1.0e-1', + }, + + cm => { + unit_ref => 'm', + unit_scale_m => '1.0e-2', + }, + + mm => { + unit_ref => 'm', + unit_scale_m => '1.0e-3', + }, + + um => { + unit_ref => 'm', + unit_scale_m => '1.0e-6', + }, + + nm => { + unit_ref => 'm', + unit_scale_m => '1.0e-9', + }, + + pm => { + unit_ref => 'm', + unit_scale_m => '1.0e-12', + }, + + fm => { + unit_ref => 'm', + unit_scale_m => '1.0e-15', + }, + + in => { + base_ref => 4, + unit_symbol => '″', + unit => 'in', + unit_long => { + de => 'Zoll', + en => 'inch', + fr => 'inch', + nl => 'inch', + pl => 'inch', + }, + unit_long_pl => { + de => 'Zoll', + en => 'inches', + fr => 'inches', + nl => 'inches', + pl => 'inches', + }, + txt_format => '%value%%unit_symbol%', + txt_format_long => '%value% %unit_long%', + txt_format_long_pl => '%value% %unit_long_pl%', + }, + + ft => { + base_ref => 0, + unit_symbol => '′', + unit => 'ft', + unit_long => { + de => 'Fuss', + en => 'foot', + fr => 'foot', + nl => 'foot', + pl => 'foot', + }, + unit_long_pl => { + de => 'Fuss', + en => 'feet', + fr => 'feet', + nl => 'feet', + pl => 'feet', + }, + txt_format => '%value%%unit_symbol%', + txt_format_long => '%value% %unit_long%', + txt_format_long_pl => '%value% %unit_long_pl%', + }, + + yd => { + base_ref => 0, + unit => 'yd', + unit_long => { + de => 'Yard', + en => 'yard', + fr => 'yard', + nl => 'yard', + pl => 'yard', + }, + unit_long_pl => { + de => 'Yards', + en => 'yards', + fr => 'yards', + nl => 'yards', + pl => 'yards', }, }, - "mm" => { - "unit_type" => 4, - "unit" => "mm", - "unit_long" => { - "de" => "Millimeter", - "en" => "milimeter", - "fr" => "milimeter", - "nl" => "milimeter", - "pl" => "milimeter", - }, - }, - - "cm" => { - "unit_type" => 4, - "unit" => "cm", - "unit_long" => { - "de" => "Zentimeter", - "en" => "centimeter", - "fr" => "centimeter", - "nl" => "centimeter", - "pl" => "centimeter", - }, - }, - - "in" => { - "unit_type" => 4, - "unit_symbol" => "″", - "unit" => "in", - "unit_long" => { - "de" => "Zoll", - "en" => "inch", - "fr" => "inch", - "nl" => "inch", - "pl" => "inch", - }, - "unit_long_pl" => { - "de" => "Zoll", - "en" => "inches", - "fr" => "inches", - "nl" => "inches", - "pl" => "inches", - }, - "txt_format" => '%value%%unit_symbol%', - "txt_format_long" => '%value% %unit_long%', - "txt_format_long_pl" => '%value% %unit_long_pl%', - }, - - "ft" => { - "unit_type" => 4, - "unit_symbol" => "′", - "unit" => "ft", - "unit_long" => { - "de" => "Fuss", - "en" => "foot", - "fr" => "foot", - "nl" => "foot", - "pl" => "foot", - }, - "unit_long_pl" => { - "de" => "Fuss", - "en" => "feet", - "fr" => "feet", - "nl" => "feet", - "pl" => "feet", - }, - "txt_format" => '%value%%unit_symbol%', - "txt_format_long" => '%value% %unit_long%', - "txt_format_long_pl" => '%value% %unit_long_pl%', - }, - - "yd" => { - "unit_type" => 4, - "unit" => "yd", - "unit_long" => { - "de" => "Yard", - "en" => "yard", - "fr" => "yard", - "nl" => "yard", - "pl" => "yard", - }, - "unit_long_pl" => { - "de" => "Yards", - "en" => "yards", - "fr" => "yards", - "nl" => "yards", - "pl" => "yards", - }, - }, - - "mi" => { - "unit_type" => 4, - "unit" => "mi", - "unit_long" => { - "de" => "Meilen", - "en" => "miles", - "fr" => "miles", - "nl" => "miles", - "pl" => "miles", + mi => { + base_ref => 0, + unit => 'mi', + unit_long => { + de => 'Meilen', + en => 'miles', + fr => 'miles', + nl => 'miles', + pl => 'miles', }, }, # time - "sec" => { - "unit_type" => 5, - "unit" => { - "de" => "s", - "en" => "s", - "fr" => "s", - "nl" => "s", - "pl" => "s", + sec => { + base_ref => 2, + unit_scale_t => '1', + unit => { + de => 's', + en => 's', + fr => 's', + nl => 'sec', + pl => 'sec', }, - "unit_long" => { - "de" => "Sekunde", - "en" => "second", - "fr" => "second", - "nl" => "second", - "pl" => "second", + unit_long => { + de => 'Sekunde', + en => 'second', + fr => 'second', + nl => 'second', + pl => 'second', }, - "unit_long_pl" => { - "de" => "Sekunden", - "en" => "seconds", - "fr" => "seconds", - "nl" => "seconds", - "pl" => "seconds", + unit_long_pl => { + de => 'Sekunden', + en => 'seconds', + fr => 'seconds', + nl => 'seconds', + pl => 'seconds', }, }, - "min" => { - "unit_type" => 5, - "unit" => { - "de" => "Min", - "en" => "min", - "fr" => "min", - "nl" => "min", - "pl" => "min", + min => { + base_ref => 2, + unit_scale_t => '60', + unit => { + de => 'Min', + en => 'min', + fr => 'min', + nl => 'min', + pl => 'min', }, - "unit_long" => { - "de" => "Minute", - "en" => "minute", - "fr" => "minute", - "nl" => "minute", - "pl" => "minute", + unit_long => { + de => 'Minute', + en => 'minute', + fr => 'minute', + nl => 'minute', + pl => 'minute', }, - "unit_long_pl" => { - "de" => "Minuten", - "en" => "minutes", - "fr" => "minutes", - "nl" => "minutes", - "pl" => "minutes", + unit_long_pl => { + de => 'Minuten', + en => 'minutes', + fr => 'minutes', + nl => 'minutes', + pl => 'minutes', }, }, - "hr" => { - "unit_type" => 5, - "unit" => { - "de" => "Std", - "en" => "hr", - "fr" => "hr", - "nl" => "hr", - "pl" => "hr", + hr => { + base_ref => 2, + unit_scale_t => '3600', + unit => 'h', + unit_long => { + de => 'Stunde', + en => 'hour', + fr => 'hour', + nl => 'hour', + pl => 'hour', }, - "unit_long" => { - "de" => "Stunde", - "en" => "hour", - "fr" => "hour", - "nl" => "hour", - "pl" => "hour", - }, - "unit_long_pl" => { - "de" => "Stunden", - "en" => "hours", - "fr" => "hours", - "nl" => "hours", - "pl" => "hours", + unit_long_pl => { + de => 'Stunden', + en => 'hours', + fr => 'hours', + nl => 'hours', + pl => 'hours', }, }, - "d" => { - "unit_type" => 5, - "unit" => { - "de" => "T", - "en" => "d", - "fr" => "d", - "nl" => "d", - "pl" => "d", + d => { + base_ref => 2, + unit_scale_t => '86400', + unit => { + de => 'T', + en => 'd', + fr => 'd', + nl => 'd', + pl => 'd', }, - "unit_long" => { - "de" => "Tag", - "en" => "day", - "fr" => "day", - "nl" => "day", - "pl" => "day", + unit_long => { + de => 'Tag', + en => 'day', + fr => 'day', + nl => 'day', + pl => 'day', }, - "unit_long_pl" => { - "de" => "Tage", - "en" => "days", - "fr" => "days", - "nl" => "days", - "pl" => "days", + unit_long_pl => { + de => 'Tage', + en => 'days', + fr => 'days', + nl => 'days', + pl => 'days', }, }, - "w" => { - "unit_type" => 5, - "unit" => { - "de" => "W", - "en" => "w", - "fr" => "w", - "nl" => "w", - "pl" => "w", + w => { + base_ref => 2, + unit_scale_t => '604800', + unit => { + de => 'W', + en => 'w', + fr => 'w', + nl => 'w', + pl => 'w', }, - "unit_long" => { - "de" => "Woche", - "en" => "week", - "fr" => "week", - "nl" => "week", - "pl" => "week", + unit_long => { + de => 'Woche', + en => 'week', + fr => 'week', + nl => 'week', + pl => 'week', }, - "unit_long_pl" => { - "de" => "Wochen", - "en" => "weeks", - "fr" => "weeks", - "nl" => "weeks", - "pl" => "weeks", + unit_long_pl => { + de => 'Wochen', + en => 'weeks', + fr => 'weeks', + nl => 'weeks', + pl => 'weeks', }, }, - "m" => { - "unit_type" => 5, - "unit" => { - "de" => "M", - "en" => "m", - "fr" => "m", - "nl" => "m", - "pl" => "m", + mon => { + base_ref => 2, + unit_scale_t => '2592000', + unit => { + de => 'M', + en => 'm', + fr => 'm', + nl => 'm', + pl => 'm', }, - "unit_long" => { - "de" => "Monat", - "en" => "month", - "fr" => "month", - "nl" => "month", - "pl" => "month", + unit_long => { + de => 'Monat', + en => 'month', + fr => 'month', + nl => 'month', + pl => 'month', }, - "unit_long_pl" => { - "de" => "Monate", - "en" => "Monat", - "fr" => "Monat", - "nl" => "Monat", - "pl" => "Monat", + unit_long_pl => { + de => 'Monate', + en => 'Monat', + fr => 'Monat', + nl => 'Monat', + pl => 'Monat', }, }, - "y" => { - "unit_type" => 5, - "unit" => { - "de" => "J", - "en" => "y", - "fr" => "y", - "nl" => "y", - "pl" => "y", + y => { + base_ref => 2, + unit_scale_t => '31536000', + unit => { + de => 'J', + en => 'y', + fr => 'y', + nl => 'y', + pl => 'y', }, - "unit_long" => { - "de" => "Jahr", - "en" => "year", - "fr" => "year", - "nl" => "year", - "pl" => "year", + unit_long => { + de => 'Jahr', + en => 'year', + fr => 'year', + nl => 'year', + pl => 'year', }, - "unit_long_pl" => { - "de" => "Jahre", - "en" => "years", - "fr" => "years", - "nl" => "years", - "pl" => "years", + unit_long_pl => { + de => 'Jahre', + en => 'years', + fr => 'years', + nl => 'years', + pl => 'years', }, }, # speed - "bft" => { - "unit_type" => 6, - "unit" => "bft", - "unit_long" => { - "de" => "Windstärke", - "en" => "wind force", - "fr" => "wind force", - "nl" => "wind force", - "pl" => "wind force", + bft => { + base_ref => 15, + unit => 'bft', + unit_long => { + de => 'Windstärke', + en => 'wind force', + fr => 'wind force', + nl => 'wind force', + pl => 'wind force', }, - "txt_format_long" => '%unit_long% %value%', + txt_format_long => '%unit_long% %value%', }, - "fts" => { - "unit_type" => 6, - "unit" => "ft/s", - "unit_long" => { - "de" => "Feet pro Sekunde", - "en" => "feets per second", - "fr" => "feets per second", - "nl" => "feets per second", - "pl" => "feets per second", + kn => { + base_ref => 15, + unit => 'kn', + unit_long => { + de => 'Knoten', + en => 'knots', + fr => 'knots', + nl => 'knots', + pl => 'knots', }, }, - "kmh" => { - "unit_type" => 6, - "unit" => "km/h", - "unit_long" => { - "de" => "Kilometer pro Stunde", - "en" => "kilometer per hour", - "fr" => "kilometer per hour", - "nl" => "kilometer per hour", - "pl" => "kilometer per hour", + fts => { + base_ref => 15, + unit_ref => 'ft', + unit_ref_t => 'sec', + txt_format => '%value% %unit%/%unit_t%', + txt_format_long => { + de => '%value% %unit_long% pro %unit_long_t%', + en => '%value% %unit_long% per %unit_long_t%', + fr => '%value% %unit_long% per %unit_long_t%', + nl => '%value% %unit_long% per %unit_long_t%', + pl => '%value% %unit_long% per %unit_long_t%', + }, + txt_format_long_pl => { + de => '%value% %unit_long_pl% pro %unit_long_t%', + en => '%value% %unit_long_pl% per %unit_long_t%', + fr => '%value% %unit_long_pl% per %unit_long_t%', + nl => '%value% %unit_long_pl% per %unit_long_t%', + pl => '%value% %unit_long_pl% per %unit_long_t%', }, }, - "kn" => { - "unit_type" => 6, - "unit" => "kn", - "unit_long" => { - "de" => "Knoten", - "en" => "knots", - "fr" => "knots", - "nl" => "knots", - "pl" => "knots", + mph => { + base_ref => 15, + unit_ref => 'mi', + unit_ref_t => 'hr', + txt_format => '%value% %unit%/%unit_t%', + txt_format_long => { + de => '%value% %unit_long% pro %unit_long_t%', + en => '%value% %unit_long% per %unit_long_t%', + fr => '%value% %unit_long% per %unit_long_t%', + nl => '%value% %unit_long% per %unit_long_t%', + pl => '%value% %unit_long% per %unit_long_t%', + }, + txt_format_long_pl => { + de => '%value% %unit_long_pl% pro %unit_long_t%', + en => '%value% %unit_long_pl% per %unit_long_t%', + fr => '%value% %unit_long_pl% per %unit_long_t%', + nl => '%value% %unit_long_pl% per %unit_long_t%', + pl => '%value% %unit_long_pl% per %unit_long_t%', }, }, - "mph" => { - "unit_type" => 6, - "unit" => "mi/h", - "unit_long" => { - "de" => "Meilen pro Stunde", - "en" => "miles per hour", - "fr" => "miles per hour", - "nl" => "miles per hour", - "pl" => "miles per hour", + kmh => { + base_ref => 15, + unit_ref => 'm', + unit_ref_t => 'hr', + unit_scale_m => '1.0e3', + txt_format => '%value% %unit%/%unit_t%', + txt_format_long => { + de => '%value% %unit_long% pro %unit_long_t%', + en => '%value% %unit_long% per %unit_long_t%', + fr => '%value% %unit_long% per %unit_long_t%', + nl => '%value% %unit_long% per %unit_long_t%', + pl => '%value% %unit_long% per %unit_long_t%', + }, + txt_format_long_pl => { + de => '%value% %unit_long_pl% pro %unit_long_t%', + en => '%value% %unit_long_pl% per %unit_long_t%', + fr => '%value% %unit_long_pl% per %unit_long_t%', + nl => '%value% %unit_long_pl% per %unit_long_t%', + pl => '%value% %unit_long_pl% per %unit_long_t%', }, }, - "mps" => { - "unit_type" => 6, - "unit" => "m/s", - "unit_long" => { - "de" => "Meter pro Sekunde", - "en" => "meter per second", - "fr" => "meter per second", - "nl" => "meter per second", - "pl" => "meter per second", + mps => { + base_ref => 15, + unit_ref => 'm', + unit_ref_t => 'sec', + unit_scale_m => '1.0e0', + txt_format => '%value% %unit%/%unit_t%', + txt_format_long => { + de => '%value% %unit_long% pro %unit_long_t%', + en => '%value% %unit_long% per %unit_long_t%', + fr => '%value% %unit_long% per %unit_long_t%', + nl => '%value% %unit_long% per %unit_long_t%', + pl => '%value% %unit_long% per %unit_long_t%', + }, + txt_format_long_pl => { + de => '%value% %unit_long_pl% pro %unit_long_t%', + en => '%value% %unit_long_pl% per %unit_long_t%', + fr => '%value% %unit_long_pl% per %unit_long_t%', + nl => '%value% %unit_long_pl% per %unit_long_t%', + pl => '%value% %unit_long_pl% per %unit_long_t%', }, }, # weight - "mol" => { - "unit_type" => 7, - "unit" => "mol", + mol => { + base_ref => 5, + unit => 'mol', }, - "n" => { - "unit_type" => 7, - "unit" => "N", - "unit_long" => { - "de" => "Newton", - "en" => "Newton", - "fr" => "Newton", - "nl" => "Newton", - "pl" => "Newton", + pg => { + unit_ref => 'g', + unit_scale_m => "1.0e-12", + }, + + ng => { + unit_ref => 'g', + unit_scale_m => "1.0e-9", + }, + + ug => { + unit_ref => 'g', + unit_scale_m => "1.0e-6", + }, + + mg => { + unit_ref => 'g', + unit_scale_m => "1.0e-3", + }, + + cg => { + unit_ref => 'g', + unit_scale_m => "1.0e-2", + }, + + dg => { + unit_ref => 'g', + unit_scale_m => "1.0e-1", + }, + + g => { + base_ref => 1, + unit_scale_m => "1.0e0", + unit => 'g', + unit_long => { + de => 'Gramm', + en => 'gram', + fr => 'gram', + nl => 'gram', + pl => 'gram', }, }, - "g" => { - "unit_type" => 7, - "unit" => "g", - "unit_long" => { - "de" => "Gramm", - "en" => "gram", - "fr" => "gram", - "nl" => "gram", - "pl" => "gram", + kg => { + unit_ref => 'g', + unit_scale_m => "1.0e3", + }, + + t => { + unit_ref => 'g', + unit_scale_m => "1.0e6", + unit => 't', + unit_long => { + de => 'Tonne', + en => 'ton', + fr => 'ton', + nl => 'ton', + pl => 'ton', + }, + unit_long_pl => { + de => 'Tonnen', + en => 'tons', + fr => 'tons', + nl => 'tons', + pl => 'tons', }, }, - "dg" => { - "unit_type" => 7, - "unit" => "dg", - "unit_long" => { - "de" => "Dekagramm", - "en" => "dekagram", - "fr" => "dekagram", - "nl" => "dekagram", - "pl" => "dekagram", + lb => { + base_ref => 1, + unit => 'lb', + unit_long => { + de => 'Pfund', + en => 'pound', + fr => 'pound', + nl => 'pound', + pl => 'pound', }, }, - "kg" => { - "unit_type" => 7, - "unit" => "kg", - "unit_long" => { - "de" => "Kilogramm", - "en" => "kilogram", - "fr" => "kilogram", - "nl" => "kilogram", - "pl" => "kilogram", + lbs => { + base_ref => 1, + unit => 'lbs', + unit_long => { + de => 'Pfund', + en => 'pound', + fr => 'pound', + nl => 'pound', + pl => 'pound', }, }, - "t" => { - "unit_type" => 7, - "unit" => "t", - "unit_long" => { - "de" => "Tonne", - "en" => "ton", - "fr" => "ton", - "nl" => "ton", - "pl" => "ton", - }, - "unit_long_pl" => { - "de" => "Tonnen", - "en" => "tons", - "fr" => "tons", - "nl" => "tons", - "pl" => "tons", + # luminous intensity + cd => { + base_ref => 6, + unit => 'cd', + unit_long => { + de => 'Candela', + en => 'Candela', + fr => 'Candela', + nl => 'Candela', + pl => 'Candela', }, }, - "lb" => { - "unit_type" => 7, - "unit" => "lb", - "unit_long" => { - "de" => "Pfund", - "en" => "pound", - "fr" => "pound", - "nl" => "pound", - "pl" => "pound", + # illumination intensity + lx => { + base_ref => 16, + unit => 'lx', + unit_long => { + de => 'Lux', + en => 'Lux', + fr => 'Lux', + nl => 'Lux', + pl => 'Lux', }, }, - "lbs" => { - "unit_type" => 7, - "unit" => "lbs", - "unit_long" => { - "de" => "Pfund", - "en" => "pound", - "fr" => "pound", - "nl" => "pound", - "pl" => "pound", + # luminous flux + lm => { + base_ref => 17, + unit => 'lm', + unit_long => { + de => 'Lumen', + en => 'Lumen', + fr => 'Lumen', + nl => 'Lumen', + pl => 'Lumen', }, }, - # solar - "cd" => { - "unit_type" => 8, - "unit" => "cd", - "unit_long" => { - "de" => "Candela", - "en" => "Candela", - "fr" => "Candela", - "nl" => "Candela", - "pl" => "Candela", + uvi => { + unit => 'UVI', + unit_long => { + de => 'UV-Index', + en => 'UV-Index', + fr => 'UV-Index', + nl => 'UV-Index', + pl => 'UV-Index', }, - }, - - "lx" => { - "unit_type" => 8, - "unit" => "lx", - "unit_long" => { - "de" => "Lux", - "en" => "Lux", - "fr" => "Lux", - "nl" => "Lux", - "pl" => "Lux", - }, - }, - - "lm" => { - "unit_type" => 8, - "unit" => "lm", - "unit_long" => { - "de" => "Lumen", - "en" => "Lumen", - "fr" => "Lumen", - "nl" => "Lumen", - "pl" => "Lumen", - }, - }, - - "uvi" => { - "unit_type" => 8, - "unit" => "UVI", - "unit_long" => { - "de" => "UV-Index", - "en" => "UV-Index", - "fr" => "UV-Index", - "nl" => "UV-Index", - "pl" => "UV-Index", - }, - "txt_format" => '%unit% %value%', - "txt_format_long" => '%unit_long% %value%', - "txt_format_long_pl" => '%unit_long% %value%', + txt_format => '%unit% %value%', + txt_format_long => '%unit_long% %value%', + txt_format_long_pl => '%unit_long% %value%', }, # volume - "ml" => { - "unit_type" => 9, - "unit" => "ml", - "unit_long" => { - "de" => "Milliliter", - "en" => "mililitre", - "fr" => "mililitre", - "nl" => "mililitre", - "pl" => "mililitre", + cm3 => { + base_ref => 18, + unit_ref => 'm', + unit_scale_cu => '1.0e-2', + }, + + m3 => { + base_ref => 18, + unit_ref => 'm', + unit_scale_cu => '1.0e0', + }, + + ml => { + unit_ref => 'l', + unit_scale_m => '1.0e-3', + }, + + l => { + base_ref => 18, + unit => 'l', + unit_long => { + de => 'Liter', + en => 'liter', + fr => 'liter', + nl => 'liter', + pl => 'liter', }, - "unit_long_pl" => { - "de" => "Milliliter", - "en" => "mililitres", - "fr" => "mililitres", - "nl" => "mililitres", - "pl" => "mililitres", + unit_long_pl => { + de => 'Liter', + en => 'liters', + fr => 'liters', + nl => 'liters', + pl => 'liters', }, }, - "l" => { - "unit_type" => 9, - "unit" => "l", - "unit_long" => { - "de" => "Liter", - "en" => "litre", - "fr" => "litre", - "nl" => "litre", - "pl" => "litre", - }, - "unit_long_pl" => { - "de" => "Liter", - "en" => "litres", - "fr" => "litres", - "nl" => "litres", - "pl" => "litres", + hl => { + unit_ref => 'l', + unit_scale_m => '1.0e2', + }, + + b => { + base_ref => 19, + unit_scale_m => '1.0e0', + unit => 'B', + unit_long => { + de => 'Bel', + en => 'Bel', + fr => 'Bel', + nl => 'Bel', + pl => 'Bel', }, }, - "oz" => { - "unit_type" => 9, - "unit" => "oz", - "unit_long" => { - "de" => "Unze", - "en" => "ounce", - "fr" => "ounce", - "nl" => "ounce", - "pl" => "ounce", - }, - "unit_long_pl" => { - "de" => "Unzen", - "en" => "ounces", - "fr" => "ounces", - "nl" => "ounces", - "pl" => "ounces", + db => { + unit_ref => 'b', + unit_scale_m => '1.0e-1', + }, + + ua => { + unit_ref => 'a', + unit_scale_m => '1.0e-6', + }, + + ma => { + unit_ref => 'a', + unit_scale_m => '1.0e-3', + }, + + a => { + base_ref => 3, + unit_scale_m => '1.0e0', + unit => 'A', + unit_long => { + de => 'Ampere', + en => 'Ampere', + fr => 'Ampere', + nl => 'Ampere', + pl => 'Ampere', }, }, - "floz" => { - "unit_type" => 9, - "unit" => "fl oz", - "unit_long" => { - "de" => "fl. Unze", - "en" => "fl. ounce", - "fr" => "fl. ounce", - "nl" => "fl. ounce", - "pl" => "fl. ounce", - }, - "unit_long_pl" => { - "de" => "fl. Unzen", - "en" => "fl. ounces", - "fr" => "fl. ounces", - "nl" => "fl. ounces", - "pl" => "fl. ounces", + uv => { + unit_ref => 'v', + unit_scale_m => '1.0e-6', + }, + + mv => { + unit_ref => 'v', + unit_scale_m => '1.0e-3', + }, + + v => { + base_ref => 13, + unit_scale_m => '1.0e0', + unit => 'V', + unit_long => { + de => 'Volt', + en => 'Volt', + fr => 'Volt', + nl => 'Volt', + pl => 'Volt', }, }, - "ozfl" => { - "unit_type" => 9, - "unit" => "fl oz", - "unit_long" => { - "de" => "fl. Unze", - "en" => "fl. ounce", - "fr" => "fl. ounce", - "nl" => "fl. ounce", - "pl" => "fl. ounce", - }, - "unit_long_pl" => { - "de" => "fl. Unzen", - "en" => "fl. ounces", - "fr" => "fl. ounces", - "nl" => "fl. ounces", - "pl" => "fl. ounces", + uj => { + unit_ref => 'j', + unit_scale_m => '1.0e-6', + }, + + mj => { + unit_ref => 'j', + unit_scale_m => '1.0e-3', + }, + + j => { + base_ref => 7, + unit_scale_m => '1.0e0', + unit => 'J', + unit_long => { + de => 'Joule', + en => 'Joule', + fr => 'Joule', + nl => 'Joule', + pl => 'Joule', }, }, - "quart" => { - "unit_type" => 9, - "unit" => "quart", - "unit_long" => { - "de" => "Quart", - "en" => "quart", - "fr" => "quart", - "nl" => "quart", - "pl" => "quart", - }, - "unit_long_pl" => { - "de" => "Quarts", - "en" => "quarts", - "fr" => "quarts", - "nl" => "quarts", - "pl" => "quarts", + uw => { + unit_ref => 'j', + unit_scale_m => '1.0e-6', + }, + + mw => { + unit_ref => 'j', + unit_scale_m => '1.0e-3', + }, + + w => { + base_ref => 9, + unit_scale_m => '1.0e0', + unit => 'Watt', + unit_long => { + de => 'Watt', + en => 'Watt', + fr => 'Watt', + nl => 'Watt', + pl => 'Watt', }, }, - "gallon" => { - "unit_type" => 9, - "unit" => "gallon", - "unit_long" => { - "de" => "Gallone", - "en" => "gallon", - "fr" => "gallon", - "nl" => "gallon", - "pl" => "gallon", + va => { + unit_ref => 'w', + }, + + uwpscm => { + unit_ref => 'w', + unit_scale_m => '1.0e-6', + unit_ref_sq => 'm', + unit_scale_sq => '1.0e-2', + txt_format => '%value% %unit%/%unit_sq%', + txt_format_long => { + de => '%value% %unit_long% pro %unit_long_t%', + en => '%value% %unit_long% per %unit_long_t%', + fr => '%value% %unit_long% per %unit_long_t%', + nl => '%value% %unit_long% per %unit_long_t%', + pl => '%value% %unit_long% per %unit_long_t%', }, - "unit_long_pl" => { - "de" => "Gallonen", - "en" => "gallons", - "fr" => "gallons", - "nl" => "gallons", - "pl" => "gallons", + txt_format_long_pl => { + de => '%value% %unit_long_pl% pro %unit_long_t%', + en => '%value% %unit_long_pl% per %unit_long_t%', + fr => '%value% %unit_long_pl% per %unit_long_t%', + nl => '%value% %unit_long_pl% per %unit_long_t%', + pl => '%value% %unit_long_pl% per %unit_long_t%', }, }, - # energy - "b" => { - "unit_type" => 10, - "unit" => "B", - "unit_long" => { - "de" => "Bel", - "en" => "Bel", - "fr" => "Bel", - "nl" => "Bel", - "pl" => "Bel", + uwpsm => { + unit_ref => 'w', + unit_scale_m => '1.0e-6', + unit_ref_sq => 'm', + unit_scale_sq => '1.0e0', + txt_format => '%value% %unit%/%unit_sq%', + txt_format_long => { + de => '%value% %unit_long% pro %unit_long_t%', + en => '%value% %unit_long% per %unit_long_t%', + fr => '%value% %unit_long% per %unit_long_t%', + nl => '%value% %unit_long% per %unit_long_t%', + pl => '%value% %unit_long% per %unit_long_t%', + }, + txt_format_long_pl => { + de => '%value% %unit_long_pl% pro %unit_long_t%', + en => '%value% %unit_long_pl% per %unit_long_t%', + fr => '%value% %unit_long_pl% per %unit_long_t%', + nl => '%value% %unit_long_pl% per %unit_long_t%', + pl => '%value% %unit_long_pl% per %unit_long_t%', }, }, - "db" => { - "unit_type" => 10, - "unit" => "dB", - "unit_long" => { - "de" => "Dezibel", - "en" => "Decibel", - "fr" => "Decibel", - "nl" => "Decibel", - "pl" => "Decibel", + mwpscm => { + unit_ref => 'w', + unit_scale_m => '1.0e-3', + unit_ref_sq => 'm', + unit_scale_sq => '1.0e-2', + txt_format => '%value% %unit%/%unit_sq%', + txt_format_long => { + de => '%value% %unit_long% pro %unit_long_t%', + en => '%value% %unit_long% per %unit_long_t%', + fr => '%value% %unit_long% per %unit_long_t%', + nl => '%value% %unit_long% per %unit_long_t%', + pl => '%value% %unit_long% per %unit_long_t%', + }, + txt_format_long_pl => { + de => '%value% %unit_long_pl% pro %unit_long_t%', + en => '%value% %unit_long_pl% per %unit_long_t%', + fr => '%value% %unit_long_pl% per %unit_long_t%', + nl => '%value% %unit_long_pl% per %unit_long_t%', + pl => '%value% %unit_long_pl% per %unit_long_t%', }, }, - "uwpscm" => { - "unit_type" => 10, - "unit" => "uW/cm2", - "unit_long" => { - "de" => "Micro-Watt pro Quadratzentimeter", - "en" => "Micro-Watt per square centimeter", - "fr" => "Micro-Watt per square centimeter", - "nl" => "Micro-Watt per square centimeter", - "pl" => "Micro-Watt per square centimeter", + mwpsm => { + unit_ref => 'w', + unit_scale_m => '1.0e-3', + unit_ref_sq => 'm', + unit_scale_sq => '1.0e0', + txt_format => '%value% %unit%/%unit_sq%', + txt_format_long => { + de => '%value% %unit_long% pro %unit_long_t%', + en => '%value% %unit_long% per %unit_long_t%', + fr => '%value% %unit_long% per %unit_long_t%', + nl => '%value% %unit_long% per %unit_long_t%', + pl => '%value% %unit_long% per %unit_long_t%', + }, + txt_format_long_pl => { + de => '%value% %unit_long_pl% pro %unit_long_t%', + en => '%value% %unit_long_pl% per %unit_long_t%', + fr => '%value% %unit_long_pl% per %unit_long_t%', + nl => '%value% %unit_long_pl% per %unit_long_t%', + pl => '%value% %unit_long_pl% per %unit_long_t%', }, }, - "wpsm" => { - "unit_type" => 10, - "unit" => "W/m2", - "unit_long" => { - "de" => "Watt pro Quadratmeter", - "en" => "Watt per square meter", - "fr" => "Watt per square meter", - "nl" => "Watt per square meter", - "pl" => "Watt per square meter", + wpscm => { + unit_ref => 'w', + unit_scale_m => '1.0e0', + unit_ref_sq => 'm', + unit_scale_sq => '1.0e-2', + txt_format => '%value% %unit%/%unit_sq%', + txt_format_long => { + de => '%value% %unit_long% pro %unit_long_t%', + en => '%value% %unit_long% per %unit_long_t%', + fr => '%value% %unit_long% per %unit_long_t%', + nl => '%value% %unit_long% per %unit_long_t%', + pl => '%value% %unit_long% per %unit_long_t%', + }, + txt_format_long_pl => { + de => '%value% %unit_long_pl% pro %unit_long_t%', + en => '%value% %unit_long_pl% per %unit_long_t%', + fr => '%value% %unit_long_pl% per %unit_long_t%', + nl => '%value% %unit_long_pl% per %unit_long_t%', + pl => '%value% %unit_long_pl% per %unit_long_t%', }, }, - "a" => { - "unit_type" => 10, - "unit" => "A", - "unit_long" => { - "de" => "Ampere", - "en" => "Ampere", - "fr" => "Ampere", - "nl" => "Ampere", - "pl" => "Ampere", + wpsm => { + unit_ref => 'w', + unit_scale_m => '1.0e0', + unit_ref_sq => 'm', + unit_scale_sq => '1.0e0', + txt_format => '%value% %unit%/%unit_sq%', + txt_format_long => { + de => '%value% %unit_long% pro %unit_long_t%', + en => '%value% %unit_long% per %unit_long_t%', + fr => '%value% %unit_long% per %unit_long_t%', + nl => '%value% %unit_long% per %unit_long_t%', + pl => '%value% %unit_long% per %unit_long_t%', + }, + txt_format_long_pl => { + de => '%value% %unit_long_pl% pro %unit_long_t%', + en => '%value% %unit_long_pl% per %unit_long_t%', + fr => '%value% %unit_long_pl% per %unit_long_t%', + nl => '%value% %unit_long_pl% per %unit_long_t%', + pl => '%value% %unit_long_pl% per %unit_long_t%', }, }, - "v" => { - "unit_type" => 10, - "unit" => "V", - "unit_long" => { - "de" => "Volt", - "en" => "Volt", - "fr" => "Volt", - "nl" => "Volt", - "pl" => "Volt", + coul => { + base_ref => 20, + unit => 'C', + unit_long => { + de => 'Coulomb', + en => 'Coulomb', + fr => 'Coulomb', + nl => 'Coulomb', + pl => 'Coulomb', }, }, - "w" => { - "unit_type" => 10, - "unit" => "Watt", - "unit_long" => { - "de" => "Watt", - "en" => "Watt", - "fr" => "Watt", - "nl" => "Watt", - "pl" => "Watt", + far => { + base_ref => 21, + unit => 'F', + unit_long => { + de => 'Farad', + en => 'Farad', + fr => 'Farad', + nl => 'Farad', + pl => 'Farad', }, }, - "j" => { - "unit_type" => 10, - "unit" => "J", - "unit_long" => { - "de" => "Joule", - "en" => "Joule", - "fr" => "Joule", - "nl" => "Joule", - "pl" => "Joule", - }, - }, - - "coul" => { - "unit_type" => 10, - "unit" => "C", - "unit_long" => { - "de" => "Coulomb", - "en" => "Coulomb", - "fr" => "Coulomb", - "nl" => "Coulomb", - "pl" => "Coulomb", - }, - }, - - "far" => { - "unit_type" => 10, - "unit" => "F", - "unit_long" => { - "de" => "Farad", - "en" => "Farad", - "fr" => "Farad", - "nl" => "Farad", - "pl" => "Farad", - }, - }, - - "ohm" => { - "unit_type" => 10, - "unit" => "Ω", - "unit_long" => { - "de" => "Ohm", - "en" => "Ohm", - "fr" => "Ohm", - "nl" => "Ohm", - "pl" => "Ohm", - }, - }, - - "s" => { - "unit_type" => 10, - "unit" => "S", - "unit_long" => { - "de" => "Siemens", - "en" => "Siemens", - "fr" => "Siemens", - "nl" => "Siemens", - "pl" => "Siemens", - }, - }, - - "wb" => { - "unit_type" => 10, - "unit" => "Wb", - "unit_long" => { - "de" => "Weber", - "en" => "Weber", - "fr" => "Weber", - "nl" => "Weber", - "pl" => "Weber", - }, - }, - - "t" => { - "unit_type" => 10, - "unit" => "T", - "unit_long" => { - "de" => "Tesla", - "en" => "Tesla", - "fr" => "Tesla", - "nl" => "Tesla", - "pl" => "Tesla", - }, - }, - - "h" => { - "unit_type" => 10, - "unit" => "H", - "unit_long" => { - "de" => "Henry", - "en" => "Henry", - "fr" => "Henry", - "nl" => "Henry", - "pl" => "Henry", - }, - }, - - "bq" => { - "unit_type" => 10, - "unit" => "Bq", - "unit_long" => { - "de" => "Becquerel", - "en" => "Becquerel", - "fr" => "Becquerel", - "nl" => "Becquerel", - "pl" => "Becquerel", - }, - }, - - "gy" => { - "unit_type" => 10, - "unit" => "Gy", - "unit_long" => { - "de" => "Gray", - "en" => "Gray", - "fr" => "Gray", - "nl" => "Gray", - "pl" => "Gray", - }, - }, - - "sv" => { - "unit_type" => 10, - "unit" => "Sv", - "unit_long" => { - "de" => "Sievert", - "en" => "Sievert", - "fr" => "Sievert", - "nl" => "Sievert", - "pl" => "Sievert", - }, - }, - - "kat" => { - "unit_type" => 10, - "unit" => "kat", - "unit_long" => { - "de" => "Katal", - "en" => "Katal", - "fr" => "Katal", - "nl" => "Katal", - "pl" => "Katal", + ohm => { + base_ref => 22, + unit_symbol => 'Ω', + unit => 'Ohm', + unit_long => { + de => 'Ohm', + en => 'Ohm', + fr => 'Ohm', + nl => 'Ohm', + pl => 'Ohm', }, }, ); my %readingsDB = ( - "airpress" => { - "unified" => "pressure_hpa", # link only + airpress => { + unified => 'pressure_hpa', # link only }, - "azimuth" => { - "short" => "AZ", - "unit" => "deg", + azimuth => { + short => 'AZ', + unit => 'gon', }, - "compasspoint" => { - "short" => "CP", + compasspoint => { + short => 'CP', }, - "dewpoint" => { - "unified" => "dewpoint_c", # link only + dewpoint => { + unified => 'dewpoint_c', # link only }, - "dewpoint_c" => { - "short" => "D", - "unit" => "c", + dewpoint_c => { + short => 'D', + unit => 'c', }, - "dewpoint_f" => { - "short" => "Df", - "unit" => "f", + dewpoint_f => { + short => 'Df', + unit => 'f', }, - "dewpoint_k" => { - "short" => "Dk", - "unit" => "k", + dewpoint_k => { + short => 'Dk', + unit => 'k', }, - "elevation" => { - "short" => "EL", - "unit" => "deg", + elevation => { + short => 'EL', + unit => 'gon', }, - "feelslike" => { - "unified" => "feelslike_c", # link only + feelslike => { + unified => 'feelslike_c', # link only }, - "feelslike_c" => { - "short" => "Tf", - "unit" => "c", + feelslike_c => { + short => 'Tf', + unit => 'c', }, - "feelslike_f" => { - "short" => "Tff", - "unit" => "f", + feelslike_f => { + short => 'Tff', + unit => 'f', }, - "heat_index" => { - "unified" => "heat_index_c", # link only + heat_index => { + unified => 'heat_index_c', # link only }, - "heat_index_c" => { - "short" => "HI", - "unit" => "c", + heat_index_c => { + short => 'HI', + unit => 'c', }, - "heat_index_f" => { - "short" => "HIf", - "unit" => "f", + heat_index_f => { + short => 'HIf', + unit => 'f', }, - "high" => { - "unified" => "high_c", # link only + high => { + unified => 'high_c', # link only }, - "high_c" => { - "short" => "Th", - "unit" => "c", + high_c => { + short => 'Th', + unit => 'c', }, - "high_f" => { - "short" => "Thf", - "unit" => "f", + high_f => { + short => 'Thf', + unit => 'f', }, - "humidity" => { - "short" => "H", - "unit" => "pct", + humidity => { + short => 'H', + unit => 'pct', }, - "humidityabs" => { - "unified" => "humidityabs_c", # link only + humidityabs => { + unified => 'humidityabs_c', # link only }, - "humidityabs_c" => { - "short" => "Ha", - "unit" => "c", + humidityabs_c => { + short => 'Ha', + unit => 'c', }, - "humidityabs_f" => { - "short" => "Haf", - "unit" => "f", + humidityabs_f => { + short => 'Haf', + unit => 'f', }, - "humidityabs_k" => { - "short" => "Hak", - "unit" => "k", + humidityabs_k => { + short => 'Hak', + unit => 'k', }, - "horizon" => { - "short" => "HORIZ", - "unit" => "deg", + horizon => { + short => 'HORIZ', + unit => 'gon', }, - "indoordewpoint" => { - "unified" => "indoordewpoint_c", # link only + indoordewpoint => { + unified => 'indoordewpoint_c', # link only }, - "indoordewpoint_c" => { - "short" => "Di", - "unit" => "c", + indoordewpoint_c => { + short => 'Di', + unit => 'c', }, - "indoordewpoint_f" => { - "short" => "Dif", - "unit" => "f", + indoordewpoint_f => { + short => 'Dif', + unit => 'f', }, - "indoordewpoint_k" => { - "short" => "Dik", - "unit" => "k", + indoordewpoint_k => { + short => 'Dik', + unit => 'k', }, - "indoorhumidity" => { - "short" => "Hi", - "unit" => "pct", + indoorhumidity => { + short => 'Hi', + unit => 'pct', }, - "indoorhumidityabs" => { - "unified" => "indoorhumidityabs_c", # link only + indoorhumidityabs => { + unified => 'indoorhumidityabs_c', # link only }, - "indoorhumidityabs_c" => { - "short" => "Hai", - "unit" => "c", + indoorhumidityabs_c => { + short => 'Hai', + unit => 'c', }, - "indoorhumidityabs_f" => { - "short" => "Haif", - "unit" => "f", + indoorhumidityabs_f => { + short => 'Haif', + unit => 'f', }, - "indoorhumidityabs_k" => { - "short" => "Haik", - "unit" => "k", + indoorhumidityabs_k => { + short => 'Haik', + unit => 'k', }, - "indoortemperature" => { - "unified" => "indoortemperature_c", # link only + indoortemperature => { + unified => 'indoortemperature_c', # link only }, - "indoortemperature_c" => { - "short" => "Ti", - "unit" => "c", + indoortemperature_c => { + short => 'Ti', + unit => 'c', }, - "indoortemperature_f" => { - "short" => "Tif", - "unit" => "f", + indoortemperature_f => { + short => 'Tif', + unit => 'f', }, - "indoortemperature_k" => { - "short" => "Tik", - "unit" => "k", + indoortemperature_k => { + short => 'Tik', + unit => 'k', }, - "israining" => { - "short" => "IR", + israining => { + short => 'IR', }, - "level" => { - "short" => "LVL", - "unit" => "pct", + level => { + short => 'LVL', + unit => 'pct', }, - "low" => { - "unified" => "low_c", # link only + low => { + unified => 'low_c', # link only }, - "low_c" => { - "short" => "Tl", - "unit" => "c", + low_c => { + short => 'Tl', + unit => 'c', }, - "low_f" => { - "short" => "Tlf", - "unit" => "f", + low_f => { + short => 'Tlf', + unit => 'f', }, - "luminosity" => { - "short" => "L", - "unit" => "lx", + luminosity => { + short => 'L', + unit => 'lx', }, - "pct" => { - "short" => "PCT", - "unit" => "pct", + pct => { + short => 'PCT', + unit => 'pct', }, - "pressure" => { - "unified" => "pressure_hpa", # link only + pressure => { + unified => 'pressure_hpa', # link only }, - "pressure_hpa" => { - "short" => "P", - "unit" => "hpa", + pressure_hpa => { + short => 'P', + unit => 'hpamb', }, - "pressure_in" => { - "short" => "Pin", - "unit" => "inhg", + pressure_in => { + short => 'Pin', + unit => 'inhg', }, - "pressure_mm" => { - "short" => "Pmm", - "unit" => "mmhg", + pressure_mm => { + short => 'Pmm', + unit => 'mmhg', }, - "pressure_psi" => { - "short" => "Ppsi", - "unit" => "psi", + pressure_psi => { + short => 'Ppsi', + unit => 'psi', }, - "pressure_psig" => { - "short" => "Ppsi", - "unit" => "psig", + pressure_psig => { + short => 'Ppsi', + unit => 'psig', }, - "pressureabs" => { - "unified" => "pressureabs_hpa", # link only + pressureabs => { + unified => 'pressureabs_hpamb', # link only }, - "pressureabs_hpa" => { - "short" => "Pa", - "unit" => "hpa", + pressureabs_hpa => { + short => 'Pa', + unit => 'hpamb', }, - "pressureabs_in" => { - "short" => "Pain", - "unit" => "inhg", + pressureabs_in => { + short => 'Pain', + unit => 'inhg', }, - "pressureabs_mm" => { - "short" => "Pamm", - "unit" => "mmhg", + pressureabs_mm => { + short => 'Pamm', + unit => 'mmhg', }, - "pressureabs_psi" => { - "short" => "Ppsia", - "unit" => "psia", + pressureabs_psi => { + short => 'Ppsia', + unit => 'psia', }, - "pressureabs_psia" => { - "short" => "Ppsia", - "unit" => "psia", + pressureabs_psia => { + short => 'Ppsia', + unit => 'psia', }, - "rain" => { - "unified" => "rain_mm", # link only + rain => { + unified => 'rain_mm', # link only }, - "rain_mm" => { - "short" => "R", - "unit" => "mm", + rain_mm => { + short => 'R', + unit => 'mm', }, - "rain_in" => { - "short" => "Rin", - "unit" => "in", + rain_in => { + short => 'Rin', + unit => 'in', }, - "rain_day" => { - "unified" => "rain_day_mm", # link only + rain_day => { + unified => 'rain_day_mm', # link only }, - "rain_day_mm" => { - "short" => "Rd", - "unit" => "mm", + rain_day_mm => { + short => 'Rd', + unit => 'mm', }, - "rain_day_in" => { - "short" => "Rdin", - "unit" => "in", + rain_day_in => { + short => 'Rdin', + unit => 'in', }, - "rain_night" => { - "unified" => "rain_night_mm", # link only + rain_night => { + unified => 'rain_night_mm', # link only }, - "rain_night_mm" => { - "short" => "Rn", - "unit" => "mm", + rain_night_mm => { + short => 'Rn', + unit => 'mm', }, - "rain_night_in" => { - "short" => "Rnin", - "unit" => "in", + rain_night_in => { + short => 'Rnin', + unit => 'in', }, - "rain_week" => { - "unified" => "rain_week_mm", # link only + rain_week => { + unified => 'rain_week_mm', # link only }, - "rain_week_mm" => { - "short" => "Rw", - "unit" => "mm", + rain_week_mm => { + short => 'Rw', + unit => 'mm', }, - "rain_week_in" => { - "short" => "Rwin", - "unit" => "in", + rain_week_in => { + short => 'Rwin', + unit => 'in', }, - "rain_month" => { - "unified" => "rain_month_mm", # link only + rain_month => { + unified => 'rain_month_mm', # link only }, - "rain_month_mm" => { - "short" => "Rm", - "unit" => "mm", + rain_month_mm => { + short => 'Rm', + unit => 'mm', }, - "rain_month_in" => { - "short" => "Rmin", - "unit" => "in", + rain_month_in => { + short => 'Rmin', + unit => 'in', }, - "rain_year" => { - "unified" => "rain_year_mm", # link only + rain_year => { + unified => 'rain_year_mm', # link only }, - "rain_year_mm" => { - "short" => "Ry", - "unit" => "mm", + rain_year_mm => { + short => 'Ry', + unit => 'mm', }, - "rain_year_in" => { - "short" => "Ryin", - "unit" => "in", + rain_year_in => { + short => 'Ryin', + unit => 'in', }, - "snow" => { - "unified" => "snow_cm", # link only + snow => { + unified => 'snow_cm', # link only }, - "snow_cm" => { - "short" => "S", - "unit" => "cm", + snow_cm => { + short => 'S', + unit => 'cm', }, - "snow_in" => { - "short" => "Sin", - "unit" => "in", + snow_in => { + short => 'Sin', + unit => 'in', }, - "snow_day" => { - "unified" => "snow_day_cm", # link only + snow_day => { + unified => 'snow_day_cm', # link only }, - "snow_day_cm" => { - "short" => "Sd", - "unit" => "cm", + snow_day_cm => { + short => 'Sd', + unit => 'cm', }, - "snow_day_in" => { - "short" => "Sdin", - "unit" => "in", + snow_day_in => { + short => 'Sdin', + unit => 'in', }, - "snow_night" => { - "unified" => "snow_night_cm", # link only + snow_night => { + unified => 'snow_night_cm', # link only }, - "snow_night_cm" => { - "short" => "Sn", - "unit" => "cm", + snow_night_cm => { + short => 'Sn', + unit => 'cm', }, - "snow_night_in" => { - "short" => "Snin", - "unit" => "in", + snow_night_in => { + short => 'Snin', + unit => 'in', }, - "sunshine" => { - "unified" => "solarradiation", # link only + sunshine => { + unified => 'solarradiation', # link only }, - "solarradiation" => { - "short" => "SR", - "unit" => "wpsm", + solarradiation => { + short => 'SR', + unit => 'wpsm', }, - "temp" => { - "unified" => "temperature_c", # link only + temp => { + unified => 'temperature_c', # link only }, - "temp_c" => { - "unified" => "temperature_c", # link only + temp_c => { + unified => 'temperature_c', # link only }, - "temp_f" => { - "unified" => "temperature_f", # link only + temp_f => { + unified => 'temperature_f', # link only }, - "temp_k" => { - "unified" => "temperature_k", # link only + temp_k => { + unified => 'temperature_k', # link only }, - "temperature" => { - "unified" => "temperature_c", # link only + temperature => { + unified => 'temperature_c', # link only }, - "temperature_c" => { - "short" => "T", - "unit" => "c", + temperature_c => { + short => 'T', + unit => 'c', }, - "temperature_f" => { - "short" => "Tf", - "unit" => "f", + temperature_f => { + short => 'Tf', + unit => 'f', }, - "temperature_k" => { - "short" => "Tk", - "unit" => "k", + temperature_k => { + short => 'Tk', + unit => 'k', }, - "uv" => { - "unified" => "uvi", # link only + uv => { + unified => 'uvi', # link only }, - "uvi" => { - "short" => "UV", - "unit" => "uvi", + uvi => { + short => 'UV', + unit => 'uvi', }, - "uvr" => { - "short" => "UVR", - "unit" => "uwpscm", + uvr => { + short => 'UVR', + unit => 'uwpscm', }, - "valvedesired" => { - "unified" => "valve", # link only + valvedesired => { + unified => 'valve', # link only }, - "valvepos" => { - "unified" => "valve", # link only + valvepos => { + unified => 'valve', # link only }, - "valveposition" => { - "unified" => "valve", # link only + valveposition => { + unified => 'valve', # link only }, - "valvepostc" => { - "unified" => "valve", # link only + valvepostc => { + unified => 'valve', # link only }, - "valve" => { - "short" => "VAL", - "unit" => "pct", + valve => { + short => 'VAL', + unit => 'pct', }, - "visibility" => { - "unified" => "visibility_km", # link only + visibility => { + unified => 'visibility_km', # link only }, - "visibility_km" => { - "short" => "V", - "unit" => "km", + visibility_km => { + short => 'V', + unit => 'km', }, - "visibility_mi" => { - "short" => "Vmi", - "unit" => "mi", + visibility_mi => { + short => 'Vmi', + unit => 'mi', }, - "wind_chill" => { - "unified" => "wind_chill_c", # link only + wind_chill => { + unified => 'wind_chill_c', # link only }, - "wind_chill_c" => { - "short" => "Wc", - "unit" => "c", + wind_chill_c => { + short => 'Wc', + unit => 'c', }, - "wind_chill_f" => { - "short" => "Wcf", - "unit" => "f", + wind_chill_f => { + short => 'Wcf', + unit => 'f', }, - "wind_chill_k" => { - "short" => "Wck", - "unit" => "k", + wind_chill_k => { + short => 'Wck', + unit => 'k', }, - "wind_compasspoint" => { - "short" => "Wdc", + wind_compasspoint => { + short => 'Wdc', }, - "windspeeddirection" => { - "unified" => "wind_compasspoint", # link only + windspeeddirection => { + unified => 'wind_compasspoint', # link only }, - "winddirectiontext" => { - "unified" => "wind_compasspoint", # link only + winddirectiontext => { + unified => 'wind_compasspoint', # link only }, - "wind_direction" => { - "short" => "Wd", - "unit" => "deg", + wind_direction => { + short => 'Wd', + unit => 'gon', }, - "wind_dir" => { - "unified" => "wind_direction", # link only + wind_dir => { + unified => 'wind_direction', # link only }, - "winddir" => { - "unified" => "wind_direction", # link only + winddir => { + unified => 'wind_direction', # link only }, - "winddirection" => { - "unified" => "wind_direction", # link only + winddirection => { + unified => 'wind_direction', # link only }, - "wind_gust" => { - "unified" => "wind_gust_kmh", # link only + wind_gust => { + unified => 'wind_gust_kmh', # link only }, - "wind_gust_kmh" => { - "short" => "Wg", - "unit" => "kmh", + wind_gust_kmh => { + short => 'Wg', + unit => 'kmh', }, - "wind_gust_bft" => { - "short" => "Wgbft", - "unit" => "bft", + wind_gust_bft => { + short => 'Wgbft', + unit => 'bft', }, - "wind_gust_fts" => { - "short" => "Wgfts", - "unit" => "fts", + wind_gust_fts => { + short => 'Wgfts', + unit => 'fts', }, - "wind_gust_kn" => { - "short" => "Wgkn", - "unit" => "kn", + wind_gust_kn => { + short => 'Wgkn', + unit => 'kn', }, - "wind_gust_mph" => { - "short" => "Wgmph", - "unit" => "mph", + wind_gust_mph => { + short => 'Wgmph', + unit => 'mph', }, - "wind_gust_mps" => { - "short" => "Wgmps", - "unit" => "mps", + wind_gust_mps => { + short => 'Wgmps', + unit => 'mps', }, - "wind_speed" => { - "unified" => "wind_speed_kmh", # link only + wind_speed => { + unified => 'wind_speed_kmh', # link only }, - "wind_speed_kmh" => { - "short" => "Ws", - "unit" => "kmh", + wind_speed_kmh => { + short => 'Ws', + unit => 'kmh', }, - "wind_speed_bft" => { - "short" => "Wsbft", - "unit" => "bft", + wind_speed_bft => { + short => 'Wsbft', + unit => 'bft', }, - "wind_speed_fts" => { - "short" => "Wsfts", - "unit" => "fts", + wind_speed_fts => { + short => 'Wsfts', + unit => 'fts', }, - "wind_speed_kn" => { - "short" => "Wskn", - "unit" => "kn", + wind_speed_kn => { + short => 'Wskn', + unit => 'kn', }, - "wind_speed_mph" => { - "short" => "Wsmph", - "unit" => "mph", + wind_speed_mph => { + short => 'Wsmph', + unit => 'mph', }, - "wind_speed_mps" => { - "short" => "Wsmps", - "unit" => "mps", + wind_speed_mps => { + short => 'Wsmps', + unit => 'mps', }, ); # Get unit list in local language as hash sub GetList (@) { my ( $lang, $type ) = @_; + my $l = ( $lang ? lc($lang) : "en" ); my %list; foreach my $u ( keys %unitsDB ) { my $details = GetDetails( $u, $lang ); - my $tid = $details->{"unit_type"}; - my $tn = ( $unit_types{$tid} ? $unit_types{$tid} : "unknown" ); + my $tn = ( + $details->{base_parameter} + ? $details->{base_parameter} + : "others" + ); $list{$tn}{$u} = $details - if ( !$type || $type eq $tid || lc($type) eq $tn ); + if ( !$type || lc($type) eq $tn ); } return \%list; @@ -1992,61 +2452,89 @@ sub GetDetails ($@) { foreach my $k ( keys %{ $unitsDB{$u} } ) { $details{$k} = $unitsDB{$u}{$k}; } - $details{"unit_abbr"} = $u; + $details{unit_abbr} = $u; + + foreach ( 'unit_ref', 'unit_ref_t', 'unit_ref_sq', 'unit_ref_cu' ) { + my $suffix = $_; + $suffix =~ s/^[a-z]+_[a-z]+//; + if ( defined( $details{$_} ) ) { + my $ref = $details{$_}; + if ( !defined( $unitsDB{$ref} ) ) { + ::Log 1, "Unit::GetDetails($unit) broken reference $_"; + next; + } + foreach my $k ( keys %{ $unitsDB{$ref} } ) { + next if ( $k =~ /^unit_scale/ ); + if ( !defined( $details{$k} ) ) { + $details{$k} = $unitsDB{$ref}{$k}; + } + else { + $details{ $k . $suffix } = $unitsDB{$ref}{$k} + if ( !defined( $details{ $k . $suffix } ) ); + } + } + } + } + + if ( $details{unit_scale_m} ) { + my $ref = $details{unit_scale_m}; + foreach my $k ( keys %{ $scales_m{$ref} } ) { + $details{ $k . '_m' } = $scales_m{$ref}{$k} + if ( !defined( $details{ $k . '_m' } ) ); + } + } + if ( $details{unit_scale_sq} ) { + foreach my $k ( keys %scales_sq ) { + $details{ $k . "_sq" } = $scales_sq{$k} + if ( !defined( $details{ $k . "_sq" } ) ); + } + } + if ( $details{unit_scale_cu} ) { + foreach my $k ( keys %scales_cu ) { + $details{ $k . "_cu" } = $scales_cu{$k} + if ( !defined( $details{ $k . "_cu" } ) ); + } + } + + if ( defined( $details{base_ref} ) ) { + my $ref = $details{base_ref}; + foreach my $k ( keys %{ $unit_base{$ref} } ) { + $details{$k} = $unit_base{$ref}{$k} + if ( !defined( $details{$k} ) ); + } + } if ($lang) { $details{"lang"} = $l; - - if ( $details{"txt_format"} - && ref( $unitsDB{$u}{"txt_format"} ) eq "HASH" - && $unitsDB{$u}{"txt_format"}{$l} ) - { - delete $details{"txt_format"}; - $details{"txt_format"} = $unitsDB{$u}{"txt_format"}{$l}; + foreach ( keys %details ) { + if ( $details{$_} + && ref( $details{$_} ) eq "HASH" ) + { + my $v; + $v = $details{$_}{$l} + if ( $details{$_}{$l} ); + delete $details{$_}; + $details{$_} = $v if ($v); + } } - if ( $details{"txt_format_long"} - && ref( $unitsDB{$u}{"txt_format_long"} ) eq "HASH" - && $unitsDB{$u}{"txt_format_long"}{$l} ) - { - delete $details{"txt_format_long"}; - $details{"txt_format_long"} = - $unitsDB{$u}{"txt_format_long"}{$l}; - } + $details{unit} = $details{scale_m} . $details{unit} + if ( $details{scale_m} ); + $details{unit_long} = + $details{scale_long_m} . lc( $details{unit_long} ) + if ( $details{scale_long_m} ); - if ( $details{"txt_format_long_pl"} - && ref( $unitsDB{$u}{"txt_format_long_pl"} ) eq "HASH" - && $unitsDB{$u}{"txt_format_long_pl"}{$l} ) - { - delete $details{"txt_format_long_pl"}; - $details{"txt_format_long_pl"} = - $unitsDB{$u}{"txt_format_long_pl"}{$l}; - } - - if ( $details{"unit"} - && ref( $unitsDB{$u}{"unit"} ) eq "HASH" - && $unitsDB{$u}{"unit"}{$l} ) - { - delete $details{"unit"}; - $details{"unit"} = $unitsDB{$u}{"unit"}{$l}; - } - - if ( $details{"unit_long"} - && ref( $unitsDB{$u}{"unit_long"} ) eq "HASH" - && $unitsDB{$u}{"unit_long"}{$l} ) - { - delete $details{"unit_long"}; - $details{"unit_long"} = $unitsDB{$u}{"unit_long"}{$l}; - } - - if ( $details{"unit_long_pl"} - && ref( $unitsDB{$u}{"unit_long_pl"} ) eq "HASH" - && $unitsDB{$u}{"unit_long_pl"}{$l} ) - { - delete $details{"unit_long_pl"}; - $details{"unit_long_pl"} = $unitsDB{$u}{"unit_long_pl"}{$l}; - } + $details{unit_sq} = $details{unit_sq} . $details{scale_sq} + if ( $details{scale_sq} ); + $details{unit_long_sq} = + $details{scale_long_sq} . lc( $details{unit_long_sq} ) + if ( $details{scale_long_sq} ); + $details{unit_cu} = $details{unit_cu} . $details{scale_cu} + if ( $details{scale_cu} ); + $details{unit_long_cu} = + $details{scale_long_cu} . lc( $details{unit_long_cu} ) + if ( $details{scale_long_cu} ); } return \%details; @@ -2106,7 +2594,7 @@ sub GetDetailsFromReadingname ($@) { $u = lc($1); } - return if ( !%return && !$u ); + return {} if ( !%return && !$u ); return \%return if ( !$u ); my $unitDetails = GetDetails( $u, $l );