WPILibC++ 2024.3.2
SimDataValue.h File Reference
#include <memory>
#include <wpi/Compiler.h>
#include <wpi/UidVector.h>
#include <wpi/spinlock.h>
#include "hal/simulation/NotifyListener.h"
#include "hal/simulation/SimCallbackRegistry.h"

Go to the source code of this file.

Classes

class  hal::impl::SimDataValueBase< T, MakeValue >
 
class  hal::SimDataValue< T, MakeValue, GetName, GetDefault >
 Simulation data value wrapper. More...
 

Namespaces

namespace  hal
 WPILib Hardware Abstraction Layer (HAL) namespace.
 
namespace  hal::impl
 

Macros

#define HAL_SIMDATAVALUE_DEFINE_NAME(NAME)
 Define a name functor for use with SimDataValue. More...
 
#define HAL_SIMDATAVALUE_DEFINE_CAPI(TYPE, NS, CAPINAME, DATA, LOWERNAME)
 Define a standard C API for simulation data. More...
 
#define HAL_SIMDATAVALUE_DEFINE_CAPI_CHANNEL(TYPE, NS, CAPINAME, DATA, LOWERNAME)
 Define a standard C API for simulation data (channel variant). More...
 
#define HAL_SIMDATAVALUE_DEFINE_CAPI_NOINDEX(TYPE, NS, CAPINAME, DATA, LOWERNAME)
 Define a standard C API for simulation data (no index variant). More...
 
#define HAL_SIMDATAVALUE_STUB_CAPI(TYPE, NS, CAPINAME, RETURN)
 Define a stub standard C API for simulation data. More...
 
#define HAL_SIMDATAVALUE_STUB_CAPI_CHANNEL(TYPE, NS, CAPINAME, RETURN)
 Define a stub standard C API for simulation data (channel variant). More...
 
#define HAL_SIMDATAVALUE_STUB_CAPI_NOINDEX(TYPE, NS, CAPINAME, RETURN)
 Define a stub standard C API for simulation data (no index variant). More...
 

Macro Definition Documentation

◆ HAL_SIMDATAVALUE_DEFINE_CAPI

#define HAL_SIMDATAVALUE_DEFINE_CAPI (   TYPE,
  NS,
  CAPINAME,
  DATA,
  LOWERNAME 
)
Value:
int32_t NS##_Register##CAPINAME##Callback( \
int32_t index, HAL_NotifyCallback callback, void* param, \
HAL_Bool initialNotify) { \
return DATA[index].LOWERNAME.RegisterCallback(callback, param, \
initialNotify); \
} \
\
void NS##_Cancel##CAPINAME##Callback(int32_t index, int32_t uid) { \
DATA[index].LOWERNAME.CancelCallback(uid); \
} \
\
TYPE NS##_Get##CAPINAME(int32_t index) { \
return DATA[index].LOWERNAME; \
} \
\
void NS##_Set##CAPINAME(int32_t index, TYPE LOWERNAME) { \
DATA[index].LOWERNAME = LOWERNAME; \
}
void(* HAL_NotifyCallback)(const char *name, void *param, const struct HAL_Value *value)
Definition: NotifyListener.h:9
int32_t HAL_Bool
Definition: Types.h:73

Define a standard C API for simulation data.

Functions defined:

  • int32 NS_RegisterCAPINAMECallback( int32_t index, HAL_NotifyCallback callback, void* param, HAL_Bool initialNotify)
  • void NS_CancelCAPINAMECallback(int32_t index, int32_t uid)
  • TYPE NS_GetCAPINAME(int32_t index)
  • void NS_SetCAPINAME(int32_t index, TYPE value)
Parameters
TYPEthe underlying value type (e.g. double)
NSthe "namespace" (e.g. HALSIM)
CAPINAMEthe C API name (usually first letter capitalized)
DATAthe backing data array
LOWERNAMEthe lowercase name of the backing data variable

◆ HAL_SIMDATAVALUE_DEFINE_CAPI_CHANNEL

#define HAL_SIMDATAVALUE_DEFINE_CAPI_CHANNEL (   TYPE,
  NS,
  CAPINAME,
  DATA,
  LOWERNAME 
)
Value:
int32_t NS##_Register##CAPINAME##Callback( \
int32_t index, int32_t channel, HAL_NotifyCallback callback, \
void* param, HAL_Bool initialNotify) { \
return DATA[index].LOWERNAME[channel].RegisterCallback(callback, param, \
initialNotify); \
} \
\
void NS##_Cancel##CAPINAME##Callback(int32_t index, int32_t channel, \
int32_t uid) { \
DATA[index].LOWERNAME[channel].CancelCallback(uid); \
} \
\
TYPE NS##_Get##CAPINAME(int32_t index, int32_t channel) { \
return DATA[index].LOWERNAME[channel]; \
} \
\
void NS##_Set##CAPINAME(int32_t index, int32_t channel, TYPE LOWERNAME) { \
DATA[index].LOWERNAME[channel] = LOWERNAME; \
}

Define a standard C API for simulation data (channel variant).

Functions defined:

  • int32 NS_RegisterCAPINAMECallback( int32_t index, int32_t channel, HAL_NotifyCallback callback, void* param, HAL_Bool initialNotify)
  • void NS_CancelCAPINAMECallback(int32_t index, int32_t channel, int32_t uid)
  • TYPE NS_GetCAPINAME(int32_t index, int32_t channel)
  • void NS_SetCAPINAME(int32_t index, int32_t channel, TYPE value)
Parameters
TYPEthe underlying value type (e.g. double)
NSthe "namespace" (e.g. HALSIM)
CAPINAMEthe C API name (usually first letter capitalized)
DATAthe backing data array
LOWERNAMEthe lowercase name of the backing data variable array

◆ HAL_SIMDATAVALUE_DEFINE_CAPI_NOINDEX

#define HAL_SIMDATAVALUE_DEFINE_CAPI_NOINDEX (   TYPE,
  NS,
  CAPINAME,
  DATA,
  LOWERNAME 
)
Value:
int32_t NS##_Register##CAPINAME##Callback( \
HAL_NotifyCallback callback, void* param, HAL_Bool initialNotify) { \
return DATA->LOWERNAME.RegisterCallback(callback, param, initialNotify); \
} \
\
void NS##_Cancel##CAPINAME##Callback(int32_t uid) { \
DATA->LOWERNAME.CancelCallback(uid); \
} \
\
TYPE NS##_Get##CAPINAME(void) { \
return DATA->LOWERNAME; \
} \
\
void NS##_Set##CAPINAME(TYPE LOWERNAME) { \
DATA->LOWERNAME = LOWERNAME; \
}

Define a standard C API for simulation data (no index variant).

Functions defined:

  • int32 NS_RegisterCAPINAMECallback( HAL_NotifyCallback callback, void* param, HAL_Bool initialNotify)
  • void NS_CancelCAPINAMECallback(int32_t uid)
  • TYPE NS_GetCAPINAME(void)
  • void NS_SetCAPINAME(TYPE value)
Parameters
TYPEthe underlying value type (e.g. double)
NSthe "namespace" (e.g. HALSIM)
CAPINAMEthe C API name (usually first letter capitalized)
DATAthe backing data pointer
LOWERNAMEthe lowercase name of the backing data variable

◆ HAL_SIMDATAVALUE_DEFINE_NAME

#define HAL_SIMDATAVALUE_DEFINE_NAME (   NAME)
Value:
static LLVM_ATTRIBUTE_ALWAYS_INLINE constexpr const char* \
Get##NAME##Name() { \
return #NAME; \
}
#define LLVM_ATTRIBUTE_ALWAYS_INLINE
LLVM_ATTRIBUTE_ALWAYS_INLINE - On compilers where we have a directive to do so, mark a method "always...
Definition: Compiler.h:258

Define a name functor for use with SimDataValue.

This creates a function named GetNAMEName() that returns "NAME".

Parameters
NAMEthe name to return

◆ HAL_SIMDATAVALUE_STUB_CAPI

#define HAL_SIMDATAVALUE_STUB_CAPI (   TYPE,
  NS,
  CAPINAME,
  RETURN 
)
Value:
int32_t NS##_Register##CAPINAME##Callback( \
int32_t index, HAL_NotifyCallback callback, void* param, \
HAL_Bool initialNotify) { \
return 0; \
} \
\
void NS##_Cancel##CAPINAME##Callback(int32_t index, int32_t uid) {} \
\
TYPE NS##_Get##CAPINAME(int32_t index) { \
return RETURN; \
} \
\
void NS##_Set##CAPINAME(int32_t index, TYPE) {}

Define a stub standard C API for simulation data.

Functions defined:

  • int32 NS_RegisterCAPINAMECallback( int32_t index, HAL_NotifyCallback callback, void* param, HAL_Bool initialNotify)
  • void NS_CancelCAPINAMECallback(int32_t index, int32_t uid)
  • TYPE NS_GetCAPINAME(int32_t index)
  • void NS_SetCAPINAME(int32_t index, TYPE value)
Parameters
TYPEthe underlying value type (e.g. double)
NSthe "namespace" (e.g. HALSIM)
CAPINAMEthe C API name (usually first letter capitalized)
RETURNwhat to return from the Get function

◆ HAL_SIMDATAVALUE_STUB_CAPI_CHANNEL

#define HAL_SIMDATAVALUE_STUB_CAPI_CHANNEL (   TYPE,
  NS,
  CAPINAME,
  RETURN 
)
Value:
int32_t NS##_Register##CAPINAME##Callback( \
int32_t index, int32_t channel, HAL_NotifyCallback callback, \
void* param, HAL_Bool initialNotify) { \
return 0; \
} \
\
void NS##_Cancel##CAPINAME##Callback(int32_t index, int32_t channel, \
int32_t uid) {} \
\
TYPE NS##_Get##CAPINAME(int32_t index, int32_t channel) { \
return RETURN; \
} \
\
void NS##_Set##CAPINAME(int32_t index, int32_t channel, TYPE) {}

Define a stub standard C API for simulation data (channel variant).

Functions defined:

  • int32 NS_RegisterCAPINAMECallback( int32_t index, int32_t channel, HAL_NotifyCallback callback, void* param, HAL_Bool initialNotify)
  • void NS_CancelCAPINAMECallback(int32_t index, int32_t channel, int32_t uid)
  • TYPE NS_GetCAPINAME(int32_t index, int32_t channel)
  • void NS_SetCAPINAME(int32_t index, int32_t channel, TYPE value)
Parameters
TYPEthe underlying value type (e.g. double)
NSthe "namespace" (e.g. HALSIM)
CAPINAMEthe C API name (usually first letter capitalized)
RETURNwhat to return from the Get function

◆ HAL_SIMDATAVALUE_STUB_CAPI_NOINDEX

#define HAL_SIMDATAVALUE_STUB_CAPI_NOINDEX (   TYPE,
  NS,
  CAPINAME,
  RETURN 
)
Value:
int32_t NS##_Register##CAPINAME##Callback( \
HAL_NotifyCallback callback, void* param, HAL_Bool initialNotify) { \
return 0; \
} \
\
void NS##_Cancel##CAPINAME##Callback(int32_t uid) {} \
\
TYPE NS##_Get##CAPINAME(void) { \
return RETURN; \
} \
\
void NS##_Set##CAPINAME(TYPE) {}

Define a stub standard C API for simulation data (no index variant).

Functions defined:

  • int32 NS_RegisterCAPINAMECallback( HAL_NotifyCallback callback, void* param, HAL_Bool initialNotify)
  • void NS_CancelCAPINAMECallback(int32_t uid)
  • TYPE NS_GetCAPINAME(void)
  • void NS_SetCAPINAME(TYPE value)
Parameters
TYPEthe underlying value type (e.g. double)
NSthe "namespace" (e.g. HALSIM)
CAPINAMEthe C API name (usually first letter capitalized)
RETURNwhat to return from the Get function