-
Notifications
You must be signed in to change notification settings - Fork 0
Register missing units to addUnit #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 11 commits
18cabf0
c0c47de
fdc9811
116f983
87bad26
fd97702
b5ed06f
d7a64ff
4135c88
adecc40
1a8b43f
b84dbc5
ee6dc90
09145db
dd68d90
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,9 +12,11 @@ | |
import java.util.HashSet; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
import javax.measure.MetricPrefix; | ||
import javax.measure.Unit; | ||
import javax.measure.quantity.*; | ||
import tech.units.indriya.format.SimpleUnitFormat; | ||
import tech.units.indriya.function.MultiplyConverter; | ||
import tech.units.indriya.unit.*; | ||
import tech.units.indriya.unit.Units; | ||
|
||
|
@@ -76,26 +78,29 @@ public class PowerSystemUnits extends Units { | |
public static final Unit<Energy> WATTHOUR = | ||
new TransformedUnit<>("Wh", JOULE, DoubleConverterFactory.withFactor(3600)); | ||
|
||
/** Varhour */ | ||
public static final Unit<Energy> VARHOUR = | ||
new TransformedUnit<>("varh", JOULE, DoubleConverterFactory.withFactor(3600)); | ||
|
||
/** Kilowatthour */ | ||
public static final Unit<Energy> KILOWATTHOUR = DoubleConverterFactory.withPrefix(WATTHOUR, KILO); | ||
|
||
public static final Unit<Energy> KILOVARHOUR = DoubleConverterFactory.withPrefix(VARHOUR, KILO); | ||
/** Kilovarhour */ | ||
public static final Unit<Energy> KILOVARHOUR = MetricPrefix.KILO(VARHOUR); | ||
|
||
/** Megawatthour */ | ||
public static final Unit<Energy> MEGAWATTHOUR = DoubleConverterFactory.withPrefix(WATTHOUR, MEGA); | ||
|
||
public static final Unit<Energy> MEGAVARHOUR = DoubleConverterFactory.withPrefix(VARHOUR, MEGA); | ||
/** Megavarhour */ | ||
public static final Unit<Energy> MEGAVARHOUR = MetricPrefix.MEGA(VARHOUR); | ||
|
||
/** Watthour per metre */ | ||
public static final Unit<SpecificEnergy> WATTHOUR_PER_METRE = | ||
new ProductUnit<>(WATTHOUR.divide(METRE)); | ||
|
||
/** Kilowatthour per Kilometre */ | ||
public static final Unit<SpecificEnergy> KILOWATTHOUR_PER_KILOMETRE = | ||
new TransformedUnit<>("kWh/km", WATTHOUR_PER_METRE, DoubleConverterFactory.withFactor(1d)); | ||
new TransformedUnit<>("kWh/km", WATTHOUR_PER_METRE, MultiplyConverter.of(1d)); | ||
|
||
/** Watthour per squaremetre */ | ||
public static final Unit<Irradiation> WATTHOUR_PER_SQUAREMETRE = | ||
|
@@ -226,13 +231,17 @@ public class PowerSystemUnits extends Units { | |
private static final HashSet<String> REGISTERED_LABELS = new HashSet<>(); | ||
|
||
static { | ||
// varh, kvarh, Mvarh are kept out of this because they register for the same units as Wh, kWh, | ||
// MWh | ||
Comment on lines
-229
to
-230
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added this remark for a reason... Something broke, when I added varh etc., because they collided with Wh etc. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
addUnit(WATTHOUR, "Wh"); | ||
addUnit(WATTHOUR_PER_METRE, "Wh/m"); | ||
addUnit(KILOWATTHOUR_PER_KILOMETRE, "kWh/km"); | ||
addUnit(KILOWATTHOUR, "kWh"); | ||
addUnit(MEGAWATTHOUR, "MWh"); | ||
addUnit(OHM_PER_KILOMETRE, "Ω/km"); | ||
addUnit(SIEMENS_PER_KILOMETRE, "S/km"); | ||
addUnit(VOLTAMPERE, "VA"); | ||
addUnit(WATT, "W"); | ||
addUnit(KILOWATT, "kW"); | ||
addUnit(MEGAWATT, "MW"); | ||
addUnit(KILOVOLTAMPERE, "kVA"); | ||
addUnit(MEGAVOLTAMPERE, "MVA"); | ||
addUnit(WATT_PER_SQUAREMETRE, "W/m²"); | ||
|
@@ -241,8 +250,12 @@ public class PowerSystemUnits extends Units { | |
addUnit(VAR, "var"); | ||
addUnit(KILOVAR, "kvar"); | ||
addUnit(MEGAVAR, "Mvar"); | ||
addUnit(VARHOUR, "varh"); | ||
addUnit(KILOVARHOUR, "kvarh"); | ||
addUnit(MEGAVARHOUR, "Mvarh"); | ||
addUnit(PU, "p.u."); | ||
addUnit(EURO, "EUR"); | ||
addUnit(EURO, "€"); | ||
addUnit(EURO_PER_KILOMETRE, "EUR/km"); | ||
addUnit(EURO_PER_WATTHOUR, "EUR/Wh"); | ||
addUnit(EURO_PER_KILOWATTHOUR, "EUR/kWh"); | ||
|
Uh oh!
There was an error while loading. Please reload this page.