mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +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:
@@ -8,14 +8,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include <hal/simulation/AnalogInData.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
#include "frc/AnalogInput.h"
|
||||
#include "frc/simulation/CallbackStore.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class AnalogInput;
|
||||
|
||||
namespace sim {
|
||||
|
||||
/**
|
||||
@@ -28,166 +27,79 @@ class AnalogInputSim {
|
||||
*
|
||||
* @param analogInput AnalogInput to simulate
|
||||
*/
|
||||
explicit AnalogInputSim(const AnalogInput& analogInput)
|
||||
: m_index{analogInput.GetChannel()} {}
|
||||
explicit AnalogInputSim(const AnalogInput& analogInput);
|
||||
|
||||
/**
|
||||
* Constructs from an analog input channel number.
|
||||
*
|
||||
* @param channel Channel number
|
||||
*/
|
||||
explicit AnalogInputSim(int channel) : m_index{channel} {}
|
||||
explicit AnalogInputSim(int channel);
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterInitializedCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelAnalogInInitializedCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogInInitializedCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
NotifyCallback callback, bool initialNotify);
|
||||
|
||||
bool GetInitialized() const { return HALSIM_GetAnalogInInitialized(m_index); }
|
||||
bool GetInitialized() const;
|
||||
|
||||
void SetInitialized(bool initialized) {
|
||||
HALSIM_SetAnalogInInitialized(m_index, initialized);
|
||||
}
|
||||
void SetInitialized(bool initialized);
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterAverageBitsCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelAnalogInAverageBitsCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogInAverageBitsCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
NotifyCallback callback, bool initialNotify);
|
||||
|
||||
int GetAverageBits() const { return HALSIM_GetAnalogInAverageBits(m_index); }
|
||||
int GetAverageBits() const;
|
||||
|
||||
void SetAverageBits(int averageBits) {
|
||||
HALSIM_SetAnalogInAverageBits(m_index, averageBits);
|
||||
}
|
||||
void SetAverageBits(int averageBits);
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterOversampleBitsCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelAnalogInOversampleBitsCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogInOversampleBitsCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
NotifyCallback callback, bool initialNotify);
|
||||
|
||||
int GetOversampleBits() const {
|
||||
return HALSIM_GetAnalogInOversampleBits(m_index);
|
||||
}
|
||||
int GetOversampleBits() const;
|
||||
|
||||
void SetOversampleBits(int oversampleBits) {
|
||||
HALSIM_SetAnalogInOversampleBits(m_index, oversampleBits);
|
||||
}
|
||||
void SetOversampleBits(int oversampleBits);
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterVoltageCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelAnalogInVoltageCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogInVoltageCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
NotifyCallback callback, bool initialNotify);
|
||||
|
||||
double GetVoltage() const { return HALSIM_GetAnalogInVoltage(m_index); }
|
||||
double GetVoltage() const;
|
||||
|
||||
void SetVoltage(double voltage) {
|
||||
HALSIM_SetAnalogInVoltage(m_index, voltage);
|
||||
}
|
||||
void SetVoltage(double voltage);
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterAccumulatorInitializedCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback,
|
||||
&HALSIM_CancelAnalogInAccumulatorInitializedCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogInAccumulatorInitializedCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
NotifyCallback callback, bool initialNotify);
|
||||
|
||||
bool GetAccumulatorInitialized() const {
|
||||
return HALSIM_GetAnalogInAccumulatorInitialized(m_index);
|
||||
}
|
||||
bool GetAccumulatorInitialized() const;
|
||||
|
||||
void SetAccumulatorInitialized(bool accumulatorInitialized) {
|
||||
HALSIM_SetAnalogInAccumulatorInitialized(m_index, accumulatorInitialized);
|
||||
}
|
||||
void SetAccumulatorInitialized(bool accumulatorInitialized);
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterAccumulatorValueCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelAnalogInAccumulatorValueCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogInAccumulatorValueCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
NotifyCallback callback, bool initialNotify);
|
||||
|
||||
int64_t GetAccumulatorValue() const {
|
||||
return HALSIM_GetAnalogInAccumulatorValue(m_index);
|
||||
}
|
||||
int64_t GetAccumulatorValue() const;
|
||||
|
||||
void SetAccumulatorValue(int64_t accumulatorValue) {
|
||||
HALSIM_SetAnalogInAccumulatorValue(m_index, accumulatorValue);
|
||||
}
|
||||
void SetAccumulatorValue(int64_t accumulatorValue);
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterAccumulatorCountCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelAnalogInAccumulatorCountCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogInAccumulatorCountCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
NotifyCallback callback, bool initialNotify);
|
||||
|
||||
int64_t GetAccumulatorCount() const {
|
||||
return HALSIM_GetAnalogInAccumulatorCount(m_index);
|
||||
}
|
||||
int64_t GetAccumulatorCount() const;
|
||||
|
||||
void SetAccumulatorCount(int64_t accumulatorCount) {
|
||||
HALSIM_SetAnalogInAccumulatorCount(m_index, accumulatorCount);
|
||||
}
|
||||
void SetAccumulatorCount(int64_t accumulatorCount);
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterAccumulatorCenterCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelAnalogInAccumulatorCenterCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogInAccumulatorCenterCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
NotifyCallback callback, bool initialNotify);
|
||||
|
||||
int GetAccumulatorCenter() const {
|
||||
return HALSIM_GetAnalogInAccumulatorCenter(m_index);
|
||||
}
|
||||
int GetAccumulatorCenter() const;
|
||||
|
||||
void SetAccumulatorCenter(int accumulatorCenter) {
|
||||
HALSIM_SetAnalogInAccumulatorCenter(m_index, accumulatorCenter);
|
||||
}
|
||||
void SetAccumulatorCenter(int accumulatorCenter);
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterAccumulatorDeadbandCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback,
|
||||
&HALSIM_CancelAnalogInAccumulatorDeadbandCallback);
|
||||
store->SetUid(HALSIM_RegisterAnalogInAccumulatorDeadbandCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
NotifyCallback callback, bool initialNotify);
|
||||
|
||||
int GetAccumulatorDeadband() const {
|
||||
return HALSIM_GetAnalogInAccumulatorDeadband(m_index);
|
||||
}
|
||||
int GetAccumulatorDeadband() const;
|
||||
|
||||
void SetAccumulatorDeadband(int accumulatorDeadband) {
|
||||
HALSIM_SetAnalogInAccumulatorDeadband(m_index, accumulatorDeadband);
|
||||
}
|
||||
void SetAccumulatorDeadband(int accumulatorDeadband);
|
||||
|
||||
void ResetData() { HALSIM_ResetAnalogInData(m_index); }
|
||||
void ResetData();
|
||||
|
||||
private:
|
||||
int m_index;
|
||||
|
||||
Reference in New Issue
Block a user