mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[wpilib] Fix usage reporting for static classes (#6090)
This commit is contained in:
@@ -18,7 +18,7 @@ import java.util.function.Consumer;
|
||||
|
||||
final class ShuffleboardInstance implements ShuffleboardRoot {
|
||||
private final Map<String, ShuffleboardTab> m_tabs = new LinkedHashMap<>();
|
||||
|
||||
private boolean m_reported = false; // NOPMD redundant field initializer
|
||||
private boolean m_tabsChanged = false; // NOPMD redundant field initializer
|
||||
private final NetworkTable m_rootTable;
|
||||
private final NetworkTable m_rootMetaTable;
|
||||
@@ -35,12 +35,15 @@ final class ShuffleboardInstance implements ShuffleboardRoot {
|
||||
m_rootMetaTable = m_rootTable.getSubTable(".metadata");
|
||||
m_selectedTabPub =
|
||||
m_rootMetaTable.getStringTopic("Selected").publish(PubSubOption.keepDuplicates(true));
|
||||
HAL.report(tResourceType.kResourceType_Shuffleboard, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShuffleboardTab getTab(String title) {
|
||||
requireNonNullParam(title, "title", "getTab");
|
||||
if (!m_reported) {
|
||||
HAL.report(tResourceType.kResourceType_Shuffleboard, 0);
|
||||
m_reported = true;
|
||||
}
|
||||
if (!m_tabs.containsKey(title)) {
|
||||
m_tabs.put(title, new ShuffleboardTab(this, title));
|
||||
m_tabsChanged = true;
|
||||
|
||||
@@ -35,9 +35,10 @@ public final class SmartDashboard {
|
||||
/** The executor for listener tasks; calls listener tasks synchronously from main thread. */
|
||||
private static final ListenerExecutor listenerExecutor = new ListenerExecutor();
|
||||
|
||||
private static boolean m_reported = false; // NOPMD redundant field initializer
|
||||
|
||||
static {
|
||||
setNetworkTableInstance(NetworkTableInstance.getDefault());
|
||||
HAL.report(tResourceType.kResourceType_SmartDashboard, 0);
|
||||
}
|
||||
|
||||
private SmartDashboard() {
|
||||
@@ -64,6 +65,10 @@ public final class SmartDashboard {
|
||||
*/
|
||||
@SuppressWarnings("PMD.CompareObjectsWithEquals")
|
||||
public static synchronized void putData(String key, Sendable data) {
|
||||
if (!m_reported) {
|
||||
HAL.report(tResourceType.kResourceType_SmartDashboard, 0);
|
||||
m_reported = true;
|
||||
}
|
||||
Sendable sddata = tablesToData.get(key);
|
||||
if (sddata == null || sddata != data) {
|
||||
tablesToData.put(key, data);
|
||||
@@ -114,6 +119,10 @@ public final class SmartDashboard {
|
||||
* @return Network table entry.
|
||||
*/
|
||||
public static NetworkTableEntry getEntry(String key) {
|
||||
if (!m_reported) {
|
||||
HAL.report(tResourceType.kResourceType_SmartDashboard, 0);
|
||||
m_reported = true;
|
||||
}
|
||||
return table.getEntry(key);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user