mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
SCRIPT namespace replacements
This commit is contained in:
committed by
Peter Johnson
parent
ae6c043632
commit
9aca8e0fd6
@@ -17,7 +17,7 @@
|
||||
using namespace halsimgui;
|
||||
|
||||
namespace {
|
||||
class AddressableLEDModel : public glass::LEDDisplayModel {
|
||||
class AddressableLEDModel : public wpi::glass::LEDDisplayModel {
|
||||
public:
|
||||
explicit AddressableLEDModel(int32_t channel) : m_channel{channel} {}
|
||||
|
||||
@@ -26,7 +26,7 @@ class AddressableLEDModel : public glass::LEDDisplayModel {
|
||||
return HALSIM_GetAddressableLEDInitialized(m_channel);
|
||||
}
|
||||
|
||||
std::span<const Data> GetData(wpi::SmallVectorImpl<Data>&) override {
|
||||
std::span<const Data> GetData(wpi::util::SmallVectorImpl<Data>&) override {
|
||||
size_t length = HALSIM_GetAddressableLEDData(
|
||||
HALSIM_GetAddressableLEDStart(m_channel),
|
||||
HALSIM_GetAddressableLEDLength(m_channel), m_data);
|
||||
@@ -39,7 +39,7 @@ class AddressableLEDModel : public glass::LEDDisplayModel {
|
||||
HAL_AddressableLEDData m_data[HAL_kAddressableLEDMaxLength];
|
||||
};
|
||||
|
||||
class AddressableLEDsModel : public glass::LEDDisplaysModel {
|
||||
class AddressableLEDsModel : public wpi::glass::LEDDisplaysModel {
|
||||
public:
|
||||
AddressableLEDsModel() : m_models(HAL_GetNumAddressableLEDs()) {}
|
||||
|
||||
@@ -49,7 +49,7 @@ class AddressableLEDsModel : public glass::LEDDisplaysModel {
|
||||
size_t GetNumLEDDisplays() override { return m_models.size(); }
|
||||
|
||||
void ForEachLEDDisplay(
|
||||
wpi::function_ref<void(glass::LEDDisplayModel& model, int channel)> func)
|
||||
wpi::util::function_ref<void(wpi::glass::LEDDisplayModel& model, int channel)> func)
|
||||
override;
|
||||
|
||||
private:
|
||||
@@ -83,7 +83,7 @@ bool AddressableLEDsModel::Exists() {
|
||||
}
|
||||
|
||||
void AddressableLEDsModel::ForEachLEDDisplay(
|
||||
wpi::function_ref<void(glass::LEDDisplayModel& model, int channel)> func) {
|
||||
wpi::util::function_ref<void(wpi::glass::LEDDisplayModel& model, int channel)> func) {
|
||||
for (int i = 0; i < static_cast<int>(m_models.size()); ++i) {
|
||||
if (m_models[i]) {
|
||||
func(*m_models[i], i);
|
||||
@@ -105,11 +105,11 @@ void AddressableLEDGui::Initialize() {
|
||||
HALSimGui::halProvider->Register(
|
||||
"Addressable LEDs", [] { return AddressableLEDsExists(); },
|
||||
[] { return std::make_unique<AddressableLEDsModel>(); },
|
||||
[](glass::Window* win, glass::Model* model) {
|
||||
[](wpi::glass::Window* win, wpi::glass::Model* model) {
|
||||
win->SetFlags(ImGuiWindowFlags_AlwaysAutoResize);
|
||||
win->SetDefaultPos(290, 100);
|
||||
return glass::MakeFunctionView([=] {
|
||||
glass::DisplayLEDDisplays(static_cast<AddressableLEDsModel*>(model));
|
||||
return wpi::glass::MakeFunctionView([=] {
|
||||
wpi::glass::DisplayLEDDisplays(static_cast<AddressableLEDsModel*>(model));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ using namespace halsimgui;
|
||||
namespace {
|
||||
HALSIMGUI_DATASOURCE_DOUBLE_INDEXED(AnalogInVoltage, "AIn");
|
||||
|
||||
class AnalogInputSimModel : public glass::AnalogInputModel {
|
||||
class AnalogInputSimModel : public wpi::glass::AnalogInputModel {
|
||||
public:
|
||||
explicit AnalogInputSimModel(int32_t index)
|
||||
: m_index{index}, m_voltageData{m_index} {}
|
||||
@@ -37,7 +37,7 @@ class AnalogInputSimModel : public glass::AnalogInputModel {
|
||||
}
|
||||
}
|
||||
|
||||
glass::DoubleSource* GetVoltageData() override { return &m_voltageData; }
|
||||
wpi::glass::DoubleSource* GetVoltageData() override { return &m_voltageData; }
|
||||
|
||||
void SetVoltage(double val) override {
|
||||
HALSIM_SetAnalogInVoltage(m_index, val);
|
||||
@@ -48,7 +48,7 @@ class AnalogInputSimModel : public glass::AnalogInputModel {
|
||||
AnalogInVoltageSource m_voltageData;
|
||||
};
|
||||
|
||||
class AnalogInputsSimModel : public glass::AnalogInputsModel {
|
||||
class AnalogInputsSimModel : public wpi::glass::AnalogInputsModel {
|
||||
public:
|
||||
AnalogInputsSimModel() : m_models(HAL_GetNumAnalogInputs()) {}
|
||||
|
||||
@@ -57,7 +57,7 @@ class AnalogInputsSimModel : public glass::AnalogInputsModel {
|
||||
bool Exists() override { return true; }
|
||||
|
||||
void ForEachAnalogInput(
|
||||
wpi::function_ref<void(glass::AnalogInputModel& model, int index)> func)
|
||||
wpi::util::function_ref<void(wpi::glass::AnalogInputModel& model, int index)> func)
|
||||
override;
|
||||
|
||||
private:
|
||||
@@ -81,7 +81,7 @@ void AnalogInputsSimModel::Update() {
|
||||
}
|
||||
|
||||
void AnalogInputsSimModel::ForEachAnalogInput(
|
||||
wpi::function_ref<void(glass::AnalogInputModel& model, int index)> func) {
|
||||
wpi::util::function_ref<void(wpi::glass::AnalogInputModel& model, int index)> func) {
|
||||
for (int32_t i = 0, iend = static_cast<int32_t>(m_models.size()); i < iend;
|
||||
++i) {
|
||||
if (auto model = m_models[i].get()) {
|
||||
@@ -104,11 +104,11 @@ void AnalogInputSimGui::Initialize() {
|
||||
HALSimGui::halProvider->Register(
|
||||
"Analog Inputs", AnalogInputsAnyInitialized,
|
||||
[] { return std::make_unique<AnalogInputsSimModel>(); },
|
||||
[](glass::Window* win, glass::Model* model) {
|
||||
[](wpi::glass::Window* win, wpi::glass::Model* model) {
|
||||
win->SetFlags(ImGuiWindowFlags_AlwaysAutoResize);
|
||||
win->SetDefaultPos(640, 20);
|
||||
return glass::MakeFunctionView([=] {
|
||||
glass::DisplayAnalogInputs(static_cast<AnalogInputsSimModel*>(model));
|
||||
return wpi::glass::MakeFunctionView([=] {
|
||||
wpi::glass::DisplayAnalogInputs(static_cast<AnalogInputsSimModel*>(model));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ HALSIMGUI_DATASOURCE_BOOLEAN_INDEXED(DIOValue, "DIO");
|
||||
HALSIMGUI_DATASOURCE_DOUBLE_INDEXED(DigitalPWMDutyCycle, "DPWM");
|
||||
HALSIMGUI_DATASOURCE_DOUBLE_INDEXED(DutyCycleOutput, "DutyCycle");
|
||||
|
||||
class DPWMSimModel : public glass::DPWMModel {
|
||||
class DPWMSimModel : public wpi::glass::DPWMModel {
|
||||
public:
|
||||
DPWMSimModel(int32_t index, int32_t dioChannel)
|
||||
: m_dioChannel{dioChannel}, m_index{index}, m_valueData{index} {}
|
||||
@@ -43,7 +43,7 @@ class DPWMSimModel : public glass::DPWMModel {
|
||||
}
|
||||
}
|
||||
|
||||
glass::DoubleSource* GetValueData() override { return &m_valueData; }
|
||||
wpi::glass::DoubleSource* GetValueData() override { return &m_valueData; }
|
||||
|
||||
void SetValue(double val) override {
|
||||
HALSIM_SetDigitalPWMDutyCycle(m_index, val);
|
||||
@@ -55,7 +55,7 @@ class DPWMSimModel : public glass::DPWMModel {
|
||||
DigitalPWMDutyCycleSource m_valueData;
|
||||
};
|
||||
|
||||
class DutyCycleSimModel : public glass::DutyCycleModel {
|
||||
class DutyCycleSimModel : public wpi::glass::DutyCycleModel {
|
||||
public:
|
||||
explicit DutyCycleSimModel(int32_t index)
|
||||
: m_index{index}, m_valueData{index} {}
|
||||
@@ -72,7 +72,7 @@ class DutyCycleSimModel : public glass::DutyCycleModel {
|
||||
}
|
||||
}
|
||||
|
||||
glass::DoubleSource* GetValueData() override { return &m_valueData; }
|
||||
wpi::glass::DoubleSource* GetValueData() override { return &m_valueData; }
|
||||
|
||||
void SetValue(double val) override {
|
||||
HALSIM_SetDutyCycleOutput(m_index, val);
|
||||
@@ -83,7 +83,7 @@ class DutyCycleSimModel : public glass::DutyCycleModel {
|
||||
DutyCycleOutputSource m_valueData;
|
||||
};
|
||||
|
||||
class DIOSimModel : public glass::DIOModel {
|
||||
class DIOSimModel : public wpi::glass::DIOModel {
|
||||
public:
|
||||
explicit DIOSimModel(int32_t channel)
|
||||
: m_channel{channel}, m_valueData{channel} {}
|
||||
@@ -106,15 +106,15 @@ class DIOSimModel : public glass::DIOModel {
|
||||
|
||||
DPWMSimModel* GetDPWM() override { return m_dpwmSource; }
|
||||
DutyCycleSimModel* GetDutyCycle() override { return m_dutyCycleSource; }
|
||||
glass::EncoderModel* GetEncoder() override { return m_encoderSource; }
|
||||
wpi::glass::EncoderModel* GetEncoder() override { return m_encoderSource; }
|
||||
|
||||
void SetDPWM(DPWMSimModel* model) { m_dpwmSource = model; }
|
||||
void SetDutyCycle(DutyCycleSimModel* model) { m_dutyCycleSource = model; }
|
||||
void SetEncoder(glass::EncoderModel* model) { m_encoderSource = model; }
|
||||
void SetEncoder(wpi::glass::EncoderModel* model) { m_encoderSource = model; }
|
||||
|
||||
bool IsInput() const override { return HALSIM_GetDIOIsInput(m_channel); }
|
||||
|
||||
glass::BooleanSource* GetValueData() override { return &m_valueData; }
|
||||
wpi::glass::BooleanSource* GetValueData() override { return &m_valueData; }
|
||||
|
||||
void SetValue(bool val) override { HALSIM_SetDIOValue(m_channel, val); }
|
||||
|
||||
@@ -123,10 +123,10 @@ class DIOSimModel : public glass::DIOModel {
|
||||
DIOValueSource m_valueData;
|
||||
DPWMSimModel* m_dpwmSource = nullptr;
|
||||
DutyCycleSimModel* m_dutyCycleSource = nullptr;
|
||||
glass::EncoderModel* m_encoderSource = nullptr;
|
||||
wpi::glass::EncoderModel* m_encoderSource = nullptr;
|
||||
};
|
||||
|
||||
class DIOsSimModel : public glass::DIOsModel {
|
||||
class DIOsSimModel : public wpi::glass::DIOsModel {
|
||||
public:
|
||||
DIOsSimModel()
|
||||
: m_dioModels(HAL_GetNumDigitalChannels()),
|
||||
@@ -138,7 +138,7 @@ class DIOsSimModel : public glass::DIOsModel {
|
||||
bool Exists() override { return true; }
|
||||
|
||||
void ForEachDIO(
|
||||
wpi::function_ref<void(glass::DIOModel& model, int index)> func) override;
|
||||
wpi::util::function_ref<void(wpi::glass::DIOModel& model, int index)> func) override;
|
||||
|
||||
private:
|
||||
// indexed by channel
|
||||
@@ -210,7 +210,7 @@ void DIOsSimModel::Update() {
|
||||
}
|
||||
|
||||
void DIOsSimModel::ForEachDIO(
|
||||
wpi::function_ref<void(glass::DIOModel& model, int index)> func) {
|
||||
wpi::util::function_ref<void(wpi::glass::DIOModel& model, int index)> func) {
|
||||
const int32_t numDIO = m_dioModels.size();
|
||||
for (int32_t i = 0; i < numDIO; ++i) {
|
||||
if (auto model = m_dioModels[i].get()) {
|
||||
@@ -232,11 +232,11 @@ static bool DIOAnyInitialized() {
|
||||
void DIOSimGui::Initialize() {
|
||||
HALSimGui::halProvider->Register(
|
||||
"DIO", DIOAnyInitialized, [] { return std::make_unique<DIOsSimModel>(); },
|
||||
[](glass::Window* win, glass::Model* model) {
|
||||
[](wpi::glass::Window* win, wpi::glass::Model* model) {
|
||||
win->SetFlags(ImGuiWindowFlags_AlwaysAutoResize);
|
||||
win->SetDefaultPos(470, 20);
|
||||
return glass::MakeFunctionView([=] {
|
||||
glass::DisplayDIOs(static_cast<DIOsSimModel*>(model),
|
||||
return wpi::glass::MakeFunctionView([=] {
|
||||
wpi::glass::DisplayDIOs(static_cast<DIOsSimModel*>(model),
|
||||
HALSimGui::halProvider->AreOutputsEnabled());
|
||||
});
|
||||
});
|
||||
|
||||
@@ -94,7 +94,7 @@ class GlfwSystemJoystick : public SystemJoystick {
|
||||
|
||||
class KeyboardJoystick : public SystemJoystick {
|
||||
public:
|
||||
KeyboardJoystick(glass::Storage& storage, int index);
|
||||
KeyboardJoystick(wpi::glass::Storage& storage, int index);
|
||||
|
||||
void SettingsDisplay() override;
|
||||
void Update() override;
|
||||
@@ -124,7 +124,7 @@ class KeyboardJoystick : public SystemJoystick {
|
||||
int& m_povCount;
|
||||
|
||||
struct AxisConfig {
|
||||
explicit AxisConfig(glass::Storage& storage);
|
||||
explicit AxisConfig(wpi::glass::Storage& storage);
|
||||
|
||||
int& incKey;
|
||||
int& decKey;
|
||||
@@ -133,14 +133,14 @@ class KeyboardJoystick : public SystemJoystick {
|
||||
float& maxAbsValue;
|
||||
};
|
||||
|
||||
std::vector<std::unique_ptr<glass::Storage>>& m_axisStorage;
|
||||
std::vector<std::unique_ptr<wpi::glass::Storage>>& m_axisStorage;
|
||||
std::vector<AxisConfig> m_axisConfig;
|
||||
|
||||
static constexpr int kMaxButtonCount = 32;
|
||||
std::vector<int>& m_buttonKey;
|
||||
|
||||
struct PovConfig {
|
||||
explicit PovConfig(glass::Storage& storage);
|
||||
explicit PovConfig(wpi::glass::Storage& storage);
|
||||
|
||||
int& keyUp;
|
||||
int& keyUpRight;
|
||||
@@ -152,21 +152,21 @@ class KeyboardJoystick : public SystemJoystick {
|
||||
int& keyUpLeft;
|
||||
};
|
||||
|
||||
std::vector<std::unique_ptr<glass::Storage>>& m_povStorage;
|
||||
std::vector<std::unique_ptr<wpi::glass::Storage>>& m_povStorage;
|
||||
std::vector<PovConfig> m_povConfig;
|
||||
};
|
||||
|
||||
class GlfwKeyboardJoystick : public KeyboardJoystick {
|
||||
public:
|
||||
GlfwKeyboardJoystick(glass::Storage& storage, int index);
|
||||
GlfwKeyboardJoystick(wpi::glass::Storage& storage, int index);
|
||||
|
||||
const char* GetKeyName(int key) const override;
|
||||
};
|
||||
|
||||
struct RobotJoystick {
|
||||
explicit RobotJoystick(glass::Storage& storage);
|
||||
explicit RobotJoystick(wpi::glass::Storage& storage);
|
||||
|
||||
glass::NameSetting name;
|
||||
wpi::glass::NameSetting name;
|
||||
std::string& guid;
|
||||
const SystemJoystick* sys = nullptr;
|
||||
bool& useGamepad; // = false;
|
||||
@@ -197,11 +197,11 @@ class JoystickModel {
|
||||
int axisCount;
|
||||
int buttonCount;
|
||||
int povCount;
|
||||
std::unique_ptr<glass::DoubleSource> axes[HAL_kMaxJoystickAxes];
|
||||
std::unique_ptr<wpi::glass::DoubleSource> axes[HAL_kMaxJoystickAxes];
|
||||
// use pointer instead of unique_ptr to allow it to be passed directly
|
||||
// to DrawLEDSources()
|
||||
glass::BooleanSource* buttons[32];
|
||||
std::unique_ptr<glass::IntegerSource> povs[HAL_kMaxJoystickPOVs];
|
||||
wpi::glass::BooleanSource* buttons[32];
|
||||
std::unique_ptr<wpi::glass::IntegerSource> povs[HAL_kMaxJoystickPOVs];
|
||||
|
||||
private:
|
||||
static void CallbackFunc(const char*, void* param, const HAL_Value*);
|
||||
@@ -210,21 +210,21 @@ class JoystickModel {
|
||||
int32_t m_callback;
|
||||
};
|
||||
|
||||
class FMSSimModel : public glass::FMSModel {
|
||||
class FMSSimModel : public wpi::glass::FMSModel {
|
||||
public:
|
||||
FMSSimModel();
|
||||
|
||||
glass::BooleanSource* GetFmsAttachedData() override { return &m_fmsAttached; }
|
||||
glass::BooleanSource* GetDsAttachedData() override { return &m_dsAttached; }
|
||||
glass::IntegerSource* GetAllianceStationIdData() override {
|
||||
wpi::glass::BooleanSource* GetFmsAttachedData() override { return &m_fmsAttached; }
|
||||
wpi::glass::BooleanSource* GetDsAttachedData() override { return &m_dsAttached; }
|
||||
wpi::glass::IntegerSource* GetAllianceStationIdData() override {
|
||||
return &m_allianceStationId;
|
||||
}
|
||||
glass::DoubleSource* GetMatchTimeData() override { return &m_matchTime; }
|
||||
glass::BooleanSource* GetEStopData() override { return &m_estop; }
|
||||
glass::BooleanSource* GetEnabledData() override { return &m_enabled; }
|
||||
glass::BooleanSource* GetTestData() override { return &m_test; }
|
||||
glass::BooleanSource* GetAutonomousData() override { return &m_autonomous; }
|
||||
glass::StringSource* GetGameSpecificMessageData() override {
|
||||
wpi::glass::DoubleSource* GetMatchTimeData() override { return &m_matchTime; }
|
||||
wpi::glass::BooleanSource* GetEStopData() override { return &m_estop; }
|
||||
wpi::glass::BooleanSource* GetEnabledData() override { return &m_enabled; }
|
||||
wpi::glass::BooleanSource* GetTestData() override { return &m_test; }
|
||||
wpi::glass::BooleanSource* GetAutonomousData() override { return &m_autonomous; }
|
||||
wpi::glass::StringSource* GetGameSpecificMessageData() override {
|
||||
return &m_gameMessage;
|
||||
}
|
||||
|
||||
@@ -251,16 +251,16 @@ class FMSSimModel : public glass::FMSModel {
|
||||
bool IsReadOnly() override;
|
||||
|
||||
private:
|
||||
glass::BooleanSource m_fmsAttached{"FMS:FMSAttached"};
|
||||
glass::BooleanSource m_dsAttached{"FMS:DSAttached"};
|
||||
glass::IntegerSource m_allianceStationId{"FMS:AllianceStationID"};
|
||||
glass::DoubleSource m_matchTime{"FMS:MatchTime"};
|
||||
glass::BooleanSource m_estop{"FMS:EStop"};
|
||||
glass::BooleanSource m_enabled{"FMS:RobotEnabled"};
|
||||
glass::BooleanSource m_test{"FMS:TestMode"};
|
||||
glass::BooleanSource m_autonomous{"FMS:AutonomousMode"};
|
||||
wpi::glass::BooleanSource m_fmsAttached{"FMS:FMSAttached"};
|
||||
wpi::glass::BooleanSource m_dsAttached{"FMS:DSAttached"};
|
||||
wpi::glass::IntegerSource m_allianceStationId{"FMS:AllianceStationID"};
|
||||
wpi::glass::DoubleSource m_matchTime{"FMS:MatchTime"};
|
||||
wpi::glass::BooleanSource m_estop{"FMS:EStop"};
|
||||
wpi::glass::BooleanSource m_enabled{"FMS:RobotEnabled"};
|
||||
wpi::glass::BooleanSource m_test{"FMS:TestMode"};
|
||||
wpi::glass::BooleanSource m_autonomous{"FMS:AutonomousMode"};
|
||||
double m_startMatchTime = -1.0;
|
||||
glass::StringSource m_gameMessage{"FMS:GameSpecificMessage"};
|
||||
wpi::glass::StringSource m_gameMessage{"FMS:GameSpecificMessage"};
|
||||
};
|
||||
|
||||
} // namespace
|
||||
@@ -296,7 +296,7 @@ JoystickModel::JoystickModel(int index) : m_index{index} {
|
||||
HALSIM_GetJoystickAxes(index, &halAxes);
|
||||
axisCount = static_cast<uint8_t>(16 - std::countl_zero(halAxes.available));
|
||||
for (int i = 0; i < axisCount; ++i) {
|
||||
axes[i] = std::make_unique<glass::DoubleSource>(
|
||||
axes[i] = std::make_unique<wpi::glass::DoubleSource>(
|
||||
fmt::format("Joystick[{}] Axis[{}]", index, i));
|
||||
}
|
||||
|
||||
@@ -305,7 +305,7 @@ JoystickModel::JoystickModel(int index) : m_index{index} {
|
||||
buttonCount =
|
||||
static_cast<uint8_t>(64 - std::countl_zero(halButtons.available));
|
||||
for (int i = 0; i < buttonCount; ++i) {
|
||||
buttons[i] = new glass::BooleanSource(
|
||||
buttons[i] = new wpi::glass::BooleanSource(
|
||||
fmt::format("Joystick[{}] Button[{}]", index, i + 1));
|
||||
}
|
||||
for (int i = buttonCount; i < 64; ++i) {
|
||||
@@ -316,7 +316,7 @@ JoystickModel::JoystickModel(int index) : m_index{index} {
|
||||
HALSIM_GetJoystickPOVs(index, &halPOVs);
|
||||
povCount = static_cast<uint8_t>(8 - std::countl_zero(halPOVs.available));
|
||||
for (int i = 0; i < povCount; ++i) {
|
||||
povs[i] = std::make_unique<glass::IntegerSource>(
|
||||
povs[i] = std::make_unique<wpi::glass::IntegerSource>(
|
||||
fmt::format("Joystick[{}] POV [{}]", index, i));
|
||||
}
|
||||
|
||||
@@ -468,7 +468,7 @@ void GlfwSystemJoystick::GetData(HALJoystickData* data, bool mapGamepad) const {
|
||||
}
|
||||
}
|
||||
|
||||
KeyboardJoystick::AxisConfig::AxisConfig(glass::Storage& storage)
|
||||
KeyboardJoystick::AxisConfig::AxisConfig(wpi::glass::Storage& storage)
|
||||
: incKey{storage.GetInt("incKey", -1)},
|
||||
decKey{storage.GetInt("decKey", -1)},
|
||||
keyRate{storage.GetFloat("keyRate", 0.05f)},
|
||||
@@ -483,7 +483,7 @@ KeyboardJoystick::AxisConfig::AxisConfig(glass::Storage& storage)
|
||||
}
|
||||
}
|
||||
|
||||
KeyboardJoystick::PovConfig::PovConfig(glass::Storage& storage)
|
||||
KeyboardJoystick::PovConfig::PovConfig(wpi::glass::Storage& storage)
|
||||
: keyUp{storage.GetInt("keyUp", -1)},
|
||||
keyUpRight{storage.GetInt("keyUpRight", -1)},
|
||||
keyRight{storage.GetInt("keyRight", -1)},
|
||||
@@ -519,7 +519,7 @@ KeyboardJoystick::PovConfig::PovConfig(glass::Storage& storage)
|
||||
}
|
||||
}
|
||||
|
||||
KeyboardJoystick::KeyboardJoystick(glass::Storage& storage, int index)
|
||||
KeyboardJoystick::KeyboardJoystick(wpi::glass::Storage& storage, int index)
|
||||
: m_index{index},
|
||||
m_axisCount{storage.GetInt("axisCount", -1)},
|
||||
m_buttonCount{storage.GetInt("buttonCount", -1)},
|
||||
@@ -527,8 +527,8 @@ KeyboardJoystick::KeyboardJoystick(glass::Storage& storage, int index)
|
||||
m_axisStorage{storage.GetChildArray("axisConfig")},
|
||||
m_buttonKey{storage.GetIntArray("buttonKeys")},
|
||||
m_povStorage{storage.GetChildArray("povConfig")} {
|
||||
wpi::format_to_n_c_str(m_name, sizeof(m_name), "Keyboard {}", index);
|
||||
wpi::format_to_n_c_str(m_guid, sizeof(m_guid), "Keyboard{}", index);
|
||||
wpi::util::format_to_n_c_str(m_name, sizeof(m_name), "Keyboard {}", index);
|
||||
wpi::util::format_to_n_c_str(m_guid, sizeof(m_guid), "Keyboard{}", index);
|
||||
|
||||
// init axes
|
||||
for (auto&& axisConfig : m_axisStorage) {
|
||||
@@ -562,9 +562,9 @@ void KeyboardJoystick::EditKey(const char* label, int* key) {
|
||||
|
||||
char editLabel[32];
|
||||
if (s_keyEdit == key) {
|
||||
wpi::format_to_n_c_str(editLabel, sizeof(editLabel), "(press key)###edit");
|
||||
wpi::util::format_to_n_c_str(editLabel, sizeof(editLabel), "(press key)###edit");
|
||||
} else {
|
||||
wpi::format_to_n_c_str(editLabel, sizeof(editLabel), "{}###edit",
|
||||
wpi::util::format_to_n_c_str(editLabel, sizeof(editLabel), "{}###edit",
|
||||
GetKeyName(*key));
|
||||
}
|
||||
|
||||
@@ -608,11 +608,11 @@ void KeyboardJoystick::SettingsDisplay() {
|
||||
}
|
||||
}
|
||||
while (m_axisCount > static_cast<int>(m_axisConfig.size())) {
|
||||
m_axisStorage.emplace_back(std::make_unique<glass::Storage>());
|
||||
m_axisStorage.emplace_back(std::make_unique<wpi::glass::Storage>());
|
||||
m_axisConfig.emplace_back(*m_axisStorage.back());
|
||||
}
|
||||
for (int i = 0; i < m_axisCount; ++i) {
|
||||
wpi::format_to_n_c_str(label, sizeof(label), "Axis {}", i);
|
||||
wpi::util::format_to_n_c_str(label, sizeof(label), "Axis {}", i);
|
||||
|
||||
if (ImGui::TreeNodeEx(label, ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||
EditKey("Increase", &m_axisConfig[i].incKey);
|
||||
@@ -646,7 +646,7 @@ void KeyboardJoystick::SettingsDisplay() {
|
||||
m_buttonKey.emplace_back(-1);
|
||||
}
|
||||
for (int i = 0; i < m_buttonCount; ++i) {
|
||||
wpi::format_to_n_c_str(label, sizeof(label), "Button {}", i + 1);
|
||||
wpi::util::format_to_n_c_str(label, sizeof(label), "Button {}", i + 1);
|
||||
|
||||
EditKey(label, &m_buttonKey[i]);
|
||||
}
|
||||
@@ -665,11 +665,11 @@ void KeyboardJoystick::SettingsDisplay() {
|
||||
}
|
||||
}
|
||||
while (m_povCount > static_cast<int>(m_povConfig.size())) {
|
||||
m_povStorage.emplace_back(std::make_unique<glass::Storage>());
|
||||
m_povStorage.emplace_back(std::make_unique<wpi::glass::Storage>());
|
||||
m_povConfig.emplace_back(*m_povStorage.back());
|
||||
}
|
||||
for (int i = 0; i < m_povCount; ++i) {
|
||||
wpi::format_to_n_c_str(label, sizeof(label), "POV {}", i);
|
||||
wpi::util::format_to_n_c_str(label, sizeof(label), "POV {}", i);
|
||||
|
||||
if (ImGui::TreeNodeEx(label, ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||
EditKey(" Up", &m_povConfig[i].keyUp);
|
||||
@@ -842,14 +842,14 @@ void KeyboardJoystick::ClearKey(int key) {
|
||||
}
|
||||
}
|
||||
|
||||
GlfwKeyboardJoystick::GlfwKeyboardJoystick(glass::Storage& storage, int index)
|
||||
GlfwKeyboardJoystick::GlfwKeyboardJoystick(wpi::glass::Storage& storage, int index)
|
||||
: KeyboardJoystick{storage, index} {
|
||||
// set up a default keyboard config for 0, 1, and 2
|
||||
if (index == 0) {
|
||||
if (m_axisCount == -1 && m_axisStorage.empty()) {
|
||||
m_axisCount = 3;
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
m_axisStorage.emplace_back(std::make_unique<glass::Storage>());
|
||||
m_axisStorage.emplace_back(std::make_unique<wpi::glass::Storage>());
|
||||
m_axisConfig.emplace_back(*m_axisStorage.back());
|
||||
}
|
||||
m_axisConfig[0].incKey = GLFW_KEY_D;
|
||||
@@ -871,7 +871,7 @@ GlfwKeyboardJoystick::GlfwKeyboardJoystick(glass::Storage& storage, int index)
|
||||
}
|
||||
if (m_povCount == -1 && m_povStorage.empty()) {
|
||||
m_povCount = 1;
|
||||
m_povStorage.emplace_back(std::make_unique<glass::Storage>());
|
||||
m_povStorage.emplace_back(std::make_unique<wpi::glass::Storage>());
|
||||
m_povConfig.emplace_back(*m_povStorage.back());
|
||||
m_povConfig[0].keyUp = GLFW_KEY_KP_8;
|
||||
m_povConfig[0].keyUpRight = GLFW_KEY_KP_9;
|
||||
@@ -886,7 +886,7 @@ GlfwKeyboardJoystick::GlfwKeyboardJoystick(glass::Storage& storage, int index)
|
||||
if (m_axisCount == -1 && m_axisStorage.empty()) {
|
||||
m_axisCount = 2;
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
m_axisStorage.emplace_back(std::make_unique<glass::Storage>());
|
||||
m_axisStorage.emplace_back(std::make_unique<wpi::glass::Storage>());
|
||||
m_axisConfig.emplace_back(*m_axisStorage.back());
|
||||
}
|
||||
m_axisConfig[0].incKey = GLFW_KEY_L;
|
||||
@@ -906,7 +906,7 @@ GlfwKeyboardJoystick::GlfwKeyboardJoystick(glass::Storage& storage, int index)
|
||||
if (m_axisCount == -1 && m_axisStorage.empty()) {
|
||||
m_axisCount = 2;
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
m_axisStorage.emplace_back(std::make_unique<glass::Storage>());
|
||||
m_axisStorage.emplace_back(std::make_unique<wpi::glass::Storage>());
|
||||
m_axisConfig.emplace_back(*m_axisStorage.back());
|
||||
}
|
||||
m_axisConfig[0].incKey = GLFW_KEY_RIGHT;
|
||||
@@ -961,7 +961,7 @@ const char* GlfwKeyboardJoystick::GetKeyName(int key) const {
|
||||
return "(Unknown)";
|
||||
}
|
||||
|
||||
RobotJoystick::RobotJoystick(glass::Storage& storage)
|
||||
RobotJoystick::RobotJoystick(wpi::glass::Storage& storage)
|
||||
: name{storage.GetString("name")},
|
||||
guid{storage.GetString("guid")},
|
||||
useGamepad{storage.GetBool("useGamepad")} {}
|
||||
@@ -1040,11 +1040,11 @@ static void DriverStationExecute() {
|
||||
bool disableDS = IsDSDisabled();
|
||||
if (disableDS && !prevDisableDS) {
|
||||
if (auto win = DriverStationGui::dsManager->GetWindow("System Joysticks")) {
|
||||
win->SetVisibility(glass::Window::kDisabled);
|
||||
win->SetVisibility(wpi::glass::Window::kDisabled);
|
||||
}
|
||||
} else if (!disableDS && prevDisableDS) {
|
||||
if (auto win = DriverStationGui::dsManager->GetWindow("System Joysticks")) {
|
||||
win->SetVisibility(glass::Window::kShow);
|
||||
win->SetVisibility(wpi::glass::Window::kShow);
|
||||
}
|
||||
}
|
||||
prevDisableDS = disableDS;
|
||||
@@ -1166,7 +1166,7 @@ void FMSSimModel::UpdateHAL() {
|
||||
HALSIM_SetDriverStationTest(m_test.GetValue());
|
||||
HALSIM_SetDriverStationAutonomous(m_autonomous.GetValue());
|
||||
HALSIM_SetDriverStationMatchTime(m_matchTime.GetValue());
|
||||
auto str = wpi::make_string(m_gameMessage.GetValue());
|
||||
auto str = wpi::util::make_string(m_gameMessage.GetValue());
|
||||
HALSIM_SetGameSpecificMessage(&str);
|
||||
HALSIM_SetDriverStationDsAttached(m_dsAttached.GetValue());
|
||||
}
|
||||
@@ -1216,7 +1216,7 @@ bool FMSSimModel::IsReadOnly() {
|
||||
|
||||
static void DisplaySystemJoystick(SystemJoystick& joy, int i) {
|
||||
char label[64];
|
||||
wpi::format_to_n_c_str(label, sizeof(label), "{}: {}", i, joy.GetName());
|
||||
wpi::util::format_to_n_c_str(label, sizeof(label), "{}: {}", i, joy.GetName());
|
||||
|
||||
// highlight if any buttons pressed
|
||||
bool anyButtonPressed = joy.IsAnyButtonPressed();
|
||||
@@ -1250,7 +1250,7 @@ static void DisplaySystemJoysticks() {
|
||||
DisplaySystemJoystick(*joy, i + GLFW_JOYSTICK_LAST + 1);
|
||||
if (ImGui::BeginPopupContextItem()) {
|
||||
char buf[64];
|
||||
wpi::format_to_n_c_str(buf, sizeof(buf), "{} Settings", joy->GetName());
|
||||
wpi::util::format_to_n_c_str(buf, sizeof(buf), "{} Settings", joy->GetName());
|
||||
|
||||
if (ImGui::MenuItem(buf)) {
|
||||
if (auto win = DriverStationGui::dsManager->GetWindow(buf)) {
|
||||
@@ -1301,7 +1301,7 @@ static void DisplayJoysticks() {
|
||||
joy.guid = payload_sys->GetGUID();
|
||||
std::string_view name{payload_sys->GetName()};
|
||||
joy.useGamepad =
|
||||
wpi::starts_with(name, "Xbox") || wpi::contains(name, "pad");
|
||||
wpi::util::starts_with(name, "Xbox") || wpi::util::contains(name, "pad");
|
||||
}
|
||||
ImGui::EndDragDropTarget();
|
||||
}
|
||||
@@ -1339,7 +1339,7 @@ static void DisplayJoysticks() {
|
||||
for (int j = 0; j < axesCount; ++j) {
|
||||
if (source && source->axes[j]) {
|
||||
char label[64];
|
||||
wpi::format_to_n_c_str(label, sizeof(label), "Axis[{}]", j);
|
||||
wpi::util::format_to_n_c_str(label, sizeof(label), "Axis[{}]", j);
|
||||
|
||||
ImGui::Selectable(label);
|
||||
source->axes[j]->EmitDrag();
|
||||
@@ -1356,7 +1356,7 @@ static void DisplayJoysticks() {
|
||||
for (int j = 0; j < povCount; ++j) {
|
||||
if (source && source->povs[j]) {
|
||||
char label[64];
|
||||
wpi::format_to_n_c_str(label, sizeof(label), "POVs[{}]", j);
|
||||
wpi::util::format_to_n_c_str(label, sizeof(label), "POVs[{}]", j);
|
||||
|
||||
ImGui::Selectable(label);
|
||||
source->povs[j]->EmitDrag();
|
||||
@@ -1372,7 +1372,7 @@ static void DisplayJoysticks() {
|
||||
|
||||
// show buttons as multiple lines of LED indicators, 8 per line
|
||||
static const ImU32 color = IM_COL32(255, 255, 102, 255);
|
||||
wpi::SmallVector<int, 64> buttons;
|
||||
wpi::util::SmallVector<int, 64> buttons;
|
||||
buttons.resize(buttonCount);
|
||||
for (int j = 0; j < buttonCount; ++j) {
|
||||
buttons[j] = joy.IsButtonPressed(j) ? 1 : -1;
|
||||
@@ -1415,7 +1415,7 @@ void DSManager::DisplayMenu() {
|
||||
}
|
||||
|
||||
void DriverStationGui::GlobalInit() {
|
||||
auto& storageRoot = glass::GetStorageRoot("ds");
|
||||
auto& storageRoot = wpi::glass::GetStorageRoot("ds");
|
||||
dsManager = std::make_unique<DSManager>(storageRoot);
|
||||
|
||||
// set up system joysticks (both GLFW and keyboard)
|
||||
@@ -1441,7 +1441,7 @@ void DriverStationGui::GlobalInit() {
|
||||
keyboardStorage.resize(4);
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
if (!keyboardStorage[i]) {
|
||||
keyboardStorage[i] = std::make_unique<glass::Storage>();
|
||||
keyboardStorage[i] = std::make_unique<wpi::glass::Storage>();
|
||||
}
|
||||
gKeyboardJoysticks.emplace_back(
|
||||
std::make_unique<GlfwKeyboardJoystick>(*keyboardStorage[i], i));
|
||||
@@ -1451,7 +1451,7 @@ void DriverStationGui::GlobalInit() {
|
||||
robotJoystickStorage.resize(HAL_kMaxJoysticks);
|
||||
for (int i = 0; i < HAL_kMaxJoysticks; ++i) {
|
||||
if (!robotJoystickStorage[i]) {
|
||||
robotJoystickStorage[i] = std::make_unique<glass::Storage>();
|
||||
robotJoystickStorage[i] = std::make_unique<wpi::glass::Storage>();
|
||||
}
|
||||
gRobotJoysticks.emplace_back(*robotJoystickStorage[i]);
|
||||
}
|
||||
@@ -1459,12 +1459,12 @@ void DriverStationGui::GlobalInit() {
|
||||
int i = 0;
|
||||
for (auto&& joy : gKeyboardJoysticks) {
|
||||
char label[64];
|
||||
wpi::format_to_n_c_str(label, sizeof(label), "{} Settings",
|
||||
wpi::util::format_to_n_c_str(label, sizeof(label), "{} Settings",
|
||||
joy->GetName());
|
||||
|
||||
if (auto win = dsManager->AddWindow(
|
||||
label, [j = joy.get()] { j->SettingsDisplay(); },
|
||||
glass::Window::kHide)) {
|
||||
wpi::glass::Window::kHide)) {
|
||||
win->DisableRenamePopup();
|
||||
win->SetDefaultPos(10 + 310 * i++, 50);
|
||||
if (i > 3) {
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
|
||||
namespace halsimgui {
|
||||
|
||||
class DSManager : public glass::WindowManager {
|
||||
class DSManager : public wpi::glass::WindowManager {
|
||||
public:
|
||||
explicit DSManager(glass::Storage& storage) : WindowManager{storage} {}
|
||||
explicit DSManager(wpi::glass::Storage& storage) : WindowManager{storage} {}
|
||||
|
||||
void DisplayMenu() override;
|
||||
};
|
||||
|
||||
@@ -24,7 +24,7 @@ using namespace halsimgui;
|
||||
|
||||
namespace {
|
||||
|
||||
class EncoderSimModel : public glass::EncoderModel {
|
||||
class EncoderSimModel : public wpi::glass::EncoderModel {
|
||||
public:
|
||||
EncoderSimModel(std::string_view id, int32_t index, int channelA,
|
||||
int channelB)
|
||||
@@ -88,14 +88,14 @@ class EncoderSimModel : public glass::EncoderModel {
|
||||
int GetChannelA() const override { return m_channelA; }
|
||||
int GetChannelB() const override { return m_channelB; }
|
||||
|
||||
glass::DoubleSource* GetDistancePerPulseData() override {
|
||||
wpi::glass::DoubleSource* GetDistancePerPulseData() override {
|
||||
return &m_distancePerPulse;
|
||||
}
|
||||
glass::IntegerSource* GetCountData() override { return &m_count; }
|
||||
glass::DoubleSource* GetPeriodData() override { return &m_period; }
|
||||
glass::BooleanSource* GetDirectionData() override { return &m_direction; }
|
||||
glass::DoubleSource* GetDistanceData() override { return &m_distance; }
|
||||
glass::DoubleSource* GetRateData() override { return &m_rate; }
|
||||
wpi::glass::IntegerSource* GetCountData() override { return &m_count; }
|
||||
wpi::glass::DoubleSource* GetPeriodData() override { return &m_period; }
|
||||
wpi::glass::BooleanSource* GetDirectionData() override { return &m_direction; }
|
||||
wpi::glass::DoubleSource* GetDistanceData() override { return &m_distance; }
|
||||
wpi::glass::DoubleSource* GetRateData() override { return &m_rate; }
|
||||
|
||||
double GetMaxPeriod() override { return HALSIM_GetEncoderMaxPeriod(m_index); }
|
||||
bool GetReverseDirection() override {
|
||||
@@ -176,12 +176,12 @@ class EncoderSimModel : public glass::EncoderModel {
|
||||
}
|
||||
}
|
||||
|
||||
glass::DoubleSource m_distancePerPulse;
|
||||
glass::IntegerSource m_count;
|
||||
glass::DoubleSource m_period;
|
||||
glass::BooleanSource m_direction;
|
||||
glass::DoubleSource m_distance;
|
||||
glass::DoubleSource m_rate;
|
||||
wpi::glass::DoubleSource m_distancePerPulse;
|
||||
wpi::glass::IntegerSource m_count;
|
||||
wpi::glass::DoubleSource m_period;
|
||||
wpi::glass::BooleanSource m_direction;
|
||||
wpi::glass::DoubleSource m_distance;
|
||||
wpi::glass::DoubleSource m_rate;
|
||||
|
||||
int32_t m_index;
|
||||
int m_channelA;
|
||||
@@ -192,7 +192,7 @@ class EncoderSimModel : public glass::EncoderModel {
|
||||
int32_t m_directionCallback;
|
||||
};
|
||||
|
||||
class EncodersSimModel : public glass::EncodersModel {
|
||||
class EncodersSimModel : public wpi::glass::EncodersModel {
|
||||
public:
|
||||
EncodersSimModel() : m_models(HAL_GetNumEncoders()) {}
|
||||
|
||||
@@ -201,7 +201,7 @@ class EncodersSimModel : public glass::EncodersModel {
|
||||
bool Exists() override { return true; }
|
||||
|
||||
void ForEachEncoder(
|
||||
wpi::function_ref<void(glass::EncoderModel& model, int index)> func)
|
||||
wpi::util::function_ref<void(wpi::glass::EncoderModel& model, int index)> func)
|
||||
override;
|
||||
|
||||
private:
|
||||
@@ -224,7 +224,7 @@ void EncodersSimModel::Update() {
|
||||
}
|
||||
|
||||
void EncodersSimModel::ForEachEncoder(
|
||||
wpi::function_ref<void(glass::EncoderModel& model, int index)> func) {
|
||||
wpi::util::function_ref<void(wpi::glass::EncoderModel& model, int index)> func) {
|
||||
for (int32_t i = 0, iend = static_cast<int32_t>(m_models.size()); i < iend;
|
||||
++i) {
|
||||
if (auto model = m_models[i].get()) {
|
||||
@@ -247,16 +247,16 @@ void EncoderSimGui::Initialize() {
|
||||
HALSimGui::halProvider->Register(
|
||||
"Encoders", EncodersAnyInitialized,
|
||||
[] { return std::make_unique<EncodersSimModel>(); },
|
||||
[](glass::Window* win, glass::Model* model) {
|
||||
[](wpi::glass::Window* win, wpi::glass::Model* model) {
|
||||
win->SetFlags(ImGuiWindowFlags_AlwaysAutoResize);
|
||||
win->SetDefaultPos(5, 250);
|
||||
return glass::MakeFunctionView(
|
||||
return wpi::glass::MakeFunctionView(
|
||||
[=] { DisplayEncoders(static_cast<EncodersSimModel*>(model)); });
|
||||
});
|
||||
}
|
||||
|
||||
glass::EncodersModel& EncoderSimGui::GetEncodersModel() {
|
||||
wpi::glass::EncodersModel& EncoderSimGui::GetEncodersModel() {
|
||||
static auto model = HALSimGui::halProvider->GetModel("Encoders");
|
||||
assert(model);
|
||||
return *static_cast<glass::EncodersModel*>(model);
|
||||
return *static_cast<wpi::glass::EncodersModel*>(model);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace glass {
|
||||
namespace wpi::glass {
|
||||
class EncodersModel;
|
||||
} // namespace glass
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace halsimgui {
|
||||
class EncoderSimGui {
|
||||
public:
|
||||
static void Initialize();
|
||||
static glass::EncodersModel& GetEncodersModel();
|
||||
static wpi::glass::EncodersModel& GetEncodersModel();
|
||||
};
|
||||
|
||||
} // namespace halsimgui
|
||||
|
||||
@@ -15,7 +15,7 @@ using namespace halsimgui;
|
||||
|
||||
static bool gDisableOutputsOnDSDisable = true;
|
||||
|
||||
HALProvider::HALProvider(glass::Storage& storage) : Provider{storage} {
|
||||
HALProvider::HALProvider(wpi::glass::Storage& storage) : Provider{storage} {
|
||||
storage.SetCustomApply([this] {
|
||||
for (auto&& childIt : m_storage.GetChildren()) {
|
||||
auto it = FindViewEntry(childIt.key());
|
||||
@@ -65,7 +65,7 @@ void HALProvider::DisplayMenu() {
|
||||
}
|
||||
}
|
||||
|
||||
glass::Model* HALProvider::GetModel(std::string_view name) {
|
||||
wpi::glass::Model* HALProvider::GetModel(std::string_view name) {
|
||||
auto it = FindModelEntry(name);
|
||||
if (it == m_modelEntries.end() || (*it)->name != name) {
|
||||
return nullptr;
|
||||
@@ -79,7 +79,7 @@ glass::Model* HALProvider::GetModel(std::string_view name) {
|
||||
return entry->model.get();
|
||||
}
|
||||
|
||||
void HALProvider::Show(ViewEntry* entry, glass::Window* window) {
|
||||
void HALProvider::Show(ViewEntry* entry, wpi::glass::Window* window) {
|
||||
// if there's already a window, we're done
|
||||
if (entry->window) {
|
||||
return;
|
||||
@@ -97,7 +97,7 @@ void HALProvider::Show(ViewEntry* entry, glass::Window* window) {
|
||||
if (!window) {
|
||||
window = GetOrAddWindow(
|
||||
entry->name, true,
|
||||
entry->showDefault ? glass::Window::kShow : glass::Window::kHide);
|
||||
entry->showDefault ? wpi::glass::Window::kShow : wpi::glass::Window::kHide);
|
||||
}
|
||||
if (!window) {
|
||||
return;
|
||||
|
||||
@@ -15,25 +15,25 @@
|
||||
|
||||
using namespace halsimgui;
|
||||
|
||||
glass::MainMenuBar HALSimGui::mainMenu;
|
||||
std::unique_ptr<glass::WindowManager> HALSimGui::manager;
|
||||
wpi::glass::MainMenuBar HALSimGui::mainMenu;
|
||||
std::unique_ptr<wpi::glass::WindowManager> HALSimGui::manager;
|
||||
std::unique_ptr<HALProvider> HALSimGui::halProvider;
|
||||
std::unique_ptr<glass::NetworkTablesProvider> HALSimGui::ntProvider;
|
||||
std::unique_ptr<wpi::glass::NetworkTablesProvider> HALSimGui::ntProvider;
|
||||
|
||||
void HALSimGui::GlobalInit() {
|
||||
manager = std::make_unique<glass::WindowManager>(
|
||||
glass::GetStorageRoot().GetChild("SimWindow"));
|
||||
manager = std::make_unique<wpi::glass::WindowManager>(
|
||||
wpi::glass::GetStorageRoot().GetChild("SimWindow"));
|
||||
manager->GlobalInit();
|
||||
halProvider = std::make_unique<HALProvider>(
|
||||
glass::GetStorageRoot().GetChild("HALProvider"));
|
||||
wpi::glass::GetStorageRoot().GetChild("HALProvider"));
|
||||
halProvider->GlobalInit();
|
||||
ntProvider = std::make_unique<glass::NetworkTablesProvider>(
|
||||
glass::GetStorageRoot().GetChild("NTProvider"));
|
||||
ntProvider = std::make_unique<wpi::glass::NetworkTablesProvider>(
|
||||
wpi::glass::GetStorageRoot().GetChild("NTProvider"));
|
||||
ntProvider->GlobalInit();
|
||||
|
||||
wpi::gui::AddLateExecute([] { mainMenu.Display(); });
|
||||
|
||||
glass::AddStandardNetworkTablesViews(*ntProvider);
|
||||
wpi::glass::AddStandardNetworkTablesViews(*ntProvider);
|
||||
}
|
||||
|
||||
namespace halsimgui {
|
||||
|
||||
@@ -14,32 +14,32 @@
|
||||
|
||||
using namespace halsimgui;
|
||||
|
||||
static std::unique_ptr<glass::NetworkTablesModel> gNetworkTablesModel;
|
||||
static std::unique_ptr<glass::Window> gNetworkTablesWindow;
|
||||
static std::unique_ptr<glass::Window> gNetworkTablesInfoWindow;
|
||||
static std::unique_ptr<wpi::glass::NetworkTablesModel> gNetworkTablesModel;
|
||||
static std::unique_ptr<wpi::glass::Window> gNetworkTablesWindow;
|
||||
static std::unique_ptr<wpi::glass::Window> gNetworkTablesInfoWindow;
|
||||
|
||||
void NetworkTablesSimGui::Initialize() {
|
||||
gNetworkTablesModel = std::make_unique<glass::NetworkTablesModel>();
|
||||
gNetworkTablesModel = std::make_unique<wpi::glass::NetworkTablesModel>();
|
||||
wpi::gui::AddEarlyExecute([] { gNetworkTablesModel->Update(); });
|
||||
|
||||
gNetworkTablesWindow = std::make_unique<glass::Window>(
|
||||
glass::GetStorageRoot().GetChild("NetworkTables View"), "NetworkTables");
|
||||
gNetworkTablesWindow = std::make_unique<wpi::glass::Window>(
|
||||
wpi::glass::GetStorageRoot().GetChild("NetworkTables View"), "NetworkTables");
|
||||
gNetworkTablesWindow->SetView(
|
||||
std::make_unique<glass::NetworkTablesView>(gNetworkTablesModel.get()));
|
||||
std::make_unique<wpi::glass::NetworkTablesView>(gNetworkTablesModel.get()));
|
||||
gNetworkTablesWindow->SetDefaultPos(250, 277);
|
||||
gNetworkTablesWindow->SetDefaultSize(750, 185);
|
||||
gNetworkTablesWindow->DisableRenamePopup();
|
||||
wpi::gui::AddLateExecute([] { gNetworkTablesWindow->Display(); });
|
||||
|
||||
// NetworkTables info window
|
||||
gNetworkTablesInfoWindow = std::make_unique<glass::Window>(
|
||||
glass::GetStorageRoot().GetChild("NetworkTables Info"),
|
||||
gNetworkTablesInfoWindow = std::make_unique<wpi::glass::Window>(
|
||||
wpi::glass::GetStorageRoot().GetChild("NetworkTables Info"),
|
||||
"NetworkTables Info");
|
||||
gNetworkTablesInfoWindow->SetView(glass::MakeFunctionView(
|
||||
[&] { glass::DisplayNetworkTablesInfo(gNetworkTablesModel.get()); }));
|
||||
gNetworkTablesInfoWindow->SetView(wpi::glass::MakeFunctionView(
|
||||
[&] { wpi::glass::DisplayNetworkTablesInfo(gNetworkTablesModel.get()); }));
|
||||
gNetworkTablesInfoWindow->SetDefaultPos(250, 130);
|
||||
gNetworkTablesInfoWindow->SetDefaultSize(750, 145);
|
||||
gNetworkTablesInfoWindow->SetDefaultVisibility(glass::Window::kHide);
|
||||
gNetworkTablesInfoWindow->SetDefaultVisibility(wpi::glass::Window::kHide);
|
||||
gNetworkTablesInfoWindow->DisableRenamePopup();
|
||||
wpi::gui::AddLateExecute([] { gNetworkTablesInfoWindow->Display(); });
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ HALSIMGUI_DATASOURCE_DOUBLE_INDEXED(CTREPCMCompressorCurrent,
|
||||
"Compressor Current");
|
||||
HALSIMGUI_DATASOURCE_BOOLEAN_INDEXED2(CTREPCMSolenoidOutput, "Solenoid");
|
||||
|
||||
class CompressorSimModel : public glass::CompressorModel {
|
||||
class CompressorSimModel : public wpi::glass::CompressorModel {
|
||||
public:
|
||||
explicit CompressorSimModel(int32_t index)
|
||||
: m_index{index},
|
||||
@@ -40,12 +40,12 @@ class CompressorSimModel : public glass::CompressorModel {
|
||||
|
||||
bool Exists() override { return HALSIM_GetCTREPCMInitialized(m_index); }
|
||||
|
||||
glass::BooleanSource* GetRunningData() override { return &m_running; }
|
||||
glass::BooleanSource* GetEnabledData() override { return &m_enabled; }
|
||||
glass::BooleanSource* GetPressureSwitchData() override {
|
||||
wpi::glass::BooleanSource* GetRunningData() override { return &m_running; }
|
||||
wpi::glass::BooleanSource* GetEnabledData() override { return &m_enabled; }
|
||||
wpi::glass::BooleanSource* GetPressureSwitchData() override {
|
||||
return &m_pressureSwitch;
|
||||
}
|
||||
glass::DoubleSource* GetCurrentData() override { return &m_current; }
|
||||
wpi::glass::DoubleSource* GetCurrentData() override { return &m_current; }
|
||||
|
||||
void SetRunning(bool val) override {
|
||||
HALSIM_SetCTREPCMCompressorOn(m_index, val);
|
||||
@@ -68,7 +68,7 @@ class CompressorSimModel : public glass::CompressorModel {
|
||||
CTREPCMCompressorCurrentSource m_current;
|
||||
};
|
||||
|
||||
class SolenoidSimModel : public glass::SolenoidModel {
|
||||
class SolenoidSimModel : public wpi::glass::SolenoidModel {
|
||||
public:
|
||||
SolenoidSimModel(int32_t index, int32_t channel)
|
||||
: m_index{index}, m_channel{channel}, m_output{index, channel} {}
|
||||
@@ -77,7 +77,7 @@ class SolenoidSimModel : public glass::SolenoidModel {
|
||||
|
||||
bool Exists() override { return HALSIM_GetCTREPCMInitialized(m_index); }
|
||||
|
||||
glass::BooleanSource* GetOutputData() override { return &m_output; }
|
||||
wpi::glass::BooleanSource* GetOutputData() override { return &m_output; }
|
||||
|
||||
void SetOutput(bool val) override {
|
||||
HALSIM_SetCTREPCMSolenoidOutput(m_index, m_channel, val);
|
||||
@@ -89,7 +89,7 @@ class SolenoidSimModel : public glass::SolenoidModel {
|
||||
CTREPCMSolenoidOutputSource m_output;
|
||||
};
|
||||
|
||||
class PCMSimModel : public glass::PneumaticControlModel {
|
||||
class PCMSimModel : public wpi::glass::PneumaticControlModel {
|
||||
public:
|
||||
explicit PCMSimModel(int32_t index)
|
||||
: m_index{index},
|
||||
@@ -103,7 +103,7 @@ class PCMSimModel : public glass::PneumaticControlModel {
|
||||
CompressorSimModel* GetCompressor() override { return &m_compressor; }
|
||||
|
||||
void ForEachSolenoid(
|
||||
wpi::function_ref<void(glass::SolenoidModel& model, int index)> func)
|
||||
wpi::util::function_ref<void(wpi::glass::SolenoidModel& model, int index)> func)
|
||||
override;
|
||||
|
||||
std::string_view GetName() override { return "PCM"; }
|
||||
@@ -117,7 +117,7 @@ class PCMSimModel : public glass::PneumaticControlModel {
|
||||
int m_solenoidInitCount = 0;
|
||||
};
|
||||
|
||||
class PCMsSimModel : public glass::PneumaticControlsModel {
|
||||
class PCMsSimModel : public wpi::glass::PneumaticControlsModel {
|
||||
public:
|
||||
PCMsSimModel() : m_models(HAL_GetNumCTREPCMModules()) {}
|
||||
|
||||
@@ -126,7 +126,7 @@ class PCMsSimModel : public glass::PneumaticControlsModel {
|
||||
bool Exists() override { return true; }
|
||||
|
||||
void ForEachPneumaticControl(
|
||||
wpi::function_ref<void(glass::PneumaticControlModel& model, int index)>
|
||||
wpi::util::function_ref<void(wpi::glass::PneumaticControlModel& model, int index)>
|
||||
func) override;
|
||||
|
||||
private:
|
||||
@@ -151,7 +151,7 @@ void PCMSimModel::Update() {
|
||||
}
|
||||
|
||||
void PCMSimModel::ForEachSolenoid(
|
||||
wpi::function_ref<void(glass::SolenoidModel& model, int index)> func) {
|
||||
wpi::util::function_ref<void(wpi::glass::SolenoidModel& model, int index)> func) {
|
||||
if (m_solenoidInitCount == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -179,7 +179,7 @@ void PCMsSimModel::Update() {
|
||||
}
|
||||
|
||||
void PCMsSimModel::ForEachPneumaticControl(
|
||||
wpi::function_ref<void(glass::PneumaticControlModel& model, int index)>
|
||||
wpi::util::function_ref<void(wpi::glass::PneumaticControlModel& model, int index)>
|
||||
func) {
|
||||
int32_t numCTREPCMs = m_models.size();
|
||||
for (int32_t i = 0; i < numCTREPCMs; ++i) {
|
||||
@@ -199,10 +199,10 @@ bool PCMSimGui::PCMsAnyInitialized() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PCMSimGui::PCMsAnySolenoids(glass::PneumaticControlsModel* model) {
|
||||
bool PCMSimGui::PCMsAnySolenoids(wpi::glass::PneumaticControlsModel* model) {
|
||||
bool any = false;
|
||||
static_cast<PCMsSimModel*>(model)->ForEachPneumaticControl(
|
||||
[&](glass::PneumaticControlModel& CTREPCM, int) {
|
||||
[&](wpi::glass::PneumaticControlModel& CTREPCM, int) {
|
||||
if (static_cast<PCMSimModel*>(&CTREPCM)->GetNumSolenoids() > 0) {
|
||||
any = true;
|
||||
}
|
||||
@@ -210,7 +210,7 @@ bool PCMSimGui::PCMsAnySolenoids(glass::PneumaticControlsModel* model) {
|
||||
return any;
|
||||
}
|
||||
|
||||
std::unique_ptr<glass::PneumaticControlsModel> PCMSimGui::GetPCMsModel() {
|
||||
std::unique_ptr<wpi::glass::PneumaticControlsModel> PCMSimGui::GetPCMsModel() {
|
||||
return std::make_unique<PCMsSimModel>();
|
||||
}
|
||||
|
||||
@@ -220,8 +220,8 @@ void PCMSimGui::Initialize() {
|
||||
[] { return std::make_unique<PCMsSimModel>(); });
|
||||
|
||||
SimDeviceGui::GetDeviceTree().Add(
|
||||
HALSimGui::halProvider->GetModel("CTREPCMs"), [](glass::Model* model) {
|
||||
glass::DisplayCompressorsDevice(
|
||||
HALSimGui::halProvider->GetModel("CTREPCMs"), [](wpi::glass::Model* model) {
|
||||
wpi::glass::DisplayCompressorsDevice(
|
||||
static_cast<PCMsSimModel*>(model),
|
||||
HALSimGui::halProvider->AreOutputsEnabled());
|
||||
});
|
||||
|
||||
@@ -13,8 +13,8 @@ class PCMSimGui {
|
||||
public:
|
||||
static void Initialize();
|
||||
static bool PCMsAnyInitialized();
|
||||
static bool PCMsAnySolenoids(glass::PneumaticControlsModel* model);
|
||||
static std::unique_ptr<glass::PneumaticControlsModel> GetPCMsModel();
|
||||
static bool PCMsAnySolenoids(wpi::glass::PneumaticControlsModel* model);
|
||||
static std::unique_ptr<wpi::glass::PneumaticControlsModel> GetPCMsModel();
|
||||
};
|
||||
|
||||
} // namespace halsimgui
|
||||
|
||||
@@ -26,7 +26,7 @@ HALSIMGUI_DATASOURCE_DOUBLE_INDEXED(REVPHCompressorCurrent,
|
||||
"Compressor Current");
|
||||
HALSIMGUI_DATASOURCE_BOOLEAN_INDEXED2(REVPHSolenoidOutput, "Solenoid");
|
||||
|
||||
class CompressorSimModel : public glass::CompressorModel {
|
||||
class CompressorSimModel : public wpi::glass::CompressorModel {
|
||||
public:
|
||||
explicit CompressorSimModel(int32_t index)
|
||||
: m_index{index},
|
||||
@@ -38,12 +38,12 @@ class CompressorSimModel : public glass::CompressorModel {
|
||||
|
||||
bool Exists() override { return HALSIM_GetREVPHInitialized(m_index); }
|
||||
|
||||
glass::BooleanSource* GetRunningData() override { return &m_running; }
|
||||
glass::BooleanSource* GetEnabledData() override { return nullptr; }
|
||||
glass::BooleanSource* GetPressureSwitchData() override {
|
||||
wpi::glass::BooleanSource* GetRunningData() override { return &m_running; }
|
||||
wpi::glass::BooleanSource* GetEnabledData() override { return nullptr; }
|
||||
wpi::glass::BooleanSource* GetPressureSwitchData() override {
|
||||
return &m_pressureSwitch;
|
||||
}
|
||||
glass::DoubleSource* GetCurrentData() override { return &m_current; }
|
||||
wpi::glass::DoubleSource* GetCurrentData() override { return &m_current; }
|
||||
|
||||
void SetRunning(bool val) override {
|
||||
HALSIM_SetREVPHCompressorOn(m_index, val);
|
||||
@@ -63,7 +63,7 @@ class CompressorSimModel : public glass::CompressorModel {
|
||||
REVPHCompressorCurrentSource m_current;
|
||||
};
|
||||
|
||||
class SolenoidSimModel : public glass::SolenoidModel {
|
||||
class SolenoidSimModel : public wpi::glass::SolenoidModel {
|
||||
public:
|
||||
SolenoidSimModel(int32_t index, int32_t channel)
|
||||
: m_index{index}, m_channel{channel}, m_output{index, channel} {}
|
||||
@@ -72,7 +72,7 @@ class SolenoidSimModel : public glass::SolenoidModel {
|
||||
|
||||
bool Exists() override { return HALSIM_GetREVPHInitialized(m_index); }
|
||||
|
||||
glass::BooleanSource* GetOutputData() override { return &m_output; }
|
||||
wpi::glass::BooleanSource* GetOutputData() override { return &m_output; }
|
||||
|
||||
void SetOutput(bool val) override {
|
||||
HALSIM_SetREVPHSolenoidOutput(m_index, m_channel, val);
|
||||
@@ -84,7 +84,7 @@ class SolenoidSimModel : public glass::SolenoidModel {
|
||||
REVPHSolenoidOutputSource m_output;
|
||||
};
|
||||
|
||||
class PHSimModel : public glass::PneumaticControlModel {
|
||||
class PHSimModel : public wpi::glass::PneumaticControlModel {
|
||||
public:
|
||||
explicit PHSimModel(int32_t index)
|
||||
: m_index{index},
|
||||
@@ -98,7 +98,7 @@ class PHSimModel : public glass::PneumaticControlModel {
|
||||
CompressorSimModel* GetCompressor() override { return &m_compressor; }
|
||||
|
||||
void ForEachSolenoid(
|
||||
wpi::function_ref<void(glass::SolenoidModel& model, int index)> func)
|
||||
wpi::util::function_ref<void(wpi::glass::SolenoidModel& model, int index)> func)
|
||||
override;
|
||||
|
||||
std::string_view GetName() override { return "PH"; }
|
||||
@@ -112,7 +112,7 @@ class PHSimModel : public glass::PneumaticControlModel {
|
||||
int m_solenoidInitCount = 0;
|
||||
};
|
||||
|
||||
class PHsSimModel : public glass::PneumaticControlsModel {
|
||||
class PHsSimModel : public wpi::glass::PneumaticControlsModel {
|
||||
public:
|
||||
PHsSimModel() : m_models(HAL_GetNumREVPHModules()) {}
|
||||
|
||||
@@ -121,7 +121,7 @@ class PHsSimModel : public glass::PneumaticControlsModel {
|
||||
bool Exists() override { return true; }
|
||||
|
||||
void ForEachPneumaticControl(
|
||||
wpi::function_ref<void(glass::PneumaticControlModel& model, int index)>
|
||||
wpi::util::function_ref<void(wpi::glass::PneumaticControlModel& model, int index)>
|
||||
func) override;
|
||||
|
||||
private:
|
||||
@@ -146,7 +146,7 @@ void PHSimModel::Update() {
|
||||
}
|
||||
|
||||
void PHSimModel::ForEachSolenoid(
|
||||
wpi::function_ref<void(glass::SolenoidModel& model, int index)> func) {
|
||||
wpi::util::function_ref<void(wpi::glass::SolenoidModel& model, int index)> func) {
|
||||
if (m_solenoidInitCount == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -174,7 +174,7 @@ void PHsSimModel::Update() {
|
||||
}
|
||||
|
||||
void PHsSimModel::ForEachPneumaticControl(
|
||||
wpi::function_ref<void(glass::PneumaticControlModel& model, int index)>
|
||||
wpi::util::function_ref<void(wpi::glass::PneumaticControlModel& model, int index)>
|
||||
func) {
|
||||
int32_t numREVPHs = m_models.size();
|
||||
for (int32_t i = 0; i < numREVPHs; ++i) {
|
||||
@@ -194,10 +194,10 @@ bool PHSimGui::PHsAnyInitialized() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PHSimGui::PHsAnySolenoids(glass::PneumaticControlsModel* model) {
|
||||
bool PHSimGui::PHsAnySolenoids(wpi::glass::PneumaticControlsModel* model) {
|
||||
bool any = false;
|
||||
static_cast<PHsSimModel*>(model)->ForEachPneumaticControl(
|
||||
[&](glass::PneumaticControlModel& REVPH, int) {
|
||||
[&](wpi::glass::PneumaticControlModel& REVPH, int) {
|
||||
if (static_cast<PHSimModel*>(&REVPH)->GetNumSolenoids() > 0) {
|
||||
any = true;
|
||||
}
|
||||
@@ -205,7 +205,7 @@ bool PHSimGui::PHsAnySolenoids(glass::PneumaticControlsModel* model) {
|
||||
return any;
|
||||
}
|
||||
|
||||
std::unique_ptr<glass::PneumaticControlsModel> PHSimGui::GetPHsModel() {
|
||||
std::unique_ptr<wpi::glass::PneumaticControlsModel> PHSimGui::GetPHsModel() {
|
||||
return std::make_unique<PHsSimModel>();
|
||||
}
|
||||
|
||||
@@ -215,8 +215,8 @@ void PHSimGui::Initialize() {
|
||||
[] { return std::make_unique<PHsSimModel>(); });
|
||||
|
||||
SimDeviceGui::GetDeviceTree().Add(
|
||||
HALSimGui::halProvider->GetModel("REVPHs"), [](glass::Model* model) {
|
||||
glass::DisplayCompressorsDevice(
|
||||
HALSimGui::halProvider->GetModel("REVPHs"), [](wpi::glass::Model* model) {
|
||||
wpi::glass::DisplayCompressorsDevice(
|
||||
static_cast<PHsSimModel*>(model),
|
||||
HALSimGui::halProvider->AreOutputsEnabled());
|
||||
});
|
||||
|
||||
@@ -13,8 +13,8 @@ class PHSimGui {
|
||||
public:
|
||||
static void Initialize();
|
||||
static bool PHsAnyInitialized();
|
||||
static bool PHsAnySolenoids(glass::PneumaticControlsModel* model);
|
||||
static std::unique_ptr<glass::PneumaticControlsModel> GetPHsModel();
|
||||
static bool PHsAnySolenoids(wpi::glass::PneumaticControlsModel* model);
|
||||
static std::unique_ptr<wpi::glass::PneumaticControlsModel> GetPHsModel();
|
||||
};
|
||||
|
||||
} // namespace halsimgui
|
||||
|
||||
@@ -19,7 +19,7 @@ using namespace halsimgui;
|
||||
namespace {
|
||||
HALSIMGUI_DATASOURCE_DOUBLE_INDEXED(PWMPulseMicrosecond, "PWM");
|
||||
|
||||
class PWMSimModel : public glass::PWMModel {
|
||||
class PWMSimModel : public wpi::glass::PWMModel {
|
||||
public:
|
||||
explicit PWMSimModel(int32_t index) : m_index{index}, m_speed{m_index} {}
|
||||
|
||||
@@ -27,7 +27,7 @@ class PWMSimModel : public glass::PWMModel {
|
||||
|
||||
bool Exists() override { return HALSIM_GetPWMInitialized(m_index); }
|
||||
|
||||
glass::DoubleSource* GetSpeedData() override { return &m_speed; }
|
||||
wpi::glass::DoubleSource* GetSpeedData() override { return &m_speed; }
|
||||
|
||||
void SetSpeed(double val) override {
|
||||
HALSIM_SetPWMPulseMicrosecond(m_index, val);
|
||||
@@ -38,7 +38,7 @@ class PWMSimModel : public glass::PWMModel {
|
||||
PWMPulseMicrosecondSource m_speed;
|
||||
};
|
||||
|
||||
class PWMsSimModel : public glass::PWMsModel {
|
||||
class PWMsSimModel : public wpi::glass::PWMsModel {
|
||||
public:
|
||||
PWMsSimModel() : m_sources(HAL_GetNumPWMChannels()) {}
|
||||
|
||||
@@ -47,7 +47,7 @@ class PWMsSimModel : public glass::PWMsModel {
|
||||
bool Exists() override { return true; }
|
||||
|
||||
void ForEachPWM(
|
||||
wpi::function_ref<void(glass::PWMModel& model, int index)> func) override;
|
||||
wpi::util::function_ref<void(wpi::glass::PWMModel& model, int index)> func) override;
|
||||
|
||||
private:
|
||||
// indexed by channel
|
||||
@@ -70,7 +70,7 @@ void PWMsSimModel::Update() {
|
||||
}
|
||||
|
||||
void PWMsSimModel::ForEachPWM(
|
||||
wpi::function_ref<void(glass::PWMModel& model, int index)> func) {
|
||||
wpi::util::function_ref<void(wpi::glass::PWMModel& model, int index)> func) {
|
||||
const int32_t numPWM = m_sources.size();
|
||||
for (int32_t i = 0; i < numPWM; ++i) {
|
||||
if (auto model = m_sources[i].get()) {
|
||||
@@ -93,11 +93,11 @@ void PWMSimGui::Initialize() {
|
||||
HALSimGui::halProvider->Register(
|
||||
"PWM Outputs", PWMsAnyInitialized,
|
||||
[] { return std::make_unique<PWMsSimModel>(); },
|
||||
[](glass::Window* win, glass::Model* model) {
|
||||
[](wpi::glass::Window* win, wpi::glass::Model* model) {
|
||||
win->SetFlags(ImGuiWindowFlags_AlwaysAutoResize);
|
||||
win->SetDefaultPos(910, 20);
|
||||
return glass::MakeFunctionView([=] {
|
||||
glass::DisplayPWMs(static_cast<PWMsSimModel*>(model),
|
||||
return wpi::glass::MakeFunctionView([=] {
|
||||
wpi::glass::DisplayPWMs(static_cast<PWMsSimModel*>(model),
|
||||
HALSimGui::halProvider->AreOutputsEnabled());
|
||||
});
|
||||
});
|
||||
|
||||
@@ -25,7 +25,7 @@ HALSIMGUI_DATASOURCE_DOUBLE_INDEXED(PowerDistributionVoltage,
|
||||
HALSIMGUI_DATASOURCE_DOUBLE_INDEXED2(PowerDistributionCurrent,
|
||||
"Power Distribution Current");
|
||||
|
||||
class PowerDistributionSimModel : public glass::PowerDistributionModel {
|
||||
class PowerDistributionSimModel : public wpi::glass::PowerDistributionModel {
|
||||
public:
|
||||
explicit PowerDistributionSimModel(int32_t index)
|
||||
: m_index{index}, m_temp{index}, m_voltage{index} {
|
||||
@@ -46,9 +46,9 @@ class PowerDistributionSimModel : public glass::PowerDistributionModel {
|
||||
|
||||
int GetNumChannels() const override { return m_currents.size(); }
|
||||
|
||||
glass::DoubleSource* GetTemperatureData() override { return &m_temp; }
|
||||
glass::DoubleSource* GetVoltageData() override { return &m_voltage; }
|
||||
glass::DoubleSource* GetCurrentData(int channel) override {
|
||||
wpi::glass::DoubleSource* GetTemperatureData() override { return &m_temp; }
|
||||
wpi::glass::DoubleSource* GetVoltageData() override { return &m_voltage; }
|
||||
wpi::glass::DoubleSource* GetCurrentData(int channel) override {
|
||||
return m_currents[channel].get();
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ class PowerDistributionSimModel : public glass::PowerDistributionModel {
|
||||
std::vector<std::unique_ptr<PowerDistributionCurrentSource>> m_currents;
|
||||
};
|
||||
|
||||
class PowerDistributionsSimModel : public glass::PowerDistributionsModel {
|
||||
class PowerDistributionsSimModel : public wpi::glass::PowerDistributionsModel {
|
||||
public:
|
||||
PowerDistributionsSimModel() : m_models(HAL_GetNumREVPDHModules()) {}
|
||||
|
||||
@@ -78,7 +78,7 @@ class PowerDistributionsSimModel : public glass::PowerDistributionsModel {
|
||||
bool Exists() override { return true; }
|
||||
|
||||
void ForEachPowerDistribution(
|
||||
wpi::function_ref<void(glass::PowerDistributionModel& model, int index)>
|
||||
wpi::util::function_ref<void(wpi::glass::PowerDistributionModel& model, int index)>
|
||||
func) override;
|
||||
|
||||
private:
|
||||
@@ -101,7 +101,7 @@ void PowerDistributionsSimModel::Update() {
|
||||
}
|
||||
|
||||
void PowerDistributionsSimModel::ForEachPowerDistribution(
|
||||
wpi::function_ref<void(glass::PowerDistributionModel& model, int index)>
|
||||
wpi::util::function_ref<void(wpi::glass::PowerDistributionModel& model, int index)>
|
||||
func) {
|
||||
for (int32_t i = 0, iend = static_cast<int32_t>(m_models.size()); i < iend;
|
||||
++i) {
|
||||
@@ -125,9 +125,9 @@ void PowerDistributionSimGui::Initialize() {
|
||||
HALSimGui::halProvider->Register(
|
||||
"PowerDistributions", PowerDistributionsAnyInitialized,
|
||||
[] { return std::make_unique<PowerDistributionsSimModel>(); },
|
||||
[](glass::Window* win, glass::Model* model) {
|
||||
[](wpi::glass::Window* win, wpi::glass::Model* model) {
|
||||
win->SetDefaultPos(245, 155);
|
||||
return glass::MakeFunctionView([=] {
|
||||
return wpi::glass::MakeFunctionView([=] {
|
||||
DisplayPowerDistributions(
|
||||
static_cast<PowerDistributionsSimModel*>(model));
|
||||
});
|
||||
|
||||
@@ -21,14 +21,14 @@ HALSIMGUI_DATASOURCE_BOOLEAN(RoboRioUserActive3V3, "Rio 3.3V Active");
|
||||
HALSIMGUI_DATASOURCE_INT(RoboRioUserFaults3V3, "Rio 3.3V Faults");
|
||||
HALSIMGUI_DATASOURCE_DOUBLE(RoboRioBrownoutVoltage, "Rio Brownout Voltage");
|
||||
|
||||
class RoboRioUser3V3RailSimModel : public glass::RoboRioRailModel {
|
||||
class RoboRioUser3V3RailSimModel : public wpi::glass::RoboRioRailModel {
|
||||
public:
|
||||
void Update() override {}
|
||||
bool Exists() override { return true; }
|
||||
glass::DoubleSource* GetVoltageData() override { return &m_voltage; }
|
||||
glass::DoubleSource* GetCurrentData() override { return &m_current; }
|
||||
glass::BooleanSource* GetActiveData() override { return &m_active; }
|
||||
glass::IntegerSource* GetFaultsData() override { return &m_faults; }
|
||||
wpi::glass::DoubleSource* GetVoltageData() override { return &m_voltage; }
|
||||
wpi::glass::DoubleSource* GetCurrentData() override { return &m_current; }
|
||||
wpi::glass::BooleanSource* GetActiveData() override { return &m_active; }
|
||||
wpi::glass::IntegerSource* GetFaultsData() override { return &m_faults; }
|
||||
|
||||
void SetVoltage(double val) override { HALSIM_SetRoboRioUserVoltage3V3(val); }
|
||||
void SetCurrent(double val) override { HALSIM_SetRoboRioUserCurrent3V3(val); }
|
||||
@@ -42,16 +42,16 @@ class RoboRioUser3V3RailSimModel : public glass::RoboRioRailModel {
|
||||
RoboRioUserFaults3V3Source m_faults;
|
||||
};
|
||||
|
||||
class RoboRioSimModel : public glass::RoboRioModel {
|
||||
class RoboRioSimModel : public wpi::glass::RoboRioModel {
|
||||
public:
|
||||
void Update() override {}
|
||||
|
||||
bool Exists() override { return true; }
|
||||
|
||||
glass::RoboRioRailModel* GetUser3V3Rail() override { return &m_user3V3Rail; }
|
||||
wpi::glass::RoboRioRailModel* GetUser3V3Rail() override { return &m_user3V3Rail; }
|
||||
|
||||
glass::DoubleSource* GetVInVoltageData() override { return &m_vInVoltage; }
|
||||
glass::DoubleSource* GetBrownoutVoltage() override {
|
||||
wpi::glass::DoubleSource* GetVInVoltageData() override { return &m_vInVoltage; }
|
||||
wpi::glass::DoubleSource* GetBrownoutVoltage() override {
|
||||
return &m_brownoutVoltage;
|
||||
}
|
||||
|
||||
@@ -71,10 +71,10 @@ void RoboRioSimGui::Initialize() {
|
||||
HALSimGui::halProvider->Register(
|
||||
"RoboRIO", [] { return true; },
|
||||
[] { return std::make_unique<RoboRioSimModel>(); },
|
||||
[](glass::Window* win, glass::Model* model) {
|
||||
[](wpi::glass::Window* win, wpi::glass::Model* model) {
|
||||
win->SetFlags(ImGuiWindowFlags_AlwaysAutoResize);
|
||||
win->SetDefaultPos(5, 125);
|
||||
return glass::MakeFunctionView(
|
||||
return wpi::glass::MakeFunctionView(
|
||||
[=] { DisplayRoboRio(static_cast<RoboRioSimModel*>(model)); });
|
||||
});
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ using namespace halsimgui;
|
||||
|
||||
namespace {
|
||||
#define DEFINE_SIMVALUESOURCE(Type, TYPE, v_type) \
|
||||
class Sim##Type##ValueSource : public glass::Type##Source { \
|
||||
class Sim##Type##ValueSource : public wpi::glass::Type##Source { \
|
||||
public: \
|
||||
explicit Sim##Type##ValueSource(HAL_SimValueHandle handle, \
|
||||
const char* device, const char* name) \
|
||||
@@ -51,7 +51,7 @@ namespace {
|
||||
DEFINE_SIMVALUESOURCE(Boolean, BOOLEAN, boolean)
|
||||
DEFINE_SIMVALUESOURCE(Double, DOUBLE, double)
|
||||
|
||||
class SimIntegerValueSource : public glass::IntegerSource {
|
||||
class SimIntegerValueSource : public wpi::glass::IntegerSource {
|
||||
public:
|
||||
explicit SimIntegerValueSource(HAL_SimValueHandle handle, const char* device,
|
||||
const char* name)
|
||||
@@ -80,17 +80,17 @@ class SimIntegerValueSource : public glass::IntegerSource {
|
||||
int32_t m_callback;
|
||||
};
|
||||
|
||||
class SimDevicesModel : public glass::Model {
|
||||
class SimDevicesModel : public wpi::glass::Model {
|
||||
public:
|
||||
void Update() override;
|
||||
bool Exists() override { return true; }
|
||||
|
||||
glass::DataSource* GetSource(HAL_SimValueHandle handle) {
|
||||
wpi::glass::DataSource* GetSource(HAL_SimValueHandle handle) {
|
||||
return m_sources[handle].get();
|
||||
}
|
||||
|
||||
private:
|
||||
wpi::DenseMap<HAL_SimValueHandle, std::unique_ptr<glass::DataSource>>
|
||||
wpi::util::DenseMap<HAL_SimValueHandle, std::unique_ptr<wpi::glass::DataSource>>
|
||||
m_sources;
|
||||
};
|
||||
} // namespace
|
||||
@@ -150,7 +150,7 @@ static void DisplaySimValue(const char* name, void* data,
|
||||
switch (value->type) {
|
||||
case HAL_BOOLEAN: {
|
||||
bool v = value->data.v_boolean;
|
||||
if (glass::DeviceBoolean(name, direction == HAL_SimValueOutput, &v,
|
||||
if (wpi::glass::DeviceBoolean(name, direction == HAL_SimValueOutput, &v,
|
||||
model->GetSource(handle))) {
|
||||
valueCopy.data.v_boolean = v ? 1 : 0;
|
||||
HAL_SetSimValue(handle, valueCopy);
|
||||
@@ -158,7 +158,7 @@ static void DisplaySimValue(const char* name, void* data,
|
||||
break;
|
||||
}
|
||||
case HAL_DOUBLE:
|
||||
if (glass::DeviceDouble(name, direction == HAL_SimValueOutput,
|
||||
if (wpi::glass::DeviceDouble(name, direction == HAL_SimValueOutput,
|
||||
&valueCopy.data.v_double,
|
||||
model->GetSource(handle))) {
|
||||
HAL_SetSimValue(handle, valueCopy);
|
||||
@@ -167,7 +167,7 @@ static void DisplaySimValue(const char* name, void* data,
|
||||
case HAL_ENUM: {
|
||||
int32_t numOptions = 0;
|
||||
const char** options = HALSIM_GetSimValueEnumOptions(handle, &numOptions);
|
||||
if (glass::DeviceEnum(name, direction == HAL_SimValueOutput,
|
||||
if (wpi::glass::DeviceEnum(name, direction == HAL_SimValueOutput,
|
||||
&valueCopy.data.v_enum, options, numOptions,
|
||||
model->GetSource(handle))) {
|
||||
HAL_SetSimValue(handle, valueCopy);
|
||||
@@ -175,13 +175,13 @@ static void DisplaySimValue(const char* name, void* data,
|
||||
break;
|
||||
}
|
||||
case HAL_INT:
|
||||
if (glass::DeviceInt(name, direction == HAL_SimValueOutput,
|
||||
if (wpi::glass::DeviceInt(name, direction == HAL_SimValueOutput,
|
||||
&valueCopy.data.v_int, model->GetSource(handle))) {
|
||||
HAL_SetSimValue(handle, valueCopy);
|
||||
}
|
||||
break;
|
||||
case HAL_LONG:
|
||||
if (glass::DeviceLong(name, direction == HAL_SimValueOutput,
|
||||
if (wpi::glass::DeviceLong(name, direction == HAL_SimValueOutput,
|
||||
&valueCopy.data.v_long, model->GetSource(handle))) {
|
||||
HAL_SetSimValue(handle, valueCopy);
|
||||
}
|
||||
@@ -197,49 +197,49 @@ static void DisplaySimDevice(const char* name, void* data,
|
||||
if (!gSimDevicesShowPrefix) {
|
||||
// only show "Foo" portion of "Accel:Foo"
|
||||
std::string_view type;
|
||||
std::tie(type, id) = wpi::split(id, ':');
|
||||
std::tie(type, id) = wpi::util::split(id, ':');
|
||||
if (id.empty()) {
|
||||
id = type;
|
||||
}
|
||||
}
|
||||
if (glass::BeginDevice(id.data())) {
|
||||
if (wpi::glass::BeginDevice(id.data())) {
|
||||
HALSIM_EnumerateSimValues(handle, data, DisplaySimValue);
|
||||
glass::EndDevice();
|
||||
wpi::glass::EndDevice();
|
||||
}
|
||||
}
|
||||
|
||||
void SimDeviceGui::Initialize() {
|
||||
HALSimGui::halProvider->Register(
|
||||
"Other Devices", [] { return true; },
|
||||
[] { return std::make_unique<glass::DeviceTreeModel>(); },
|
||||
[](glass::Window* win, glass::Model* model) {
|
||||
[] { return std::make_unique<wpi::glass::DeviceTreeModel>(); },
|
||||
[](wpi::glass::Window* win, wpi::glass::Model* model) {
|
||||
win->SetDefaultPos(1025, 20);
|
||||
win->SetDefaultSize(250, 695);
|
||||
win->DisableRenamePopup();
|
||||
return glass::MakeFunctionView([=] {
|
||||
return wpi::glass::MakeFunctionView([=] {
|
||||
if (ImGui::BeginPopupContextItem()) {
|
||||
ImGui::Checkbox("Show prefix", &gSimDevicesShowPrefix);
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
static_cast<glass::DeviceTreeModel*>(model)->Display();
|
||||
static_cast<wpi::glass::DeviceTreeModel*>(model)->Display();
|
||||
});
|
||||
});
|
||||
HALSimGui::halProvider->ShowDefault("Other Devices");
|
||||
|
||||
auto model = std::make_unique<SimDevicesModel>();
|
||||
gSimDevicesModel = model.get();
|
||||
GetDeviceTree().Add(std::move(model), [](glass::Model* model) {
|
||||
GetDeviceTree().Add(std::move(model), [](wpi::glass::Model* model) {
|
||||
HALSIM_EnumerateSimDevices("", static_cast<SimDevicesModel*>(model),
|
||||
DisplaySimDevice);
|
||||
});
|
||||
}
|
||||
|
||||
glass::DataSource* SimDeviceGui::GetValueSource(HAL_SimValueHandle handle) {
|
||||
wpi::glass::DataSource* SimDeviceGui::GetValueSource(HAL_SimValueHandle handle) {
|
||||
return gSimDevicesModel->GetSource(handle);
|
||||
}
|
||||
|
||||
glass::DeviceTreeModel& SimDeviceGui::GetDeviceTree() {
|
||||
wpi::glass::DeviceTreeModel& SimDeviceGui::GetDeviceTree() {
|
||||
static auto model = HALSimGui::halProvider->GetModel("Other Devices");
|
||||
assert(model);
|
||||
return *static_cast<glass::DeviceTreeModel*>(model);
|
||||
return *static_cast<wpi::glass::DeviceTreeModel*>(model);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
using namespace halsimgui;
|
||||
|
||||
namespace {
|
||||
class TimingModel : public glass::Model {
|
||||
class TimingModel : public wpi::glass::Model {
|
||||
public:
|
||||
void Update() override {}
|
||||
bool Exists() override { return true; }
|
||||
@@ -74,11 +74,11 @@ void TimingGui::Initialize() {
|
||||
HALSimGui::halProvider->Register(
|
||||
"Timing", [] { return true; },
|
||||
[] { return std::make_unique<TimingModel>(); },
|
||||
[](glass::Window* win, glass::Model* model) {
|
||||
[](wpi::glass::Window* win, wpi::glass::Model* model) {
|
||||
win->DisableRenamePopup();
|
||||
win->SetFlags(ImGuiWindowFlags_AlwaysAutoResize);
|
||||
win->SetDefaultPos(5, 150);
|
||||
return glass::MakeFunctionView(DisplayTiming);
|
||||
return wpi::glass::MakeFunctionView(DisplayTiming);
|
||||
});
|
||||
HALSimGui::halProvider->ShowDefault("Timing");
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ using namespace halsimgui;
|
||||
|
||||
namespace gui = wpi::gui;
|
||||
|
||||
static std::unique_ptr<glass::PlotProvider> gPlotProvider;
|
||||
static std::unique_ptr<wpi::glass::PlotProvider> gPlotProvider;
|
||||
|
||||
extern "C" {
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
@@ -45,9 +45,9 @@ int HALSIM_InitExtension(void) {
|
||||
std::puts("Simulator GUI Initializing.");
|
||||
|
||||
gui::CreateContext();
|
||||
glass::CreateContext();
|
||||
wpi::glass::CreateContext();
|
||||
|
||||
glass::SetStorageName("simgui");
|
||||
wpi::glass::SetStorageName("simgui");
|
||||
|
||||
gui::AddInit([] { ImGui::GetIO().ConfigDockingWithShift = true; });
|
||||
|
||||
@@ -66,12 +66,12 @@ int HALSIM_InitExtension(void) {
|
||||
reinterpret_cast<void*>((GetGuiContextFn)&gui::GetCurrentContext));
|
||||
HAL_RegisterExtension(
|
||||
HALSIMGUI_EXT_GETGLASSCONTEXT,
|
||||
reinterpret_cast<void*>((GetGlassContextFn)&glass::GetCurrentContext));
|
||||
reinterpret_cast<void*>((GetGlassContextFn)&wpi::glass::GetCurrentContext));
|
||||
|
||||
HALSimGui::GlobalInit();
|
||||
DriverStationGui::GlobalInit();
|
||||
gPlotProvider = std::make_unique<glass::PlotProvider>(
|
||||
glass::GetStorageRoot().GetChild("Plot"));
|
||||
gPlotProvider = std::make_unique<wpi::glass::PlotProvider>(
|
||||
wpi::glass::GetStorageRoot().GetChild("Plot"));
|
||||
gPlotProvider->GlobalInit();
|
||||
|
||||
// These need to initialize first
|
||||
@@ -95,28 +95,28 @@ int HALSIM_InitExtension(void) {
|
||||
return PCMSimGui::PCMsAnyInitialized() || PHSimGui::PHsAnyInitialized();
|
||||
},
|
||||
[] {
|
||||
return std::make_unique<glass::AllPneumaticControlsModel>(
|
||||
return std::make_unique<wpi::glass::AllPneumaticControlsModel>(
|
||||
PCMSimGui::GetPCMsModel(), PHSimGui::GetPHsModel());
|
||||
});
|
||||
|
||||
HALSimGui::halProvider->RegisterView(
|
||||
"Solenoids", "AllPneumaticControls",
|
||||
[](glass::Model* model) {
|
||||
[](wpi::glass::Model* model) {
|
||||
auto pneumaticModel =
|
||||
static_cast<glass::AllPneumaticControlsModel*>(model);
|
||||
static_cast<wpi::glass::AllPneumaticControlsModel*>(model);
|
||||
return PCMSimGui::PCMsAnySolenoids(pneumaticModel->pcms.get()) ||
|
||||
PHSimGui::PHsAnySolenoids(pneumaticModel->phs.get());
|
||||
},
|
||||
[](glass::Window* win, glass::Model* model) {
|
||||
[](wpi::glass::Window* win, wpi::glass::Model* model) {
|
||||
win->SetFlags(ImGuiWindowFlags_AlwaysAutoResize);
|
||||
win->SetDefaultPos(290, 20);
|
||||
return glass::MakeFunctionView([=] {
|
||||
return wpi::glass::MakeFunctionView([=] {
|
||||
auto pneumaticModel =
|
||||
static_cast<glass::AllPneumaticControlsModel*>(model);
|
||||
glass::DisplayPneumaticControlsSolenoids(
|
||||
static_cast<wpi::glass::AllPneumaticControlsModel*>(model);
|
||||
wpi::glass::DisplayPneumaticControlsSolenoids(
|
||||
pneumaticModel->pcms.get(),
|
||||
HALSimGui::halProvider->AreOutputsEnabled());
|
||||
glass::DisplayPneumaticControlsSolenoids(
|
||||
wpi::glass::DisplayPneumaticControlsSolenoids(
|
||||
pneumaticModel->phs.get(),
|
||||
HALSimGui::halProvider->AreOutputsEnabled());
|
||||
});
|
||||
@@ -169,7 +169,7 @@ int HALSIM_InitExtension(void) {
|
||||
nullptr,
|
||||
[](void*) {
|
||||
gui::Main();
|
||||
glass::DestroyContext();
|
||||
wpi::glass::DestroyContext();
|
||||
gui::DestroyContext();
|
||||
},
|
||||
[](void*) { gui::Exit(); });
|
||||
|
||||
Reference in New Issue
Block a user