13 #include "CallbackStore.h"
14 #include "mockdata/EncoderData.h"
20 explicit EncoderSim(
int index) { m_index = index; }
22 std::unique_ptr<CallbackStore> RegisterInitializedCallback(
23 NotifyCallback callback,
bool initialNotify) {
24 auto store = std::make_unique<CallbackStore>(
25 m_index, -1, callback, &HALSIM_CancelEncoderInitializedCallback);
26 store->SetUid(HALSIM_RegisterEncoderInitializedCallback(
27 m_index, &CallbackStoreThunk, store.get(), initialNotify));
31 bool GetInitialized()
const {
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));
46 int GetCount()
const {
return HALSIM_GetEncoderCount(m_index); }
48 void SetCount(
int count) { HALSIM_SetEncoderCount(m_index, count); }
50 std::unique_ptr<CallbackStore> RegisterPeriodCallback(NotifyCallback callback,
52 auto store = std::make_unique<CallbackStore>(
53 m_index, -1, callback, &HALSIM_CancelEncoderPeriodCallback);
54 store->SetUid(HALSIM_RegisterEncoderPeriodCallback(
55 m_index, &CallbackStoreThunk, store.get(), initialNotify));
59 double GetPeriod()
const {
return HALSIM_GetEncoderPeriod(m_index); }
61 void SetPeriod(
double period) { HALSIM_SetEncoderPeriod(m_index, period); }
63 std::unique_ptr<CallbackStore> RegisterResetCallback(NotifyCallback callback,
65 auto store = std::make_unique<CallbackStore>(
66 m_index, -1, callback, &HALSIM_CancelEncoderResetCallback);
67 store->SetUid(HALSIM_RegisterEncoderResetCallback(
68 m_index, &CallbackStoreThunk, store.get(), initialNotify));
72 bool GetReset()
const {
return HALSIM_GetEncoderReset(m_index); }
74 void SetReset(
bool reset) { HALSIM_SetEncoderReset(m_index, reset); }
76 std::unique_ptr<CallbackStore> RegisterMaxPeriodCallback(
77 NotifyCallback callback,
bool initialNotify) {
78 auto store = std::make_unique<CallbackStore>(
79 m_index, -1, callback, &HALSIM_CancelEncoderMaxPeriodCallback);
80 store->SetUid(HALSIM_RegisterEncoderMaxPeriodCallback(
81 m_index, &CallbackStoreThunk, store.get(), initialNotify));
85 double GetMaxPeriod()
const {
return HALSIM_GetEncoderMaxPeriod(m_index); }
87 void SetMaxPeriod(
double maxPeriod) {
88 HALSIM_SetEncoderMaxPeriod(m_index, maxPeriod);
91 std::unique_ptr<CallbackStore> RegisterDirectionCallback(
92 NotifyCallback callback,
bool initialNotify) {
93 auto store = std::make_unique<CallbackStore>(
94 m_index, -1, callback, &HALSIM_CancelEncoderDirectionCallback);
95 store->SetUid(HALSIM_RegisterEncoderDirectionCallback(
96 m_index, &CallbackStoreThunk, store.get(), initialNotify));
100 bool GetDirection()
const {
return HALSIM_GetEncoderDirection(m_index); }
102 void SetDirection(
bool direction) {
103 HALSIM_SetEncoderDirection(m_index, direction);
106 std::unique_ptr<CallbackStore> RegisterReverseDirectionCallback(
107 NotifyCallback callback,
bool initialNotify) {
108 auto store = std::make_unique<CallbackStore>(
109 m_index, -1, callback, &HALSIM_CancelEncoderReverseDirectionCallback);
110 store->SetUid(HALSIM_RegisterEncoderReverseDirectionCallback(
111 m_index, &CallbackStoreThunk, store.get(), initialNotify));
115 bool GetReverseDirection()
const {
116 return HALSIM_GetEncoderReverseDirection(m_index);
119 void SetReverseDirection(
bool reverseDirection) {
120 HALSIM_SetEncoderReverseDirection(m_index, reverseDirection);
123 std::unique_ptr<CallbackStore> RegisterSamplesToAverageCallback(
124 NotifyCallback callback,
bool initialNotify) {
125 auto store = std::make_unique<CallbackStore>(
126 m_index, -1, callback, &HALSIM_CancelEncoderSamplesToAverageCallback);
127 store->SetUid(HALSIM_RegisterEncoderSamplesToAverageCallback(
128 m_index, &CallbackStoreThunk, store.get(), initialNotify));
132 int GetSamplesToAverage()
const {
133 return HALSIM_GetEncoderSamplesToAverage(m_index);
136 void SetSamplesToAverage(
int samplesToAverage) {
137 HALSIM_SetEncoderSamplesToAverage(m_index, samplesToAverage);
140 std::unique_ptr<CallbackStore> RegisterDistancePerPulseCallback(
141 NotifyCallback callback,
bool initialNotify) {
142 auto store = std::make_unique<CallbackStore>(
143 m_index, -1, callback, &HALSIM_CancelEncoderDistancePerPulseCallback);
144 store->SetUid(HALSIM_RegisterEncoderDistancePerPulseCallback(
145 m_index, &CallbackStoreThunk, store.get(), initialNotify));
149 double GetDistancePerPulse()
const {
150 return HALSIM_GetEncoderDistancePerPulse(m_index);
153 void SetDistancePerPulse(
double distancePerPulse) {
154 HALSIM_SetEncoderDistancePerPulse(m_index, distancePerPulse);
157 void ResetData() { HALSIM_ResetEncoderData(m_index); }