Package edu.wpi.first.units
Class VoltageUnit
java.lang.Object
edu.wpi.first.units.Unit
edu.wpi.first.units.VoltageUnit
Unit of electric voltage dimension.
This is the base type for units of voltage dimension. It is also used to specify the dimension
for Measure
: Measure<VoltageUnit>
.
Actual units (such as Units.Volts
and Units.Millivolts
) can be found in the
Units
class.
-
Method Summary
Modifier and TypeMethodDescriptiondouble
convertFrom
(double magnitude, VoltageUnit otherUnit) Converts a measurement value in terms of another voltage unit to this unit.Gets the base unit of measurement that this unit is derived from.mult
(CurrentUnit current, String name, String symbol) Constructs a unit of power equivalent to this unit of voltage multiplied by another unit of electrical current.mutable
(double magnitude) Creates a new mutable measurement that is initialized to the given magnitude in terms of this unit.of
(double magnitude) Creates a new immutable measurement of the given magnitude in terms of this unit.ofBaseUnits
(double baseUnitMagnitude) Creates a new immutable measurement of the given magnitude in terms of this unit's base unit.one()
Gets a measure with a magnitude of 1.0 in terms of this unit.per
(CurrentUnit currentUnit) Combines this unit of voltage with a unit of current to form a unit of resistance.Combines this unit with a unit of time.<U extends Unit>
PerUnit<VoltageUnit,U> per
(U other) Creates a generic ratio unit of this voltage to a different unit type.zero()
Gets a measure of zero magnitude in terms of this unit.Methods inherited from class edu.wpi.first.units.Unit
equals, equivalent, fromBaseUnits, getConverterFromBase, getConverterToBase, hashCode, isBaseUnit, name, symbol, toBaseUnits, toString
-
Method Details
-
getBaseUnit
Description copied from class:Unit
Gets the base unit of measurement that this unit is derived from. If the unit is the base unit, the unit will be returned.NOTE: Subclasses must override this method to provide the correct return type. Failing to do say will make unit combinations that use it break at runtime!
Unit baseUnit = new Unit(null, ...); baseUnit.getBaseUnit(); // returns baseUnit Unit derivedUnit = new Unit(baseUnit, ...); derivedUnit.getBaseUnit(); // returns baseUnit
- Overrides:
getBaseUnit
in classUnit
- Returns:
- the base unit
-
mult
Constructs a unit of power equivalent to this unit of voltage multiplied by another unit of electrical current. For example,Volts.times(Amps)
will return a unit of power equivalent to one Watt;Volts.times(Milliamps)
will return a unit of power equivalent to a milliwatt, and so on.- Parameters:
current
- the current unit to multiply byname
- the name of the resulting unit of powersymbol
- the symbol used to represent the unit of power- Returns:
- the power unit
-
of
Description copied from class:Unit
Creates a new immutable measurement of the given magnitude in terms of this unit. Implementations are strongly recommended to sharpen the return type to a unit-specific measurement implementation. -
ofBaseUnits
Description copied from class:Unit
Creates a new immutable measurement of the given magnitude in terms of this unit's base unit. Implementations are strongly recommended to sharpen the return type to a unit-specific measurement implementation.- Specified by:
ofBaseUnits
in classUnit
- Parameters:
baseUnitMagnitude
- the magnitude in terms of the base unit- Returns:
- the measurement object
-
zero
Description copied from class:Unit
Gets a measure of zero magnitude in terms of this unit. The returned object is guaranteed to be of the same type returned byUnit.of(double)
. Subclasses are encouraged to override this method to sharpen the return type. -
one
Description copied from class:Unit
Gets a measure with a magnitude of 1.0 in terms of this unit. The returned object is guaranteed to be of the same type returned byUnit.of(double)
. Subclasses are encouraged to override this method to sharpen the return type. -
mutable
Description copied from class:Unit
Creates a new mutable measurement that is initialized to the given magnitude in terms of this unit. Implementations are strongly recommended to sharpen the return type to a unit-specific measurement implementation. -
per
Description copied from class:Unit
Combines this unit with a unit of time. This often - but not always - results in a velocity. Subclasses should sharpen the return type to be unit-specific. -
per
Combines this unit of voltage with a unit of current to form a unit of resistance.- Parameters:
currentUnit
- the unit of current- Returns:
- the combined resistance unit
-
per
Creates a generic ratio unit of this voltage to a different unit type.- Type Parameters:
U
- the type of the other unit- Parameters:
other
- the other unit type- Returns:
- the combined ratio type
-
convertFrom
Converts a measurement value in terms of another voltage unit to this unit.- Parameters:
magnitude
- the magnitude of the measurement in terms of the other voltage unitotherUnit
- the other voltage unit- Returns:
- the value of the measurement in terms of this unit
-