WPILibC++  2018.4.1-20180729223220-1149-g7bd3f9f
 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  bool GetFPGAButton() { return HALSIM_GetRoboRioFPGAButton(m_index); }
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  double GetVInVoltage() { return HALSIM_GetRoboRioVInVoltage(m_index); }
46  void SetVInVoltage(double vInVoltage) {
47  HALSIM_SetRoboRioVInVoltage(m_index, vInVoltage);
48  }
49 
50  std::unique_ptr<CallbackStore> RegisterVInCurrentCallback(
51  NotifyCallback callback, bool initialNotify) {
52  auto store = std::make_unique<CallbackStore>(
53  m_index, -1, callback, &HALSIM_CancelRoboRioVInCurrentCallback);
54  store->SetUid(HALSIM_RegisterRoboRioVInCurrentCallback(
55  m_index, &CallbackStoreThunk, store.get(), initialNotify));
56  return store;
57  }
58  double GetVInCurrent() { return HALSIM_GetRoboRioVInCurrent(m_index); }
59  void SetVInCurrent(double vInCurrent) {
60  HALSIM_SetRoboRioVInCurrent(m_index, vInCurrent);
61  }
62 
63  std::unique_ptr<CallbackStore> RegisterUserVoltage6VCallback(
64  NotifyCallback callback, bool initialNotify) {
65  auto store = std::make_unique<CallbackStore>(
66  m_index, -1, callback, &HALSIM_CancelRoboRioUserVoltage6VCallback);
67  store->SetUid(HALSIM_RegisterRoboRioUserVoltage6VCallback(
68  m_index, &CallbackStoreThunk, store.get(), initialNotify));
69  return store;
70  }
71  double GetUserVoltage6V() { return HALSIM_GetRoboRioUserVoltage6V(m_index); }
72  void SetUserVoltage6V(double userVoltage6V) {
73  HALSIM_SetRoboRioUserVoltage6V(m_index, userVoltage6V);
74  }
75 
76  std::unique_ptr<CallbackStore> RegisterUserCurrent6VCallback(
77  NotifyCallback callback, bool initialNotify) {
78  auto store = std::make_unique<CallbackStore>(
79  m_index, -1, callback, &HALSIM_CancelRoboRioUserCurrent6VCallback);
80  store->SetUid(HALSIM_RegisterRoboRioUserCurrent6VCallback(
81  m_index, &CallbackStoreThunk, store.get(), initialNotify));
82  return store;
83  }
84  double GetUserCurrent6V() { return HALSIM_GetRoboRioUserCurrent6V(m_index); }
85  void SetUserCurrent6V(double userCurrent6V) {
86  HALSIM_SetRoboRioUserCurrent6V(m_index, userCurrent6V);
87  }
88 
89  std::unique_ptr<CallbackStore> RegisterUserActive6VCallback(
90  NotifyCallback callback, bool initialNotify) {
91  auto store = std::make_unique<CallbackStore>(
92  m_index, -1, callback, &HALSIM_CancelRoboRioUserActive6VCallback);
93  store->SetUid(HALSIM_RegisterRoboRioUserActive6VCallback(
94  m_index, &CallbackStoreThunk, store.get(), initialNotify));
95  return store;
96  }
97  bool GetUserActive6V() { return HALSIM_GetRoboRioUserActive6V(m_index); }
98  void SetUserActive6V(bool userActive6V) {
99  HALSIM_SetRoboRioUserActive6V(m_index, userActive6V);
100  }
101 
102  std::unique_ptr<CallbackStore> RegisterUserVoltage5VCallback(
103  NotifyCallback callback, bool initialNotify) {
104  auto store = std::make_unique<CallbackStore>(
105  m_index, -1, callback, &HALSIM_CancelRoboRioUserVoltage5VCallback);
106  store->SetUid(HALSIM_RegisterRoboRioUserVoltage5VCallback(
107  m_index, &CallbackStoreThunk, store.get(), initialNotify));
108  return store;
109  }
110  double GetUserVoltage5V() { return HALSIM_GetRoboRioUserVoltage5V(m_index); }
111  void SetUserVoltage5V(double userVoltage5V) {
112  HALSIM_SetRoboRioUserVoltage5V(m_index, userVoltage5V);
113  }
114 
115  std::unique_ptr<CallbackStore> RegisterUserCurrent5VCallback(
116  NotifyCallback callback, bool initialNotify) {
117  auto store = std::make_unique<CallbackStore>(
118  m_index, -1, callback, &HALSIM_CancelRoboRioUserCurrent5VCallback);
119  store->SetUid(HALSIM_RegisterRoboRioUserCurrent5VCallback(
120  m_index, &CallbackStoreThunk, store.get(), initialNotify));
121  return store;
122  }
123  double GetUserCurrent5V() { return HALSIM_GetRoboRioUserCurrent5V(m_index); }
124  void SetUserCurrent5V(double userCurrent5V) {
125  HALSIM_SetRoboRioUserCurrent5V(m_index, userCurrent5V);
126  }
127 
128  std::unique_ptr<CallbackStore> RegisterUserActive5VCallback(
129  NotifyCallback callback, bool initialNotify) {
130  auto store = std::make_unique<CallbackStore>(
131  m_index, -1, callback, &HALSIM_CancelRoboRioUserActive5VCallback);
132  store->SetUid(HALSIM_RegisterRoboRioUserActive5VCallback(
133  m_index, &CallbackStoreThunk, store.get(), initialNotify));
134  return store;
135  }
136  bool GetUserActive5V() { return HALSIM_GetRoboRioUserActive5V(m_index); }
137  void SetUserActive5V(bool userActive5V) {
138  HALSIM_SetRoboRioUserActive5V(m_index, userActive5V);
139  }
140 
141  std::unique_ptr<CallbackStore> RegisterUserVoltage3V3Callback(
142  NotifyCallback callback, bool initialNotify) {
143  auto store = std::make_unique<CallbackStore>(
144  m_index, -1, callback, &HALSIM_CancelRoboRioUserVoltage3V3Callback);
145  store->SetUid(HALSIM_RegisterRoboRioUserVoltage3V3Callback(
146  m_index, &CallbackStoreThunk, store.get(), initialNotify));
147  return store;
148  }
149  double GetUserVoltage3V3() {
150  return HALSIM_GetRoboRioUserVoltage3V3(m_index);
151  }
152  void SetUserVoltage3V3(double userVoltage3V3) {
153  HALSIM_SetRoboRioUserVoltage3V3(m_index, userVoltage3V3);
154  }
155 
156  std::unique_ptr<CallbackStore> RegisterUserCurrent3V3Callback(
157  NotifyCallback callback, bool initialNotify) {
158  auto store = std::make_unique<CallbackStore>(
159  m_index, -1, callback, &HALSIM_CancelRoboRioUserCurrent3V3Callback);
160  store->SetUid(HALSIM_RegisterRoboRioUserCurrent3V3Callback(
161  m_index, &CallbackStoreThunk, store.get(), initialNotify));
162  return store;
163  }
164  double GetUserCurrent3V3() {
165  return HALSIM_GetRoboRioUserCurrent3V3(m_index);
166  }
167  void SetUserCurrent3V3(double userCurrent3V3) {
168  HALSIM_SetRoboRioUserCurrent3V3(m_index, userCurrent3V3);
169  }
170 
171  std::unique_ptr<CallbackStore> RegisterUserActive3V3Callback(
172  NotifyCallback callback, bool initialNotify) {
173  auto store = std::make_unique<CallbackStore>(
174  m_index, -1, callback, &HALSIM_CancelRoboRioUserActive3V3Callback);
175  store->SetUid(HALSIM_RegisterRoboRioUserActive3V3Callback(
176  m_index, &CallbackStoreThunk, store.get(), initialNotify));
177  return store;
178  }
179  bool GetUserActive3V3() { return HALSIM_GetRoboRioUserActive3V3(m_index); }
180  void SetUserActive3V3(bool userActive3V3) {
181  HALSIM_SetRoboRioUserActive3V3(m_index, userActive3V3);
182  }
183 
184  std::unique_ptr<CallbackStore> RegisterUserFaults6VCallback(
185  NotifyCallback callback, bool initialNotify) {
186  auto store = std::make_unique<CallbackStore>(
187  m_index, -1, callback, &HALSIM_CancelRoboRioUserFaults6VCallback);
188  store->SetUid(HALSIM_RegisterRoboRioUserFaults6VCallback(
189  m_index, &CallbackStoreThunk, store.get(), initialNotify));
190  return store;
191  }
192  int GetUserFaults6V() { return HALSIM_GetRoboRioUserFaults6V(m_index); }
193  void SetUserFaults6V(int userFaults6V) {
194  HALSIM_SetRoboRioUserFaults6V(m_index, userFaults6V);
195  }
196 
197  std::unique_ptr<CallbackStore> RegisterUserFaults5VCallback(
198  NotifyCallback callback, bool initialNotify) {
199  auto store = std::make_unique<CallbackStore>(
200  m_index, -1, callback, &HALSIM_CancelRoboRioUserFaults5VCallback);
201  store->SetUid(HALSIM_RegisterRoboRioUserFaults5VCallback(
202  m_index, &CallbackStoreThunk, store.get(), initialNotify));
203  return store;
204  }
205  int GetUserFaults5V() { return HALSIM_GetRoboRioUserFaults5V(m_index); }
206  void SetUserFaults5V(int userFaults5V) {
207  HALSIM_SetRoboRioUserFaults5V(m_index, userFaults5V);
208  }
209 
210  std::unique_ptr<CallbackStore> RegisterUserFaults3V3Callback(
211  NotifyCallback callback, bool initialNotify) {
212  auto store = std::make_unique<CallbackStore>(
213  m_index, -1, callback, &HALSIM_CancelRoboRioUserFaults3V3Callback);
214  store->SetUid(HALSIM_RegisterRoboRioUserFaults3V3Callback(
215  m_index, &CallbackStoreThunk, store.get(), initialNotify));
216  return store;
217  }
218  int GetUserFaults3V3() { return HALSIM_GetRoboRioUserFaults3V3(m_index); }
219  void SetUserFaults3V3(int userFaults3V3) {
220  HALSIM_SetRoboRioUserFaults3V3(m_index, userFaults3V3);
221  }
222 
223  void ResetData() { HALSIM_ResetRoboRioData(m_index); }
224 
225  private:
226  int m_index;
227 };
228 } // namespace sim
229 } // namespace frc
230 #endif // __FRC_ROBORIO__
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
Definition: RoboRioSim.h:20