13 #include "CallbackStore.h"
14 #include "mockdata/PWMData.h"
20 explicit PWMSim(
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_CancelPWMInitializedCallback);
26 store->SetUid(HALSIM_RegisterPWMInitializedCallback(
27 m_index, &CallbackStoreThunk, store.get(), initialNotify));
31 bool GetInitialized()
const {
return HALSIM_GetPWMInitialized(m_index); }
33 void SetInitialized(
bool initialized) {
34 HALSIM_SetPWMInitialized(m_index, initialized);
37 std::unique_ptr<CallbackStore> RegisterRawValueCallback(
38 NotifyCallback callback,
bool initialNotify) {
39 auto store = std::make_unique<CallbackStore>(
40 m_index, -1, callback, &HALSIM_CancelPWMRawValueCallback);
41 store->SetUid(HALSIM_RegisterPWMRawValueCallback(
42 m_index, &CallbackStoreThunk, store.get(), initialNotify));
46 int GetRawValue()
const {
return HALSIM_GetPWMRawValue(m_index); }
48 void SetRawValue(
int rawValue) { HALSIM_SetPWMRawValue(m_index, rawValue); }
50 std::unique_ptr<CallbackStore> RegisterSpeedCallback(NotifyCallback callback,
52 auto store = std::make_unique<CallbackStore>(
53 m_index, -1, callback, &HALSIM_CancelPWMSpeedCallback);
54 store->SetUid(HALSIM_RegisterPWMSpeedCallback(m_index, &CallbackStoreThunk,
55 store.get(), initialNotify));
59 double GetSpeed()
const {
return HALSIM_GetPWMSpeed(m_index); }
61 void SetSpeed(
double speed) { HALSIM_SetPWMSpeed(m_index, speed); }
63 std::unique_ptr<CallbackStore> RegisterPositionCallback(
64 NotifyCallback callback,
bool initialNotify) {
65 auto store = std::make_unique<CallbackStore>(
66 m_index, -1, callback, &HALSIM_CancelPWMPositionCallback);
67 store->SetUid(HALSIM_RegisterPWMPositionCallback(
68 m_index, &CallbackStoreThunk, store.get(), initialNotify));
72 double GetPosition()
const {
return HALSIM_GetPWMPosition(m_index); }
74 void SetPosition(
double position) {
75 HALSIM_SetPWMPosition(m_index, position);
78 std::unique_ptr<CallbackStore> RegisterPeriodScaleCallback(
79 NotifyCallback callback,
bool initialNotify) {
80 auto store = std::make_unique<CallbackStore>(
81 m_index, -1, callback, &HALSIM_CancelPWMPeriodScaleCallback);
82 store->SetUid(HALSIM_RegisterPWMPeriodScaleCallback(
83 m_index, &CallbackStoreThunk, store.get(), initialNotify));
87 int GetPeriodScale()
const {
return HALSIM_GetPWMPeriodScale(m_index); }
89 void SetPeriodScale(
int periodScale) {
90 HALSIM_SetPWMPeriodScale(m_index, periodScale);
93 std::unique_ptr<CallbackStore> RegisterZeroLatchCallback(
94 NotifyCallback callback,
bool initialNotify) {
95 auto store = std::make_unique<CallbackStore>(
96 m_index, -1, callback, &HALSIM_CancelPWMZeroLatchCallback);
97 store->SetUid(HALSIM_RegisterPWMZeroLatchCallback(
98 m_index, &CallbackStoreThunk, store.get(), initialNotify));
102 bool GetZeroLatch()
const {
return HALSIM_GetPWMZeroLatch(m_index); }
104 void SetZeroLatch(
bool zeroLatch) {
105 HALSIM_SetPWMZeroLatch(m_index, zeroLatch);
108 void ResetData() { HALSIM_ResetPWMData(m_index); }