mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Update LiveWindow to provide continuous telemetry. (#771)
LiveWindow.updateValues() is now called from IterativeRobotBase on every loop iteration. Telemetry for all WPILib classes is enabled by default; it can be disabled for specific classes using LiveWindow.disableTelemetry(), or all telemetry can be disabled using LiveWindow.disableAllTelemetry(). This necessitated changing the hook methodology into other classes to be more property-based rather than each class providing multiple functions. This had the benefit of reducing boilerplate and increasing consistency. - Remove NamedSendable, add name to Sendable. - Provide SendableBase abstract class. - Deprecate LiveWindow addSensor/addActuator interfaces. - Add LiveWindow support to drive classes. - Add addChild() helper functions to Subsystem. - Fix inheritance hierarchy. Now only sensors inherit from SensorBase. Other devices inherit from some combination of SendableBase, ErrorBase, or nothing.
This commit is contained in:
@@ -19,6 +19,7 @@ import edu.wpi.first.wpilibj.Relay.Direction;
|
||||
import edu.wpi.first.wpilibj.Relay.InvalidValueException;
|
||||
import edu.wpi.first.wpilibj.Relay.Value;
|
||||
import edu.wpi.first.wpilibj.fixtures.RelayCrossConnectFixture;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SendableBuilderImpl;
|
||||
import edu.wpi.first.wpilibj.test.AbstractComsSetup;
|
||||
import edu.wpi.first.wpilibj.test.TestBench;
|
||||
|
||||
@@ -34,13 +35,16 @@ public class RelayCrossConnectTest extends AbstractComsSetup {
|
||||
private static final NetworkTable table =
|
||||
NetworkTableInstance.getDefault().getTable("_RELAY_CROSS_CONNECT_TEST_");
|
||||
private RelayCrossConnectFixture m_relayFixture;
|
||||
private SendableBuilderImpl m_builder;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
m_relayFixture = TestBench.getRelayCrossConnectFixture();
|
||||
m_relayFixture.setup();
|
||||
m_relayFixture.getRelay().initTable(table);
|
||||
m_builder = new SendableBuilderImpl();
|
||||
m_builder.setTable(table);
|
||||
m_relayFixture.getRelay().initSendable(m_builder);
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -53,7 +57,7 @@ public class RelayCrossConnectTest extends AbstractComsSetup {
|
||||
public void testBothHigh() {
|
||||
m_relayFixture.getRelay().setDirection(Direction.kBoth);
|
||||
m_relayFixture.getRelay().set(Value.kOn);
|
||||
m_relayFixture.getRelay().updateTable();
|
||||
m_builder.updateTable();
|
||||
assertTrue("Input one was not high when relay set both high", m_relayFixture.getInputOne()
|
||||
.get());
|
||||
assertTrue("Input two was not high when relay set both high", m_relayFixture.getInputTwo()
|
||||
@@ -66,7 +70,7 @@ public class RelayCrossConnectTest extends AbstractComsSetup {
|
||||
public void testFirstHigh() {
|
||||
m_relayFixture.getRelay().setDirection(Direction.kBoth);
|
||||
m_relayFixture.getRelay().set(Value.kForward);
|
||||
m_relayFixture.getRelay().updateTable();
|
||||
m_builder.updateTable();
|
||||
assertFalse("Input one was not low when relay set Value.kForward", m_relayFixture.getInputOne()
|
||||
.get());
|
||||
assertTrue("Input two was not high when relay set Value.kForward", m_relayFixture
|
||||
@@ -80,7 +84,7 @@ public class RelayCrossConnectTest extends AbstractComsSetup {
|
||||
public void testSecondHigh() {
|
||||
m_relayFixture.getRelay().setDirection(Direction.kBoth);
|
||||
m_relayFixture.getRelay().set(Value.kReverse);
|
||||
m_relayFixture.getRelay().updateTable();
|
||||
m_builder.updateTable();
|
||||
assertTrue("Input one was not high when relay set Value.kReverse", m_relayFixture.getInputOne()
|
||||
.get());
|
||||
assertFalse("Input two was not low when relay set Value.kReverse", m_relayFixture
|
||||
@@ -94,7 +98,7 @@ public class RelayCrossConnectTest extends AbstractComsSetup {
|
||||
public void testForwardDirection() {
|
||||
m_relayFixture.getRelay().setDirection(Direction.kForward);
|
||||
m_relayFixture.getRelay().set(Value.kOn);
|
||||
m_relayFixture.getRelay().updateTable();
|
||||
m_builder.updateTable();
|
||||
assertFalse("Input one was not low when relay set Value.kOn in kForward Direction",
|
||||
m_relayFixture.getInputOne().get());
|
||||
assertTrue("Input two was not high when relay set Value.kOn in kForward Direction",
|
||||
@@ -107,7 +111,7 @@ public class RelayCrossConnectTest extends AbstractComsSetup {
|
||||
public void testReverseDirection() {
|
||||
m_relayFixture.getRelay().setDirection(Direction.kReverse);
|
||||
m_relayFixture.getRelay().set(Value.kOn);
|
||||
m_relayFixture.getRelay().updateTable();
|
||||
m_builder.updateTable();
|
||||
assertTrue("Input one was not high when relay set Value.kOn in kReverse Direction",
|
||||
m_relayFixture.getInputOne().get());
|
||||
assertFalse("Input two was not low when relay set Value.kOn in kReverse Direction",
|
||||
@@ -130,6 +134,7 @@ public class RelayCrossConnectTest extends AbstractComsSetup {
|
||||
|
||||
@Test
|
||||
public void testInitialSettings() {
|
||||
m_builder.updateTable();
|
||||
assertEquals(Value.kOff, m_relayFixture.getRelay().get());
|
||||
// Initially both outputs should be off
|
||||
assertFalse(m_relayFixture.getInputOne().get());
|
||||
|
||||
Reference in New Issue
Block a user