mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[sim] Move WPILib C++ sim implementations out of line (#2598)
This makes the sim classes consistent with the rest of the WPILibC classes.
This commit is contained in:
77
wpilibc/src/main/native/cpp/simulation/AnalogGyroSim.cpp
Normal file
77
wpilibc/src/main/native/cpp/simulation/AnalogGyroSim.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "frc/simulation/AnalogGyroSim.h"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include <hal/simulation/AnalogGyroData.h>
|
||||
|
||||
#include "frc/AnalogGyro.h"
|
||||
#include "frc/AnalogInput.h"
|
||||
|
||||
using namespace frc;
|
||||
using namespace frc::sim;
|
||||
|
||||
AnalogGyroSim::AnalogGyroSim(const AnalogGyro& gyro)
|
||||
: m_index{gyro.GetAnalogInput()->GetChannel()} {}
|
||||
|
||||
AnalogGyroSim::AnalogGyroSim(int channel) : m_index{channel} {}
|
||||
|
||||
std::unique_ptr<CallbackStore> AnalogGyroSim::RegisterAngleCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelAnalogGyroAngleCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogGyroAngleCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double AnalogGyroSim::GetAngle() const {
|
||||
return HALSIM_GetAnalogGyroAngle(m_index);
|
||||
}
|
||||
|
||||
void AnalogGyroSim::SetAngle(double angle) {
|
||||
HALSIM_SetAnalogGyroAngle(m_index, angle);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> AnalogGyroSim::RegisterRateCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelAnalogGyroRateCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogGyroRateCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double AnalogGyroSim::GetRate() const {
|
||||
return HALSIM_GetAnalogGyroRate(m_index);
|
||||
}
|
||||
|
||||
void AnalogGyroSim::SetRate(double rate) {
|
||||
HALSIM_SetAnalogGyroRate(m_index, rate);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> AnalogGyroSim::RegisterInitializedCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelAnalogGyroInitializedCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogGyroInitializedCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool AnalogGyroSim::GetInitialized() const {
|
||||
return HALSIM_GetAnalogGyroInitialized(m_index);
|
||||
}
|
||||
|
||||
void AnalogGyroSim::SetInitialized(bool initialized) {
|
||||
HALSIM_SetAnalogGyroInitialized(m_index, initialized);
|
||||
}
|
||||
|
||||
void AnalogGyroSim::ResetData() { HALSIM_ResetAnalogGyroData(m_index); }
|
||||
Reference in New Issue
Block a user