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