RobotCore 1.0
WPILib port to raspberry Pi
Loading...
Searching...
No Matches
org.wpilib.units.TimeUnit Class Reference
Inheritance diagram for org.wpilib.units.TimeUnit:
org.wpilib.units.Unit

Public Member Functions

TimeUnit getBaseUnit ()
DimensionlessUnit per (TimeUnit other)
double convertFrom (double magnitude, TimeUnit otherUnit)
Time of (double magnitude)
Time ofBaseUnits (double baseUnitMagnitude)
Time zero ()
Time one ()
Public Member Functions inherited from org.wpilib.units.Unit
boolean isBaseUnit ()
double fromBaseUnits (double valueInBaseUnits)
double toBaseUnits (double valueInNativeUnits)
UnaryFunction getConverterToBase ()
UnaryFunction getConverterFromBase ()
boolean equivalent (Unit other)
boolean equals (Object o)
int hashCode ()
String name ()
String symbol ()
String toString ()

Additional Inherited Members

Protected Member Functions inherited from org.wpilib.units.Unit
 Unit (Unit baseUnit, UnaryFunction toBaseConverter, UnaryFunction fromBaseConverter, String name, String symbol)
 Unit (Unit baseUnit, double baseUnitEquivalent, String name, String symbol)

Detailed Description

Unit of time dimension.

This is the base type for units of time dimension. It is also used to specify the dimension for Measure: Measure<TimeUnit>.

Actual units (such as Units#Seconds and Units#Milliseconds) can be found in the Units class.

Definition at line 18 of file TimeUnit.java.

Member Function Documentation

◆ convertFrom()

double org.wpilib.units.TimeUnit.convertFrom ( double magnitude,
TimeUnit otherUnit )

Converts a measurement value in terms of another unit to this unit.

Parameters
magnitudethe magnitude of the measurement in terms of the other unit
otherUnitthe other unit
Returns
the value of the measurement in terms of this unit

Definition at line 72 of file TimeUnit.java.

◆ getBaseUnit()

TimeUnit org.wpilib.units.TimeUnit.getBaseUnit ( )

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
Returns
the base unit

Reimplemented from org.wpilib.units.Unit.

Definition at line 33 of file TimeUnit.java.

◆ of()

Time org.wpilib.units.TimeUnit.of ( double magnitude)

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.

Parameters
magnitudethe magnitude of the measurement.
Returns
the measurement object

Reimplemented from org.wpilib.units.Unit.

Definition at line 77 of file TimeUnit.java.

◆ ofBaseUnits()

Time org.wpilib.units.TimeUnit.ofBaseUnits ( double baseUnitMagnitude)

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.

Parameters
baseUnitMagnitudethe magnitude in terms of the base unit
Returns
the measurement object

Reimplemented from org.wpilib.units.Unit.

Definition at line 82 of file TimeUnit.java.

◆ one()

Time org.wpilib.units.TimeUnit.one ( )

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 by of(double). Subclasses are encouraged to override this method to sharpen the return type.

Returns
a measure of magnitude 1.0 in terms of this unit

Reimplemented from org.wpilib.units.Unit.

Definition at line 92 of file TimeUnit.java.

◆ per()

DimensionlessUnit org.wpilib.units.TimeUnit.per ( TimeUnit other)

Creates a dimensionless unit corresponding to the scale factor between this and another unit of time.

Parameters
otherthe other unit of time
Returns
the result

Reimplemented from org.wpilib.units.Unit.

Definition at line 45 of file TimeUnit.java.

◆ zero()

Time org.wpilib.units.TimeUnit.zero ( )

Gets a measure of zero magnitude in terms of this unit. The returned object is guaranteed to be of the same type returned by of(double). Subclasses are encouraged to override this method to sharpen the return type.

Returns
a zero-magnitude measure of this unit

Reimplemented from org.wpilib.units.Unit.

Definition at line 87 of file TimeUnit.java.


The documentation for this class was generated from the following file: