WPILibC++ 2027.0.0-alpha-5
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_INVALID_HANDLE; }
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_INVALID_HANDLE;
363 }
364
366 m_handle = rhs.m_handle;
367 rhs.m_handle = HAL_INVALID_HANDLE;
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_INVALID_HANDLE; }
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, Direction direction,
407 const HAL_Value& initialValue) {
408 return HAL_CreateSimValue(m_handle, name, static_cast<int32_t>(direction),
409 &initialValue);
410 }
411
412 /**
413 * Creates an int value on the simulated device.
414 *
415 * If not in simulation, results in an "empty" object that evaluates to false
416 * in a boolean context.
417 *
418 * @param name value name
419 * @param direction input/output/bidir (from perspective of user code)
420 * @param initialValue initial value
421 * @return simulated double value object
422 */
423 SimInt CreateInt(const char* name, Direction direction,
424 int32_t initialValue) {
426 static_cast<int32_t>(direction), initialValue);
427 }
428
429 /**
430 * Creates a long value on the simulated device.
431 *
432 * If not in simulation, results in an "empty" object that evaluates to false
433 * in a boolean context.
434 *
435 * @param name value name
436 * @param direction input/output/bidir (from perspective of user code)
437 * @param initialValue initial value
438 * @return simulated double value object
439 */
440 SimLong CreateLong(const char* name, Direction direction,
441 int64_t initialValue) {
443 m_handle, name, static_cast<int32_t>(direction), initialValue);
444 }
445
446 /**
447 * Creates a double value on the simulated device.
448 *
449 * If not in simulation, results in an "empty" object that evaluates to false
450 * in a boolean context.
451 *
452 * @param name value name
453 * @param direction input/output/bidir (from perspective of user code)
454 * @param initialValue initial value
455 * @return simulated double value object
456 */
457 SimDouble CreateDouble(const char* name, Direction direction,
458 double initialValue) {
460 m_handle, name, static_cast<int32_t>(direction), initialValue);
461 }
462
463 /**
464 * Creates an enumerated value on the simulated device.
465 *
466 * Enumerated values are always in the range 0 to numOptions-1.
467 *
468 * If not in simulation, results in an "empty" object that evaluates to false
469 * in a boolean context.
470 *
471 * @param name value name
472 * @param direction input/output/bidir (from perspective of user code)
473 * @param options array of option descriptions
474 * @param initialValue initial value (selection)
475 * @return simulated enum value object
476 */
477 SimEnum CreateEnum(const char* name, Direction direction,
478 std::initializer_list<const char*> options,
479 int32_t initialValue) {
481 m_handle, name, static_cast<int32_t>(direction), options.size(),
482 const_cast<const char**>(options.begin()), initialValue);
483 }
484
485 /**
486 * Creates an enumerated value on the simulated device.
487 *
488 * Enumerated values are always in the range 0 to numOptions-1.
489 *
490 * If not in simulation, results in an "empty" object that evaluates to false
491 * in a boolean context.
492 *
493 * @param name value name
494 * @param direction input/output/bidir (from perspective of user code)
495 * @param options array of option descriptions
496 * @param initialValue initial value (selection)
497 * @return simulated enum value object
498 */
499 SimEnum CreateEnum(const char* name, Direction direction,
500 std::span<const char* const> options,
501 int32_t initialValue) {
503 m_handle, name, static_cast<int32_t>(direction), options.size(),
504 const_cast<const char**>(options.data()), initialValue);
505 }
506
507 /**
508 * Creates an enumerated value on the simulated device with double values.
509 *
510 * Enumerated values are always in the range 0 to numOptions-1.
511 *
512 * If not in simulation, results in an "empty" object that evaluates to false
513 * in a boolean context.
514 *
515 * @param name value name
516 * @param direction input/output/bidir (from perspective of user code)
517 * @param options array of option descriptions
518 * @param optionValues array of option values (must be the same size as
519 * options)
520 * @param initialValue initial value (selection)
521 * @return simulated enum value object
522 */
523 SimEnum CreateEnumDouble(const char* name, Direction direction,
524 std::initializer_list<const char*> options,
525 std::initializer_list<double> optionValues,
526 int32_t initialValue) {
527 if (options.size() != optionValues.size()) {
528 return {};
529 }
531 m_handle, name, static_cast<int32_t>(direction), options.size(),
532 const_cast<const char**>(options.begin()), optionValues.begin(),
533 initialValue);
534 }
535
536 /**
537 * Creates an enumerated value on the simulated device with double values.
538 *
539 * Enumerated values are always in the range 0 to numOptions-1.
540 *
541 * If not in simulation, results in an "empty" object that evaluates to false
542 * in a boolean context.
543 *
544 * @param name value name
545 * @param direction input/output/bidir (from perspective of user code)
546 * @param options array of option descriptions
547 * @param optionValues array of option values (must be the same size as
548 * options)
549 * @param initialValue initial value (selection)
550 * @return simulated enum value object
551 */
552 SimEnum CreateEnumDouble(const char* name, Direction direction,
553 std::span<const char* const> options,
554 std::span<const double> optionValues,
555 int32_t initialValue) {
556 if (options.size() != optionValues.size()) {
557 return {};
558 }
560 m_handle, name, static_cast<int32_t>(direction), options.size(),
561 const_cast<const char**>(options.data()), optionValues.data(),
562 initialValue);
563 }
564
565 /**
566 * Creates a boolean value on the simulated device.
567 *
568 * If not in simulation, results in an "empty" object that evaluates to false
569 * in a boolean context.
570 *
571 * @param name value name
572 * @param direction input/output/bidir (from perspective of user code)
573 * @param initialValue initial value
574 * @return simulated boolean value object
575 */
576 SimBoolean CreateBoolean(const char* name, Direction direction,
577 bool initialValue) {
579 m_handle, name, static_cast<int32_t>(direction), initialValue);
580 }
581
582 protected:
584};
585
586} // 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
SimDevice(SimDevice &&rhs)
Definition SimDevice.hpp:361
SimEnum CreateEnum(const char *name, Direction direction, std::span< const char *const > options, int32_t initialValue)
Creates an enumerated value on the simulated device.
Definition SimDevice.hpp:499
SimBoolean CreateBoolean(const char *name, Direction direction, bool initialValue)
Creates a boolean value on the simulated device.
Definition SimDevice.hpp:576
SimDevice(const SimDevice &)=delete
SimDevice(const char *name, int index, int channel)
Creates a simulated device.
SimDevice & operator=(const SimDevice &)=delete
HAL_SimDeviceHandle m_handle
Definition SimDevice.hpp:583
SimDevice & operator=(SimDevice &&rhs)
Definition SimDevice.hpp:365
SimDevice(const char *name)
Creates a simulated device.
Definition SimDevice.hpp:311
SimDouble CreateDouble(const char *name, Direction direction, double initialValue)
Creates a double value on the simulated device.
Definition SimDevice.hpp:457
SimDevice()=default
Default constructor that results in an "empty" object that is false in a boolean context.
SimEnum CreateEnumDouble(const char *name, Direction 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:552
~SimDevice()
Definition SimDevice.hpp:352
SimValue CreateValue(const char *name, Direction direction, const HAL_Value &initialValue)
Creates a value on the simulated device.
Definition SimDevice.hpp:406
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
@ OUTPUT
Definition SimDevice.hpp:285
@ INPUT
Definition SimDevice.hpp:284
@ BIDIR
Definition SimDevice.hpp:286
std::string GetName() const
Get the name of the simulated device.
Definition SimDevice.hpp:391
SimEnum CreateEnum(const char *name, Direction direction, std::initializer_list< const char * > options, int32_t initialValue)
Creates an enumerated value on the simulated device.
Definition SimDevice.hpp:477
SimLong CreateLong(const char *name, Direction direction, int64_t initialValue)
Creates a long value on the simulated device.
Definition SimDevice.hpp:440
SimInt CreateInt(const char *name, Direction direction, int32_t initialValue)
Creates an int value on the simulated device.
Definition SimDevice.hpp:423
SimEnum CreateEnumDouble(const char *name, Direction 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:523
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_SIM_VALUE_OUTPUT
output from user code to the simulator
Definition SimDevice.h:29
@ HAL_SIM_VALUE_INPUT
input to user code from the simulator
Definition SimDevice.h:28
@ HAL_SIM_VALUE_BIDIR
bidirectional between user code and simulator
Definition SimDevice.h:30
#define HAL_INVALID_HANDLE
Definition Types.h:15
HAL_Handle HAL_SimDeviceHandle
Definition Types.h:45
HAL_Handle HAL_SimValueHandle
Definition Types.h:47
WPILib Hardware Abstraction Layer (HAL) namespace.
Definition Types.hpp:9
HAL Entry Value.
Definition Value.h:26