[wpilib] Add metadata to all dashboard ".type" entries (#6799)

This commit is contained in:
Ryan Blue
2024-07-02 16:31:50 -04:00
committed by GitHub
parent 7366a03fc9
commit 6a5448322b
12 changed files with 95 additions and 23 deletions

View File

@@ -28,6 +28,7 @@
#include <wpi/DataLog.h>
#include <wpi/EventVector.h>
#include <wpi/condition_variable.h>
#include <wpi/json.h>
#include <wpi/mutex.h>
#include <wpi/timestamp.h>
@@ -45,8 +46,11 @@ class MatchDataSenderEntry {
public:
MatchDataSenderEntry(const std::shared_ptr<nt::NetworkTable>& table,
std::string_view key,
typename Topic::ParamType initialVal)
: publisher{Topic{table->GetTopic(key)}.Publish()}, prevVal{initialVal} {
typename Topic::ParamType initialVal,
wpi::json topicProperties = {{}})
: publisher{Topic{table->GetTopic(key)}.PublishEx(Topic::kTypeString,
topicProperties)},
prevVal{initialVal} {
publisher.Set(initialVal);
}
@@ -62,10 +66,16 @@ class MatchDataSenderEntry {
typename Topic::ValueType prevVal;
};
static constexpr std::string_view kSmartDashboardType = "FMSInfo";
struct MatchDataSender {
std::shared_ptr<nt::NetworkTable> table =
nt::NetworkTableInstance::GetDefault().GetTable("FMSInfo");
MatchDataSenderEntry<nt::StringTopic> typeMetaData{table, ".type", "FMSInfo"};
MatchDataSenderEntry<nt::StringTopic> typeMetaData{
table,
".type",
kSmartDashboardType,
{{"SmartDashboard", kSmartDashboardType}}};
MatchDataSenderEntry<nt::StringTopic> gameSpecificMessage{
table, "GameSpecificMessage", ""};
MatchDataSenderEntry<nt::StringTopic> eventName{table, "EventName", ""};