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));
32 bool GetInitialized() {
return HALSIM_GetEncoderInitialized(m_index); }
33 void SetInitialized(
bool initialized) {
34 HALSIM_SetEncoderInitialized(m_index, initialized);
37 std::unique_ptr<CallbackStore> RegisterCountCallback(NotifyCallback callback,
39 auto store = std::make_unique<CallbackStore>(
40 m_index, -1, callback, &HALSIM_CancelEncoderCountCallback);
41 store->SetUid(HALSIM_RegisterEncoderCountCallback(
42 m_index, &CallbackStoreThunk, store.get(), initialNotify));
45 int GetCount() {
return HALSIM_GetEncoderCount(m_index); }
46 void SetCount(
int count) { HALSIM_SetEncoderCount(m_index, count); }
48 std::unique_ptr<CallbackStore> RegisterPeriodCallback(NotifyCallback callback,
50 auto store = std::make_unique<CallbackStore>(
51 m_index, -1, callback, &HALSIM_CancelEncoderPeriodCallback);
52 store->SetUid(HALSIM_RegisterEncoderPeriodCallback(
53 m_index, &CallbackStoreThunk, store.get(), initialNotify));
56 double GetPeriod() {
return HALSIM_GetEncoderPeriod(m_index); }
57 void SetPeriod(
double period) { HALSIM_SetEncoderPeriod(m_index, period); }
59 std::unique_ptr<CallbackStore> RegisterResetCallback(NotifyCallback callback,
61 auto store = std::make_unique<CallbackStore>(
62 m_index, -1, callback, &HALSIM_CancelEncoderResetCallback);
63 store->SetUid(HALSIM_RegisterEncoderResetCallback(
64 m_index, &CallbackStoreThunk, store.get(), initialNotify));
67 bool GetReset() {
return HALSIM_GetEncoderReset(m_index); }
68 void SetReset(
bool reset) { HALSIM_SetEncoderReset(m_index, reset); }
70 std::unique_ptr<CallbackStore> RegisterMaxPeriodCallback(
71 NotifyCallback callback,
bool initialNotify) {
72 auto store = std::make_unique<CallbackStore>(
73 m_index, -1, callback, &HALSIM_CancelEncoderMaxPeriodCallback);
74 store->SetUid(HALSIM_RegisterEncoderMaxPeriodCallback(
75 m_index, &CallbackStoreThunk, store.get(), initialNotify));
78 double GetMaxPeriod() {
return HALSIM_GetEncoderMaxPeriod(m_index); }
79 void SetMaxPeriod(
double maxPeriod) {
80 HALSIM_SetEncoderMaxPeriod(m_index, maxPeriod);
83 std::unique_ptr<CallbackStore> RegisterDirectionCallback(
84 NotifyCallback callback,
bool initialNotify) {
85 auto store = std::make_unique<CallbackStore>(
86 m_index, -1, callback, &HALSIM_CancelEncoderDirectionCallback);
87 store->SetUid(HALSIM_RegisterEncoderDirectionCallback(
88 m_index, &CallbackStoreThunk, store.get(), initialNotify));
91 bool GetDirection() {
return HALSIM_GetEncoderDirection(m_index); }
92 void SetDirection(
bool direction) {
93 HALSIM_SetEncoderDirection(m_index, direction);
96 std::unique_ptr<CallbackStore> RegisterReverseDirectionCallback(
97 NotifyCallback callback,
bool initialNotify) {
98 auto store = std::make_unique<CallbackStore>(
99 m_index, -1, callback, &HALSIM_CancelEncoderReverseDirectionCallback);
100 store->SetUid(HALSIM_RegisterEncoderReverseDirectionCallback(
101 m_index, &CallbackStoreThunk, store.get(), initialNotify));
104 bool GetReverseDirection() {
105 return HALSIM_GetEncoderReverseDirection(m_index);
107 void SetReverseDirection(
bool reverseDirection) {
108 HALSIM_SetEncoderReverseDirection(m_index, reverseDirection);
111 std::unique_ptr<CallbackStore> RegisterSamplesToAverageCallback(
112 NotifyCallback callback,
bool initialNotify) {
113 auto store = std::make_unique<CallbackStore>(
114 m_index, -1, callback, &HALSIM_CancelEncoderSamplesToAverageCallback);
115 store->SetUid(HALSIM_RegisterEncoderSamplesToAverageCallback(
116 m_index, &CallbackStoreThunk, store.get(), initialNotify));
119 int GetSamplesToAverage() {
120 return HALSIM_GetEncoderSamplesToAverage(m_index);
122 void SetSamplesToAverage(
int samplesToAverage) {
123 HALSIM_SetEncoderSamplesToAverage(m_index, samplesToAverage);
126 std::unique_ptr<CallbackStore> RegisterDistancePerPulseCallback(
127 NotifyCallback callback,
bool initialNotify) {
128 auto store = std::make_unique<CallbackStore>(
129 m_index, -1, callback, &HALSIM_CancelEncoderDistancePerPulseCallback);
130 store->SetUid(HALSIM_RegisterEncoderDistancePerPulseCallback(
131 m_index, &CallbackStoreThunk, store.get(), initialNotify));
134 double GetDistancePerPulse() {
135 return HALSIM_GetEncoderDistancePerPulse(m_index);
137 void SetDistancePerPulse(
double distancePerPulse) {
138 HALSIM_SetEncoderDistancePerPulse(m_index, distancePerPulse);
141 void ResetData() { HALSIM_ResetEncoderData(m_index); }
148 #endif // __FRC_ROBORIO__
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
Definition: EncoderSim.h:20