WPILibC++  2020.3.2
RoboRioSim.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2018-2019 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 #include <memory>
11 #include <utility>
12 
13 #include "CallbackStore.h"
14 #include "mockdata/RoboRioData.h"
15 
16 namespace frc {
17 namespace sim {
18 class RoboRioSim {
19  public:
20  explicit RoboRioSim(int index) { m_index = index; }
21 
22  std::unique_ptr<CallbackStore> RegisterFPGAButtonCallback(
23  NotifyCallback callback, bool initialNotify) {
24  auto store = std::make_unique<CallbackStore>(
25  m_index, -1, callback, &HALSIM_CancelRoboRioFPGAButtonCallback);
26  store->SetUid(HALSIM_RegisterRoboRioFPGAButtonCallback(
27  m_index, &CallbackStoreThunk, store.get(), initialNotify));
28  return store;
29  }
30 
31  bool GetFPGAButton() const { return HALSIM_GetRoboRioFPGAButton(m_index); }
32 
33  void SetFPGAButton(bool fPGAButton) {
34  HALSIM_SetRoboRioFPGAButton(m_index, fPGAButton);
35  }
36 
37  std::unique_ptr<CallbackStore> RegisterVInVoltageCallback(
38  NotifyCallback callback, bool initialNotify) {
39  auto store = std::make_unique<CallbackStore>(
40  m_index, -1, callback, &HALSIM_CancelRoboRioVInVoltageCallback);
41  store->SetUid(HALSIM_RegisterRoboRioVInVoltageCallback(
42  m_index, &CallbackStoreThunk, store.get(), initialNotify));
43  return store;
44  }
45 
46  double GetVInVoltage() const { return HALSIM_GetRoboRioVInVoltage(m_index); }
47 
48  void SetVInVoltage(double vInVoltage) {
49  HALSIM_SetRoboRioVInVoltage(m_index, vInVoltage);
50  }
51 
52  std::unique_ptr<CallbackStore> RegisterVInCurrentCallback(
53  NotifyCallback callback, bool initialNotify) {
54  auto store = std::make_unique<CallbackStore>(
55  m_index, -1, callback, &HALSIM_CancelRoboRioVInCurrentCallback);
56  store->SetUid(HALSIM_RegisterRoboRioVInCurrentCallback(
57  m_index, &CallbackStoreThunk, store.get(), initialNotify));
58  return store;
59  }
60 
61  double GetVInCurrent() const { return HALSIM_GetRoboRioVInCurrent(m_index); }
62 
63  void SetVInCurrent(double vInCurrent) {
64  HALSIM_SetRoboRioVInCurrent(m_index, vInCurrent);
65  }
66 
67  std::unique_ptr<CallbackStore> RegisterUserVoltage6VCallback(
68  NotifyCallback callback, bool initialNotify) {
69  auto store = std::make_unique<CallbackStore>(
70  m_index, -1, callback, &HALSIM_CancelRoboRioUserVoltage6VCallback);
71  store->SetUid(HALSIM_RegisterRoboRioUserVoltage6VCallback(
72  m_index, &CallbackStoreThunk, store.get(), initialNotify));
73  return store;
74  }
75 
76  double GetUserVoltage6V() const {
77  return HALSIM_GetRoboRioUserVoltage6V(m_index);
78  }
79 
80  void SetUserVoltage6V(double userVoltage6V) {
81  HALSIM_SetRoboRioUserVoltage6V(m_index, userVoltage6V);
82  }
83 
84  std::unique_ptr<CallbackStore> RegisterUserCurrent6VCallback(
85  NotifyCallback callback, bool initialNotify) {
86  auto store = std::make_unique<CallbackStore>(
87  m_index, -1, callback, &HALSIM_CancelRoboRioUserCurrent6VCallback);
88  store->SetUid(HALSIM_RegisterRoboRioUserCurrent6VCallback(
89  m_index, &CallbackStoreThunk, store.get(), initialNotify));
90  return store;
91  }
92 
93  double GetUserCurrent6V() const {
94  return HALSIM_GetRoboRioUserCurrent6V(m_index);
95  }
96 
97  void SetUserCurrent6V(double userCurrent6V) {
98  HALSIM_SetRoboRioUserCurrent6V(m_index, userCurrent6V);
99  }
100 
101  std::unique_ptr<CallbackStore> RegisterUserActive6VCallback(
102  NotifyCallback callback, bool initialNotify) {
103  auto store = std::make_unique<CallbackStore>(
104  m_index, -1, callback, &HALSIM_CancelRoboRioUserActive6VCallback);
105  store->SetUid(HALSIM_RegisterRoboRioUserActive6VCallback(
106  m_index, &CallbackStoreThunk, store.get(), initialNotify));
107  return store;
108  }
109 
110  bool GetUserActive6V() const {
111  return HALSIM_GetRoboRioUserActive6V(m_index);
112  }
113 
114  void SetUserActive6V(bool userActive6V) {
115  HALSIM_SetRoboRioUserActive6V(m_index, userActive6V);
116  }
117 
118  std::unique_ptr<CallbackStore> RegisterUserVoltage5VCallback(
119  NotifyCallback callback, bool initialNotify) {
120  auto store = std::make_unique<CallbackStore>(
121  m_index, -1, callback, &HALSIM_CancelRoboRioUserVoltage5VCallback);
122  store->SetUid(HALSIM_RegisterRoboRioUserVoltage5VCallback(
123  m_index, &CallbackStoreThunk, store.get(), initialNotify));
124  return store;
125  }
126 
127  double GetUserVoltage5V() const {
128  return HALSIM_GetRoboRioUserVoltage5V(m_index);
129  }
130 
131  void SetUserVoltage5V(double userVoltage5V) {
132  HALSIM_SetRoboRioUserVoltage5V(m_index, userVoltage5V);
133  }
134 
135  std::unique_ptr<CallbackStore> RegisterUserCurrent5VCallback(
136  NotifyCallback callback, bool initialNotify) {
137  auto store = std::make_unique<CallbackStore>(
138  m_index, -1, callback, &HALSIM_CancelRoboRioUserCurrent5VCallback);
139  store->SetUid(HALSIM_RegisterRoboRioUserCurrent5VCallback(
140  m_index, &CallbackStoreThunk, store.get(), initialNotify));
141  return store;
142  }
143 
144  double GetUserCurrent5V() const {
145  return HALSIM_GetRoboRioUserCurrent5V(m_index);
146  }
147 
148  void SetUserCurrent5V(double userCurrent5V) {
149  HALSIM_SetRoboRioUserCurrent5V(m_index, userCurrent5V);
150  }
151 
152  std::unique_ptr<CallbackStore> RegisterUserActive5VCallback(
153  NotifyCallback callback, bool initialNotify) {
154  auto store = std::make_unique<CallbackStore>(
155  m_index, -1, callback, &HALSIM_CancelRoboRioUserActive5VCallback);
156  store->SetUid(HALSIM_RegisterRoboRioUserActive5VCallback(
157  m_index, &CallbackStoreThunk, store.get(), initialNotify));
158  return store;
159  }
160 
161  bool GetUserActive5V() const {
162  return HALSIM_GetRoboRioUserActive5V(m_index);
163  }
164 
165  void SetUserActive5V(bool userActive5V) {
166  HALSIM_SetRoboRioUserActive5V(m_index, userActive5V);
167  }
168 
169  std::unique_ptr<CallbackStore> RegisterUserVoltage3V3Callback(
170  NotifyCallback callback, bool initialNotify) {
171  auto store = std::make_unique<CallbackStore>(
172  m_index, -1, callback, &HALSIM_CancelRoboRioUserVoltage3V3Callback);
173  store->SetUid(HALSIM_RegisterRoboRioUserVoltage3V3Callback(
174  m_index, &CallbackStoreThunk, store.get(), initialNotify));
175  return store;
176  }
177 
178  double GetUserVoltage3V3() const {
179  return HALSIM_GetRoboRioUserVoltage3V3(m_index);
180  }
181 
182  void SetUserVoltage3V3(double userVoltage3V3) {
183  HALSIM_SetRoboRioUserVoltage3V3(m_index, userVoltage3V3);
184  }
185 
186  std::unique_ptr<CallbackStore> RegisterUserCurrent3V3Callback(
187  NotifyCallback callback, bool initialNotify) {
188  auto store = std::make_unique<CallbackStore>(
189  m_index, -1, callback, &HALSIM_CancelRoboRioUserCurrent3V3Callback);
190  store->SetUid(HALSIM_RegisterRoboRioUserCurrent3V3Callback(
191  m_index, &CallbackStoreThunk, store.get(), initialNotify));
192  return store;
193  }
194 
195  double GetUserCurrent3V3() const {
196  return HALSIM_GetRoboRioUserCurrent3V3(m_index);
197  }
198 
199  void SetUserCurrent3V3(double userCurrent3V3) {
200  HALSIM_SetRoboRioUserCurrent3V3(m_index, userCurrent3V3);
201  }
202 
203  std::unique_ptr<CallbackStore> RegisterUserActive3V3Callback(
204  NotifyCallback callback, bool initialNotify) {
205  auto store = std::make_unique<CallbackStore>(
206  m_index, -1, callback, &HALSIM_CancelRoboRioUserActive3V3Callback);
207  store->SetUid(HALSIM_RegisterRoboRioUserActive3V3Callback(
208  m_index, &CallbackStoreThunk, store.get(), initialNotify));
209  return store;
210  }
211 
212  bool GetUserActive3V3() const {
213  return HALSIM_GetRoboRioUserActive3V3(m_index);
214  }
215 
216  void SetUserActive3V3(bool userActive3V3) {
217  HALSIM_SetRoboRioUserActive3V3(m_index, userActive3V3);
218  }
219 
220  std::unique_ptr<CallbackStore> RegisterUserFaults6VCallback(
221  NotifyCallback callback, bool initialNotify) {
222  auto store = std::make_unique<CallbackStore>(
223  m_index, -1, callback, &HALSIM_CancelRoboRioUserFaults6VCallback);
224  store->SetUid(HALSIM_RegisterRoboRioUserFaults6VCallback(
225  m_index, &CallbackStoreThunk, store.get(), initialNotify));
226  return store;
227  }
228 
229  int GetUserFaults6V() const { return HALSIM_GetRoboRioUserFaults6V(m_index); }
230 
231  void SetUserFaults6V(int userFaults6V) {
232  HALSIM_SetRoboRioUserFaults6V(m_index, userFaults6V);
233  }
234 
235  std::unique_ptr<CallbackStore> RegisterUserFaults5VCallback(
236  NotifyCallback callback, bool initialNotify) {
237  auto store = std::make_unique<CallbackStore>(
238  m_index, -1, callback, &HALSIM_CancelRoboRioUserFaults5VCallback);
239  store->SetUid(HALSIM_RegisterRoboRioUserFaults5VCallback(
240  m_index, &CallbackStoreThunk, store.get(), initialNotify));
241  return store;
242  }
243 
244  int GetUserFaults5V() const { return HALSIM_GetRoboRioUserFaults5V(m_index); }
245 
246  void SetUserFaults5V(int userFaults5V) {
247  HALSIM_SetRoboRioUserFaults5V(m_index, userFaults5V);
248  }
249 
250  std::unique_ptr<CallbackStore> RegisterUserFaults3V3Callback(
251  NotifyCallback callback, bool initialNotify) {
252  auto store = std::make_unique<CallbackStore>(
253  m_index, -1, callback, &HALSIM_CancelRoboRioUserFaults3V3Callback);
254  store->SetUid(HALSIM_RegisterRoboRioUserFaults3V3Callback(
255  m_index, &CallbackStoreThunk, store.get(), initialNotify));
256  return store;
257  }
258 
259  int GetUserFaults3V3() const {
260  return HALSIM_GetRoboRioUserFaults3V3(m_index);
261  }
262 
263  void SetUserFaults3V3(int userFaults3V3) {
264  HALSIM_SetRoboRioUserFaults3V3(m_index, userFaults3V3);
265  }
266 
267  void ResetData() { HALSIM_ResetRoboRioData(m_index); }
268 
269  private:
270  int m_index;
271 };
272 } // namespace sim
273 } // namespace frc
frc::sim::RoboRioSim
Definition: RoboRioSim.h:18
frc
A class that enforces constraints on the differential drive kinematics.
Definition: SPIAccelerometerSim.h:16