use of edu.wpi.first.networktables.NetworkTableInstance in project shuffleboard by wpilibsuite.
the class NetworkTableTreeTest method testDelete.
@Test
public void testDelete() {
final NetworkTableInstance inst = NetworkTableInstance.getDefault();
String key = "testDelete";
table.getEntry(key).setString("value");
inst.waitForEntryListenerQueue(-1.0);
waitForFxEvents();
assertNotNull(lookup(hasText(key)).query(), "There should be a cell for the entry");
table.delete(key);
inst.waitForEntryListenerQueue(-1.0);
waitForFxEvents();
assertNull(lookup(hasText(key)).query(), "The cell should have been removed");
}
use of edu.wpi.first.networktables.NetworkTableInstance in project shuffleboard by wpilibsuite.
the class CompositeNetworkTableSourceTest method testUpdatesCorrectEntry.
@RepeatedTest(10)
public void testUpdatesCorrectEntry() {
// given
final CompositeNetworkTableSource<MapData> source = new CompositeNetworkTableSource<>(tableName, DataTypes.Map);
final NetworkTableInstance inst = NetworkTableInstance.getDefault();
final NetworkTable table = inst.getTable(tableName);
final NetworkTableEntry entry = table.getEntry("testUpdatesCorrectEntry");
// when
source.setData(new MapData(ImmutableMap.of("testUpdatesCorrectEntry", "It does!")));
waitForNtEvents();
// then
assertAll(() -> assertThat("Unexpected keys: " + table.getKeys(), table.getKeys(), hasItem("testUpdatesCorrectEntry")), () -> assertEquals(NetworkTableType.kString, entry.getValue().getType()), () -> assertEquals("It does!", entry.getValue().getValue()));
source.close();
}
use of edu.wpi.first.networktables.NetworkTableInstance in project shuffleboard by wpilibsuite.
the class Playback method stop.
/**
* Stops playback.
*/
public void stop() {
if (!started) {
// This playback was never started, so there's no point in stopping it
return;
}
nextFrameFuture.cancel(true);
currentPlayback.setValue(null);
NetworkTableInstance inst = NetworkTableInstance.getDefault();
inst.deleteAllEntries();
SourceTypes.getDefault().getItems().forEach(SourceType::connect);
Recorder.getInstance().start();
}
use of edu.wpi.first.networktables.NetworkTableInstance in project shuffleboard by wpilibsuite.
the class MainWindowControllerTest method testNetworkTableSourceContextMenu.
@Test
@Tag("NonHeadlessTests")
public void testNetworkTableSourceContextMenu() {
NetworkTableInstance inst = NetworkTableInstance.getDefault();
inst.getEntry("/testSourceContextMenu").setString("value");
inst.waitForEntryListenerQueue(-1.0);
WaitForAsyncUtils.waitForFxEvents();
rightClickOn(TextMatchers.hasText("testSourceContextMenu"));
Node showAsText = lookup(TextMatchers.hasText("Show as: Text View")).query();
assertNotNull(showAsText);
clickOn(showAsText);
WidgetTile tile = lookup(".tile").query();
assertNotNull(tile);
Widget widget = tile.getContent();
DataSource source = widget.getSources().get(0);
assertTrue(source.isActive());
assertEquals("testSourceContextMenu", source.getName());
assertEquals("value", source.getData());
}
use of edu.wpi.first.networktables.NetworkTableInstance in project 2022Season by Robotiators-888.
the class NetworkTablesBase method run.
@Override
public void run() {
NetworkTableInstance inst = NetworkTableInstance.getDefault();
NetworkTable table = inst.getTable("datatable");
xEntry = table.getEntry("x");
yEntry = table.getEntry("y");
// where TEAM=190, 294, etc, or use inst.startClient("hostname") or similar
inst.startClientTeam(888);
// recommended if running on DS computer; this gets the robot IP from the DS
inst.startDSClient();
double x = SmartDashboard.getNumber("front_ball_x", 0);
double y = SmartDashboard.getNumber("front_ball_y", 0);
// System.out.println("X: " + x + " Y: " + y);
}
Aggregations