mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[hal] Rename PowerDistributionPanel to PowerDistribution (#3466)
Makes HAL more generic for the PDP, to enable the Rev PDH in the future.
This commit is contained in:
@@ -1,99 +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 "frc/simulation/PDPSim.h"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include <hal/simulation/PDPData.h>
|
||||
|
||||
#include "frc/PowerDistributionPanel.h"
|
||||
|
||||
using namespace frc;
|
||||
using namespace frc::sim;
|
||||
|
||||
PDPSim::PDPSim(int module) : m_index{module} {}
|
||||
|
||||
PDPSim::PDPSim(const PowerDistributionPanel& pdp) : m_index{pdp.GetModule()} {}
|
||||
|
||||
std::unique_ptr<CallbackStore> PDPSim::RegisterInitializedCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelPDPInitializedCallback);
|
||||
store->SetUid(HALSIM_RegisterPDPInitializedCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool PDPSim::GetInitialized() const {
|
||||
return HALSIM_GetPDPInitialized(m_index);
|
||||
}
|
||||
|
||||
void PDPSim::SetInitialized(bool initialized) {
|
||||
HALSIM_SetPDPInitialized(m_index, initialized);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> PDPSim::RegisterTemperatureCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelPDPTemperatureCallback);
|
||||
store->SetUid(HALSIM_RegisterPDPTemperatureCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double PDPSim::GetTemperature() const {
|
||||
return HALSIM_GetPDPTemperature(m_index);
|
||||
}
|
||||
|
||||
void PDPSim::SetTemperature(double temperature) {
|
||||
HALSIM_SetPDPTemperature(m_index, temperature);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> PDPSim::RegisterVoltageCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelPDPVoltageCallback);
|
||||
store->SetUid(HALSIM_RegisterPDPVoltageCallback(m_index, &CallbackStoreThunk,
|
||||
store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double PDPSim::GetVoltage() const {
|
||||
return HALSIM_GetPDPVoltage(m_index);
|
||||
}
|
||||
|
||||
void PDPSim::SetVoltage(double voltage) {
|
||||
HALSIM_SetPDPVoltage(m_index, voltage);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> PDPSim::RegisterCurrentCallback(
|
||||
int channel, NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, channel, -1, callback, &HALSIM_CancelPDPCurrentCallback);
|
||||
store->SetUid(HALSIM_RegisterPDPCurrentCallback(
|
||||
m_index, channel, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double PDPSim::GetCurrent(int channel) const {
|
||||
return HALSIM_GetPDPCurrent(m_index, channel);
|
||||
}
|
||||
|
||||
void PDPSim::SetCurrent(int channel, double current) {
|
||||
HALSIM_SetPDPCurrent(m_index, channel, current);
|
||||
}
|
||||
|
||||
void PDPSim::GetAllCurrents(double* currents) const {
|
||||
HALSIM_GetPDPAllCurrents(m_index, currents);
|
||||
}
|
||||
|
||||
void PDPSim::SetAllCurrents(const double* currents) {
|
||||
HALSIM_SetPDPAllCurrents(m_index, currents);
|
||||
}
|
||||
|
||||
void PDPSim::ResetData() {
|
||||
HALSIM_ResetPDPData(m_index);
|
||||
}
|
||||
105
wpilibc/src/main/native/cpp/simulation/PowerDistributionSim.cpp
Normal file
105
wpilibc/src/main/native/cpp/simulation/PowerDistributionSim.cpp
Normal file
@@ -0,0 +1,105 @@
|
||||
// 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 "frc/simulation/PowerDistributionSim.h"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include <hal/simulation/PowerDistributionData.h>
|
||||
|
||||
#include "frc/PowerDistribution.h"
|
||||
|
||||
using namespace frc;
|
||||
using namespace frc::sim;
|
||||
|
||||
PowerDistributionSim::PowerDistributionSim(int module) : m_index{module} {}
|
||||
|
||||
PowerDistributionSim::PowerDistributionSim(const PowerDistribution& pdp)
|
||||
: m_index{pdp.GetModule()} {}
|
||||
|
||||
std::unique_ptr<CallbackStore>
|
||||
PowerDistributionSim::RegisterInitializedCallback(NotifyCallback callback,
|
||||
bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback,
|
||||
&HALSIM_CancelPowerDistributionInitializedCallback);
|
||||
store->SetUid(HALSIM_RegisterPowerDistributionInitializedCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool PowerDistributionSim::GetInitialized() const {
|
||||
return HALSIM_GetPowerDistributionInitialized(m_index);
|
||||
}
|
||||
|
||||
void PowerDistributionSim::SetInitialized(bool initialized) {
|
||||
HALSIM_SetPowerDistributionInitialized(m_index, initialized);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore>
|
||||
PowerDistributionSim::RegisterTemperatureCallback(NotifyCallback callback,
|
||||
bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback,
|
||||
&HALSIM_CancelPowerDistributionTemperatureCallback);
|
||||
store->SetUid(HALSIM_RegisterPowerDistributionTemperatureCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double PowerDistributionSim::GetTemperature() const {
|
||||
return HALSIM_GetPowerDistributionTemperature(m_index);
|
||||
}
|
||||
|
||||
void PowerDistributionSim::SetTemperature(double temperature) {
|
||||
HALSIM_SetPowerDistributionTemperature(m_index, temperature);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> PowerDistributionSim::RegisterVoltageCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelPowerDistributionVoltageCallback);
|
||||
store->SetUid(HALSIM_RegisterPowerDistributionVoltageCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double PowerDistributionSim::GetVoltage() const {
|
||||
return HALSIM_GetPowerDistributionVoltage(m_index);
|
||||
}
|
||||
|
||||
void PowerDistributionSim::SetVoltage(double voltage) {
|
||||
HALSIM_SetPowerDistributionVoltage(m_index, voltage);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> PowerDistributionSim::RegisterCurrentCallback(
|
||||
int channel, NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, channel, -1, callback,
|
||||
&HALSIM_CancelPowerDistributionCurrentCallback);
|
||||
store->SetUid(HALSIM_RegisterPowerDistributionCurrentCallback(
|
||||
m_index, channel, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double PowerDistributionSim::GetCurrent(int channel) const {
|
||||
return HALSIM_GetPowerDistributionCurrent(m_index, channel);
|
||||
}
|
||||
|
||||
void PowerDistributionSim::SetCurrent(int channel, double current) {
|
||||
HALSIM_SetPowerDistributionCurrent(m_index, channel, current);
|
||||
}
|
||||
|
||||
void PowerDistributionSim::GetAllCurrents(double* currents) const {
|
||||
HALSIM_GetPowerDistributionAllCurrents(m_index, currents);
|
||||
}
|
||||
|
||||
void PowerDistributionSim::SetAllCurrents(const double* currents) {
|
||||
HALSIM_SetPowerDistributionAllCurrents(m_index, currents);
|
||||
}
|
||||
|
||||
void PowerDistributionSim::ResetData() {
|
||||
HALSIM_ResetPowerDistributionData(m_index);
|
||||
}
|
||||
Reference in New Issue
Block a user