WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
RoboRioSim.hpp
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <memory>
8#include <string>
9
12#include "wpi/units/current.hpp"
13#include "wpi/units/temperature.hpp"
14#include "wpi/units/voltage.hpp"
15
16namespace wpi::sim {
17
18/**
19 * A utility class to control a simulated RoboRIO.
20 */
22 public:
23 /**
24 * Register a callback to be run whenever the Vin voltage changes.
25 *
26 * @param callback the callback
27 * @param initialNotify whether to call the callback with the initial state
28 * @return the CallbackStore object associated with this callback
29 */
30 [[nodiscard]]
31 static std::unique_ptr<CallbackStore> RegisterVInVoltageCallback(
32 NotifyCallback callback, bool initialNotify);
33
34 /**
35 * Measure the Vin voltage.
36 *
37 * @return the Vin voltage
38 */
39 static wpi::units::volt_t GetVInVoltage();
40
41 /**
42 * Define the Vin voltage.
43 *
44 * @param vInVoltage the new voltage
45 */
46 static void SetVInVoltage(wpi::units::volt_t vInVoltage);
47
48 /**
49 * Register a callback to be run whenever the 3.3V rail voltage changes.
50 *
51 * @param callback the callback
52 * @param initialNotify whether the callback should be called with the
53 * initial value
54 * @return the CallbackStore object associated with this callback
55 */
56 [[nodiscard]]
57 static std::unique_ptr<CallbackStore> RegisterUserVoltage3V3Callback(
58 NotifyCallback callback, bool initialNotify);
59
60 /**
61 * Measure the 3.3V rail voltage.
62 *
63 * @return the 3.3V rail voltage
64 */
65 static wpi::units::volt_t GetUserVoltage3V3();
66
67 /**
68 * Define the 3.3V rail voltage.
69 *
70 * @param userVoltage3V3 the new voltage
71 */
72 static void SetUserVoltage3V3(wpi::units::volt_t userVoltage3V3);
73
74 /**
75 * Register a callback to be run whenever the 3.3V rail current changes.
76 *
77 * @param callback the callback
78 * @param initialNotify whether the callback should be called with the
79 * initial value
80 * @return the CallbackStore object associated with this callback
81 */
82 [[nodiscard]]
83 static std::unique_ptr<CallbackStore> RegisterUserCurrent3V3Callback(
84 NotifyCallback callback, bool initialNotify);
85
86 /**
87 * Measure the 3.3V rail current.
88 *
89 * @return the 3.3V rail current
90 */
91 static wpi::units::ampere_t GetUserCurrent3V3();
92
93 /**
94 * Define the 3.3V rail current.
95 *
96 * @param userCurrent3V3 the new current
97 */
98 static void SetUserCurrent3V3(wpi::units::ampere_t userCurrent3V3);
99
100 /**
101 * Register a callback to be run whenever the 3.3V rail active state changes.
102 *
103 * @param callback the callback
104 * @param initialNotify whether the callback should be called with the
105 * initial state
106 * @return the CallbackStore object associated with this callback
107 */
108 [[nodiscard]]
109 static std::unique_ptr<CallbackStore> RegisterUserActive3V3Callback(
110 NotifyCallback callback, bool initialNotify);
111
112 /**
113 * Get the 3.3V rail active state.
114 *
115 * @return true if the 3.3V rail is active
116 */
117 static bool GetUserActive3V3();
118
119 /**
120 * Set the 3.3V rail active state.
121 *
122 * @param userActive3V3 true to make rail active
123 */
124 static void SetUserActive3V3(bool userActive3V3);
125
126 /**
127 * Register a callback to be run whenever the 3.3V rail number of faults
128 * changes.
129 *
130 * @param callback the callback
131 * @param initialNotify whether the callback should be called with the
132 * initial value
133 * @return the CallbackStore object associated with this callback
134 */
135 [[nodiscard]]
136 static std::unique_ptr<CallbackStore> RegisterUserFaults3V3Callback(
137 NotifyCallback callback, bool initialNotify);
138
139 /**
140 * Get the 3.3V rail number of faults.
141 *
142 * @return number of faults
143 */
144 static int GetUserFaults3V3();
145
146 /**
147 * Set the 3.3V rail number of faults.
148 *
149 * @param userFaults3V3 number of faults
150 */
151 static void SetUserFaults3V3(int userFaults3V3);
152
153 /**
154 * Register a callback to be run whenever the brownout voltage changes.
155 *
156 * @param callback the callback
157 * @param initialNotify whether to call the callback with the initial state
158 * @return the CallbackStore object associated with this callback
159 */
160 [[nodiscard]]
161 static std::unique_ptr<CallbackStore> RegisterBrownoutVoltageCallback(
162 NotifyCallback callback, bool initialNotify);
163
164 /**
165 * Measure the brownout voltage.
166 *
167 * @return the brownout voltage
168 */
169 static wpi::units::volt_t GetBrownoutVoltage();
170
171 /**
172 * Define the brownout voltage.
173 *
174 * @param brownoutVoltage the new voltage
175 */
176 static void SetBrownoutVoltage(wpi::units::volt_t brownoutVoltage);
177
178 /**
179 * Register a callback to be run whenever the cpu temp changes.
180 *
181 * @param callback the callback
182 * @param initialNotify whether to call the callback with the initial state
183 * @return the CallbackStore object associated with this callback
184 */
185 [[nodiscard]]
186 static std::unique_ptr<CallbackStore> RegisterCPUTempCallback(
187 NotifyCallback callback, bool initialNotify);
188
189 /**
190 * Get the cpu temp.
191 *
192 * @return the cpu temp.
193 */
194 static wpi::units::celsius_t GetCPUTemp();
195
196 /**
197 * Define the cpu temp.
198 *
199 * @param cpuTemp the new cpu temp.
200 */
201 static void SetCPUTemp(wpi::units::celsius_t cpuTemp);
202
203 /**
204 * Register a callback to be run whenever the team number changes.
205 *
206 * @param callback the callback
207 * @param initialNotify whether to call the callback with the initial state
208 * @return the CallbackStore object associated with this callback
209 */
210 [[nodiscard]]
211 static std::unique_ptr<CallbackStore> RegisterTeamNumberCallback(
212 NotifyCallback callback, bool initialNotify);
213
214 /**
215 * Get the team number.
216 *
217 * @return the team number.
218 */
219 static int32_t GetTeamNumber();
220
221 /**
222 * Set the team number.
223 *
224 * @param teamNumber the new team number.
225 */
226 static void SetTeamNumber(int32_t teamNumber);
227
228 /**
229 * Get the serial number.
230 *
231 * @return The serial number.
232 */
233 static std::string GetSerialNumber();
234
235 /**
236 * Set the serial number.
237 *
238 * @param serialNumber The serial number.
239 */
240 static void SetSerialNumber(std::string_view serialNumber);
241
242 /**
243 * Get the comments.
244 *
245 * @return The comments.
246 */
247 static std::string GetComments();
248
249 /**
250 * Set the comments.
251 *
252 * @param comments The comments.
253 */
254 static void SetComments(std::string_view comments);
255
256 /**
257 * Reset all simulation data.
258 */
259 static void ResetData();
260};
261} // namespace wpi::sim
A utility class to control a simulated RoboRIO.
Definition RoboRioSim.hpp:21
static void SetSerialNumber(std::string_view serialNumber)
Set the serial number.
static void SetCPUTemp(wpi::units::celsius_t cpuTemp)
Define the cpu temp.
static void SetUserActive3V3(bool userActive3V3)
Set the 3.3V rail active state.
static std::unique_ptr< CallbackStore > RegisterCPUTempCallback(NotifyCallback callback, bool initialNotify)
Register a callback to be run whenever the cpu temp changes.
static std::unique_ptr< CallbackStore > RegisterUserVoltage3V3Callback(NotifyCallback callback, bool initialNotify)
Register a callback to be run whenever the 3.3V rail voltage changes.
static std::unique_ptr< CallbackStore > RegisterUserFaults3V3Callback(NotifyCallback callback, bool initialNotify)
Register a callback to be run whenever the 3.3V rail number of faults changes.
static void SetComments(std::string_view comments)
Set the comments.
static std::unique_ptr< CallbackStore > RegisterBrownoutVoltageCallback(NotifyCallback callback, bool initialNotify)
Register a callback to be run whenever the brownout voltage changes.
static wpi::units::celsius_t GetCPUTemp()
Get the cpu temp.
static void SetVInVoltage(wpi::units::volt_t vInVoltage)
Define the Vin voltage.
static void SetBrownoutVoltage(wpi::units::volt_t brownoutVoltage)
Define the brownout voltage.
static wpi::units::ampere_t GetUserCurrent3V3()
Measure the 3.3V rail current.
static void ResetData()
Reset all simulation data.
static void SetTeamNumber(int32_t teamNumber)
Set the team number.
static int32_t GetTeamNumber()
Get the team number.
static std::string GetComments()
Get the comments.
static void SetUserVoltage3V3(wpi::units::volt_t userVoltage3V3)
Define the 3.3V rail voltage.
static void SetUserFaults3V3(int userFaults3V3)
Set the 3.3V rail number of faults.
static std::string GetSerialNumber()
Get the serial number.
static wpi::units::volt_t GetUserVoltage3V3()
Measure the 3.3V rail voltage.
static bool GetUserActive3V3()
Get the 3.3V rail active state.
static wpi::units::volt_t GetVInVoltage()
Measure the Vin voltage.
static std::unique_ptr< CallbackStore > RegisterUserActive3V3Callback(NotifyCallback callback, bool initialNotify)
Register a callback to be run whenever the 3.3V rail active state changes.
static std::unique_ptr< CallbackStore > RegisterVInVoltageCallback(NotifyCallback callback, bool initialNotify)
Register a callback to be run whenever the Vin voltage changes.
static int GetUserFaults3V3()
Get the 3.3V rail number of faults.
static std::unique_ptr< CallbackStore > RegisterUserCurrent3V3Callback(NotifyCallback callback, bool initialNotify)
Register a callback to be run whenever the 3.3V rail current changes.
static std::unique_ptr< CallbackStore > RegisterTeamNumberCallback(NotifyCallback callback, bool initialNotify)
Register a callback to be run whenever the team number changes.
static wpi::units::volt_t GetBrownoutVoltage()
Measure the brownout voltage.
static void SetUserCurrent3V3(wpi::units::ampere_t userCurrent3V3)
Define the 3.3V rail current.
Definition CTREPCMSim.hpp:13
std::function< void(std::string_view, const HAL_Value *)> NotifyCallback
Definition CallbackStore.hpp:16