WPILibC++  2018.4.1-20180816013227-1153-g1462a5b
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
SPIAccelerometerSim.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2018 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #ifndef __FRC_ROBORIO__
11 
12 #include <memory>
13 #include <utility>
14 
15 #include "CallbackStore.h"
16 #include "mockdata/SPIAccelerometerData.h"
17 
18 namespace frc {
19 namespace sim {
21  public:
22  explicit SPIAccelerometerSim(int index) { m_index = index; }
23 
24  std::unique_ptr<CallbackStore> RegisterActiveCallback(NotifyCallback callback,
25  bool initialNotify) {
26  auto store = std::make_unique<CallbackStore>(
27  m_index, -1, callback, &HALSIM_CancelSPIAccelerometerActiveCallback);
28  store->SetUid(HALSIM_RegisterSPIAccelerometerActiveCallback(
29  m_index, &CallbackStoreThunk, store.get(), initialNotify));
30  return store;
31  }
32 
33  bool GetActive() const { return HALSIM_GetSPIAccelerometerActive(m_index); }
34 
35  void SetActive(bool active) {
36  HALSIM_SetSPIAccelerometerActive(m_index, active);
37  }
38 
39  std::unique_ptr<CallbackStore> RegisterRangeCallback(NotifyCallback callback,
40  bool initialNotify) {
41  auto store = std::make_unique<CallbackStore>(
42  m_index, -1, callback, &HALSIM_CancelSPIAccelerometerRangeCallback);
43  store->SetUid(HALSIM_RegisterSPIAccelerometerRangeCallback(
44  m_index, &CallbackStoreThunk, store.get(), initialNotify));
45  return store;
46  }
47 
48  int GetRange() const { return HALSIM_GetSPIAccelerometerRange(m_index); }
49 
50  void SetRange(int range) { HALSIM_SetSPIAccelerometerRange(m_index, range); }
51 
52  std::unique_ptr<CallbackStore> RegisterXCallback(NotifyCallback callback,
53  bool initialNotify) {
54  auto store = std::make_unique<CallbackStore>(
55  m_index, -1, callback, &HALSIM_CancelSPIAccelerometerXCallback);
56  store->SetUid(HALSIM_RegisterSPIAccelerometerXCallback(
57  m_index, &CallbackStoreThunk, store.get(), initialNotify));
58  return store;
59  }
60 
61  double GetX() const { return HALSIM_GetSPIAccelerometerX(m_index); }
62 
63  void SetX(double x) { HALSIM_SetSPIAccelerometerX(m_index, x); }
64 
65  std::unique_ptr<CallbackStore> RegisterYCallback(NotifyCallback callback,
66  bool initialNotify) {
67  auto store = std::make_unique<CallbackStore>(
68  m_index, -1, callback, &HALSIM_CancelSPIAccelerometerYCallback);
69  store->SetUid(HALSIM_RegisterSPIAccelerometerYCallback(
70  m_index, &CallbackStoreThunk, store.get(), initialNotify));
71  return store;
72  }
73 
74  double GetY() const { return HALSIM_GetSPIAccelerometerY(m_index); }
75 
76  void SetY(double y) { HALSIM_SetSPIAccelerometerY(m_index, y); }
77 
78  std::unique_ptr<CallbackStore> RegisterZCallback(NotifyCallback callback,
79  bool initialNotify) {
80  auto store = std::make_unique<CallbackStore>(
81  m_index, -1, callback, &HALSIM_CancelSPIAccelerometerZCallback);
82  store->SetUid(HALSIM_RegisterSPIAccelerometerZCallback(
83  m_index, &CallbackStoreThunk, store.get(), initialNotify));
84  return store;
85  }
86 
87  double GetZ() const { return HALSIM_GetSPIAccelerometerZ(m_index); }
88 
89  void SetZ(double z) { HALSIM_SetSPIAccelerometerZ(m_index, z); }
90 
91  void ResetData() { HALSIM_ResetSPIAccelerometerData(m_index); }
92 
93  private:
94  int m_index;
95 };
96 } // namespace sim
97 } // namespace frc
98 #endif // __FRC_ROBORIO__
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
Definition: SPIAccelerometerSim.h:20