RobotCore
1.0
WPILib port to raspberry Pi
Toggle main menu visibility
Loading...
Searching...
No Matches
TimeUnit.java
1
// Copyright (c) FIRST and other WPILib contributors.
2
// Open Source Software; you can modify and/or share it under the terms of
3
// the WPILib BSD license file in the root directory of this project.
4
5
package
org.wpilib.units;
6
7
import
org.wpilib.units.measure.Time;
8
18
public
final
class
TimeUnit
extends
Unit
{
19
TimeUnit(TimeUnit baseUnit,
double
baseUnitEquivalent, String
name
, String
symbol
) {
20
super(baseUnit, baseUnitEquivalent,
name
,
symbol
);
21
}
22
23
TimeUnit(
24
TimeUnit baseUnit,
25
UnaryFunction
toBaseConverter,
26
UnaryFunction
fromBaseConverter,
27
String
name
,
28
String
symbol
) {
29
super(baseUnit, toBaseConverter, fromBaseConverter,
name
,
symbol
);
30
}
31
32
@Override
33
public
TimeUnit
getBaseUnit
() {
34
return
(TimeUnit) super.
getBaseUnit
();
35
}
36
44
@Override
45
public
DimensionlessUnit
per
(TimeUnit other) {
46
return
Units
.derive(
Units
.
Value
)
47
.toBase(this.
getConverterToBase
().div(other.
getConverterToBase
()))
48
.fromBase(other.
getConverterFromBase
().
div
(
this
.getConverterFromBase()))
49
.named(this.name() +
" per "
+ other.
name
())
50
.symbol(this.symbol() +
"/"
+ other.
symbol
())
51
.make();
52
}
53
61
public <U extends Unit>
PerUnit<TimeUnit, U>
per
(U other) {
62
return
PerUnit
.
combine
(
this
, other);
63
}
64
72
public
double
convertFrom
(
double
magnitude, TimeUnit otherUnit) {
73
return
fromBaseUnits
(otherUnit.
toBaseUnits
(magnitude));
74
}
75
76
@Override
77
public
Time
of
(
double
magnitude) {
78
return
new
Time(magnitude,
toBaseUnits
(magnitude),
this
);
79
}
80
81
@Override
82
public
Time
ofBaseUnits
(
double
baseUnitMagnitude) {
83
return
new
Time(
fromBaseUnits
(baseUnitMagnitude), baseUnitMagnitude,
this
);
84
}
85
86
@Override
87
public
Time
zero
() {
88
return
(Time) super.zero();
89
}
90
91
@Override
92
public
Time
one
() {
93
return
(Time) super.one();
94
}
95
}
org.wpilib.units.DimensionlessUnit
Definition
DimensionlessUnit.java:12
org.wpilib.units.PerUnit
Definition
PerUnit.java:17
org.wpilib.units.PerUnit.combine
static< N extends Unit, D extends Unit > PerUnit< N, D > combine(N numerator, D denominator)
Definition
PerUnit.java:93
org.wpilib.units.TimeUnit.zero
Time zero()
Definition
TimeUnit.java:87
org.wpilib.units.TimeUnit.per
DimensionlessUnit per(TimeUnit other)
Definition
TimeUnit.java:45
org.wpilib.units.TimeUnit.one
Time one()
Definition
TimeUnit.java:92
org.wpilib.units.TimeUnit.of
Time of(double magnitude)
Definition
TimeUnit.java:77
org.wpilib.units.TimeUnit.ofBaseUnits
Time ofBaseUnits(double baseUnitMagnitude)
Definition
TimeUnit.java:82
org.wpilib.units.TimeUnit.convertFrom
double convertFrom(double magnitude, TimeUnit otherUnit)
Definition
TimeUnit.java:72
org.wpilib.units.TimeUnit.getBaseUnit
TimeUnit getBaseUnit()
Definition
TimeUnit.java:33
org.wpilib.units.Unit.toBaseUnits
double toBaseUnits(double valueInNativeUnits)
Definition
Unit.java:166
org.wpilib.units.Unit.name
String name()
Definition
Unit.java:234
org.wpilib.units.Unit.getConverterToBase
UnaryFunction getConverterToBase()
Definition
Unit.java:176
org.wpilib.units.Unit.getConverterFromBase
UnaryFunction getConverterFromBase()
Definition
Unit.java:186
org.wpilib.units.Unit.symbol
String symbol()
Definition
Unit.java:243
org.wpilib.units.Unit.Unit
Unit(Unit baseUnit, UnaryFunction toBaseConverter, UnaryFunction fromBaseConverter, String name, String symbol)
Definition
Unit.java:38
org.wpilib.units.Unit.fromBaseUnits
double fromBaseUnits(double valueInBaseUnits)
Definition
Unit.java:156
org.wpilib.units.Units
Definition
Units.java:10
org.wpilib.units.Units.Value
static final DimensionlessUnit Value
Definition
Units.java:19
org.wpilib.units.UnaryFunction
Definition
UnaryFunction.java:17
org.wpilib.units.UnaryFunction.div
default UnaryFunction div(UnaryFunction divisor)
Definition
UnaryFunction.java:77
org
wpilib
units
TimeUnit.java
Generated by
1.18.0