WPILibC++  2018.4.1-20180729184725-1146-g6db5f80
 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  bool GetActive() { return HALSIM_GetSPIAccelerometerActive(m_index); }
33  void SetActive(bool active) {
34  HALSIM_SetSPIAccelerometerActive(m_index, active);
35  }
36 
37  std::unique_ptr<CallbackStore> RegisterRangeCallback(NotifyCallback callback,
38  bool initialNotify) {
39  auto store = std::make_unique<CallbackStore>(
40  m_index, -1, callback, &HALSIM_CancelSPIAccelerometerRangeCallback);
41  store->SetUid(HALSIM_RegisterSPIAccelerometerRangeCallback(
42  m_index, &CallbackStoreThunk, store.get(), initialNotify));
43  return store;
44  }
45  int GetRange() { return HALSIM_GetSPIAccelerometerRange(m_index); }
46  void SetRange(int range) { HALSIM_SetSPIAccelerometerRange(m_index, range); }
47 
48  std::unique_ptr<CallbackStore> RegisterXCallback(NotifyCallback callback,
49  bool initialNotify) {
50  auto store = std::make_unique<CallbackStore>(
51  m_index, -1, callback, &HALSIM_CancelSPIAccelerometerXCallback);
52  store->SetUid(HALSIM_RegisterSPIAccelerometerXCallback(
53  m_index, &CallbackStoreThunk, store.get(), initialNotify));
54  return store;
55  }
56  double GetX() { return HALSIM_GetSPIAccelerometerX(m_index); }
57  void SetX(double x) { HALSIM_SetSPIAccelerometerX(m_index, x); }
58 
59  std::unique_ptr<CallbackStore> RegisterYCallback(NotifyCallback callback,
60  bool initialNotify) {
61  auto store = std::make_unique<CallbackStore>(
62  m_index, -1, callback, &HALSIM_CancelSPIAccelerometerYCallback);
63  store->SetUid(HALSIM_RegisterSPIAccelerometerYCallback(
64  m_index, &CallbackStoreThunk, store.get(), initialNotify));
65  return store;
66  }
67  double GetY() { return HALSIM_GetSPIAccelerometerY(m_index); }
68  void SetY(double y) { HALSIM_SetSPIAccelerometerY(m_index, y); }
69 
70  std::unique_ptr<CallbackStore> RegisterZCallback(NotifyCallback callback,
71  bool initialNotify) {
72  auto store = std::make_unique<CallbackStore>(
73  m_index, -1, callback, &HALSIM_CancelSPIAccelerometerZCallback);
74  store->SetUid(HALSIM_RegisterSPIAccelerometerZCallback(
75  m_index, &CallbackStoreThunk, store.get(), initialNotify));
76  return store;
77  }
78  double GetZ() { return HALSIM_GetSPIAccelerometerZ(m_index); }
79  void SetZ(double z) { HALSIM_SetSPIAccelerometerZ(m_index, z); }
80 
81  void ResetData() { HALSIM_ResetSPIAccelerometerData(m_index); }
82 
83  private:
84  int m_index;
85 };
86 } // namespace sim
87 } // namespace frc
88 #endif // __FRC_ROBORIO__
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
Definition: SPIAccelerometerSim.h:20