mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +00:00
[hal] Rename SimDevice constants to all caps
Also use enum class for SimDevice C++ wrapper.
This commit is contained in:
@@ -119,13 +119,13 @@ public class ADXL345_I2C implements NTSendable, AutoCloseable {
|
||||
m_simRange =
|
||||
m_simDevice.createEnumDouble(
|
||||
"range",
|
||||
SimDevice.Direction.kOutput,
|
||||
SimDevice.Direction.OUTPUT,
|
||||
new String[] {"2G", "4G", "8G", "16G"},
|
||||
new double[] {2.0, 4.0, 8.0, 16.0},
|
||||
0);
|
||||
m_simX = m_simDevice.createDouble("x", SimDevice.Direction.kInput, 0.0);
|
||||
m_simY = m_simDevice.createDouble("y", SimDevice.Direction.kInput, 0.0);
|
||||
m_simZ = m_simDevice.createDouble("z", SimDevice.Direction.kInput, 0.0);
|
||||
m_simX = m_simDevice.createDouble("x", SimDevice.Direction.INPUT, 0.0);
|
||||
m_simY = m_simDevice.createDouble("y", SimDevice.Direction.INPUT, 0.0);
|
||||
m_simZ = m_simDevice.createDouble("z", SimDevice.Direction.INPUT, 0.0);
|
||||
}
|
||||
|
||||
// Turn on the measurements
|
||||
|
||||
@@ -48,7 +48,7 @@ public abstract class PWMMotorController extends MotorSafety
|
||||
|
||||
m_simDevice = SimDevice.create("PWMMotorController", channel);
|
||||
if (m_simDevice != null) {
|
||||
m_simDutyCycle = m_simDevice.createDouble("DutyCycle", Direction.kOutput, 0.0);
|
||||
m_simDutyCycle = m_simDevice.createDouble("DutyCycle", Direction.OUTPUT, 0.0);
|
||||
m_pwm.setSimDevice(m_simDevice);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public class SharpIR implements Sendable, AutoCloseable {
|
||||
|
||||
m_simDevice = SimDevice.create("SharpIR", m_sensor.getChannel());
|
||||
if (m_simDevice != null) {
|
||||
m_simRange = m_simDevice.createDouble("Range (m)", Direction.kInput, 0.0);
|
||||
m_simRange = m_simDevice.createDouble("Range (m)", Direction.INPUT, 0.0);
|
||||
m_sensor.setSimDevice(m_simDevice);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public class AnalogEncoder implements Sendable, AutoCloseable {
|
||||
m_simDevice = SimDevice.create("AnalogEncoder", m_analogInput.getChannel());
|
||||
|
||||
if (m_simDevice != null) {
|
||||
m_simPosition = m_simDevice.createDouble("Position", Direction.kInput, 0.0);
|
||||
m_simPosition = m_simDevice.createDouble("Position", Direction.INPUT, 0.0);
|
||||
}
|
||||
|
||||
m_fullRange = fullRange;
|
||||
|
||||
@@ -86,8 +86,8 @@ public class DutyCycleEncoder implements Sendable, AutoCloseable {
|
||||
m_simDevice = SimDevice.create("DutyCycle:DutyCycleEncoder", m_dutyCycle.getSourceChannel());
|
||||
|
||||
if (m_simDevice != null) {
|
||||
m_simPosition = m_simDevice.createDouble("Position", SimDevice.Direction.kInput, 0.0);
|
||||
m_simIsConnected = m_simDevice.createBoolean("Connected", SimDevice.Direction.kInput, true);
|
||||
m_simPosition = m_simDevice.createDouble("Position", SimDevice.Direction.INPUT, 0.0);
|
||||
m_simIsConnected = m_simDevice.createBoolean("Connected", SimDevice.Direction.INPUT, true);
|
||||
}
|
||||
|
||||
m_fullRange = fullRange;
|
||||
|
||||
@@ -19,7 +19,7 @@ class SimDeviceSimTest {
|
||||
@Test
|
||||
void testBasic() {
|
||||
try (SimDevice dev = SimDevice.create("test")) {
|
||||
SimBoolean devBool = dev.createBoolean("bool", Direction.kBidir, false);
|
||||
SimBoolean devBool = dev.createBoolean("bool", Direction.BIDIR, false);
|
||||
|
||||
SimDeviceSim sim = new SimDeviceSim("test");
|
||||
SimBoolean simBool = sim.getBoolean("bool");
|
||||
@@ -92,7 +92,7 @@ class SimDeviceSimTest {
|
||||
AtomicInteger callback2Counter = new AtomicInteger(0);
|
||||
|
||||
try (SimDevice dev1 = SimDevice.create("testVM1")) {
|
||||
dev1.createBoolean("v1", Direction.kBidir, false);
|
||||
dev1.createBoolean("v1", Direction.BIDIR, false);
|
||||
SimDeviceSim sim = new SimDeviceSim("testVM1");
|
||||
try (CallbackStore callback1 =
|
||||
sim.registerValueCreatedCallback(
|
||||
@@ -106,13 +106,13 @@ class SimDeviceSimTest {
|
||||
callback2Counter.get(),
|
||||
"Callback 2 called early or not initialized with existing devices");
|
||||
|
||||
dev1.createDouble("v2", Direction.kBidir, 0);
|
||||
dev1.createDouble("v2", Direction.BIDIR, 0);
|
||||
|
||||
assertEquals(
|
||||
1, callback1Counter.get(), "Callback 1 called either more than once or not at all");
|
||||
assertEquals(2, callback2Counter.get(), "Callback 2 called either more or less than twice");
|
||||
}
|
||||
dev1.createBoolean("v3", Direction.kBidir, false);
|
||||
dev1.createBoolean("v3", Direction.BIDIR, false);
|
||||
|
||||
assertEquals(1, callback1Counter.get(), "Callback 1 called after closure");
|
||||
assertEquals(2, callback2Counter.get(), "Callback 2 called after closure");
|
||||
@@ -125,7 +125,7 @@ class SimDeviceSimTest {
|
||||
AtomicInteger callback2Counter = new AtomicInteger(0);
|
||||
|
||||
try (SimDevice dev1 = SimDevice.create("testVM1")) {
|
||||
SimBoolean val = dev1.createBoolean("v1", Direction.kBidir, false);
|
||||
SimBoolean val = dev1.createBoolean("v1", Direction.BIDIR, false);
|
||||
SimDeviceSim sim = new SimDeviceSim("testVM1");
|
||||
SimValue simVal = sim.getValue("v1");
|
||||
try (CallbackStore callback1 =
|
||||
|
||||
Reference in New Issue
Block a user