mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-30 02:31:44 +00:00
[hal] Add handle constructor and name getters for sim devices (#4925)
This commit is contained in:
@@ -12,6 +12,10 @@ HAL_SimDeviceHandle HAL_CreateSimDevice(const char* name) {
|
||||
|
||||
void HAL_FreeSimDevice(HAL_SimDeviceHandle handle) {}
|
||||
|
||||
const char* HAL_GetSimDeviceName(HAL_SimDeviceHandle handle) {
|
||||
return "";
|
||||
}
|
||||
|
||||
HAL_SimValueHandle HAL_CreateSimValue(HAL_SimDeviceHandle device,
|
||||
const char* name, int32_t direction,
|
||||
const struct HAL_Value* initialValue) {
|
||||
|
||||
@@ -63,6 +63,18 @@ Java_edu_wpi_first_hal_SimDeviceJNI_freeSimDevice
|
||||
HAL_FreeSimDevice(handle);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_SimDeviceJNI
|
||||
* Method: getSimDeviceName
|
||||
* Signature: (I)Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_edu_wpi_first_hal_SimDeviceJNI_getSimDeviceName
|
||||
(JNIEnv* env, jclass, jint handle)
|
||||
{
|
||||
return MakeJString(env, HAL_GetSimDeviceName(handle));
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_SimDeviceJNI
|
||||
* Method: createSimValueNative
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#ifdef __cplusplus
|
||||
#include <initializer_list>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#endif
|
||||
|
||||
#include "hal/Types.h"
|
||||
@@ -66,6 +67,14 @@ HAL_SimDeviceHandle HAL_CreateSimDevice(const char* name);
|
||||
*/
|
||||
void HAL_FreeSimDevice(HAL_SimDeviceHandle handle);
|
||||
|
||||
/**
|
||||
* Get the name of a simulated device
|
||||
*
|
||||
* @param handle simulated device handle
|
||||
* @return name of the simulated device
|
||||
*/
|
||||
const char* HAL_GetSimDeviceName(HAL_SimDeviceHandle handle);
|
||||
|
||||
/**
|
||||
* Creates a value on a simulated device.
|
||||
*
|
||||
@@ -731,6 +740,15 @@ class SimDevice {
|
||||
*/
|
||||
operator HAL_SimDeviceHandle() const { return m_handle; } // NOLINT
|
||||
|
||||
/**
|
||||
* Get the name of the simulated device.
|
||||
*
|
||||
* @return name
|
||||
*/
|
||||
std::string GetName() const {
|
||||
return std::string(HAL_GetSimDeviceName(m_handle));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a value on the simulated device.
|
||||
*
|
||||
|
||||
@@ -26,6 +26,10 @@ void HAL_FreeSimDevice(HAL_SimDeviceHandle handle) {
|
||||
SimSimDeviceData->FreeDevice(handle);
|
||||
}
|
||||
|
||||
const char* HAL_GetSimDeviceName(HAL_SimDeviceHandle handle) {
|
||||
return SimSimDeviceData->GetDeviceName(handle);
|
||||
}
|
||||
|
||||
HAL_SimValueHandle HAL_CreateSimValue(HAL_SimDeviceHandle device,
|
||||
const char* name, int32_t direction,
|
||||
const struct HAL_Value* initialValue) {
|
||||
|
||||
Reference in New Issue
Block a user