mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
Remove getTable from wpilibj Sendable interface.
This allows nearly all m_table member variables to be removed.
This commit is contained in:
@@ -175,7 +175,6 @@ public class ADXL345_I2C extends SensorBase implements Accelerometer, LiveWindow
|
||||
return "3AxisAccelerometer";
|
||||
}
|
||||
|
||||
private NetworkTable m_table;
|
||||
@SuppressWarnings("MemberName")
|
||||
private NetworkTableEntry m_xEntry;
|
||||
@SuppressWarnings("MemberName")
|
||||
@@ -185,11 +184,10 @@ public class ADXL345_I2C extends SensorBase implements Accelerometer, LiveWindow
|
||||
|
||||
@Override
|
||||
public void initTable(NetworkTable subtable) {
|
||||
m_table = subtable;
|
||||
if (m_table != null) {
|
||||
m_xEntry = m_table.getEntry("X");
|
||||
m_yEntry = m_table.getEntry("Y");
|
||||
m_zEntry = m_table.getEntry("Z");
|
||||
if (subtable != null) {
|
||||
m_xEntry = subtable.getEntry("X");
|
||||
m_yEntry = subtable.getEntry("Y");
|
||||
m_zEntry = subtable.getEntry("Z");
|
||||
updateTable();
|
||||
} else {
|
||||
m_xEntry = null;
|
||||
@@ -211,11 +209,6 @@ public class ADXL345_I2C extends SensorBase implements Accelerometer, LiveWindow
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkTable getTable() {
|
||||
return m_table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startLiveWindowMode() {
|
||||
}
|
||||
|
||||
@@ -193,7 +193,6 @@ public class ADXL345_SPI extends SensorBase implements Accelerometer, LiveWindow
|
||||
return "3AxisAccelerometer";
|
||||
}
|
||||
|
||||
private NetworkTable m_table;
|
||||
@SuppressWarnings("MemberName")
|
||||
private NetworkTableEntry m_xEntry;
|
||||
@SuppressWarnings("MemberName")
|
||||
@@ -203,11 +202,10 @@ public class ADXL345_SPI extends SensorBase implements Accelerometer, LiveWindow
|
||||
|
||||
@Override
|
||||
public void initTable(NetworkTable subtable) {
|
||||
m_table = subtable;
|
||||
if (m_table != null) {
|
||||
m_xEntry = m_table.getEntry("X");
|
||||
m_yEntry = m_table.getEntry("Y");
|
||||
m_zEntry = m_table.getEntry("Z");
|
||||
if (subtable != null) {
|
||||
m_xEntry = subtable.getEntry("X");
|
||||
m_yEntry = subtable.getEntry("Y");
|
||||
m_zEntry = subtable.getEntry("Z");
|
||||
updateTable();
|
||||
} else {
|
||||
m_xEntry = null;
|
||||
@@ -229,11 +227,6 @@ public class ADXL345_SPI extends SensorBase implements Accelerometer, LiveWindow
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkTable getTable() {
|
||||
return m_table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startLiveWindowMode() {
|
||||
}
|
||||
|
||||
@@ -209,7 +209,6 @@ public class ADXL362 extends SensorBase implements Accelerometer, LiveWindowSend
|
||||
return "3AxisAccelerometer";
|
||||
}
|
||||
|
||||
private NetworkTable m_table;
|
||||
@SuppressWarnings("MemberName")
|
||||
private NetworkTableEntry m_xEntry;
|
||||
@SuppressWarnings("MemberName")
|
||||
@@ -219,11 +218,10 @@ public class ADXL362 extends SensorBase implements Accelerometer, LiveWindowSend
|
||||
|
||||
@Override
|
||||
public void initTable(NetworkTable subtable) {
|
||||
m_table = subtable;
|
||||
if (m_table != null) {
|
||||
m_xEntry = m_table.getEntry("X");
|
||||
m_yEntry = m_table.getEntry("Y");
|
||||
m_zEntry = m_table.getEntry("Z");
|
||||
if (subtable != null) {
|
||||
m_xEntry = subtable.getEntry("X");
|
||||
m_yEntry = subtable.getEntry("Y");
|
||||
m_zEntry = subtable.getEntry("Z");
|
||||
updateTable();
|
||||
} else {
|
||||
m_xEntry = null;
|
||||
@@ -245,11 +243,6 @@ public class ADXL362 extends SensorBase implements Accelerometer, LiveWindowSend
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkTable getTable() {
|
||||
return m_table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startLiveWindowMode() {
|
||||
}
|
||||
|
||||
@@ -141,25 +141,18 @@ public class AnalogAccelerometer extends SensorBase implements PIDSource, LiveWi
|
||||
/*
|
||||
* Live Window code, only does anything if live window is activated.
|
||||
*/
|
||||
private NetworkTable m_table;
|
||||
private NetworkTableEntry m_valueEntry;
|
||||
|
||||
@Override
|
||||
public void initTable(NetworkTable subtable) {
|
||||
m_table = subtable;
|
||||
if (m_table != null) {
|
||||
m_valueEntry = m_table.getEntry("Value");
|
||||
if (subtable != null) {
|
||||
m_valueEntry = subtable.getEntry("Value");
|
||||
updateTable();
|
||||
} else {
|
||||
m_valueEntry = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkTable getTable() {
|
||||
return m_table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTable() {
|
||||
if (m_valueEntry != null) {
|
||||
|
||||
@@ -365,14 +365,12 @@ public class AnalogInput extends SensorBase implements PIDSource, LiveWindowSend
|
||||
return "Analog Input";
|
||||
}
|
||||
|
||||
private NetworkTable m_table;
|
||||
private NetworkTableEntry m_valueEntry;
|
||||
|
||||
@Override
|
||||
public void initTable(NetworkTable subtable) {
|
||||
m_table = subtable;
|
||||
if (m_table != null) {
|
||||
m_valueEntry = m_table.getEntry("Value");
|
||||
if (subtable != null) {
|
||||
m_valueEntry = subtable.getEntry("Value");
|
||||
updateTable();
|
||||
} else {
|
||||
m_valueEntry = null;
|
||||
@@ -386,11 +384,6 @@ public class AnalogInput extends SensorBase implements PIDSource, LiveWindowSend
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkTable getTable() {
|
||||
return m_table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Analog Channels don't have to do anything special when entering the LiveWindow. {@inheritDoc}
|
||||
*/
|
||||
|
||||
@@ -70,14 +70,12 @@ public class AnalogOutput extends SensorBase implements LiveWindowSendable {
|
||||
return "Analog Output";
|
||||
}
|
||||
|
||||
private NetworkTable m_table;
|
||||
private NetworkTableEntry m_valueEntry;
|
||||
|
||||
@Override
|
||||
public void initTable(NetworkTable subtable) {
|
||||
m_table = subtable;
|
||||
if (m_table != null) {
|
||||
m_valueEntry = m_table.getEntry("Value");
|
||||
if (subtable != null) {
|
||||
m_valueEntry = subtable.getEntry("Value");
|
||||
updateTable();
|
||||
} else {
|
||||
m_valueEntry = null;
|
||||
@@ -91,11 +89,6 @@ public class AnalogOutput extends SensorBase implements LiveWindowSendable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkTable getTable() {
|
||||
return m_table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Analog Channels don't have to do anything special when entering the LiveWindow. {@inheritDoc}
|
||||
*/
|
||||
|
||||
@@ -153,14 +153,12 @@ public class AnalogPotentiometer implements Potentiometer, LiveWindowSendable {
|
||||
return "Analog Input";
|
||||
}
|
||||
|
||||
private NetworkTable m_table;
|
||||
private NetworkTableEntry m_valueEntry;
|
||||
|
||||
@Override
|
||||
public void initTable(NetworkTable subtable) {
|
||||
m_table = subtable;
|
||||
if (m_table != null) {
|
||||
m_valueEntry = m_table.getEntry("Value");
|
||||
if (subtable != null) {
|
||||
m_valueEntry = subtable.getEntry("Value");
|
||||
updateTable();
|
||||
} else {
|
||||
m_valueEntry = null;
|
||||
@@ -174,11 +172,6 @@ public class AnalogPotentiometer implements Potentiometer, LiveWindowSendable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkTable getTable() {
|
||||
return m_table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees this resource.
|
||||
*/
|
||||
|
||||
@@ -98,7 +98,6 @@ public class BuiltInAccelerometer implements Accelerometer, LiveWindowSendable {
|
||||
return "3AxisAccelerometer";
|
||||
}
|
||||
|
||||
private NetworkTable m_table;
|
||||
@SuppressWarnings("MemberName")
|
||||
private NetworkTableEntry m_xEntry;
|
||||
@SuppressWarnings("MemberName")
|
||||
@@ -108,11 +107,10 @@ public class BuiltInAccelerometer implements Accelerometer, LiveWindowSendable {
|
||||
|
||||
@Override
|
||||
public void initTable(NetworkTable subtable) {
|
||||
m_table = subtable;
|
||||
if (m_table != null) {
|
||||
m_xEntry = m_table.getEntry("X");
|
||||
m_yEntry = m_table.getEntry("Y");
|
||||
m_zEntry = m_table.getEntry("Z");
|
||||
if (subtable != null) {
|
||||
m_xEntry = subtable.getEntry("X");
|
||||
m_yEntry = subtable.getEntry("Y");
|
||||
m_zEntry = subtable.getEntry("Z");
|
||||
updateTable();
|
||||
} else {
|
||||
m_xEntry = null;
|
||||
@@ -134,11 +132,6 @@ public class BuiltInAccelerometer implements Accelerometer, LiveWindowSendable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkTable getTable() {
|
||||
return m_table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startLiveWindowMode() {
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
package edu.wpi.first.wpilibj;
|
||||
|
||||
import edu.wpi.first.networktables.EntryListenerFlags;
|
||||
import edu.wpi.first.networktables.NetworkTable;
|
||||
import edu.wpi.first.wpilibj.livewindow.LiveWindowSendable;
|
||||
|
||||
public interface CANSpeedController extends SpeedController, PIDInterface, LiveWindowSendable {
|
||||
@@ -141,94 +139,8 @@ public interface CANSpeedController extends SpeedController, PIDInterface, LiveW
|
||||
*/
|
||||
String SMART_DASHBOARD_TYPE = "CANSpeedController";
|
||||
|
||||
@Override
|
||||
default void updateTable() {
|
||||
NetworkTable table = getTable();
|
||||
if (table != null) {
|
||||
table.getEntry("~TYPE~").setString(SMART_DASHBOARD_TYPE);
|
||||
table.getEntry("Type").setString(getClass().getSimpleName());
|
||||
table.getEntry("Mode").setDouble(getControlMode().getValue());
|
||||
if (getControlMode().isPID()) {
|
||||
table.getEntry("p").setDouble(getP());
|
||||
table.getEntry("i").setDouble(getI());
|
||||
table.getEntry("d").setDouble(getD());
|
||||
table.getEntry("f").setDouble(getF());
|
||||
}
|
||||
table.getEntry("Enabled").setBoolean(isEnabled());
|
||||
table.getEntry("Value").setDouble(get());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
default String getSmartDashboardType() {
|
||||
return SMART_DASHBOARD_TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove table listeners.
|
||||
*/
|
||||
default void removeTableListeners(int[] listeners) {
|
||||
NetworkTable table = getTable();
|
||||
if (table != null) {
|
||||
table.getEntry("Mode").removeListener(listeners[0]);
|
||||
table.getEntry("p").removeListener(listeners[1]);
|
||||
table.getEntry("i").removeListener(listeners[2]);
|
||||
table.getEntry("d").removeListener(listeners[3]);
|
||||
table.getEntry("f").removeListener(listeners[4]);
|
||||
table.getEntry("Enabled").removeListener(listeners[5]);
|
||||
table.getEntry("Value").removeListener(listeners[6]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create table listeners.
|
||||
*/
|
||||
default int[] createTableListeners() {
|
||||
int[] listeners = new int[7];
|
||||
NetworkTable table = getTable();
|
||||
if (table != null) {
|
||||
listeners[0] = table.getEntry("Mode").addListener(
|
||||
(event) -> setControlMode((int) event.value.getDouble()),
|
||||
EntryListenerFlags.kNew | EntryListenerFlags.kUpdate);
|
||||
|
||||
listeners[1] = table.getEntry("p").addListener((event) -> {
|
||||
if (getControlMode().isPID()) {
|
||||
setP(event.value.getDouble());
|
||||
}
|
||||
}, EntryListenerFlags.kNew | EntryListenerFlags.kUpdate);
|
||||
|
||||
listeners[2] = table.getEntry("i").addListener((event) -> {
|
||||
if (getControlMode().isPID()) {
|
||||
setI(event.value.getDouble());
|
||||
}
|
||||
}, EntryListenerFlags.kNew | EntryListenerFlags.kUpdate);
|
||||
|
||||
listeners[3] = table.getEntry("d").addListener((event) -> {
|
||||
if (getControlMode().isPID()) {
|
||||
setD(event.value.getDouble());
|
||||
}
|
||||
}, EntryListenerFlags.kNew | EntryListenerFlags.kUpdate);
|
||||
|
||||
listeners[4] = table.getEntry("f").addListener((event) -> {
|
||||
if (getControlMode().isPID()) {
|
||||
setF(event.value.getDouble());
|
||||
}
|
||||
}, EntryListenerFlags.kNew | EntryListenerFlags.kUpdate);
|
||||
|
||||
listeners[5] = table.getEntry("Enabled").addListener((event) -> {
|
||||
if (event.value.getBoolean()) {
|
||||
enable();
|
||||
} else {
|
||||
disable();
|
||||
}
|
||||
}, EntryListenerFlags.kNew | EntryListenerFlags.kUpdate);
|
||||
|
||||
listeners[6] = table.getEntry("Value").addListener(
|
||||
(event) -> set(event.value.getDouble()),
|
||||
EntryListenerFlags.kNew | EntryListenerFlags.kUpdate);
|
||||
}
|
||||
return listeners;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ public class Compressor extends SensorBase implements LiveWindowSendable {
|
||||
* @param module The PCM CAN device ID (0 - 62 inclusive)
|
||||
*/
|
||||
public Compressor(int module) {
|
||||
m_table = null;
|
||||
m_module = (byte) module;
|
||||
|
||||
m_compressorHandle = CompressorJNI.initializeCompressor((byte) module);
|
||||
@@ -215,17 +214,15 @@ public class Compressor extends SensorBase implements LiveWindowSendable {
|
||||
return "Compressor";
|
||||
}
|
||||
|
||||
private NetworkTable m_table;
|
||||
private NetworkTableEntry m_enabledEntry;
|
||||
private NetworkTableEntry m_pressureSwitchEntry;
|
||||
private int m_enabledListener;
|
||||
|
||||
@Override
|
||||
public void initTable(NetworkTable subtable) {
|
||||
m_table = subtable;
|
||||
if (m_table != null) {
|
||||
m_enabledEntry = m_table.getEntry("Enabled");
|
||||
m_pressureSwitchEntry = m_table.getEntry("Pressure Switch");
|
||||
if (subtable != null) {
|
||||
m_enabledEntry = subtable.getEntry("Enabled");
|
||||
m_pressureSwitchEntry = subtable.getEntry("Pressure Switch");
|
||||
updateTable();
|
||||
} else {
|
||||
m_enabledEntry = null;
|
||||
@@ -233,11 +230,6 @@ public class Compressor extends SensorBase implements LiveWindowSendable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkTable getTable() {
|
||||
return m_table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTable() {
|
||||
if (m_enabledEntry != null) {
|
||||
|
||||
@@ -557,25 +557,18 @@ public class Counter extends SensorBase implements CounterBase, LiveWindowSendab
|
||||
return "Counter";
|
||||
}
|
||||
|
||||
private NetworkTable m_table;
|
||||
private NetworkTableEntry m_valueEntry;
|
||||
|
||||
@Override
|
||||
public void initTable(NetworkTable subtable) {
|
||||
m_table = subtable;
|
||||
if (m_table != null) {
|
||||
m_valueEntry = m_table.getEntry("Value");
|
||||
if (subtable != null) {
|
||||
m_valueEntry = subtable.getEntry("Value");
|
||||
updateTable();
|
||||
} else {
|
||||
m_valueEntry = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkTable getTable() {
|
||||
return m_table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTable() {
|
||||
if (m_valueEntry != null) {
|
||||
|
||||
@@ -106,14 +106,12 @@ public class DigitalInput extends DigitalSource implements LiveWindowSendable {
|
||||
return "Digital Input";
|
||||
}
|
||||
|
||||
private NetworkTable m_table;
|
||||
private NetworkTableEntry m_valueEntry;
|
||||
|
||||
@Override
|
||||
public void initTable(NetworkTable subtable) {
|
||||
m_table = subtable;
|
||||
if (m_table != null) {
|
||||
m_valueEntry = m_table.getEntry("Value");
|
||||
if (subtable != null) {
|
||||
m_valueEntry = subtable.getEntry("Value");
|
||||
updateTable();
|
||||
} else {
|
||||
m_valueEntry = null;
|
||||
@@ -129,12 +127,6 @@ public class DigitalInput extends DigitalSource implements LiveWindowSendable {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public NetworkTable getTable() {
|
||||
return m_table;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void startLiveWindowMode() {
|
||||
}
|
||||
|
||||
@@ -205,16 +205,14 @@ public class DigitalOutput extends DigitalSource implements LiveWindowSendable {
|
||||
return "Digital Output";
|
||||
}
|
||||
|
||||
private NetworkTable m_table;
|
||||
private NetworkTableEntry m_valueEntry;
|
||||
private int m_valueListener;
|
||||
|
||||
|
||||
@Override
|
||||
public void initTable(NetworkTable subtable) {
|
||||
m_table = subtable;
|
||||
if (m_table != null) {
|
||||
m_valueEntry = m_table.getEntry("Value");
|
||||
if (subtable != null) {
|
||||
m_valueEntry = subtable.getEntry("Value");
|
||||
updateTable();
|
||||
} else {
|
||||
m_valueEntry = null;
|
||||
@@ -222,12 +220,6 @@ public class DigitalOutput extends DigitalSource implements LiveWindowSendable {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public NetworkTable getTable() {
|
||||
return m_table;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateTable() {
|
||||
// TODO: Put current value.
|
||||
|
||||
@@ -176,26 +176,19 @@ public class DoubleSolenoid extends SolenoidBase implements LiveWindowSendable {
|
||||
return "Double Solenoid";
|
||||
}
|
||||
|
||||
private NetworkTable m_table;
|
||||
private NetworkTableEntry m_valueEntry;
|
||||
private int m_valueListener;
|
||||
|
||||
@Override
|
||||
public void initTable(NetworkTable subtable) {
|
||||
m_table = subtable;
|
||||
if (m_table != null) {
|
||||
m_valueEntry = m_table.getEntry("Value");
|
||||
if (subtable != null) {
|
||||
m_valueEntry = subtable.getEntry("Value");
|
||||
updateTable();
|
||||
} else {
|
||||
m_valueEntry = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkTable getTable() {
|
||||
return m_table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTable() {
|
||||
if (m_valueEntry != null) {
|
||||
|
||||
@@ -577,18 +577,16 @@ public class Encoder extends SensorBase implements CounterBase, PIDSource, LiveW
|
||||
return "Encoder";
|
||||
}
|
||||
|
||||
private NetworkTable m_table;
|
||||
private NetworkTableEntry m_speedEntry;
|
||||
private NetworkTableEntry m_distanceEntry;
|
||||
private NetworkTableEntry m_distancePerTickEntry;
|
||||
|
||||
@Override
|
||||
public void initTable(NetworkTable subtable) {
|
||||
m_table = subtable;
|
||||
if (m_table != null) {
|
||||
m_speedEntry = m_table.getEntry("Speed");
|
||||
m_distanceEntry = m_table.getEntry("Distance");
|
||||
m_distancePerTickEntry = m_table.getEntry("Distance per Tick");
|
||||
if (subtable != null) {
|
||||
m_speedEntry = subtable.getEntry("Speed");
|
||||
m_distanceEntry = subtable.getEntry("Distance");
|
||||
m_distancePerTickEntry = subtable.getEntry("Distance per Tick");
|
||||
updateTable();
|
||||
} else {
|
||||
m_speedEntry = null;
|
||||
@@ -597,11 +595,6 @@ public class Encoder extends SensorBase implements CounterBase, PIDSource, LiveW
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkTable getTable() {
|
||||
return m_table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTable() {
|
||||
if (m_speedEntry != null) {
|
||||
|
||||
@@ -60,25 +60,18 @@ public abstract class GyroBase extends SensorBase implements Gyro, PIDSource, Li
|
||||
return "Gyro";
|
||||
}
|
||||
|
||||
private NetworkTable m_table;
|
||||
private NetworkTableEntry m_valueEntry;
|
||||
|
||||
@Override
|
||||
public void initTable(NetworkTable subtable) {
|
||||
m_table = subtable;
|
||||
if (m_table != null) {
|
||||
m_valueEntry = m_table.getEntry("Value");
|
||||
if (subtable != null) {
|
||||
m_valueEntry = subtable.getEntry("Value");
|
||||
updateTable();
|
||||
} else {
|
||||
m_valueEntry = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkTable getTable() {
|
||||
return m_table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTable() {
|
||||
if (m_valueEntry != null) {
|
||||
|
||||
@@ -695,7 +695,6 @@ public class PIDController implements PIDInterface, LiveWindowSendable, Controll
|
||||
return "PIDController";
|
||||
}
|
||||
|
||||
private NetworkTable m_table;
|
||||
@SuppressWarnings("MemberName")
|
||||
private NetworkTableEntry m_pEntry;
|
||||
@SuppressWarnings("MemberName")
|
||||
@@ -741,7 +740,6 @@ public class PIDController implements PIDInterface, LiveWindowSendable, Controll
|
||||
@Override
|
||||
public void initTable(NetworkTable table) {
|
||||
removeListeners();
|
||||
m_table = table;
|
||||
if (table != null) {
|
||||
m_pEntry = table.getEntry("p");
|
||||
m_pEntry.setDouble(getP());
|
||||
@@ -826,12 +824,6 @@ public class PIDController implements PIDInterface, LiveWindowSendable, Controll
|
||||
return error;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkTable getTable() {
|
||||
return m_table;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateTable() {
|
||||
}
|
||||
|
||||
@@ -250,15 +250,13 @@ public class PWM extends SensorBase implements LiveWindowSendable {
|
||||
return "Speed Controller";
|
||||
}
|
||||
|
||||
private NetworkTable m_table;
|
||||
private NetworkTableEntry m_valueEntry;
|
||||
private int m_valueListener;
|
||||
|
||||
@Override
|
||||
public void initTable(NetworkTable subtable) {
|
||||
m_table = subtable;
|
||||
if (m_table != null) {
|
||||
m_valueEntry = m_table.getEntry("Value");
|
||||
if (subtable != null) {
|
||||
m_valueEntry = subtable.getEntry("Value");
|
||||
updateTable();
|
||||
} else {
|
||||
m_valueEntry = null;
|
||||
@@ -272,11 +270,6 @@ public class PWM extends SensorBase implements LiveWindowSendable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkTable getTable() {
|
||||
return m_table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startLiveWindowMode() {
|
||||
setSpeed(0); // Stop for safety
|
||||
|
||||
@@ -118,21 +118,19 @@ public class PowerDistributionPanel extends SensorBase implements LiveWindowSend
|
||||
/*
|
||||
* Live Window code, only does anything if live window is activated.
|
||||
*/
|
||||
private NetworkTable m_table;
|
||||
private NetworkTableEntry[] m_chanEntry;
|
||||
private NetworkTableEntry m_voltageEntry;
|
||||
private NetworkTableEntry m_totalCurrentEntry;
|
||||
|
||||
@Override
|
||||
public void initTable(NetworkTable subtable) {
|
||||
m_table = subtable;
|
||||
if (m_table != null) {
|
||||
if (subtable != null) {
|
||||
m_chanEntry = new NetworkTableEntry[16];
|
||||
for (int i = 0; i < m_chanEntry.length; i++) {
|
||||
m_chanEntry[i] = m_table.getEntry("Chan" + i);
|
||||
m_chanEntry[i] = subtable.getEntry("Chan" + i);
|
||||
}
|
||||
m_voltageEntry = m_table.getEntry("Voltage");
|
||||
m_totalCurrentEntry = m_table.getEntry("TotalCurrent");
|
||||
m_voltageEntry = subtable.getEntry("Voltage");
|
||||
m_totalCurrentEntry = subtable.getEntry("TotalCurrent");
|
||||
updateTable();
|
||||
} else {
|
||||
m_chanEntry = null;
|
||||
@@ -141,11 +139,6 @@ public class PowerDistributionPanel extends SensorBase implements LiveWindowSend
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkTable getTable() {
|
||||
return m_table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTable() {
|
||||
if (m_chanEntry != null) {
|
||||
|
||||
@@ -337,26 +337,19 @@ public class Relay extends SensorBase implements MotorSafety, LiveWindowSendable
|
||||
return "Relay";
|
||||
}
|
||||
|
||||
private NetworkTable m_table;
|
||||
private NetworkTableEntry m_valueEntry;
|
||||
private int m_valueListener;
|
||||
|
||||
@Override
|
||||
public void initTable(NetworkTable subtable) {
|
||||
m_table = subtable;
|
||||
if (m_table != null) {
|
||||
m_valueEntry = m_table.getEntry("Value");
|
||||
if (subtable != null) {
|
||||
m_valueEntry = subtable.getEntry("Value");
|
||||
updateTable();
|
||||
} else {
|
||||
m_valueEntry = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkTable getTable() {
|
||||
return m_table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTable() {
|
||||
if (m_valueEntry != null) {
|
||||
|
||||
@@ -21,13 +21,6 @@ public interface Sendable {
|
||||
*/
|
||||
void initTable(NetworkTable subtable);
|
||||
|
||||
/**
|
||||
* The table that is associated with this {@link Sendable}.
|
||||
*
|
||||
* @return the table that is currently associated with the {@link Sendable}.
|
||||
*/
|
||||
NetworkTable getTable();
|
||||
|
||||
/**
|
||||
* The string representation of the named data type that will be used by the smart dashboard for
|
||||
* this {@link Sendable}.
|
||||
|
||||
@@ -105,26 +105,19 @@ public class Solenoid extends SolenoidBase implements LiveWindowSendable {
|
||||
return "Solenoid";
|
||||
}
|
||||
|
||||
private NetworkTable m_table;
|
||||
private NetworkTableEntry m_valueEntry;
|
||||
private int m_valueListener;
|
||||
|
||||
@Override
|
||||
public void initTable(NetworkTable subtable) {
|
||||
m_table = subtable;
|
||||
if (m_table != null) {
|
||||
m_valueEntry = m_table.getEntry("Value");
|
||||
if (subtable != null) {
|
||||
m_valueEntry = subtable.getEntry("Value");
|
||||
updateTable();
|
||||
} else {
|
||||
m_valueEntry = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkTable getTable() {
|
||||
return m_table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTable() {
|
||||
if (m_valueEntry != null) {
|
||||
|
||||
@@ -399,25 +399,18 @@ public class Ultrasonic extends SensorBase implements PIDSource, LiveWindowSenda
|
||||
return "Ultrasonic";
|
||||
}
|
||||
|
||||
private NetworkTable m_table;
|
||||
private NetworkTableEntry m_valueEntry;
|
||||
|
||||
@Override
|
||||
public void initTable(NetworkTable subtable) {
|
||||
m_table = subtable;
|
||||
if (m_table != null) {
|
||||
m_valueEntry = m_table.getEntry("Value");
|
||||
if (subtable != null) {
|
||||
m_valueEntry = subtable.getEntry("Value");
|
||||
updateTable();
|
||||
} else {
|
||||
m_valueEntry = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkTable getTable() {
|
||||
return m_table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTable() {
|
||||
if (m_valueEntry != null) {
|
||||
|
||||
@@ -195,12 +195,10 @@ public abstract class Trigger implements Sendable {
|
||||
return "Button";
|
||||
}
|
||||
|
||||
private NetworkTable m_table;
|
||||
private NetworkTableEntry m_pressedEntry;
|
||||
|
||||
@Override
|
||||
public void initTable(NetworkTable table) {
|
||||
m_table = table;
|
||||
if (table != null) {
|
||||
m_pressedEntry = table.getEntry("pressed");
|
||||
m_pressedEntry.setBoolean(get());
|
||||
@@ -208,9 +206,4 @@ public abstract class Trigger implements Sendable {
|
||||
m_pressedEntry = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkTable getTable() {
|
||||
return m_table;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -564,7 +564,6 @@ public abstract class Command implements NamedSendable {
|
||||
return "Command";
|
||||
}
|
||||
|
||||
private NetworkTable m_table;
|
||||
private NetworkTableEntry m_runningEntry;
|
||||
private NetworkTableEntry m_isParentedEntry;
|
||||
private int m_runningListener;
|
||||
@@ -574,7 +573,6 @@ public abstract class Command implements NamedSendable {
|
||||
if (m_runningEntry != null) {
|
||||
m_runningEntry.removeListener(m_runningListener);
|
||||
}
|
||||
m_table = table;
|
||||
if (table != null) {
|
||||
m_runningEntry = table.getEntry("running");
|
||||
m_isParentedEntry = table.getEntry("isParented");
|
||||
@@ -593,10 +591,4 @@ public abstract class Command implements NamedSendable {
|
||||
m_isParentedEntry = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkTable getTable() {
|
||||
return m_table;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -73,7 +73,6 @@ public class Scheduler implements NamedSendable {
|
||||
* A list of all {@link Command Commands} which need to be added.
|
||||
*/
|
||||
private Vector<Command> m_additions = new Vector<>();
|
||||
private NetworkTable m_table;
|
||||
private NetworkTableEntry m_namesEntry;
|
||||
private NetworkTableEntry m_idsEntry;
|
||||
private NetworkTableEntry m_cancelEntry;
|
||||
@@ -315,11 +314,10 @@ public class Scheduler implements NamedSendable {
|
||||
|
||||
@Override
|
||||
public void initTable(NetworkTable subtable) {
|
||||
m_table = subtable;
|
||||
if (m_table != null) {
|
||||
m_namesEntry = m_table.getEntry("Names");
|
||||
m_idsEntry = m_table.getEntry("Ids");
|
||||
m_cancelEntry = m_table.getEntry("Cancel");
|
||||
if (subtable != null) {
|
||||
m_namesEntry = subtable.getEntry("Names");
|
||||
m_idsEntry = subtable.getEntry("Ids");
|
||||
m_cancelEntry = subtable.getEntry("Cancel");
|
||||
m_namesEntry.setStringArray(new String[0]);
|
||||
m_idsEntry.setDoubleArray(new double[0]);
|
||||
m_cancelEntry.setDoubleArray(new double[0]);
|
||||
@@ -331,7 +329,7 @@ public class Scheduler implements NamedSendable {
|
||||
}
|
||||
|
||||
private void updateTable() {
|
||||
if (m_table != null) {
|
||||
if (m_namesEntry != null && m_idsEntry != null && m_cancelEntry != null) {
|
||||
// Get the commands to cancel
|
||||
double[] toCancel = m_cancelEntry.getDoubleArray(new double[0]);
|
||||
if (toCancel.length > 0) {
|
||||
@@ -365,11 +363,6 @@ public class Scheduler implements NamedSendable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkTable getTable() {
|
||||
return m_table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSmartDashboardType() {
|
||||
return "Scheduler";
|
||||
|
||||
@@ -110,7 +110,7 @@ public abstract class Subsystem implements NamedSendable {
|
||||
}
|
||||
m_defaultCommand = command;
|
||||
}
|
||||
if (m_table != null) {
|
||||
if (m_hasDefaultEntry != null && m_defaultEntry != null) {
|
||||
if (m_defaultCommand != null) {
|
||||
m_hasDefaultEntry.setBoolean(true);
|
||||
m_defaultEntry.setString(m_defaultCommand.getName());
|
||||
@@ -150,7 +150,7 @@ public abstract class Subsystem implements NamedSendable {
|
||||
*/
|
||||
void confirmCommand() {
|
||||
if (m_currentCommandChanged) {
|
||||
if (m_table != null) {
|
||||
if (m_hasCommandEntry != null && m_commandEntry != null) {
|
||||
if (m_currentCommand != null) {
|
||||
m_hasCommandEntry.setBoolean(true);
|
||||
m_commandEntry.setString(m_currentCommand.getName());
|
||||
@@ -191,7 +191,6 @@ public abstract class Subsystem implements NamedSendable {
|
||||
return "Subsystem";
|
||||
}
|
||||
|
||||
private NetworkTable m_table;
|
||||
private NetworkTableEntry m_hasDefaultEntry;
|
||||
private NetworkTableEntry m_defaultEntry;
|
||||
private NetworkTableEntry m_hasCommandEntry;
|
||||
@@ -199,7 +198,6 @@ public abstract class Subsystem implements NamedSendable {
|
||||
|
||||
@Override
|
||||
public void initTable(NetworkTable table) {
|
||||
m_table = table;
|
||||
if (table != null) {
|
||||
m_hasDefaultEntry = table.getEntry("hasDefault");
|
||||
m_defaultEntry = table.getEntry("default");
|
||||
@@ -220,9 +218,4 @@ public abstract class Subsystem implements NamedSendable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkTable getTable() {
|
||||
return m_table;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,14 +103,12 @@ public class SendableChooser<V> implements Sendable {
|
||||
return "String Chooser";
|
||||
}
|
||||
|
||||
private NetworkTable m_table;
|
||||
private NetworkTableEntry m_tableDefault;
|
||||
private NetworkTableEntry m_tableSelected;
|
||||
private NetworkTableEntry m_tableOptions;
|
||||
|
||||
@Override
|
||||
public void initTable(NetworkTable table) {
|
||||
m_table = table;
|
||||
if (table != null) {
|
||||
m_tableDefault = table.getEntry(DEFAULT);
|
||||
m_tableSelected = table.getEntry(SELECTED);
|
||||
@@ -121,9 +119,4 @@ public class SendableChooser<V> implements Sendable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkTable getTable() {
|
||||
return m_table;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user