[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

@@ -4,8 +4,12 @@
#include "frc/shuffleboard/ShuffleboardLayout.h"
#include <wpi/json.h>
using namespace frc;
static constexpr std::string_view kSmartDashboardType = "ShuffleboardLayout";
ShuffleboardLayout::ShuffleboardLayout(ShuffleboardContainer& parent,
std::string_view title,
std::string_view type)
@@ -20,7 +24,9 @@ void ShuffleboardLayout::BuildInto(
std::shared_ptr<nt::NetworkTable> metaTable) {
BuildMetadata(metaTable);
auto table = parentTable->GetSubTable(GetTitle());
table->GetEntry(".type").SetString("ShuffleboardLayout");
table->GetEntry(".type").SetString(kSmartDashboardType);
table->GetEntry(".type").GetTopic().SetProperty("SmartDashboard",
kSmartDashboardType);
for (auto& component : GetComponents()) {
component->BuildInto(table, metaTable->GetSubTable(component->GetTitle()));
}

View File

@@ -4,8 +4,12 @@
#include "frc/shuffleboard/ShuffleboardTab.h"
#include <wpi/json.h>
using namespace frc;
static constexpr std::string_view kSmartDashboardType = "ShuffleboardLayout";
ShuffleboardTab::ShuffleboardTab(ShuffleboardRoot& root, std::string_view title)
: ShuffleboardValue(title), ShuffleboardContainer(title), m_root(root) {}
@@ -16,7 +20,9 @@ ShuffleboardRoot& ShuffleboardTab::GetRoot() {
void ShuffleboardTab::BuildInto(std::shared_ptr<nt::NetworkTable> parentTable,
std::shared_ptr<nt::NetworkTable> metaTable) {
auto tabTable = parentTable->GetSubTable(GetTitle());
tabTable->GetEntry(".type").SetString("ShuffleboardTab");
tabTable->GetEntry(".type").SetString(kSmartDashboardType);
tabTable->GetEntry(".type").GetTopic().SetProperty("SmartDashboard",
kSmartDashboardType);
for (auto& component : GetComponents()) {
component->BuildInto(tabTable,
metaTable->GetSubTable(component->GetTitle()));