mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[sim] Add WPILib-class-taking constructors (#2538)
When not direct mapped, make index constructors private and add factory functions for channel and index. Co-authored-by: GabrielDeml <gabrielddeml@gmail.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -160,3 +160,7 @@ void AnalogGyro::Calibrate() {
|
||||
HAL_CalibrateAnalogGyro(m_gyroHandle, &status);
|
||||
wpi_setHALError(status);
|
||||
}
|
||||
|
||||
std::shared_ptr<AnalogInput> AnalogGyro::GetAnalogInput() const {
|
||||
return m_analog;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ double AnalogOutput::GetVoltage() const {
|
||||
return voltage;
|
||||
}
|
||||
|
||||
int AnalogOutput::GetChannel() { return m_channel; }
|
||||
int AnalogOutput::GetChannel() const { return m_channel; }
|
||||
|
||||
void AnalogOutput::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Analog Output");
|
||||
|
||||
@@ -204,6 +204,8 @@ void Compressor::ClearAllPCMStickyFaults() {
|
||||
}
|
||||
}
|
||||
|
||||
int Compressor::GetModule() const { return m_module; }
|
||||
|
||||
void Compressor::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Compressor");
|
||||
builder.AddBooleanProperty(
|
||||
|
||||
@@ -25,7 +25,7 @@ PowerDistributionPanel::PowerDistributionPanel() : PowerDistributionPanel(0) {}
|
||||
/**
|
||||
* Initialize the PDP.
|
||||
*/
|
||||
PowerDistributionPanel::PowerDistributionPanel(int module) {
|
||||
PowerDistributionPanel::PowerDistributionPanel(int module) : m_module(module) {
|
||||
int32_t status = 0;
|
||||
m_handle = HAL_InitializePDP(module, &status);
|
||||
if (status != 0) {
|
||||
@@ -136,6 +136,8 @@ void PowerDistributionPanel::ClearStickyFaults() {
|
||||
}
|
||||
}
|
||||
|
||||
int PowerDistributionPanel::GetModule() const { return m_module; }
|
||||
|
||||
void PowerDistributionPanel::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("PowerDistributionPanel");
|
||||
for (int i = 0; i < SensorUtil::kPDPChannels; ++i) {
|
||||
|
||||
@@ -11,3 +11,10 @@ void frc::sim::CallbackStoreThunk(const char* name, void* param,
|
||||
const HAL_Value* value) {
|
||||
reinterpret_cast<CallbackStore*>(param)->callback(name, value);
|
||||
}
|
||||
|
||||
void frc::sim::ConstBufferCallbackStoreThunk(const char* name, void* param,
|
||||
const unsigned char* buffer,
|
||||
unsigned int count) {
|
||||
reinterpret_cast<CallbackStore*>(param)->constBufferCallback(name, buffer,
|
||||
count);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user