RobotCore
1.0
WPILib port to raspberry Pi
Toggle main menu visibility
Loading...
Searching...
No Matches
TunableInt.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.tunable;
6
7
import
java.util.function.IntConsumer;
8
import
java.util.function.IntSupplier;
9
11
public
abstract
class
TunableInt
extends
TunableBase
implements IntSupplier, IntConsumer {
17
public
static
TunableInt
create
() {
18
return
create
(0);
19
}
20
27
public
static
TunableInt
create
(
int
initialValue) {
28
return
createConfig
(initialValue,
null
);
29
}
30
40
public
static
TunableInt
create
(IntSupplier getter, IntConsumer setter) {
41
return
createConfig
(getter, setter,
null
);
42
}
43
50
public
static
TunableInt
createConfig
(
TunableConfig
config) {
51
return
createConfig
(0, config);
52
}
53
61
public
static
TunableInt
createConfig
(
int
initialValue,
TunableConfig
config) {
62
return
new
TunableInt
(config,
true
) {
63
@Override
64
public
void
set
(
int
value) {
65
if
(m_value == value) {
66
return
;
67
}
68
m_value = value;
69
markChanged
();
70
}
71
72
@Override
73
public
int
get
() {
74
return
m_value;
75
}
76
77
private
int
m_value = initialValue;
78
};
79
}
80
91
public
static
TunableInt
createConfig
(
92
IntSupplier getter, IntConsumer setter,
TunableConfig
config) {
93
if
(config ==
null
) {
94
config =
TunableConfig
.
of
(
TunableOption
.
ALWAYS_GET
);
95
}
else
if
(config.
getPolling
() ==
TunableConfig
.
Polling
.
DEFAULT
) {
96
config = config.
withPolling
(
TunableConfig
.
Polling
.
ALWAYS_GET
);
97
}
98
return
new
TunableInt
(config,
true
) {
99
@Override
100
public
void
set
(
int
value) {
101
boolean
changed = getter.getAsInt() != value;
102
if
(setter !=
null
) {
103
setter.accept(value);
104
}
105
if
(changed) {
106
markChanged
();
107
}
108
}
109
110
@Override
111
public
int
get
() {
112
return
getter.getAsInt();
113
}
114
};
115
}
116
122
protected
TunableInt
(
TunableConfig
config) {
123
super(config);
124
}
125
132
protected
TunableInt
(
TunableConfig
config,
boolean
supportsChangeNotification
) {
133
super(config,
supportsChangeNotification
);
134
}
135
143
public
abstract
void
set
(
int
value);
144
152
public
abstract
int
get
();
153
154
@Override
155
public
int
getAsInt() {
156
return
get
();
157
}
158
159
@Override
160
public
void
accept(
int
value) {
161
set
(value);
162
}
163
}
org.wpilib.tunable.TunableBase.supportsChangeNotification
boolean supportsChangeNotification()
Definition
TunableBase.java:85
org.wpilib.tunable.TunableBase.markChanged
void markChanged()
Definition
TunableBase.java:90
org.wpilib.tunable.TunableBase.TunableBase
TunableBase(TunableConfig config)
Definition
TunableBase.java:24
org.wpilib.tunable.TunableConfig
Definition
TunableConfig.java:15
org.wpilib.tunable.TunableConfig.getPolling
Polling getPolling()
Definition
TunableConfig.java:338
org.wpilib.tunable.TunableConfig.withPolling
TunableConfig withPolling(Polling polling)
Definition
TunableConfig.java:260
org.wpilib.tunable.TunableConfig.of
static TunableConfig of(TunableOption... options)
Definition
TunableConfig.java:128
org.wpilib.tunable.TunableInt.create
static TunableInt create(IntSupplier getter, IntConsumer setter)
Definition
TunableInt.java:40
org.wpilib.tunable.TunableInt.create
static TunableInt create(int initialValue)
Definition
TunableInt.java:27
org.wpilib.tunable.TunableInt.createConfig
static TunableInt createConfig(int initialValue, TunableConfig config)
Definition
TunableInt.java:61
org.wpilib.tunable.TunableInt.TunableInt
TunableInt(TunableConfig config, boolean supportsChangeNotification)
Definition
TunableInt.java:132
org.wpilib.tunable.TunableInt.createConfig
static TunableInt createConfig(IntSupplier getter, IntConsumer setter, TunableConfig config)
Definition
TunableInt.java:91
org.wpilib.tunable.TunableInt.TunableInt
TunableInt(TunableConfig config)
Definition
TunableInt.java:122
org.wpilib.tunable.TunableInt.createConfig
static TunableInt createConfig(TunableConfig config)
Definition
TunableInt.java:50
org.wpilib.tunable.TunableInt.create
static TunableInt create()
Definition
TunableInt.java:17
org.wpilib.tunable.TunableConfig.Polling
Definition
TunableConfig.java:23
org.wpilib.tunable.TunableConfig.Polling.DEFAULT
DEFAULT
Definition
TunableConfig.java:25
org.wpilib.tunable.TunableConfig.Polling.ALWAYS_GET
ALWAYS_GET
Definition
TunableConfig.java:28
org.wpilib.tunable.TunableOption
Definition
TunableOption.java:10
org.wpilib.tunable.TunableOption.ALWAYS_GET
TunableOption ALWAYS_GET
Definition
TunableOption.java:89
org
wpilib
tunable
TunableInt.java
Generated by
1.18.0