diff --git a/wpilibc/src/main/native/cpp/smartdashboard/SendableBuilderImpl.cpp b/wpilibc/src/main/native/cpp/smartdashboard/SendableBuilderImpl.cpp index d075deb12b..135f4bec4d 100644 --- a/wpilibc/src/main/native/cpp/smartdashboard/SendableBuilderImpl.cpp +++ b/wpilibc/src/main/native/cpp/smartdashboard/SendableBuilderImpl.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -32,7 +32,9 @@ void SendableBuilderImpl::UpdateTable() { for (auto& property : m_properties) { if (property.update) property.update(property.entry, time); } - if (m_updateTable) m_updateTable(); + for (auto& updateTable : m_updateTables) { + updateTable(); + } } void SendableBuilderImpl::StartListeners() { @@ -71,7 +73,7 @@ void SendableBuilderImpl::SetSafeState(std::function func) { } void SendableBuilderImpl::SetUpdateTable(std::function func) { - m_updateTable = func; + m_updateTables.emplace_back(std::move(func)); } nt::NetworkTableEntry SendableBuilderImpl::GetEntry(const wpi::Twine& key) { diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilderImpl.h b/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilderImpl.h index eb69dcd09b..e5dea44b0b 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilderImpl.h +++ b/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilderImpl.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -202,7 +202,7 @@ class SendableBuilderImpl : public SendableBuilder { std::vector m_properties; std::function m_safeState; - std::function m_updateTable; + std::vector> m_updateTables; std::shared_ptr m_table; nt::NetworkTableEntry m_controllableEntry; bool m_actuator = false; diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableBuilderImpl.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableBuilderImpl.java index e0bb4f938e..e0d308ab9f 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableBuilderImpl.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableBuilderImpl.java @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -55,7 +55,7 @@ public class SendableBuilderImpl implements SendableBuilder { private final List m_properties = new ArrayList<>(); private Runnable m_safeState; - private Runnable m_updateTable; + private final List m_updateTables = new ArrayList<>(); private NetworkTable m_table; private NetworkTableEntry m_controllableEntry; private boolean m_actuator; @@ -105,8 +105,8 @@ public class SendableBuilderImpl implements SendableBuilder { property.m_update.accept(property.m_entry); } } - if (m_updateTable != null) { - m_updateTable.run(); + for (Runnable updateTable : m_updateTables) { + updateTable.run(); } } @@ -207,7 +207,7 @@ public class SendableBuilderImpl implements SendableBuilder { */ @Override public void setUpdateTable(Runnable func) { - m_updateTable = func; + m_updateTables.add(func); } /**