Add a .controllable key as a standard part of Sendable (#1225)

This indicates whether or not the Sendable listeners are installed.
It is set to true when SendableBuilder.startListeners() starts the listeners,
and set to false when SendableBuilder.stopListeners() stops the listeners.

This allows dashboards to choose to change their widget display based on
whether or not the value is actually controllable.
This commit is contained in:
Peter Johnson
2018-07-28 10:42:31 -07:00
committed by GitHub
parent 1d9ed8f458
commit 397a296e25
3 changed files with 8 additions and 0 deletions

View File

@@ -57,6 +57,7 @@ public class SendableBuilderImpl implements SendableBuilder {
private Runnable m_safeState;
private Runnable m_updateTable;
private NetworkTable m_table;
private NetworkTableEntry m_controllableEntry;
/**
* Set the network table. Must be called prior to any Add* functions being
@@ -65,6 +66,7 @@ public class SendableBuilderImpl implements SendableBuilder {
*/
public void setTable(NetworkTable table) {
m_table = table;
m_controllableEntry = table.getEntry(".controllable");
}
/**
@@ -96,6 +98,7 @@ public class SendableBuilderImpl implements SendableBuilder {
for (Property property : m_properties) {
property.startListener();
}
m_controllableEntry.setBoolean(true);
}
/**
@@ -105,6 +108,7 @@ public class SendableBuilderImpl implements SendableBuilder {
for (Property property : m_properties) {
property.stopListener();
}
m_controllableEntry.setBoolean(false);
}
/**