Search in sources :

Example 1 with NetworkTableInstance

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");
}
Also used : NetworkTableInstance(edu.wpi.first.networktables.NetworkTableInstance) NetworkTableTreeItemMatcher.hasDisplayString(edu.wpi.first.shuffleboard.plugin.networktables.components.NetworkTableTreeItemMatcher.hasDisplayString) ApplicationTest(org.testfx.framework.junit5.ApplicationTest) Test(org.junit.jupiter.api.Test)

Example 2 with NetworkTableInstance

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();
}
Also used : NetworkTableInstance(edu.wpi.first.networktables.NetworkTableInstance) MapData(edu.wpi.first.shuffleboard.api.data.MapData) NetworkTableEntry(edu.wpi.first.networktables.NetworkTableEntry) NetworkTable(edu.wpi.first.networktables.NetworkTable) RepeatedTest(org.junit.jupiter.api.RepeatedTest)

Example 3 with NetworkTableInstance

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();
}
Also used : NetworkTableInstance(edu.wpi.first.networktables.NetworkTableInstance) SourceType(edu.wpi.first.shuffleboard.api.sources.SourceType)

Example 4 with NetworkTableInstance

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());
}
Also used : WidgetTile(edu.wpi.first.shuffleboard.app.components.WidgetTile) NetworkTableInstance(edu.wpi.first.networktables.NetworkTableInstance) Node(javafx.scene.Node) Widget(edu.wpi.first.shuffleboard.api.widget.Widget) DataSource(edu.wpi.first.shuffleboard.api.sources.DataSource) ApplicationTest(org.testfx.framework.junit5.ApplicationTest) Test(org.junit.jupiter.api.Test) Tag(org.junit.jupiter.api.Tag)

Example 5 with NetworkTableInstance

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);
}
Also used : NetworkTableInstance(edu.wpi.first.networktables.NetworkTableInstance) NetworkTable(edu.wpi.first.networktables.NetworkTable)

Aggregations

NetworkTableInstance (edu.wpi.first.networktables.NetworkTableInstance)11 Test (org.junit.jupiter.api.Test)5 NetworkTable (edu.wpi.first.networktables.NetworkTable)4 ApplicationTest (org.testfx.framework.junit5.ApplicationTest)4 RepeatedTest (org.junit.jupiter.api.RepeatedTest)3 NetworkTableEntry (edu.wpi.first.networktables.NetworkTableEntry)2 MapData (edu.wpi.first.shuffleboard.api.data.MapData)2 DataSource (edu.wpi.first.shuffleboard.api.sources.DataSource)2 SourceType (edu.wpi.first.shuffleboard.api.sources.SourceType)2 WidgetTile (edu.wpi.first.shuffleboard.app.components.WidgetTile)2 NetworkTableTreeItemMatcher.hasDisplayString (edu.wpi.first.shuffleboard.plugin.networktables.components.NetworkTableTreeItemMatcher.hasDisplayString)2 Pose2d (edu.wpi.first.math.geometry.Pose2d)1 Transform2d (edu.wpi.first.math.geometry.Transform2d)1 ComplexDataType (edu.wpi.first.shuffleboard.api.data.ComplexDataType)1 DataType (edu.wpi.first.shuffleboard.api.data.DataType)1 AbstractDataSource (edu.wpi.first.shuffleboard.api.sources.AbstractDataSource)1 Sources (edu.wpi.first.shuffleboard.api.sources.Sources)1 AsyncUtils (edu.wpi.first.shuffleboard.api.util.AsyncUtils)1 Widget (edu.wpi.first.shuffleboard.api.widget.Widget)1 NetworkTableUtils (edu.wpi.first.shuffleboard.plugin.networktables.util.NetworkTableUtils)1