mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[wpilib] Add metadata to all dashboard ".type" entries (#6799)
This commit is contained in:
@@ -13,19 +13,21 @@
|
||||
#include <networktables/NetworkTableInstance.h>
|
||||
#include <networktables/NetworkTableListener.h>
|
||||
#include <networktables/StringTopic.h>
|
||||
#include <wpi/json.h>
|
||||
|
||||
using namespace frc;
|
||||
|
||||
// The Preferences table name
|
||||
static constexpr std::string_view kTableName{"Preferences"};
|
||||
|
||||
static constexpr std::string_view kSmartDashboardType = "RobotPreferences";
|
||||
namespace {
|
||||
struct Instance {
|
||||
Instance();
|
||||
|
||||
std::shared_ptr<nt::NetworkTable> table{
|
||||
nt::NetworkTableInstance::GetDefault().GetTable(kTableName)};
|
||||
nt::StringPublisher typePublisher{table->GetStringTopic(".type").Publish()};
|
||||
nt::StringPublisher typePublisher{table->GetStringTopic(".type").PublishEx(
|
||||
nt::StringTopic::kTypeString, {{"SmartDashboard", kSmartDashboardType}})};
|
||||
nt::MultiSubscriber tableSubscriber{nt::NetworkTableInstance::GetDefault(),
|
||||
{{fmt::format("{}/", table->GetPath())}}};
|
||||
nt::NetworkTableListener listener;
|
||||
@@ -165,7 +167,7 @@ void Preferences::RemoveAll() {
|
||||
}
|
||||
|
||||
Instance::Instance() {
|
||||
typePublisher.Set("RobotPreferences");
|
||||
typePublisher.Set(kSmartDashboardType);
|
||||
listener = nt::NetworkTableListener::CreateListener(
|
||||
tableSubscriber, NT_EVENT_PUBLISH | NT_EVENT_IMMEDIATE,
|
||||
[typeTopic = typePublisher.GetTopic().GetHandle()](auto& event) {
|
||||
|
||||
Reference in New Issue
Block a user