2020-12-26 14:31:24 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
2020-09-12 10:55:46 -07:00
|
|
|
|
|
|
|
|
#include "glass/other/FMS.h"
|
|
|
|
|
|
|
|
|
|
#include <imgui.h>
|
|
|
|
|
#include <wpi/SmallString.h>
|
|
|
|
|
|
|
|
|
|
#include "glass/DataSource.h"
|
|
|
|
|
|
|
|
|
|
using namespace glass;
|
|
|
|
|
|
|
|
|
|
static const char* stations[] = {"Red 1", "Red 2", "Red 3",
|
|
|
|
|
"Blue 1", "Blue 2", "Blue 3"};
|
|
|
|
|
|
|
|
|
|
void glass::DisplayFMS(FMSModel* model, bool* matchTimeEnabled) {
|
2020-12-28 12:58:06 -08:00
|
|
|
if (!model->Exists() || model->IsReadOnly()) {
|
|
|
|
|
return DisplayFMSReadOnly(model);
|
|
|
|
|
}
|
2020-09-12 10:55:46 -07:00
|
|
|
|
|
|
|
|
// FMS Attached
|
|
|
|
|
if (auto data = model->GetFmsAttachedData()) {
|
|
|
|
|
bool val = data->GetValue();
|
2020-12-28 12:58:06 -08:00
|
|
|
if (ImGui::Checkbox("FMS Attached", &val)) {
|
|
|
|
|
model->SetFmsAttached(val);
|
|
|
|
|
}
|
2020-09-12 10:55:46 -07:00
|
|
|
data->EmitDrag();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DS Attached
|
|
|
|
|
if (auto data = model->GetDsAttachedData()) {
|
|
|
|
|
bool val = data->GetValue();
|
2020-12-28 12:58:06 -08:00
|
|
|
if (ImGui::Checkbox("DS Attached", &val)) {
|
|
|
|
|
model->SetDsAttached(val);
|
|
|
|
|
}
|
2020-09-12 10:55:46 -07:00
|
|
|
data->EmitDrag();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Alliance Station
|
|
|
|
|
if (auto data = model->GetAllianceStationIdData()) {
|
|
|
|
|
int val = data->GetValue();
|
|
|
|
|
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 8);
|
2020-12-28 12:58:06 -08:00
|
|
|
if (ImGui::Combo("Alliance Station", &val, stations, 6)) {
|
2020-09-12 10:55:46 -07:00
|
|
|
model->SetAllianceStationId(val);
|
2020-12-28 12:58:06 -08:00
|
|
|
}
|
2020-09-12 10:55:46 -07:00
|
|
|
data->EmitDrag();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Match Time
|
|
|
|
|
if (auto data = model->GetMatchTimeData()) {
|
2020-12-28 12:58:06 -08:00
|
|
|
if (matchTimeEnabled) {
|
2020-09-12 10:55:46 -07:00
|
|
|
ImGui::Checkbox("Match Time Enabled", matchTimeEnabled);
|
2020-12-28 12:58:06 -08:00
|
|
|
}
|
2020-09-12 10:55:46 -07:00
|
|
|
|
|
|
|
|
double val = data->GetValue();
|
|
|
|
|
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 8);
|
|
|
|
|
if (ImGui::InputDouble("Match Time", &val, 0, 0, "%.1f",
|
|
|
|
|
ImGuiInputTextFlags_EnterReturnsTrue)) {
|
|
|
|
|
model->SetMatchTime(val);
|
|
|
|
|
}
|
|
|
|
|
data->EmitDrag();
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
if (ImGui::Button("Reset")) {
|
|
|
|
|
model->SetMatchTime(0.0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Game Specific Message
|
|
|
|
|
// make buffer full 64 width, null terminated, for editability
|
|
|
|
|
wpi::SmallString<64> gameSpecificMessage;
|
|
|
|
|
model->GetGameSpecificMessage(gameSpecificMessage);
|
|
|
|
|
gameSpecificMessage.resize(63);
|
|
|
|
|
gameSpecificMessage.push_back('\0');
|
|
|
|
|
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 8);
|
|
|
|
|
if (ImGui::InputText("Game Specific", gameSpecificMessage.data(),
|
|
|
|
|
gameSpecificMessage.size(),
|
|
|
|
|
ImGuiInputTextFlags_EnterReturnsTrue)) {
|
|
|
|
|
model->SetGameSpecificMessage(gameSpecificMessage.data());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void glass::DisplayFMSReadOnly(FMSModel* model) {
|
|
|
|
|
bool exists = model->Exists();
|
2020-12-28 12:58:06 -08:00
|
|
|
if (!exists) {
|
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(96, 96, 96, 255));
|
|
|
|
|
}
|
2020-09-12 10:55:46 -07:00
|
|
|
|
|
|
|
|
if (auto data = model->GetEStopData()) {
|
|
|
|
|
ImGui::Selectable("E-Stopped: ");
|
|
|
|
|
data->EmitDrag();
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::TextUnformatted(exists ? (data->GetValue() ? "Yes" : "No") : "?");
|
|
|
|
|
}
|
|
|
|
|
if (auto data = model->GetEnabledData()) {
|
|
|
|
|
ImGui::Selectable("Robot Enabled: ");
|
|
|
|
|
data->EmitDrag();
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::TextUnformatted(exists ? (data->GetValue() ? "Yes" : "No") : "?");
|
|
|
|
|
}
|
|
|
|
|
if (auto data = model->GetTestData()) {
|
|
|
|
|
ImGui::Selectable("Test Mode: ");
|
|
|
|
|
data->EmitDrag();
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::TextUnformatted(exists ? (data->GetValue() ? "Yes" : "No") : "?");
|
|
|
|
|
}
|
|
|
|
|
if (auto data = model->GetAutonomousData()) {
|
|
|
|
|
ImGui::Selectable("Autonomous Mode: ");
|
|
|
|
|
data->EmitDrag();
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::TextUnformatted(exists ? (data->GetValue() ? "Yes" : "No") : "?");
|
|
|
|
|
}
|
|
|
|
|
if (auto data = model->GetFmsAttachedData()) {
|
|
|
|
|
ImGui::Selectable("FMS Attached: ");
|
|
|
|
|
data->EmitDrag();
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::TextUnformatted(exists ? (data->GetValue() ? "Yes" : "No") : "?");
|
|
|
|
|
}
|
|
|
|
|
if (auto data = model->GetDsAttachedData()) {
|
|
|
|
|
ImGui::Selectable("DS Attached: ");
|
|
|
|
|
data->EmitDrag();
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::TextUnformatted(exists ? (data->GetValue() ? "Yes" : "No") : "?");
|
|
|
|
|
}
|
|
|
|
|
if (auto data = model->GetAllianceStationIdData()) {
|
|
|
|
|
ImGui::Selectable("Alliance Station: ");
|
|
|
|
|
data->EmitDrag();
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::TextUnformatted(exists ? stations[static_cast<int>(data->GetValue())]
|
|
|
|
|
: "?");
|
|
|
|
|
}
|
|
|
|
|
if (auto data = model->GetMatchTimeData()) {
|
|
|
|
|
ImGui::Selectable("Match Time: ");
|
|
|
|
|
data->EmitDrag();
|
|
|
|
|
ImGui::SameLine();
|
2020-12-28 12:58:06 -08:00
|
|
|
if (exists) {
|
2020-09-12 10:55:46 -07:00
|
|
|
ImGui::Text("%.1f", data->GetValue());
|
2020-12-28 12:58:06 -08:00
|
|
|
} else {
|
2020-09-12 10:55:46 -07:00
|
|
|
ImGui::TextUnformatted("?");
|
2020-12-28 12:58:06 -08:00
|
|
|
}
|
2020-09-12 10:55:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wpi::SmallString<64> gameSpecificMessage;
|
|
|
|
|
model->GetGameSpecificMessage(gameSpecificMessage);
|
|
|
|
|
ImGui::Text("Game Specific: %s", exists ? gameSpecificMessage.c_str() : "?");
|
|
|
|
|
|
2020-12-28 12:58:06 -08:00
|
|
|
if (!exists) {
|
|
|
|
|
ImGui::PopStyleColor();
|
|
|
|
|
}
|
2020-09-12 10:55:46 -07:00
|
|
|
}
|