WPILibC++ 2023.4.3-108-ge5452e3
hal::SimInt Class Reference

C++ wrapper around a HAL simulator int value handle. More...

#include <hal/SimDevice.h>

Inheritance diagram for hal::SimInt:
hal::SimValue

Public Member Functions

 SimInt ()=default
 Default constructor that results in an "empty" object that is false in a boolean context. More...
 
 SimInt (HAL_SimValueHandle val)
 Wraps a simulated value handle as returned by HAL_CreateSimValueInt(). More...
 
int32_t Get () const
 Gets the simulated value. More...
 
void Set (int32_t value)
 Sets the simulated value. More...
 
void Reset ()
 Resets the simulated value to 0. More...
 
- Public Member Functions inherited from hal::SimValue
 SimValue ()=default
 Default constructor that results in an "empty" object that is false in a boolean context. More...
 
 SimValue (HAL_SimValueHandle val)
 Wraps a simulated value handle as returned by HAL_CreateSimValue(). More...
 
 operator bool () const
 Determine if handle is empty. More...
 
 operator HAL_SimValueHandle () const
 Get the internal device handle. More...
 
HAL_Value GetValue () const
 Gets the simulated value. More...
 
void SetValue (const HAL_Value &value)
 Sets the simulated value. More...
 

Additional Inherited Members

- Protected Attributes inherited from hal::SimValue
HAL_SimValueHandle m_handle = HAL_kInvalidHandle
 

Detailed Description

C++ wrapper around a HAL simulator int value handle.

Constructor & Destructor Documentation

◆ SimInt() [1/2]

hal::SimInt::SimInt ( )
default

Default constructor that results in an "empty" object that is false in a boolean context.

◆ SimInt() [2/2]

hal::SimInt::SimInt ( HAL_SimValueHandle  val)
inline

Wraps a simulated value handle as returned by HAL_CreateSimValueInt().

Parameters
valsimulated value handle

Member Function Documentation

◆ Get()

int32_t hal::SimInt::Get ( ) const
inline

Gets the simulated value.

Returns
The current value

◆ Reset()

void hal::SimInt::Reset ( )
inline

Resets the simulated value to 0.

Use this instead of Set(0) for resetting incremental sensor values like encoder counts or gyro accumulated angle to ensure correct behavior in a distributed system (e.g. WebSockets).

◆ Set()

void hal::SimInt::Set ( int32_t  value)
inline

Sets the simulated value.

Parameters
valuethe value to set

The documentation for this class was generated from the following file: