mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
[sim] Provide method to set the runtime type (#2539)
This is needed for extensions that effectively access real hardware and want to disable the "simulation" parts of user code.
This commit is contained in:
@@ -22,6 +22,8 @@
|
||||
|
||||
using namespace hal;
|
||||
|
||||
static HAL_RuntimeType runtimeType{HAL_Mock};
|
||||
|
||||
namespace hal {
|
||||
namespace init {
|
||||
void InitializeHAL() {
|
||||
@@ -215,7 +217,9 @@ const char* HAL_GetErrorMessage(int32_t code) {
|
||||
}
|
||||
}
|
||||
|
||||
HAL_RuntimeType HAL_GetRuntimeType(void) { return HAL_Mock; }
|
||||
HAL_RuntimeType HAL_GetRuntimeType(void) { return runtimeType; }
|
||||
|
||||
void HALSIM_SetRuntimeType(HAL_RuntimeType type) { runtimeType = type; }
|
||||
|
||||
int32_t HAL_GetFPGAVersion(int32_t* status) {
|
||||
return 2018; // Automatically script this at some point
|
||||
|
||||
@@ -108,6 +108,18 @@ jmethodID GetSpiReadAutoReceiveBufferCallback() {
|
||||
} // namespace hal
|
||||
|
||||
extern "C" {
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_sim_mockdata_SimulatorJNI
|
||||
* Method: setRuntimeType
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_sim_mockdata_SimulatorJNI_setRuntimeType
|
||||
(JNIEnv*, jclass, jint type)
|
||||
{
|
||||
HALSIM_SetRuntimeType(static_cast<HAL_RuntimeType>(type));
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_sim_mockdata_SimulatorJNI
|
||||
* Method: waitForProgramStart
|
||||
|
||||
Reference in New Issue
Block a user