WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
SimDevice.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 <initializer_list>
8#include <span>
9#include <string>
10
11#include "wpi/hal/SimDevice.h"
12
14 const char* name,
15 int32_t direction,
16 const HAL_Value& initialValue) {
17 return HAL_CreateSimValue(device, name, direction, &initialValue);
18}
19
21 HAL_Value v;
22 HAL_GetSimValue(handle, &v);
23 return v;
24}
25
26inline void HAL_SetSimValue(HAL_SimValueHandle handle, const HAL_Value& value) {
27 HAL_SetSimValue(handle, &value);
28}
29
30namespace wpi::hal {
31
32/**
33 * C++ wrapper around a HAL simulator value handle.
34 */
35class SimValue {
36 public:
37 /**
38 * Default constructor that results in an "empty" object that is false in
39 * a boolean context.
40 */
41 SimValue() = default;
42
43 /**
44 * Wraps a simulated value handle as returned by HAL_CreateSimValue().
45 *
46 * @param val simulated value handle
47 */
48 /*implicit*/ SimValue(HAL_SimValueHandle val) // NOLINT
49 : m_handle(val) {}
50
51 /**
52 * Determine if handle is empty. Should be used to optimize out code paths
53 * that are taken/not taken in simulation.
54 *
55 * @return False if handle is empty, true if handle is valid.
56 */
57 explicit operator bool() const { return m_handle != HAL_kInvalidHandle; }
58
59 /**
60 * Get the internal device handle.
61 *
62 * @return internal handle
63 */
64 operator HAL_SimValueHandle() const { return m_handle; } // NOLINT
65
66 /**
67 * Gets the simulated value.
68 *
69 * @return The current value
70 */
72
73 /**
74 * Sets the simulated value.
75 *
76 * @param value the value to set
77 */
78 void SetValue(const HAL_Value& value) { HAL_SetSimValue(m_handle, value); }
79
80 protected:
82};
83
84/**
85 * C++ wrapper around a HAL simulator int value handle.
86 */
87class SimInt : public SimValue {
88 public:
89 /**
90 * Default constructor that results in an "empty" object that is false in
91 * a boolean context.
92 */
93 SimInt() = default;
94
95 /**
96 * Wraps a simulated value handle as returned by HAL_CreateSimValueInt().
97 *
98 * @param val simulated value handle
99 */
100 /*implicit*/ SimInt(HAL_SimValueHandle val) // NOLINT
101 : SimValue(val) {}
102
103 /**
104 * Gets the simulated value.
105 *
106 * @return The current value
107 */
108 int32_t Get() const { return HAL_GetSimValueInt(m_handle); }
109
110 /**
111 * Sets the simulated value.
112 *
113 * @param value the value to set
114 */
115 void Set(int32_t value) { HAL_SetSimValueInt(m_handle, value); }
116
117 /**
118 * Resets the simulated value to 0. Use this instead of Set(0) for resetting
119 * incremental sensor values like encoder counts or gyro accumulated angle
120 * to ensure correct behavior in a distributed system (e.g. WebSockets).
121 */
123};
124
125/**
126 * C++ wrapper around a HAL simulator long value handle.
127 */
128class SimLong : public SimValue {
129 public:
130 /**
131 * Default constructor that results in an "empty" object that is false in
132 * a boolean context.
133 */
134 SimLong() = default;
135
136 /**
137 * Wraps a simulated value handle as returned by HAL_CreateSimValueLong().
138 *
139 * @param val simulated value handle
140 */
141 /*implicit*/ SimLong(HAL_SimValueHandle val) // NOLINT
142 : SimValue(val) {}
143
144 /**
145 * Gets the simulated value.
146 *
147 * @return The current value
148 */
149 int64_t Get() const { return HAL_GetSimValueLong(m_handle); }
150
151 /**
152 * Sets the simulated value.
153 *
154 * @param value the value to set
155 */
156 void Set(int64_t value) { HAL_SetSimValueLong(m_handle, value); }
157
158 /**
159 * Resets the simulated value to 0. Use this instead of Set(0) for resetting
160 * incremental sensor values like encoder counts or gyro accumulated angle
161 * to ensure correct behavior in a distributed system (e.g. WebSockets).
162 */
164};
165
166/**
167 * C++ wrapper around a HAL simulator double value handle.
168 */
169class SimDouble : public SimValue {
170 public:
171 /**
172 * Default constructor that results in an "empty" object that is false in
173 * a boolean context.
174 */
175 SimDouble() = default;
176
177 /**
178 * Wraps a simulated value handle as returned by HAL_CreateSimValueDouble().
179 *
180 * @param val simulated value handle
181 */
182 /*implicit*/ SimDouble(HAL_SimValueHandle val) // NOLINT
183 : SimValue(val) {}
184
185 /**
186 * Gets the simulated value.
187 *
188 * @return The current value
189 */
190 double Get() const { return HAL_GetSimValueDouble(m_handle); }
191
192 /**
193 * Sets the simulated value.
194 *
195 * @param value the value to set
196 */
197 void Set(double value) { HAL_SetSimValueDouble(m_handle, value); }
198
199 /**
200 * Resets the simulated value to 0. Use this instead of Set(0) for resetting
201 * incremental sensor values like encoder counts or gyro accumulated angle
202 * to ensure correct behavior in a distributed system (e.g. WebSockets).
203 */
205};
206
207/**
208 * C++ wrapper around a HAL simulator enum value handle.
209 */
210class SimEnum : public SimValue {
211 public:
212 /**
213 * Default constructor that results in an "empty" object that is false in
214 * a boolean context.
215 */
216 SimEnum() = default;
217
218 /**
219 * Wraps a simulated value handle as returned by HAL_CreateSimValueEnum().
220 *
221 * @param val simulated value handle
222 */
223 /*implicit*/ SimEnum(HAL_SimValueHandle val) // NOLINT
224 : SimValue(val) {}
225
226 /**
227 * Gets the simulated value.
228 *
229 * @return The current value
230 */
231 int32_t Get() const { return HAL_GetSimValueEnum(m_handle); }
232
233 /**
234 * Sets the simulated value.
235 *
236 * @param value the value to set
237 */
238 void Set(int32_t value) { HAL_SetSimValueEnum(m_handle, value); }
239};
240
241/**
242 * C++ wrapper around a HAL simulator boolean value handle.
243 */
244class SimBoolean : public SimValue {
245 public:
246 /**
247 * Default constructor that results in an "empty" object that is false in
248 * a boolean context.
249 */
250 SimBoolean() = default;
251
252 /**
253 * Wraps a simulated value handle as returned by HAL_CreateSimValueBoolean().
254 *
255 * @param val simulated value handle
256 */
257 /*implicit*/ SimBoolean(HAL_SimValueHandle val) // NOLINT
258 : SimValue(val) {}
259
260 /**
261 * Gets the simulated value.
262 *
263 * @return The current value
264 */
265 bool Get() const { return HAL_GetSimValueBoolean(m_handle); }
266
267 /**
268 * Sets the simulated value.
269 *
270 * @param value the value to set
271 */
272 void Set(bool value) { HAL_SetSimValueBoolean(m_handle, value); }
273};
274
275/**
276 * A move-only C++ wrapper around a HAL simulator device handle.
277 */
279 public:
280 /**
281 * Direction of a simulated value (from the perspective of user code).
282 */
288
289 /**
290 * Default constructor that results in an "empty" object that is false in
291 * a boolean context.
292 */
293 SimDevice() = default;
294
295 /**
296 * Creates a simulated device.
297 *
298 * The device name must be unique. Returns null if the device name
299 * already exists. If multiple instances of the same device are desired,
300 * recommend appending the instance/unique identifier in brackets to the base
301 * name, e.g. "device[1]".
302 *
303 * Using a device name of the form "Type:Name" will create a WebSockets node
304 * with a type value of "Type" and a device value of "Name"
305 *
306 * If not in simulation, results in an "empty" object that evaluates to false
307 * in a boolean context.
308 *
309 * @param name device name
310 */
311 explicit SimDevice(const char* name) : m_handle(HAL_CreateSimDevice(name)) {}
312
313 /**
314 * Creates a simulated device.
315 *
316 * The device name must be unique. Returns null if the device name
317 * already exists. This is a convenience method that appends index in
318 * brackets to the device name, e.g. passing index=1 results in "device[1]"
319 * for the device name.
320 *
321 * Using a device name of the form "Type:Name" will create a WebSockets node
322 * with a type value of "Type" and a device value of "Name"
323 *
324 * If not in simulation, results in an "empty" object that evaluates to false
325 * in a boolean context.
326 *
327 * @param name device name
328 * @param index device index number to append to name
329 */
330 SimDevice(const char* name, int index);
331
332 /**
333 * Creates a simulated device.
334 *
335 * The device name must be unique. Returns null if the device name
336 * already exists. This is a convenience method that appends index and
337 * channel in brackets to the device name, e.g. passing index=1 and channel=2
338 * results in "device[1,2]" for the device name.
339 *
340 * Using a device name of the form "Type:Name" will create a WebSockets node
341 * with a type value of "Type" and a device value of "Name"
342 *
343 * If not in simulation, results in an "empty" object that evaluates to false
344 * in a boolean context.
345 *
346 * @param name device name
347 * @param index device index number to append to name
348 * @param channel device channel number to append to name
349 */
350 SimDevice(const char* name, int index, int channel);
351
357
358 SimDevice(const SimDevice&) = delete;
359 SimDevice& operator=(const SimDevice&) = delete;
360
362 rhs.m_handle = HAL_kInvalidHandle;
363 }
364
366 m_handle = rhs.m_handle;
367 rhs.m_handle = HAL_kInvalidHandle;
368 return *this;
369 }
370
371 /**
372 * Determine if handle is empty. Should be used to optimize out code paths
373 * that are taken/not taken in simulation.
374 *
375 * @return False if handle is empty, true if handle is valid.
376 */
377 explicit operator bool() const { return m_handle != HAL_kInvalidHandle; }
378
379 /**
380 * Get the internal device handle.
381 *
382 * @return internal handle
383 */
384 operator HAL_SimDeviceHandle() const { return m_handle; } // NOLINT
385
386 /**
387 * Get the name of the simulated device.
388 *
389 * @return name
390 */
391 std::string GetName() const {
392 return std::string(HAL_GetSimDeviceName(m_handle));
393 }
394
395 /**
396 * Creates a value on the simulated device.
397 *
398 * If not in simulation, results in an "empty" object that evaluates to false
399 * in a boolean context.
400 *
401 * @param name value name
402 * @param direction input/output/bidir (from perspective of user code)
403 * @param initialValue initial value
404 * @return simulated value object
405 */
406 SimValue CreateValue(const char* name, int32_t direction,
407 const HAL_Value& initialValue) {
408 return HAL_CreateSimValue(m_handle, name, direction, &initialValue);
409 }
410
411 /**
412 * Creates an int value on the simulated device.
413 *
414 * If not in simulation, results in an "empty" object that evaluates to false
415 * in a boolean context.
416 *
417 * @param name value name
418 * @param direction input/output/bidir (from perspective of user code)
419 * @param initialValue initial value
420 * @return simulated double value object
421 */
422 SimInt CreateInt(const char* name, int32_t direction, int32_t initialValue) {
423 return HAL_CreateSimValueInt(m_handle, name, direction, initialValue);
424 }
425
426 /**
427 * Creates a long value on the simulated device.
428 *
429 * If not in simulation, results in an "empty" object that evaluates to false
430 * in a boolean context.
431 *
432 * @param name value name
433 * @param direction input/output/bidir (from perspective of user code)
434 * @param initialValue initial value
435 * @return simulated double value object
436 */
437 SimLong CreateLong(const char* name, int32_t direction,
438 int64_t initialValue) {
439 return HAL_CreateSimValueLong(m_handle, name, direction, initialValue);
440 }
441
442 /**
443 * Creates a double value on the simulated device.
444 *
445 * If not in simulation, results in an "empty" object that evaluates to false
446 * in a boolean context.
447 *
448 * @param name value name
449 * @param direction input/output/bidir (from perspective of user code)
450 * @param initialValue initial value
451 * @return simulated double value object
452 */
453 SimDouble CreateDouble(const char* name, int32_t direction,
454 double initialValue) {
455 return HAL_CreateSimValueDouble(m_handle, name, direction, initialValue);
456 }
457
458 /**
459 * Creates an enumerated value on the simulated device.
460 *
461 * Enumerated values are always in the range 0 to numOptions-1.
462 *
463 * If not in simulation, results in an "empty" object that evaluates to false
464 * in a boolean context.
465 *
466 * @param name value name
467 * @param direction input/output/bidir (from perspective of user code)
468 * @param options array of option descriptions
469 * @param initialValue initial value (selection)
470 * @return simulated enum value object
471 */
472 SimEnum CreateEnum(const char* name, int32_t direction,
473 std::initializer_list<const char*> options,
474 int32_t initialValue) {
475 return HAL_CreateSimValueEnum(m_handle, name, direction, options.size(),
476 const_cast<const char**>(options.begin()),
477 initialValue);
478 }
479
480 /**
481 * Creates an enumerated value on the simulated device.
482 *
483 * Enumerated values are always in the range 0 to numOptions-1.
484 *
485 * If not in simulation, results in an "empty" object that evaluates to false
486 * in a boolean context.
487 *
488 * @param name value name
489 * @param direction input/output/bidir (from perspective of user code)
490 * @param options array of option descriptions
491 * @param initialValue initial value (selection)
492 * @return simulated enum value object
493 */
494 SimEnum CreateEnum(const char* name, int32_t direction,
495 std::span<const char* const> options,
496 int32_t initialValue) {
497 return HAL_CreateSimValueEnum(m_handle, name, direction, options.size(),
498 const_cast<const char**>(options.data()),
499 initialValue);
500 }
501
502 /**
503 * Creates an enumerated value on the simulated device with double values.
504 *
505 * Enumerated values are always in the range 0 to numOptions-1.
506 *
507 * If not in simulation, results in an "empty" object that evaluates to false
508 * in a boolean context.
509 *
510 * @param name value name
511 * @param direction input/output/bidir (from perspective of user code)
512 * @param options array of option descriptions
513 * @param optionValues array of option values (must be the same size as
514 * options)
515 * @param initialValue initial value (selection)
516 * @return simulated enum value object
517 */
518 SimEnum CreateEnumDouble(const char* name, int32_t direction,
519 std::initializer_list<const char*> options,
520 std::initializer_list<double> optionValues,
521 int32_t initialValue) {
522 if (options.size() != optionValues.size()) {
523 return {};
524 }
526 m_handle, name, direction, options.size(),
527 const_cast<const char**>(options.begin()), optionValues.begin(),
528 initialValue);
529 }
530
531 /**
532 * Creates an enumerated value on the simulated device with double values.
533 *
534 * Enumerated values are always in the range 0 to numOptions-1.
535 *
536 * If not in simulation, results in an "empty" object that evaluates to false
537 * in a boolean context.
538 *
539 * @param name value name
540 * @param direction input/output/bidir (from perspective of user code)
541 * @param options array of option descriptions
542 * @param optionValues array of option values (must be the same size as
543 * options)
544 * @param initialValue initial value (selection)
545 * @return simulated enum value object
546 */
547 SimEnum CreateEnumDouble(const char* name, int32_t direction,
548 std::span<const char* const> options,
549 std::span<const double> optionValues,
550 int32_t initialValue) {
551 if (options.size() != optionValues.size()) {
552 return {};
553 }
555 m_handle, name, direction, options.size(),
556 const_cast<const char**>(options.data()), optionValues.data(),
557 initialValue);
558 }
559
560 /**
561 * Creates a boolean value on the simulated device.
562 *
563 * If not in simulation, results in an "empty" object that evaluates to false
564 * in a boolean context.
565 *
566 * @param name value name
567 * @param direction input/output/bidir (from perspective of user code)
568 * @param initialValue initial value
569 * @return simulated boolean value object
570 */
571 SimBoolean CreateBoolean(const char* name, int32_t direction,
572 bool initialValue) {
573 return HAL_CreateSimValueBoolean(m_handle, name, direction, initialValue);
574 }
575
576 protected:
578};
579
580} // namespace wpi::hal
HAL_SimValueHandle HAL_CreateSimValue(HAL_SimDeviceHandle device, const char *name, int32_t direction, const HAL_Value &initialValue)
Definition SimDevice.hpp:13
HAL_Value HAL_GetSimValue(HAL_SimValueHandle handle)
Definition SimDevice.hpp:20
void HAL_SetSimValue(HAL_SimValueHandle handle, const HAL_Value &value)
Definition SimDevice.hpp:26
@ index
Definition base.h:690
@ name
Definition base.h:690
C++ wrapper around a HAL simulator boolean value handle.
Definition SimDevice.hpp:244
SimBoolean()=default
Default constructor that results in an "empty" object that is false in a boolean context.
bool Get() const
Gets the simulated value.
Definition SimDevice.hpp:265
SimBoolean(HAL_SimValueHandle val)
Wraps a simulated value handle as returned by HAL_CreateSimValueBoolean().
Definition SimDevice.hpp:257
void Set(bool value)
Sets the simulated value.
Definition SimDevice.hpp:272
SimEnum CreateEnumDouble(const char *name, int32_t direction, std::span< const char *const > options, std::span< const double > optionValues, int32_t initialValue)
Creates an enumerated value on the simulated device with double values.
Definition SimDevice.hpp:547
SimDevice(SimDevice &&rhs)
Definition SimDevice.hpp:361
SimLong CreateLong(const char *name, int32_t direction, int64_t initialValue)
Creates a long value on the simulated device.
Definition SimDevice.hpp:437
SimInt CreateInt(const char *name, int32_t direction, int32_t initialValue)
Creates an int value on the simulated device.
Definition SimDevice.hpp:422
SimDevice(const SimDevice &)=delete
SimDevice(const char *name, int index, int channel)
Creates a simulated device.
SimDevice & operator=(const SimDevice &)=delete
SimDouble CreateDouble(const char *name, int32_t direction, double initialValue)
Creates a double value on the simulated device.
Definition SimDevice.hpp:453
HAL_SimDeviceHandle m_handle
Definition SimDevice.hpp:577
SimDevice & operator=(SimDevice &&rhs)
Definition SimDevice.hpp:365
SimDevice(const char *name)
Creates a simulated device.
Definition SimDevice.hpp:311
SimValue CreateValue(const char *name, int32_t direction, const HAL_Value &initialValue)
Creates a value on the simulated device.
Definition SimDevice.hpp:406
SimEnum CreateEnumDouble(const char *name, int32_t direction, std::initializer_list< const char * > options, std::initializer_list< double > optionValues, int32_t initialValue)
Creates an enumerated value on the simulated device with double values.
Definition SimDevice.hpp:518
SimDevice()=default
Default constructor that results in an "empty" object that is false in a boolean context.
~SimDevice()
Definition SimDevice.hpp:352
SimBoolean CreateBoolean(const char *name, int32_t direction, bool initialValue)
Creates a boolean value on the simulated device.
Definition SimDevice.hpp:571
SimEnum CreateEnum(const char *name, int32_t direction, std::span< const char *const > options, int32_t initialValue)
Creates an enumerated value on the simulated device.
Definition SimDevice.hpp:494
SimDevice(const char *name, int index)
Creates a simulated device.
Direction
Direction of a simulated value (from the perspective of user code).
Definition SimDevice.hpp:283
@ kBidir
Definition SimDevice.hpp:286
@ kOutput
Definition SimDevice.hpp:285
@ kInput
Definition SimDevice.hpp:284
std::string GetName() const
Get the name of the simulated device.
Definition SimDevice.hpp:391
SimEnum CreateEnum(const char *name, int32_t direction, std::initializer_list< const char * > options, int32_t initialValue)
Creates an enumerated value on the simulated device.
Definition SimDevice.hpp:472
C++ wrapper around a HAL simulator double value handle.
Definition SimDevice.hpp:169
SimDouble(HAL_SimValueHandle val)
Wraps a simulated value handle as returned by HAL_CreateSimValueDouble().
Definition SimDevice.hpp:182
SimDouble()=default
Default constructor that results in an "empty" object that is false in a boolean context.
void Reset()
Resets the simulated value to 0.
Definition SimDevice.hpp:204
void Set(double value)
Sets the simulated value.
Definition SimDevice.hpp:197
double Get() const
Gets the simulated value.
Definition SimDevice.hpp:190
C++ wrapper around a HAL simulator enum value handle.
Definition SimDevice.hpp:210
int32_t Get() const
Gets the simulated value.
Definition SimDevice.hpp:231
SimEnum()=default
Default constructor that results in an "empty" object that is false in a boolean context.
SimEnum(HAL_SimValueHandle val)
Wraps a simulated value handle as returned by HAL_CreateSimValueEnum().
Definition SimDevice.hpp:223
void Set(int32_t value)
Sets the simulated value.
Definition SimDevice.hpp:238
C++ wrapper around a HAL simulator int value handle.
Definition SimDevice.hpp:87
int32_t Get() const
Gets the simulated value.
Definition SimDevice.hpp:108
void Set(int32_t value)
Sets the simulated value.
Definition SimDevice.hpp:115
SimInt(HAL_SimValueHandle val)
Wraps a simulated value handle as returned by HAL_CreateSimValueInt().
Definition SimDevice.hpp:100
SimInt()=default
Default constructor that results in an "empty" object that is false in a boolean context.
void Reset()
Resets the simulated value to 0.
Definition SimDevice.hpp:122
C++ wrapper around a HAL simulator long value handle.
Definition SimDevice.hpp:128
int64_t Get() const
Gets the simulated value.
Definition SimDevice.hpp:149
SimLong()=default
Default constructor that results in an "empty" object that is false in a boolean context.
SimLong(HAL_SimValueHandle val)
Wraps a simulated value handle as returned by HAL_CreateSimValueLong().
Definition SimDevice.hpp:141
void Set(int64_t value)
Sets the simulated value.
Definition SimDevice.hpp:156
void Reset()
Resets the simulated value to 0.
Definition SimDevice.hpp:163
C++ wrapper around a HAL simulator value handle.
Definition SimDevice.hpp:35
void SetValue(const HAL_Value &value)
Sets the simulated value.
Definition SimDevice.hpp:78
SimValue()=default
Default constructor that results in an "empty" object that is false in a boolean context.
SimValue(HAL_SimValueHandle val)
Wraps a simulated value handle as returned by HAL_CreateSimValue().
Definition SimDevice.hpp:48
HAL_Value GetValue() const
Gets the simulated value.
Definition SimDevice.hpp:71
HAL_SimValueHandle m_handle
Definition SimDevice.hpp:81
HAL_SimValueHandle HAL_CreateSimValueEnumDouble(HAL_SimDeviceHandle device, const char *name, int32_t direction, int32_t numOptions, const char **options, const double *optionValues, int32_t initialValue)
Creates an enumerated value on a simulated device with double values.
HAL_SimValueHandle HAL_CreateSimValueInt(HAL_SimDeviceHandle device, const char *name, int32_t direction, int32_t initialValue)
Creates an int value on a simulated device.
Definition SimDevice.h:101
double HAL_GetSimValueDouble(HAL_SimValueHandle handle)
Gets a simulated value (double).
Definition SimDevice.h:251
HAL_SimValueHandle HAL_CreateSimValue(HAL_SimDeviceHandle device, const char *name, int32_t direction, const struct HAL_Value *initialValue)
Creates a value on a simulated device.
int32_t HAL_GetSimValueEnum(HAL_SimValueHandle handle)
Gets a simulated value (enum).
Definition SimDevice.h:263
HAL_SimValueHandle HAL_CreateSimValueBoolean(HAL_SimDeviceHandle device, const char *name, int32_t direction, HAL_Bool initialValue)
Creates a boolean value on a simulated device.
Definition SimDevice.h:205
void HAL_SetSimValueEnum(HAL_SimValueHandle handle, int32_t value)
Sets a simulated value (enum).
Definition SimDevice.h:328
void HAL_SetSimValueDouble(HAL_SimValueHandle handle, double value)
Sets a simulated value (double).
Definition SimDevice.h:317
void HAL_FreeSimDevice(HAL_SimDeviceHandle handle)
Frees a simulated device.
void HAL_SetSimValue(HAL_SimValueHandle handle, const struct HAL_Value *value)
Sets a simulated value.
void HAL_SetSimValueLong(HAL_SimValueHandle handle, int64_t value)
Sets a simulated value (long).
Definition SimDevice.h:306
HAL_SimDeviceHandle HAL_CreateSimDevice(const char *name)
Creates a simulated device.
HAL_SimValueHandle HAL_CreateSimValueEnum(HAL_SimDeviceHandle device, const char *name, int32_t direction, int32_t numOptions, const char **options, int32_t initialValue)
Creates an enumerated value on a simulated device.
HAL_SimValueHandle HAL_CreateSimValueDouble(HAL_SimDeviceHandle device, const char *name, int32_t direction, double initialValue)
Creates a double value on a simulated device.
Definition SimDevice.h:141
HAL_SimValueHandle HAL_CreateSimValueLong(HAL_SimDeviceHandle device, const char *name, int32_t direction, int64_t initialValue)
Creates a long value on a simulated device.
Definition SimDevice.h:121
void HAL_SetSimValueInt(HAL_SimValueHandle handle, int value)
Sets a simulated value (int).
Definition SimDevice.h:295
HAL_Bool HAL_GetSimValueBoolean(HAL_SimValueHandle handle)
Gets a simulated value (boolean).
Definition SimDevice.h:275
void HAL_GetSimValue(HAL_SimValueHandle handle, struct HAL_Value *value)
Gets a simulated value.
int64_t HAL_GetSimValueLong(HAL_SimValueHandle handle)
Gets a simulated value (long).
Definition SimDevice.h:239
const char * HAL_GetSimDeviceName(HAL_SimDeviceHandle handle)
Get the name of a simulated device.
void HAL_SetSimValueBoolean(HAL_SimValueHandle handle, HAL_Bool value)
Sets a simulated value (boolean).
Definition SimDevice.h:339
int32_t HAL_GetSimValueInt(HAL_SimValueHandle handle)
Gets a simulated value (int).
Definition SimDevice.h:227
void HAL_ResetSimValue(HAL_SimValueHandle handle)
Resets a simulated double or integral value to 0.
@ HAL_SimValueBidir
bidirectional between user code and simulator
Definition SimDevice.h:30
@ HAL_SimValueOutput
output from user code to the simulator
Definition SimDevice.h:29
@ HAL_SimValueInput
input to user code from the simulator
Definition SimDevice.h:28
HAL_Handle HAL_SimDeviceHandle
Definition Types.h:53
HAL_Handle HAL_SimValueHandle
Definition Types.h:55
#define HAL_kInvalidHandle
Definition Types.h:15
WPILib Hardware Abstraction Layer (HAL) namespace.
Definition Types.hpp:9
HAL Entry Value.
Definition Value.h:26