[hal, wpilib] Remove analog output (#7696)

This commit is contained in:
Thad House
2025-01-16 23:20:44 -08:00
committed by GitHub
parent 5017393b3a
commit ff1b2a205e
45 changed files with 0 additions and 1685 deletions

View File

@@ -1,92 +0,0 @@
// 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.
#include "AnalogOutputSimGui.h"
#include <memory>
#include <vector>
#include <glass/hardware/AnalogOutput.h>
#include <glass/other/DeviceTree.h>
#include <hal/Ports.h>
#include <hal/simulation/AnalogOutData.h>
#include "HALDataSource.h"
#include "HALSimGui.h"
#include "SimDeviceGui.h"
using namespace halsimgui;
namespace {
HALSIMGUI_DATASOURCE_DOUBLE_INDEXED(AnalogOutVoltage, "AOut");
class AnalogOutputSimModel : public glass::AnalogOutputModel {
public:
explicit AnalogOutputSimModel(int32_t index)
: m_index{index}, m_voltageData{m_index} {}
void Update() override {}
bool Exists() override { return HALSIM_GetAnalogOutInitialized(m_index); }
glass::DoubleSource* GetVoltageData() override { return &m_voltageData; }
void SetVoltage(double val) override {
HALSIM_SetAnalogOutVoltage(m_index, val);
}
private:
int32_t m_index;
AnalogOutVoltageSource m_voltageData;
};
class AnalogOutputsSimModel : public glass::AnalogOutputsModel {
public:
AnalogOutputsSimModel() : m_models(HAL_GetNumAnalogOutputs()) {}
void Update() override;
bool Exists() override { return true; }
void ForEachAnalogOutput(
wpi::function_ref<void(glass::AnalogOutputModel& model, int index)> func)
override;
private:
// indexed by channel
std::vector<std::unique_ptr<AnalogOutputSimModel>> m_models;
};
} // namespace
void AnalogOutputsSimModel::Update() {
for (int32_t i = 0, iend = static_cast<int32_t>(m_models.size()); i < iend;
++i) {
auto& model = m_models[i];
if (HALSIM_GetAnalogOutInitialized(i)) {
if (!model) {
model = std::make_unique<AnalogOutputSimModel>(i);
}
} else {
model.reset();
}
}
}
void AnalogOutputsSimModel::ForEachAnalogOutput(
wpi::function_ref<void(glass::AnalogOutputModel& 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()) {
func(*model, i);
}
}
}
void AnalogOutputSimGui::Initialize() {
SimDeviceGui::GetDeviceTree().Add(
std::make_unique<AnalogOutputsSimModel>(), [](glass::Model* model) {
glass::DisplayAnalogOutputsDevice(
static_cast<AnalogOutputsSimModel*>(model));
});
}

View File

@@ -1,14 +0,0 @@
// 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.
#pragma once
namespace halsimgui {
class AnalogOutputSimGui {
public:
static void Initialize();
};
} // namespace halsimgui

View File

@@ -19,7 +19,6 @@
#include "AddressableLEDGui.h"
#include "AnalogGyroSimGui.h"
#include "AnalogInputSimGui.h"
#include "AnalogOutputSimGui.h"
#include "DIOSimGui.h"
#include "DriverStationGui.h"
#include "EncoderSimGui.h"
@@ -79,7 +78,6 @@ __declspec(dllexport)
AddressableLEDGui::Initialize();
AnalogGyroSimGui::Initialize();
AnalogInputSimGui::Initialize();
AnalogOutputSimGui::Initialize();
DIOSimGui::Initialize();
NetworkTablesSimGui::Initialize();
PCMSimGui::Initialize();

View File

@@ -40,7 +40,6 @@ bool HALSimWSClient::Initialize() {
HALSimWSProviderAddressableLED::Initialize(registerFunc);
HALSimWSProviderAnalogIn::Initialize(registerFunc);
HALSimWSProviderAnalogOut::Initialize(registerFunc);
HALSimWSProviderBuiltInAccelerometer::Initialize(registerFunc);
HALSimWSProviderDIO::Initialize(registerFunc);
HALSimWSProviderDigitalPWM::Initialize(registerFunc);

View File

@@ -6,7 +6,6 @@
#include <hal/Ports.h>
#include <hal/simulation/AnalogInData.h>
#include <hal/simulation/AnalogOutData.h>
#define REGISTER_AIN(halsim, jsonid, ctype, haltype) \
HALSIM_RegisterAnalogIn##halsim##Callback( \
@@ -26,15 +25,6 @@
}, \
this, true)
#define REGISTER_AOUT(halsim, jsonid, ctype, haltype) \
HALSIM_RegisterAnalogOut##halsim##Callback( \
m_channel, \
[](const char* name, void* param, const struct HAL_Value* value) { \
static_cast<HALSimWSProviderAnalogOut*>(param)->ProcessHalCallback( \
{{jsonid, static_cast<ctype>(value->data.v_##haltype)}}); \
}, \
this, true)
namespace wpilibws {
void HALSimWSProviderAnalogIn::Initialize(WSRegisterFunc webRegisterFunc) {
@@ -108,26 +98,4 @@ void HALSimWSProviderAnalogIn::OnNetValueChanged(const wpi::json& json) {
}
}
void HALSimWSProviderAnalogOut::Initialize(WSRegisterFunc webRegisterFunc) {
CreateProviders<HALSimWSProviderAnalogOut>("AO", HAL_GetNumAnalogOutputs(),
webRegisterFunc);
}
HALSimWSProviderAnalogOut::~HALSimWSProviderAnalogOut() {
CancelCallbacks();
}
void HALSimWSProviderAnalogOut::RegisterCallbacks() {
m_initCbKey = REGISTER_AOUT(Initialized, "<init", bool, boolean);
m_voltageCbKey = REGISTER_AOUT(Voltage, "<voltage", double, double);
}
void HALSimWSProviderAnalogOut::CancelCallbacks() {
HALSIM_CancelAnalogOutInitializedCallback(m_channel, m_initCbKey);
HALSIM_CancelAnalogOutVoltageCallback(m_channel, m_voltageCbKey);
m_initCbKey = 0;
m_voltageCbKey = 0;
}
} // namespace wpilibws

View File

@@ -36,21 +36,4 @@ class HALSimWSProviderAnalogIn : public HALSimWSHalChanProvider {
int32_t m_accumDeadbandCbKey = 0;
};
class HALSimWSProviderAnalogOut : public HALSimWSHalChanProvider {
public:
static void Initialize(WSRegisterFunc webRegisterFunc);
using HALSimWSHalChanProvider::HALSimWSHalChanProvider;
~HALSimWSProviderAnalogOut() override;
protected:
void RegisterCallbacks() override;
void CancelCallbacks() final;
void DoCancelCallbacks();
private:
int32_t m_initCbKey = 0;
int32_t m_voltageCbKey = 0;
};
} // namespace wpilibws

View File

@@ -39,7 +39,6 @@ bool HALSimWSServer::Initialize() {
HALSimWSProviderAddressableLED::Initialize(registerFunc);
HALSimWSProviderAnalogIn::Initialize(registerFunc);
HALSimWSProviderAnalogOut::Initialize(registerFunc);
HALSimWSProviderBuiltInAccelerometer::Initialize(registerFunc);
HALSimWSProviderDIO::Initialize(registerFunc);
HALSimWSProviderDigitalPWM::Initialize(registerFunc);