10 #ifndef __FRC_ROBORIO__
15 #include "CallbackStore.h"
16 #include "mockdata/EncoderData.h"
22 explicit EncoderSim(
int index) { m_index = index; }
24 std::unique_ptr<CallbackStore> RegisterInitializedCallback(
25 NotifyCallback callback,
bool initialNotify) {
26 auto store = std::make_unique<CallbackStore>(
27 m_index, -1, callback, &HALSIM_CancelEncoderInitializedCallback);
28 store->SetUid(HALSIM_RegisterEncoderInitializedCallback(
29 m_index, &CallbackStoreThunk, store.get(), initialNotify));
33 bool GetInitialized()
const {
return HALSIM_GetEncoderInitialized(m_index); }
35 void SetInitialized(
bool initialized) {
36 HALSIM_SetEncoderInitialized(m_index, initialized);
39 std::unique_ptr<CallbackStore> RegisterCountCallback(NotifyCallback callback,
41 auto store = std::make_unique<CallbackStore>(
42 m_index, -1, callback, &HALSIM_CancelEncoderCountCallback);
43 store->SetUid(HALSIM_RegisterEncoderCountCallback(
44 m_index, &CallbackStoreThunk, store.get(), initialNotify));
48 int GetCount()
const {
return HALSIM_GetEncoderCount(m_index); }
50 void SetCount(
int count) { HALSIM_SetEncoderCount(m_index, count); }
52 std::unique_ptr<CallbackStore> RegisterPeriodCallback(NotifyCallback callback,
54 auto store = std::make_unique<CallbackStore>(
55 m_index, -1, callback, &HALSIM_CancelEncoderPeriodCallback);
56 store->SetUid(HALSIM_RegisterEncoderPeriodCallback(
57 m_index, &CallbackStoreThunk, store.get(), initialNotify));
61 double GetPeriod()
const {
return HALSIM_GetEncoderPeriod(m_index); }
63 void SetPeriod(
double period) { HALSIM_SetEncoderPeriod(m_index, period); }
65 std::unique_ptr<CallbackStore> RegisterResetCallback(NotifyCallback callback,
67 auto store = std::make_unique<CallbackStore>(
68 m_index, -1, callback, &HALSIM_CancelEncoderResetCallback);
69 store->SetUid(HALSIM_RegisterEncoderResetCallback(
70 m_index, &CallbackStoreThunk, store.get(), initialNotify));
74 bool GetReset()
const {
return HALSIM_GetEncoderReset(m_index); }
76 void SetReset(
bool reset) { HALSIM_SetEncoderReset(m_index, reset); }
78 std::unique_ptr<CallbackStore> RegisterMaxPeriodCallback(
79 NotifyCallback callback,
bool initialNotify) {
80 auto store = std::make_unique<CallbackStore>(
81 m_index, -1, callback, &HALSIM_CancelEncoderMaxPeriodCallback);
82 store->SetUid(HALSIM_RegisterEncoderMaxPeriodCallback(
83 m_index, &CallbackStoreThunk, store.get(), initialNotify));
87 double GetMaxPeriod()
const {
return HALSIM_GetEncoderMaxPeriod(m_index); }
89 void SetMaxPeriod(
double maxPeriod) {
90 HALSIM_SetEncoderMaxPeriod(m_index, maxPeriod);
93 std::unique_ptr<CallbackStore> RegisterDirectionCallback(
94 NotifyCallback callback,
bool initialNotify) {
95 auto store = std::make_unique<CallbackStore>(
96 m_index, -1, callback, &HALSIM_CancelEncoderDirectionCallback);
97 store->SetUid(HALSIM_RegisterEncoderDirectionCallback(
98 m_index, &CallbackStoreThunk, store.get(), initialNotify));
102 bool GetDirection()
const {
return HALSIM_GetEncoderDirection(m_index); }
104 void SetDirection(
bool direction) {
105 HALSIM_SetEncoderDirection(m_index, direction);
108 std::unique_ptr<CallbackStore> RegisterReverseDirectionCallback(
109 NotifyCallback callback,
bool initialNotify) {
110 auto store = std::make_unique<CallbackStore>(
111 m_index, -1, callback, &HALSIM_CancelEncoderReverseDirectionCallback);
112 store->SetUid(HALSIM_RegisterEncoderReverseDirectionCallback(
113 m_index, &CallbackStoreThunk, store.get(), initialNotify));
117 bool GetReverseDirection()
const {
118 return HALSIM_GetEncoderReverseDirection(m_index);
121 void SetReverseDirection(
bool reverseDirection) {
122 HALSIM_SetEncoderReverseDirection(m_index, reverseDirection);
125 std::unique_ptr<CallbackStore> RegisterSamplesToAverageCallback(
126 NotifyCallback callback,
bool initialNotify) {
127 auto store = std::make_unique<CallbackStore>(
128 m_index, -1, callback, &HALSIM_CancelEncoderSamplesToAverageCallback);
129 store->SetUid(HALSIM_RegisterEncoderSamplesToAverageCallback(
130 m_index, &CallbackStoreThunk, store.get(), initialNotify));
134 int GetSamplesToAverage()
const {
135 return HALSIM_GetEncoderSamplesToAverage(m_index);
138 void SetSamplesToAverage(
int samplesToAverage) {
139 HALSIM_SetEncoderSamplesToAverage(m_index, samplesToAverage);
142 std::unique_ptr<CallbackStore> RegisterDistancePerPulseCallback(
143 NotifyCallback callback,
bool initialNotify) {
144 auto store = std::make_unique<CallbackStore>(
145 m_index, -1, callback, &HALSIM_CancelEncoderDistancePerPulseCallback);
146 store->SetUid(HALSIM_RegisterEncoderDistancePerPulseCallback(
147 m_index, &CallbackStoreThunk, store.get(), initialNotify));
151 double GetDistancePerPulse()
const {
152 return HALSIM_GetEncoderDistancePerPulse(m_index);
155 void SetDistancePerPulse(
double distancePerPulse) {
156 HALSIM_SetEncoderDistancePerPulse(m_index, distancePerPulse);
159 void ResetData() { HALSIM_ResetEncoderData(m_index); }
166 #endif // __FRC_ROBORIO__
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
Definition: EncoderSim.h:20