Split Sendable into NT and non-NT portions (#3432)

The non-NT portion has been moved to wpiutil.
The NT portion has been moved to ntcore (as NTSendable).

SendableBuilder similarly split and moved.

SendableRegistry moved to wpiutil.

In C++, SendableHelper also moved to wpiutil.

This enables use of Sendable from wpimath and also enables
moving several classes from wpilib to wpimath.
This commit is contained in:
Peter Johnson
2021-06-13 16:38:05 -07:00
committed by GitHub
parent ef4ea84cb5
commit b417d961ec
196 changed files with 1147 additions and 891 deletions

View File

@@ -7,8 +7,9 @@ package edu.wpi.first.wpilibj.livewindow;
import edu.wpi.first.networktables.NetworkTable;
import edu.wpi.first.networktables.NetworkTableEntry;
import edu.wpi.first.networktables.NetworkTableInstance;
import edu.wpi.first.wpilibj.Sendable;
import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry;
import edu.wpi.first.util.sendable.Sendable;
import edu.wpi.first.util.sendable.SendableRegistry;
import edu.wpi.first.wpilibj.smartdashboard.SendableBuilderImpl;
/**
* The LiveWindow class is the public interface for putting sensors and actuators on the LiveWindow.
@@ -31,6 +32,10 @@ public class LiveWindow {
private static Runnable enabledListener;
private static Runnable disabledListener;
static {
SendableRegistry.setLiveWindowBuilderFactory(() -> new SendableBuilderImpl());
}
private static Component getOrAdd(Sendable sendable) {
Component data = (Component) SendableRegistry.getData(sendable, dataHandle);
if (data == null) {
@@ -84,7 +89,7 @@ public class LiveWindow {
SendableRegistry.foreachLiveWindow(
dataHandle,
cbdata -> {
cbdata.builder.stopLiveWindowMode();
((SendableBuilderImpl) cbdata.builder).stopLiveWindowMode();
});
if (disabledListener != null) {
disabledListener.run();
@@ -173,7 +178,7 @@ public class LiveWindow {
table = ssTable.getSubTable(cbdata.name);
}
table.getEntry(".name").setString(cbdata.name);
cbdata.builder.setTable(table);
((SendableBuilderImpl) cbdata.builder).setTable(table);
cbdata.sendable.initSendable(cbdata.builder);
ssTable.getEntry(".type").setString("LW Subsystem");
@@ -181,9 +186,9 @@ public class LiveWindow {
}
if (startLiveWindow) {
cbdata.builder.startLiveWindowMode();
((SendableBuilderImpl) cbdata.builder).startLiveWindowMode();
}
cbdata.builder.updateTable();
cbdata.builder.update();
});
startLiveWindow = false;