diff --git a/hal/CMakeLists.txt b/hal/CMakeLists.txt index e743c0fca5..569eed447d 100644 --- a/hal/CMakeLists.txt +++ b/hal/CMakeLists.txt @@ -37,7 +37,7 @@ set_target_properties(hal PROPERTIES DEBUG_POSTFIX "d") if(USE_EXTERNAL_HAL) include(${EXTERNAL_HAL_FILE}) else() - target_sources(hal PRIVATE ${hal_sim_native_src} ${hal_sim_jni_src}) + target_sources(hal PRIVATE ${hal_sim_native_src}) endif() configure_file(src/generate/FRCUsageReporting.h.in gen/hal/FRCUsageReporting.h) @@ -78,9 +78,7 @@ if (NOT WITHOUT_JAVA) configure_file(src/generate/FRCNetComm.java.in FRCNetComm.java) - file(GLOB - hal_shared_jni_src src/main/native/cpp/jni/*.cpp - hal_sim_jni_src src/main/native/sim/jni/*.cpp) + file(GLOB_RECURSE hal_shared_jni_src src/main/native/cpp/jni/*.cpp) file(GLOB_RECURSE JAVA_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/FRCNetComm.java @@ -103,8 +101,6 @@ if (NOT WITHOUT_JAVA) if(USE_EXTERNAL_HAL) include(${EXTERNAL_HAL_FILE}) - else() - target_sources(haljni PRIVATE ${hal_sim_jni_src}) endif() set_target_properties(haljni PROPERTIES OUTPUT_NAME "wpiHaljni") diff --git a/hal/build.gradle b/hal/build.gradle index 75ee2a8197..e5b5f6cdc1 100644 --- a/hal/build.gradle +++ b/hal/build.gradle @@ -69,33 +69,6 @@ ext { it.tasks.withType(AbstractNativeSourceCompileTask) { it.dependsOn generateUsageReporting } - if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { - it.sources { - athenaJniCpp(CppSourceSet) { - source { - srcDirs = ["${rootDir}/shared/singlelib", "$buildDir/generated/cpp"] - include '**/*.cpp' - } - exportedHeaders { - srcDir 'src/main/native/include' - srcDir generatedHeaders - } - } - } - } else { - it.sources { - simJniCpp(CppSourceSet) { - source { - srcDirs 'src/main/native/sim' - include '**/jni/*.cpp' - } - exportedHeaders { - srcDir 'src/main/native/include' - srcDir generatedHeaders - } - } - } - } } splitSetup = { it.tasks.withType(AbstractNativeSourceCompileTask) { @@ -107,7 +80,6 @@ ext { source { srcDirs = ['src/main/native/athena'] include '**/*.cpp' - exclude '**/jni/*.cpp' } exportedHeaders { srcDir 'src/main/native/include' @@ -121,7 +93,6 @@ ext { source { srcDirs 'src/main/native/sim' include '**/*.cpp' - exclude '**/jni/*.cpp' } exportedHeaders { srcDir 'src/main/native/include' @@ -134,7 +105,6 @@ ext { } apply from: "${rootDir}/shared/jni/setupBuild.gradle" -apply from: 'simjni.gradle' sourceSets.main.java.srcDir "${buildDir}/generated/java/" @@ -150,12 +120,6 @@ cppSourcesZip { from('src/main/native/sim') { into '/sim' } - - from("$buildDir/generated/cpp") { - into '/athena/jni' - } - - dependsOn generateAthenaSimFiles } cppHeadersZip { diff --git a/hal/simjni.gradle b/hal/simjni.gradle deleted file mode 100644 index d2ba22b993..0000000000 --- a/hal/simjni.gradle +++ /dev/null @@ -1,113 +0,0 @@ -def athenaSimJniOutputDir = file("$buildDir/generated/cpp") -def athenaSimJniOutputFile = file("$athenaSimJniOutputDir/simjni.cpp") - -task generateAthenaSimFiles() { - Set dirs = []; - - def createdTask = it - outputs.file athenaSimJniOutputFile - - model { - components { - it.all { component -> - if (component in getJniSpecClass()) { - component.binaries.all { binary -> - if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { - binary.tasks.withType(CppCompile) { - it.dependsOn createdTask - } - component.jniHeaderLocations.each { - dependsOn it.key - createdTask.inputs.dir it.value - dirs << it.value - } - } - } - } - } - } - } - - doLast { - def symbolList = [] - dirs.each { - def tree = fileTree(dir: it) - tree.each { file -> - if (!file.name.contains('edu_wpi_first_hal_simulation_')) { - return - } - boolean reading = false - String currentLine = '' - file.eachLine { line -> - if (line.trim()) { - if (line.contains(';') && reading) { - currentLine += line.trim() - reading = false - symbolList << currentLine - currentLine = '' - } - if (line.startsWith("JNIEXPORT ") && line.contains('JNICALL')) { - if (line.contains(';')) { - symbolList << line - currentLine = '' - reading = false - } else { - reading = true - currentLine += line.trim() - } - - } - } - } - } - } - athenaSimJniOutputDir.mkdirs() - athenaSimJniOutputFile.withWriter { out -> - out.println '#include ' - out.println ''' -static JavaVM* jvm = nullptr; - -namespace hal { -namespace sim { -jint SimOnLoad(JavaVM* vm, void* reserved) { - jvm = vm; - - JNIEnv *env; - if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) - return JNI_ERR; - - return JNI_VERSION_1_6; -} - -void SimOnUnload(JavaVM * vm, void* reserved) { - JNIEnv *env; - if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) - return; - jvm = nullptr; -} -} -} - -static void ThrowSimException(JNIEnv* env) { - -} -''' - out.println 'extern "C" {' - symbolList.each { - def symbol = it.replace('JNIEnv *', 'JNIEnv * env') - if (symbol.contains('JNIEXPORT void')) { - symbol = symbol.replace(';', ''' { - ThrowSimException(env); -}''') - } else { - symbol = symbol.replace(';', ''' { - ThrowSimException(env); - return 0; -}''') - } - out.println symbol - } - out.println '}' - } - } -} diff --git a/hal/src/main/native/athena/mockdata/AccelerometerData.cpp b/hal/src/main/native/athena/mockdata/AccelerometerData.cpp new file mode 100644 index 0000000000..2baaf78e4e --- /dev/null +++ b/hal/src/main/native/athena/mockdata/AccelerometerData.cpp @@ -0,0 +1,28 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#include "hal/simulation/AccelerometerData.h" + +#include "hal/simulation/SimDataValue.h" + +extern "C" { +void HALSIM_ResetAccelerometerData(int32_t index) {} + +#define DEFINE_CAPI(TYPE, CAPINAME, RETURN) \ + HAL_SIMDATAVALUE_STUB_CAPI(TYPE, HALSIM, Accelerometer##CAPINAME, RETURN) + +DEFINE_CAPI(HAL_Bool, Active, false) +DEFINE_CAPI(HAL_AccelerometerRange, Range, HAL_AccelerometerRange_k2G) +DEFINE_CAPI(double, X, 0) +DEFINE_CAPI(double, Y, 0) +DEFINE_CAPI(double, Z, 0) + +void HALSIM_RegisterAccelerometerAllCallbacks(int32_t index, + HAL_NotifyCallback callback, + void* param, + HAL_Bool initialNotify) {} +} // extern "C" diff --git a/hal/src/main/native/athena/mockdata/AddressableLEDData.cpp b/hal/src/main/native/athena/mockdata/AddressableLEDData.cpp new file mode 100644 index 0000000000..d7187892dd --- /dev/null +++ b/hal/src/main/native/athena/mockdata/AddressableLEDData.cpp @@ -0,0 +1,45 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#include "hal/simulation/AddressableLEDData.h" + +#include "hal/simulation/SimDataValue.h" + +extern "C" { + +int32_t HALSIM_FindAddressableLEDForChannel(int32_t channel) { return 0; } + +void HALSIM_ResetAddressableLEDData(int32_t index) {} + +int32_t HALSIM_GetAddressableLEDData(int32_t index, + struct HAL_AddressableLEDData* data) { + return 0; +} + +void HALSIM_SetAddressableLEDData(int32_t index, + const struct HAL_AddressableLEDData* data, + int32_t length) {} + +#define DEFINE_CAPI(TYPE, CAPINAME, RETURN) \ + HAL_SIMDATAVALUE_STUB_CAPI(TYPE, HALSIM, AddressableLED##CAPINAME, RETURN) + +DEFINE_CAPI(HAL_Bool, Initialized, false) +DEFINE_CAPI(int32_t, OutputPort, 0) +DEFINE_CAPI(int32_t, Length, 0) +DEFINE_CAPI(HAL_Bool, Running, false) + +#undef DEFINE_CAPI +#define DEFINE_CAPI(TYPE, CAPINAME, RETURN) \ + HAL_SIMCALLBACKREGISTRY_STUB_CAPI(TYPE, HALSIM, AddressableLED##CAPINAME) + +DEFINE_CAPI(HAL_ConstBufferCallback, Data, data) + +void HALSIM_RegisterAddressableLEDAllCallbacks(int32_t index, + HAL_NotifyCallback callback, + void* param, + HAL_Bool initialNotify) {} +} // extern "C" diff --git a/hal/src/main/native/athena/mockdata/AnalogGyroData.cpp b/hal/src/main/native/athena/mockdata/AnalogGyroData.cpp new file mode 100644 index 0000000000..d91ce27462 --- /dev/null +++ b/hal/src/main/native/athena/mockdata/AnalogGyroData.cpp @@ -0,0 +1,26 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#include "hal/simulation/AnalogGyroData.h" + +#include "hal/simulation/SimDataValue.h" + +extern "C" { +void HALSIM_ResetAnalogGyroData(int32_t index) {} + +#define DEFINE_CAPI(TYPE, CAPINAME, RETURN) \ + HAL_SIMDATAVALUE_STUB_CAPI(TYPE, HALSIM, AnalogGyro##CAPINAME, RETURN) + +DEFINE_CAPI(double, Angle, 0) +DEFINE_CAPI(double, Rate, 0) +DEFINE_CAPI(HAL_Bool, Initialized, false) + +void HALSIM_RegisterAnalogGyroAllCallbacks(int32_t index, + HAL_NotifyCallback callback, + void* param, + HAL_Bool initialNotify) {} +} // extern "C" diff --git a/hal/src/main/native/athena/mockdata/AnalogInData.cpp b/hal/src/main/native/athena/mockdata/AnalogInData.cpp new file mode 100644 index 0000000000..428853896d --- /dev/null +++ b/hal/src/main/native/athena/mockdata/AnalogInData.cpp @@ -0,0 +1,33 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#include "hal/simulation/AnalogInData.h" + +#include "hal/simulation/SimDataValue.h" + +extern "C" { +void HALSIM_ResetAnalogInData(int32_t index) {} + +HAL_SimDeviceHandle HALSIM_GetAnalogInSimDevice(int32_t index) { return 0; } + +#define DEFINE_CAPI(TYPE, CAPINAME, RETURN) \ + HAL_SIMDATAVALUE_STUB_CAPI(TYPE, HALSIM, AnalogIn##CAPINAME, RETURN) + +DEFINE_CAPI(HAL_Bool, Initialized, false) +DEFINE_CAPI(int32_t, AverageBits, 0) +DEFINE_CAPI(int32_t, OversampleBits, 0) +DEFINE_CAPI(double, Voltage, 0) +DEFINE_CAPI(HAL_Bool, AccumulatorInitialized, false) +DEFINE_CAPI(int64_t, AccumulatorValue, 0) +DEFINE_CAPI(int64_t, AccumulatorCount, 0) +DEFINE_CAPI(int32_t, AccumulatorCenter, 0) +DEFINE_CAPI(int32_t, AccumulatorDeadband, 0) + +void HALSIM_RegisterAnalogInAllCallbacks(int32_t index, + HAL_NotifyCallback callback, + void* param, HAL_Bool initialNotify) {} +} // extern "C" diff --git a/hal/src/main/native/athena/mockdata/AnalogOutData.cpp b/hal/src/main/native/athena/mockdata/AnalogOutData.cpp new file mode 100644 index 0000000000..f05b0be3e1 --- /dev/null +++ b/hal/src/main/native/athena/mockdata/AnalogOutData.cpp @@ -0,0 +1,25 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#include "hal/simulation/AnalogOutData.h" + +#include "hal/simulation/SimDataValue.h" + +extern "C" { +void HALSIM_ResetAnalogOutData(int32_t index) {} + +#define DEFINE_CAPI(TYPE, CAPINAME, RETURN) \ + HAL_SIMDATAVALUE_STUB_CAPI(TYPE, HALSIM, AnalogOut##CAPINAME, RETURN) + +DEFINE_CAPI(double, Voltage, 0) +DEFINE_CAPI(HAL_Bool, Initialized, false) + +void HALSIM_RegisterAnalogOutAllCallbacks(int32_t index, + HAL_NotifyCallback callback, + void* param, HAL_Bool initialNotify) { +} +} // extern "C" diff --git a/hal/src/main/native/athena/mockdata/AnalogTriggerData.cpp b/hal/src/main/native/athena/mockdata/AnalogTriggerData.cpp new file mode 100644 index 0000000000..7781cf2c73 --- /dev/null +++ b/hal/src/main/native/athena/mockdata/AnalogTriggerData.cpp @@ -0,0 +1,31 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#include "hal/simulation/AnalogTriggerData.h" + +#include "hal/simulation/SimDataValue.h" + +extern "C" { + +int32_t HALSIM_FindAnalogTriggerForChannel(int32_t channel) { return 0; } + +void HALSIM_ResetAnalogTriggerData(int32_t index) {} + +#define DEFINE_CAPI(TYPE, CAPINAME, RETURN) \ + HAL_SIMDATAVALUE_STUB_CAPI(TYPE, HALSIM, AnalogTrigger##CAPINAME, RETURN) + +DEFINE_CAPI(HAL_Bool, Initialized, false) +DEFINE_CAPI(double, TriggerLowerBound, 0) +DEFINE_CAPI(double, TriggerUpperBound, 0) +DEFINE_CAPI(HALSIM_AnalogTriggerMode, TriggerMode, + HALSIM_AnalogTriggerUnassigned) + +void HALSIM_RegisterAnalogTriggerAllCallbacks(int32_t index, + HAL_NotifyCallback callback, + void* param, + HAL_Bool initialNotify) {} +} // extern "C" diff --git a/hal/src/main/native/athena/mockdata/CanDataInternal.cpp b/hal/src/main/native/athena/mockdata/CanDataInternal.cpp new file mode 100644 index 0000000000..69debf0cee --- /dev/null +++ b/hal/src/main/native/athena/mockdata/CanDataInternal.cpp @@ -0,0 +1,25 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#include "hal/simulation/CanData.h" +#include "hal/simulation/SimDataValue.h" + +extern "C" { + +void HALSIM_ResetCanData(void) {} + +#define DEFINE_CAPI(TYPE, CAPINAME) \ + HAL_SIMCALLBACKREGISTRY_STUB_CAPI_NOINDEX(TYPE, HALSIM, Can##CAPINAME) + +DEFINE_CAPI(HAL_CAN_SendMessageCallback, SendMessage) +DEFINE_CAPI(HAL_CAN_ReceiveMessageCallback, ReceiveMessage) +DEFINE_CAPI(HAL_CAN_OpenStreamSessionCallback, OpenStream) +DEFINE_CAPI(HAL_CAN_CloseStreamSessionCallback, CloseStream) +DEFINE_CAPI(HAL_CAN_ReadStreamSessionCallback, ReadStream) +DEFINE_CAPI(HAL_CAN_GetCANStatusCallback, GetCANStatus) + +} // extern "C" diff --git a/hal/src/main/native/athena/mockdata/DIOData.cpp b/hal/src/main/native/athena/mockdata/DIOData.cpp new file mode 100644 index 0000000000..a06855d80c --- /dev/null +++ b/hal/src/main/native/athena/mockdata/DIOData.cpp @@ -0,0 +1,28 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#include "hal/simulation/DIOData.h" + +#include "hal/simulation/SimDataValue.h" + +extern "C" { +void HALSIM_ResetDIOData(int32_t index) {} + +HAL_SimDeviceHandle HALSIM_GetDIOSimDevice(int32_t index) { return 0; } + +#define DEFINE_CAPI(TYPE, CAPINAME, RETURN) \ + HAL_SIMDATAVALUE_STUB_CAPI(TYPE, HALSIM, DIO##CAPINAME, RETURN) + +DEFINE_CAPI(HAL_Bool, Initialized, false) +DEFINE_CAPI(HAL_Bool, Value, false) +DEFINE_CAPI(double, PulseLength, 0) +DEFINE_CAPI(HAL_Bool, IsInput, false) +DEFINE_CAPI(int32_t, FilterIndex, 0) + +void HALSIM_RegisterDIOAllCallbacks(int32_t index, HAL_NotifyCallback callback, + void* param, HAL_Bool initialNotify) {} +} // extern "C" diff --git a/hal/src/main/native/athena/mockdata/DigitalPWMData.cpp b/hal/src/main/native/athena/mockdata/DigitalPWMData.cpp new file mode 100644 index 0000000000..bcbe370def --- /dev/null +++ b/hal/src/main/native/athena/mockdata/DigitalPWMData.cpp @@ -0,0 +1,28 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#include "hal/simulation/DigitalPWMData.h" + +#include "hal/simulation/SimDataValue.h" + +extern "C" { +int32_t HALSIM_FindDigitalPWMForChannel(int32_t channel) { return 0; } + +void HALSIM_ResetDigitalPWMData(int32_t index) {} + +#define DEFINE_CAPI(TYPE, CAPINAME, RETURN) \ + HAL_SIMDATAVALUE_STUB_CAPI(TYPE, HALSIM, DigitalPWM##CAPINAME, RETURN) + +DEFINE_CAPI(HAL_Bool, Initialized, false) +DEFINE_CAPI(double, DutyCycle, 0) +DEFINE_CAPI(int32_t, Pin, 0) + +void HALSIM_RegisterDigitalPWMAllCallbacks(int32_t index, + HAL_NotifyCallback callback, + void* param, + HAL_Bool initialNotify) {} +} // extern "C" diff --git a/hal/src/main/native/athena/mockdata/DriverStationData.cpp b/hal/src/main/native/athena/mockdata/DriverStationData.cpp new file mode 100644 index 0000000000..744fc2b4a7 --- /dev/null +++ b/hal/src/main/native/athena/mockdata/DriverStationData.cpp @@ -0,0 +1,51 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#include "hal/simulation/DriverStationData.h" + +#include "hal/simulation/SimDataValue.h" + +extern "C" { +void HALSIM_ResetDriverStationData(void) {} + +#define DEFINE_CAPI(TYPE, CAPINAME, RETURN) \ + HAL_SIMDATAVALUE_STUB_CAPI_NOINDEX(TYPE, HALSIM, DriverStation##CAPINAME, \ + RETURN) + +DEFINE_CAPI(HAL_Bool, Enabled, false) +DEFINE_CAPI(HAL_Bool, Autonomous, false) +DEFINE_CAPI(HAL_Bool, Test, false) +DEFINE_CAPI(HAL_Bool, EStop, false) +DEFINE_CAPI(HAL_Bool, FmsAttached, false) +DEFINE_CAPI(HAL_Bool, DsAttached, false) +DEFINE_CAPI(HAL_AllianceStationID, AllianceStationId, + HAL_AllianceStationID_kRed1) +DEFINE_CAPI(double, MatchTime, 0) + +void HALSIM_SetJoystickAxes(int32_t joystickNum, const HAL_JoystickAxes* axes) { +} + +void HALSIM_SetJoystickPOVs(int32_t joystickNum, const HAL_JoystickPOVs* povs) { +} + +void HALSIM_SetJoystickButtons(int32_t joystickNum, + const HAL_JoystickButtons* buttons) {} + +void HALSIM_SetJoystickDescriptor(int32_t joystickNum, + const HAL_JoystickDescriptor* descriptor) {} + +void HALSIM_GetJoystickOutputs(int32_t joystickNum, int64_t* outputs, + int32_t* leftRumble, int32_t* rightRumble) {} + +void HALSIM_SetMatchInfo(const HAL_MatchInfo* info) {} + +void HALSIM_NotifyDriverStationNewData(void) {} + +void HALSIM_RegisterDriverStationAllCallbacks(HAL_NotifyCallback callback, + void* param, + HAL_Bool initialNotify) {} +} // extern "C" diff --git a/hal/src/main/native/athena/mockdata/DutyCycleData.cpp b/hal/src/main/native/athena/mockdata/DutyCycleData.cpp new file mode 100644 index 0000000000..8d3cd617cf --- /dev/null +++ b/hal/src/main/native/athena/mockdata/DutyCycleData.cpp @@ -0,0 +1,33 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#include "hal/simulation/DutyCycleData.h" + +#include "hal/simulation/SimDataValue.h" + +extern "C" { +int32_t HALSIM_FindDutyCycleForChannel(int32_t channel) { return 0; } + +void HALSIM_ResetDutyCycleData(int32_t index) {} + +int32_t HALSIM_GetDutyCycleDigitalChannel(int32_t index) { return 0; } + +HAL_SimDeviceHandle HALSIM_GetDutyCycleSimDevice(int32_t index) { return 0; } + +#define DEFINE_CAPI(TYPE, CAPINAME, RETURN) \ + HAL_SIMDATAVALUE_STUB_CAPI(TYPE, HALSIM, DutyCycle##CAPINAME, RETURN) + +DEFINE_CAPI(HAL_Bool, Initialized, false) +DEFINE_CAPI(int32_t, Frequency, 0) +DEFINE_CAPI(double, Output, 0) + +void HALSIM_RegisterDutyCycleAllCallbacks(int32_t index, + HAL_NotifyCallback callback, + void* param, HAL_Bool initialNotify) { +} + +} // extern "C" diff --git a/hal/src/main/native/athena/mockdata/EncoderData.cpp b/hal/src/main/native/athena/mockdata/EncoderData.cpp new file mode 100644 index 0000000000..87a7385593 --- /dev/null +++ b/hal/src/main/native/athena/mockdata/EncoderData.cpp @@ -0,0 +1,47 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#include "hal/simulation/EncoderData.h" + +#include "hal/simulation/SimDataValue.h" + +extern "C" { +int32_t HALSIM_FindEncoderForChannel(int32_t channel) { return 0; } + +void HALSIM_ResetEncoderData(int32_t index) {} + +int32_t HALSIM_GetEncoderDigitalChannelA(int32_t index) { return 0; } + +int32_t HALSIM_GetEncoderDigitalChannelB(int32_t index) { return 0; } + +HAL_SimDeviceHandle HALSIM_GetEncoderSimDevice(int32_t index) { return 0; } + +#define DEFINE_CAPI(TYPE, CAPINAME, RETURN) \ + HAL_SIMDATAVALUE_STUB_CAPI(TYPE, HALSIM, Encoder##CAPINAME, RETURN) + +DEFINE_CAPI(HAL_Bool, Initialized, false) +DEFINE_CAPI(int32_t, Count, 0) +DEFINE_CAPI(double, Period, 0) +DEFINE_CAPI(HAL_Bool, Reset, false) +DEFINE_CAPI(double, MaxPeriod, 0) +DEFINE_CAPI(HAL_Bool, Direction, false) +DEFINE_CAPI(HAL_Bool, ReverseDirection, false) +DEFINE_CAPI(int32_t, SamplesToAverage, 0) +DEFINE_CAPI(double, DistancePerPulse, 0) + +void HALSIM_SetEncoderDistance(int32_t index, double distance) {} + +double HALSIM_GetEncoderDistance(int32_t index) { return 0; } + +void HALSIM_SetEncoderRate(int32_t index, double rate) {} + +double HALSIM_GetEncoderRate(int32_t index) { return 0; } + +void HALSIM_RegisterEncoderAllCallbacks(int32_t index, + HAL_NotifyCallback callback, + void* param, HAL_Bool initialNotify) {} +} // extern "C" diff --git a/hal/src/main/native/athena/mockdata/I2CData.cpp b/hal/src/main/native/athena/mockdata/I2CData.cpp new file mode 100644 index 0000000000..eb6a6c901c --- /dev/null +++ b/hal/src/main/native/athena/mockdata/I2CData.cpp @@ -0,0 +1,27 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#include "hal/simulation/I2CData.h" + +#include "hal/simulation/SimDataValue.h" + +extern "C" { +void HALSIM_ResetI2CData(int32_t index) {} + +#define DEFINE_CAPI(TYPE, CAPINAME, RETURN) \ + HAL_SIMDATAVALUE_STUB_CAPI(TYPE, HALSIM, I2C##CAPINAME, RETURN) + +DEFINE_CAPI(HAL_Bool, Initialized, false) + +#undef DEFINE_CAPI +#define DEFINE_CAPI(TYPE, CAPINAME) \ + HAL_SIMCALLBACKREGISTRY_STUB_CAPI(TYPE, HALSIM, I2C##CAPINAME) + +DEFINE_CAPI(HAL_BufferCallback, Read) +DEFINE_CAPI(HAL_ConstBufferCallback, Write) + +} // extern "C" diff --git a/hal/src/main/native/athena/mockdata/MockHooks.cpp b/hal/src/main/native/athena/mockdata/MockHooks.cpp new file mode 100644 index 0000000000..3302d740d8 --- /dev/null +++ b/hal/src/main/native/athena/mockdata/MockHooks.cpp @@ -0,0 +1,34 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#include "hal/simulation/MockHooks.h" + +extern "C" { + +void HALSIM_SetRuntimeType(HAL_RuntimeType type) {} + +void HALSIM_WaitForProgramStart(void) {} + +void HALSIM_SetProgramStarted(void) {} + +HAL_Bool HALSIM_GetProgramStarted(void) { return false; } + +void HALSIM_RestartTiming(void) {} + +void HALSIM_PauseTiming(void) {} + +void HALSIM_ResumeTiming(void) {} + +HAL_Bool HALSIM_IsTimingPaused(void) { return false; } + +void HALSIM_StepTiming(uint64_t delta) {} + +void HALSIM_SetSendError(HALSIM_SendErrorHandler handler) {} + +void HALSIM_SetSendConsoleLine(HALSIM_SendConsoleLineHandler handler) {} + +} // extern "C" diff --git a/hal/src/main/native/athena/mockdata/NotifierData.cpp b/hal/src/main/native/athena/mockdata/NotifierData.cpp new file mode 100644 index 0000000000..34aa6e7669 --- /dev/null +++ b/hal/src/main/native/athena/mockdata/NotifierData.cpp @@ -0,0 +1,20 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2016-2020 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#include "hal/simulation/NotifierData.h" + +extern "C" { + +uint64_t HALSIM_GetNextNotifierTimeout(void) { return 0; } + +int32_t HALSIM_GetNumNotifiers(void) { return 0; } + +int32_t HALSIM_GetNotifierInfo(struct HALSIM_NotifierInfo* arr, int32_t size) { + return 0; +} + +} // extern "C" diff --git a/hal/src/main/native/athena/mockdata/PCMData.cpp b/hal/src/main/native/athena/mockdata/PCMData.cpp new file mode 100644 index 0000000000..29302cb714 --- /dev/null +++ b/hal/src/main/native/athena/mockdata/PCMData.cpp @@ -0,0 +1,40 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#include "hal/simulation/PCMData.h" + +#include "hal/simulation/SimDataValue.h" + +extern "C" { +void HALSIM_ResetPCMData(int32_t index) {} + +#define DEFINE_CAPI(TYPE, CAPINAME, RETURN) \ + HAL_SIMDATAVALUE_STUB_CAPI(TYPE, HALSIM, PCM##CAPINAME, RETURN) + +HAL_SIMDATAVALUE_STUB_CAPI_CHANNEL(HAL_Bool, HALSIM, PCMSolenoidInitialized, + false) +HAL_SIMDATAVALUE_STUB_CAPI_CHANNEL(HAL_Bool, HALSIM, PCMSolenoidOutput, false) +DEFINE_CAPI(HAL_Bool, CompressorInitialized, false) +DEFINE_CAPI(HAL_Bool, CompressorOn, false) +DEFINE_CAPI(HAL_Bool, ClosedLoopEnabled, false) +DEFINE_CAPI(HAL_Bool, PressureSwitch, false) +DEFINE_CAPI(double, CompressorCurrent, 0) + +void HALSIM_GetPCMAllSolenoids(int32_t index, uint8_t* values) { *values = 0; } + +void HALSIM_SetPCMAllSolenoids(int32_t index, uint8_t values) {} + +void HALSIM_RegisterPCMAllNonSolenoidCallbacks(int32_t index, + HAL_NotifyCallback callback, + void* param, + HAL_Bool initialNotify) {} + +void HALSIM_RegisterPCMAllSolenoidCallbacks(int32_t index, int32_t channel, + HAL_NotifyCallback callback, + void* param, + HAL_Bool initialNotify) {} +} // extern "C" diff --git a/hal/src/main/native/athena/mockdata/PDPData.cpp b/hal/src/main/native/athena/mockdata/PDPData.cpp new file mode 100644 index 0000000000..a28bb817a4 --- /dev/null +++ b/hal/src/main/native/athena/mockdata/PDPData.cpp @@ -0,0 +1,34 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#include "hal/simulation/PDPData.h" + +#include "../PortsInternal.h" +#include "hal/simulation/SimDataValue.h" + +extern "C" { +void HALSIM_ResetPDPData(int32_t index) {} + +#define DEFINE_CAPI(TYPE, CAPINAME, RETURN) \ + HAL_SIMDATAVALUE_STUB_CAPI(TYPE, HALSIM, PDP##CAPINAME, RETURN) + +DEFINE_CAPI(HAL_Bool, Initialized, false) +DEFINE_CAPI(double, Temperature, 0) +DEFINE_CAPI(double, Voltage, 0) +HAL_SIMDATAVALUE_STUB_CAPI_CHANNEL(double, HALSIM, PDPCurrent, 0) + +void HALSIM_GetPDPAllCurrents(int32_t index, double* currents) { + for (int i = 0; i < hal::kNumPDPChannels; i++) currents[i] = 0; +} + +void HALSIM_SetPDPAllCurrents(int32_t index, const double* currents) {} + +void HALSIM_RegisterPDPAllNonCurrentCallbacks(int32_t index, int32_t channel, + HAL_NotifyCallback callback, + void* param, + HAL_Bool initialNotify) {} +} // extern "C" diff --git a/hal/src/main/native/athena/mockdata/PWMData.cpp b/hal/src/main/native/athena/mockdata/PWMData.cpp new file mode 100644 index 0000000000..b9c5691115 --- /dev/null +++ b/hal/src/main/native/athena/mockdata/PWMData.cpp @@ -0,0 +1,27 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#include "hal/simulation/PWMData.h" + +#include "hal/simulation/SimDataValue.h" + +extern "C" { +void HALSIM_ResetPWMData(int32_t index) {} + +#define DEFINE_CAPI(TYPE, CAPINAME, RETURN) \ + HAL_SIMDATAVALUE_STUB_CAPI(TYPE, HALSIM, PWM##CAPINAME, RETURN) + +DEFINE_CAPI(HAL_Bool, Initialized, false) +DEFINE_CAPI(int32_t, RawValue, 0) +DEFINE_CAPI(double, Speed, 0) +DEFINE_CAPI(double, Position, 0) +DEFINE_CAPI(int32_t, PeriodScale, 0) +DEFINE_CAPI(HAL_Bool, ZeroLatch, false) + +void HALSIM_RegisterPWMAllCallbacks(int32_t index, HAL_NotifyCallback callback, + void* param, HAL_Bool initialNotify) {} +} // extern "C" diff --git a/hal/src/main/native/athena/mockdata/RelayData.cpp b/hal/src/main/native/athena/mockdata/RelayData.cpp new file mode 100644 index 0000000000..734bf89604 --- /dev/null +++ b/hal/src/main/native/athena/mockdata/RelayData.cpp @@ -0,0 +1,26 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#include "hal/simulation/RelayData.h" + +#include "hal/simulation/SimDataValue.h" + +extern "C" { +void HALSIM_ResetRelayData(int32_t index) {} + +#define DEFINE_CAPI(TYPE, CAPINAME, RETURN) \ + HAL_SIMDATAVALUE_STUB_CAPI(TYPE, HALSIM, Relay##CAPINAME, RETURN) + +DEFINE_CAPI(HAL_Bool, InitializedForward, false) +DEFINE_CAPI(HAL_Bool, InitializedReverse, false) +DEFINE_CAPI(HAL_Bool, Forward, false) +DEFINE_CAPI(HAL_Bool, Reverse, false) + +void HALSIM_RegisterRelayAllCallbacks(int32_t index, + HAL_NotifyCallback callback, void* param, + HAL_Bool initialNotify) {} +} // extern "C" diff --git a/hal/src/main/native/athena/mockdata/RoboRioData.cpp b/hal/src/main/native/athena/mockdata/RoboRioData.cpp new file mode 100644 index 0000000000..f9e9ca7f1d --- /dev/null +++ b/hal/src/main/native/athena/mockdata/RoboRioData.cpp @@ -0,0 +1,36 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#include "hal/simulation/RoboRioData.h" + +#include "hal/simulation/SimDataValue.h" + +extern "C" { +void HALSIM_ResetRoboRioData(void) {} + +#define DEFINE_CAPI(TYPE, CAPINAME, RETURN) \ + HAL_SIMDATAVALUE_STUB_CAPI_NOINDEX(TYPE, HALSIM, RoboRio##CAPINAME, RETURN) + +DEFINE_CAPI(HAL_Bool, FPGAButton, false) +DEFINE_CAPI(double, VInVoltage, 0) +DEFINE_CAPI(double, VInCurrent, 0) +DEFINE_CAPI(double, UserVoltage6V, 0) +DEFINE_CAPI(double, UserCurrent6V, 0) +DEFINE_CAPI(HAL_Bool, UserActive6V, false) +DEFINE_CAPI(double, UserVoltage5V, 0) +DEFINE_CAPI(double, UserCurrent5V, 0) +DEFINE_CAPI(HAL_Bool, UserActive5V, false) +DEFINE_CAPI(double, UserVoltage3V3, 0) +DEFINE_CAPI(double, UserCurrent3V3, 0) +DEFINE_CAPI(HAL_Bool, UserActive3V3, false) +DEFINE_CAPI(int32_t, UserFaults6V, 0) +DEFINE_CAPI(int32_t, UserFaults5V, 0) +DEFINE_CAPI(int32_t, UserFaults3V3, 0) + +void HALSIM_RegisterRoboRioAllCallbacks(HAL_NotifyCallback callback, + void* param, HAL_Bool initialNotify) {} +} // extern "C" diff --git a/hal/src/main/native/athena/mockdata/SPIAccelerometerData.cpp b/hal/src/main/native/athena/mockdata/SPIAccelerometerData.cpp new file mode 100644 index 0000000000..c3e8ede784 --- /dev/null +++ b/hal/src/main/native/athena/mockdata/SPIAccelerometerData.cpp @@ -0,0 +1,28 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#include "hal/simulation/SPIAccelerometerData.h" + +#include "hal/simulation/SimDataValue.h" + +extern "C" { +void HALSIM_ResetSPIAccelerometerData(int32_t index) {} + +#define DEFINE_CAPI(TYPE, CAPINAME, RETURN) \ + HAL_SIMDATAVALUE_STUB_CAPI(TYPE, HALSIM, SPIAccelerometer##CAPINAME, RETURN) + +DEFINE_CAPI(HAL_Bool, Active, false) +DEFINE_CAPI(int32_t, Range, 0) +DEFINE_CAPI(double, X, 0) +DEFINE_CAPI(double, Y, 0) +DEFINE_CAPI(double, Z, 0) + +void HALSIM_RegisterSPIAccelerometerAllCallbcaks(int32_t index, + HAL_NotifyCallback callback, + void* param, + HAL_Bool initialNotify) {} +} // extern "C" diff --git a/hal/src/main/native/athena/mockdata/SPIData.cpp b/hal/src/main/native/athena/mockdata/SPIData.cpp new file mode 100644 index 0000000000..13cf67c95f --- /dev/null +++ b/hal/src/main/native/athena/mockdata/SPIData.cpp @@ -0,0 +1,28 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#include "hal/simulation/SPIData.h" + +#include "hal/simulation/SimDataValue.h" + +extern "C" { +void HALSIM_ResetSPIData(int32_t index) {} + +#define DEFINE_CAPI(TYPE, CAPINAME, RETURN) \ + HAL_SIMDATAVALUE_STUB_CAPI(TYPE, HALSIM, SPI##CAPINAME, RETURN) + +DEFINE_CAPI(HAL_Bool, Initialized, false) + +#undef DEFINE_CAPI +#define DEFINE_CAPI(TYPE, CAPINAME) \ + HAL_SIMCALLBACKREGISTRY_STUB_CAPI(TYPE, HALSIM, SPI##CAPINAME) + +DEFINE_CAPI(HAL_BufferCallback, Read) +DEFINE_CAPI(HAL_ConstBufferCallback, Write) +DEFINE_CAPI(HAL_SpiReadAutoReceiveBufferCallback, ReadAutoReceivedData) + +} // extern "C" diff --git a/hal/src/main/native/athena/mockdata/SimDeviceData.cpp b/hal/src/main/native/athena/mockdata/SimDeviceData.cpp new file mode 100644 index 0000000000..a31160c85d --- /dev/null +++ b/hal/src/main/native/athena/mockdata/SimDeviceData.cpp @@ -0,0 +1,78 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#include "hal/simulation/SimDeviceData.h" + +#include "hal/simulation/SimDataValue.h" + +extern "C" { + +void HALSIM_SetSimDeviceEnabled(const char* prefix, HAL_Bool enabled) {} + +HAL_Bool HALSIM_IsSimDeviceEnabled(const char* name) { return false; } + +int32_t HALSIM_RegisterSimDeviceCreatedCallback( + const char* prefix, void* param, HALSIM_SimDeviceCallback callback, + HAL_Bool initialNotify) { + return 0; +} + +void HALSIM_CancelSimDeviceCreatedCallback(int32_t uid) {} + +int32_t HALSIM_RegisterSimDeviceFreedCallback( + const char* prefix, void* param, HALSIM_SimDeviceCallback callback) { + return 0; +} + +void HALSIM_CancelSimDeviceFreedCallback(int32_t uid) {} + +HAL_SimDeviceHandle HALSIM_GetSimDeviceHandle(const char* name) { return 0; } + +const char* HALSIM_GetSimDeviceName(HAL_SimDeviceHandle handle) { return ""; } + +HAL_SimDeviceHandle HALSIM_GetSimValueDeviceHandle(HAL_SimValueHandle handle) { + return 0; +} + +void HALSIM_EnumerateSimDevices(const char* prefix, void* param, + HALSIM_SimDeviceCallback callback) {} + +int32_t HALSIM_RegisterSimValueCreatedCallback(HAL_SimDeviceHandle device, + void* param, + HALSIM_SimValueCallback callback, + HAL_Bool initialNotify) { + return 0; +} + +void HALSIM_CancelSimValueCreatedCallback(int32_t uid) {} + +int32_t HALSIM_RegisterSimValueChangedCallback(HAL_SimValueHandle handle, + void* param, + HALSIM_SimValueCallback callback, + HAL_Bool initialNotify) { + return 0; +} + +void HALSIM_CancelSimValueChangedCallback(int32_t uid) {} + +HAL_SimValueHandle HALSIM_GetSimValueHandle(HAL_SimDeviceHandle device, + const char* name) { + return 0; +} + +void HALSIM_EnumerateSimValues(HAL_SimDeviceHandle device, void* param, + HALSIM_SimValueCallback callback) {} + +const char** HALSIM_GetSimValueEnumOptions(HAL_SimValueHandle handle, + int32_t* numOptions) { + *numOptions = 0; + return nullptr; +} + +void HALSIM_ResetSimDeviceData(void) {} + +} // extern "C" diff --git a/hal/src/main/native/sim/jni/AccelerometerDataJNI.cpp b/hal/src/main/native/cpp/jni/simulation/AccelerometerDataJNI.cpp similarity index 100% rename from hal/src/main/native/sim/jni/AccelerometerDataJNI.cpp rename to hal/src/main/native/cpp/jni/simulation/AccelerometerDataJNI.cpp diff --git a/hal/src/main/native/sim/jni/AddressableLEDDataJNI.cpp b/hal/src/main/native/cpp/jni/simulation/AddressableLEDDataJNI.cpp similarity index 100% rename from hal/src/main/native/sim/jni/AddressableLEDDataJNI.cpp rename to hal/src/main/native/cpp/jni/simulation/AddressableLEDDataJNI.cpp diff --git a/hal/src/main/native/sim/jni/AnalogGyroDataJNI.cpp b/hal/src/main/native/cpp/jni/simulation/AnalogGyroDataJNI.cpp similarity index 100% rename from hal/src/main/native/sim/jni/AnalogGyroDataJNI.cpp rename to hal/src/main/native/cpp/jni/simulation/AnalogGyroDataJNI.cpp diff --git a/hal/src/main/native/sim/jni/AnalogInDataJNI.cpp b/hal/src/main/native/cpp/jni/simulation/AnalogInDataJNI.cpp similarity index 100% rename from hal/src/main/native/sim/jni/AnalogInDataJNI.cpp rename to hal/src/main/native/cpp/jni/simulation/AnalogInDataJNI.cpp diff --git a/hal/src/main/native/sim/jni/AnalogOutDataJNI.cpp b/hal/src/main/native/cpp/jni/simulation/AnalogOutDataJNI.cpp similarity index 100% rename from hal/src/main/native/sim/jni/AnalogOutDataJNI.cpp rename to hal/src/main/native/cpp/jni/simulation/AnalogOutDataJNI.cpp diff --git a/hal/src/main/native/sim/jni/AnalogTriggerDataJNI.cpp b/hal/src/main/native/cpp/jni/simulation/AnalogTriggerDataJNI.cpp similarity index 100% rename from hal/src/main/native/sim/jni/AnalogTriggerDataJNI.cpp rename to hal/src/main/native/cpp/jni/simulation/AnalogTriggerDataJNI.cpp diff --git a/hal/src/main/native/sim/jni/BufferCallbackStore.cpp b/hal/src/main/native/cpp/jni/simulation/BufferCallbackStore.cpp similarity index 100% rename from hal/src/main/native/sim/jni/BufferCallbackStore.cpp rename to hal/src/main/native/cpp/jni/simulation/BufferCallbackStore.cpp diff --git a/hal/src/main/native/sim/jni/BufferCallbackStore.h b/hal/src/main/native/cpp/jni/simulation/BufferCallbackStore.h similarity index 100% rename from hal/src/main/native/sim/jni/BufferCallbackStore.h rename to hal/src/main/native/cpp/jni/simulation/BufferCallbackStore.h diff --git a/hal/src/main/native/sim/jni/CallbackStore.cpp b/hal/src/main/native/cpp/jni/simulation/CallbackStore.cpp similarity index 100% rename from hal/src/main/native/sim/jni/CallbackStore.cpp rename to hal/src/main/native/cpp/jni/simulation/CallbackStore.cpp diff --git a/hal/src/main/native/sim/jni/CallbackStore.h b/hal/src/main/native/cpp/jni/simulation/CallbackStore.h similarity index 100% rename from hal/src/main/native/sim/jni/CallbackStore.h rename to hal/src/main/native/cpp/jni/simulation/CallbackStore.h diff --git a/hal/src/main/native/sim/jni/ConstBufferCallbackStore.cpp b/hal/src/main/native/cpp/jni/simulation/ConstBufferCallbackStore.cpp similarity index 100% rename from hal/src/main/native/sim/jni/ConstBufferCallbackStore.cpp rename to hal/src/main/native/cpp/jni/simulation/ConstBufferCallbackStore.cpp diff --git a/hal/src/main/native/sim/jni/ConstBufferCallbackStore.h b/hal/src/main/native/cpp/jni/simulation/ConstBufferCallbackStore.h similarity index 100% rename from hal/src/main/native/sim/jni/ConstBufferCallbackStore.h rename to hal/src/main/native/cpp/jni/simulation/ConstBufferCallbackStore.h diff --git a/hal/src/main/native/sim/jni/DIODataJNI.cpp b/hal/src/main/native/cpp/jni/simulation/DIODataJNI.cpp similarity index 100% rename from hal/src/main/native/sim/jni/DIODataJNI.cpp rename to hal/src/main/native/cpp/jni/simulation/DIODataJNI.cpp diff --git a/hal/src/main/native/sim/jni/DigitalPWMDataJNI.cpp b/hal/src/main/native/cpp/jni/simulation/DigitalPWMDataJNI.cpp similarity index 100% rename from hal/src/main/native/sim/jni/DigitalPWMDataJNI.cpp rename to hal/src/main/native/cpp/jni/simulation/DigitalPWMDataJNI.cpp diff --git a/hal/src/main/native/sim/jni/DriverStationDataJNI.cpp b/hal/src/main/native/cpp/jni/simulation/DriverStationDataJNI.cpp similarity index 100% rename from hal/src/main/native/sim/jni/DriverStationDataJNI.cpp rename to hal/src/main/native/cpp/jni/simulation/DriverStationDataJNI.cpp diff --git a/hal/src/main/native/sim/jni/DutyCycleDataJNI.cpp b/hal/src/main/native/cpp/jni/simulation/DutyCycleDataJNI.cpp similarity index 100% rename from hal/src/main/native/sim/jni/DutyCycleDataJNI.cpp rename to hal/src/main/native/cpp/jni/simulation/DutyCycleDataJNI.cpp diff --git a/hal/src/main/native/sim/jni/EncoderDataJNI.cpp b/hal/src/main/native/cpp/jni/simulation/EncoderDataJNI.cpp similarity index 100% rename from hal/src/main/native/sim/jni/EncoderDataJNI.cpp rename to hal/src/main/native/cpp/jni/simulation/EncoderDataJNI.cpp diff --git a/hal/src/main/native/sim/jni/I2CDataJNI.cpp b/hal/src/main/native/cpp/jni/simulation/I2CDataJNI.cpp similarity index 100% rename from hal/src/main/native/sim/jni/I2CDataJNI.cpp rename to hal/src/main/native/cpp/jni/simulation/I2CDataJNI.cpp diff --git a/hal/src/main/native/sim/jni/NotifierDataJNI.cpp b/hal/src/main/native/cpp/jni/simulation/NotifierDataJNI.cpp similarity index 100% rename from hal/src/main/native/sim/jni/NotifierDataJNI.cpp rename to hal/src/main/native/cpp/jni/simulation/NotifierDataJNI.cpp diff --git a/hal/src/main/native/sim/jni/PCMDataJNI.cpp b/hal/src/main/native/cpp/jni/simulation/PCMDataJNI.cpp similarity index 100% rename from hal/src/main/native/sim/jni/PCMDataJNI.cpp rename to hal/src/main/native/cpp/jni/simulation/PCMDataJNI.cpp diff --git a/hal/src/main/native/sim/jni/PDPDataJNI.cpp b/hal/src/main/native/cpp/jni/simulation/PDPDataJNI.cpp similarity index 100% rename from hal/src/main/native/sim/jni/PDPDataJNI.cpp rename to hal/src/main/native/cpp/jni/simulation/PDPDataJNI.cpp diff --git a/hal/src/main/native/sim/jni/PWMDataJNI.cpp b/hal/src/main/native/cpp/jni/simulation/PWMDataJNI.cpp similarity index 100% rename from hal/src/main/native/sim/jni/PWMDataJNI.cpp rename to hal/src/main/native/cpp/jni/simulation/PWMDataJNI.cpp diff --git a/hal/src/main/native/sim/jni/RelayDataJNI.cpp b/hal/src/main/native/cpp/jni/simulation/RelayDataJNI.cpp similarity index 100% rename from hal/src/main/native/sim/jni/RelayDataJNI.cpp rename to hal/src/main/native/cpp/jni/simulation/RelayDataJNI.cpp diff --git a/hal/src/main/native/sim/jni/RoboRioDataJNI.cpp b/hal/src/main/native/cpp/jni/simulation/RoboRioDataJNI.cpp similarity index 100% rename from hal/src/main/native/sim/jni/RoboRioDataJNI.cpp rename to hal/src/main/native/cpp/jni/simulation/RoboRioDataJNI.cpp diff --git a/hal/src/main/native/sim/jni/SPIAccelerometerDataJNI.cpp b/hal/src/main/native/cpp/jni/simulation/SPIAccelerometerDataJNI.cpp similarity index 100% rename from hal/src/main/native/sim/jni/SPIAccelerometerDataJNI.cpp rename to hal/src/main/native/cpp/jni/simulation/SPIAccelerometerDataJNI.cpp diff --git a/hal/src/main/native/sim/jni/SPIDataJNI.cpp b/hal/src/main/native/cpp/jni/simulation/SPIDataJNI.cpp similarity index 100% rename from hal/src/main/native/sim/jni/SPIDataJNI.cpp rename to hal/src/main/native/cpp/jni/simulation/SPIDataJNI.cpp diff --git a/hal/src/main/native/sim/jni/SimDeviceDataJNI.cpp b/hal/src/main/native/cpp/jni/simulation/SimDeviceDataJNI.cpp similarity index 100% rename from hal/src/main/native/sim/jni/SimDeviceDataJNI.cpp rename to hal/src/main/native/cpp/jni/simulation/SimDeviceDataJNI.cpp diff --git a/hal/src/main/native/sim/jni/SimDeviceDataJNI.h b/hal/src/main/native/cpp/jni/simulation/SimDeviceDataJNI.h similarity index 100% rename from hal/src/main/native/sim/jni/SimDeviceDataJNI.h rename to hal/src/main/native/cpp/jni/simulation/SimDeviceDataJNI.h diff --git a/hal/src/main/native/sim/jni/SimulatorJNI.cpp b/hal/src/main/native/cpp/jni/simulation/SimulatorJNI.cpp similarity index 100% rename from hal/src/main/native/sim/jni/SimulatorJNI.cpp rename to hal/src/main/native/cpp/jni/simulation/SimulatorJNI.cpp diff --git a/hal/src/main/native/sim/jni/SimulatorJNI.h b/hal/src/main/native/cpp/jni/simulation/SimulatorJNI.h similarity index 100% rename from hal/src/main/native/sim/jni/SimulatorJNI.h rename to hal/src/main/native/cpp/jni/simulation/SimulatorJNI.h diff --git a/hal/src/main/native/sim/jni/SpiReadAutoReceiveBufferCallbackStore.cpp b/hal/src/main/native/cpp/jni/simulation/SpiReadAutoReceiveBufferCallbackStore.cpp similarity index 100% rename from hal/src/main/native/sim/jni/SpiReadAutoReceiveBufferCallbackStore.cpp rename to hal/src/main/native/cpp/jni/simulation/SpiReadAutoReceiveBufferCallbackStore.cpp diff --git a/hal/src/main/native/sim/jni/SpiReadAutoReceiveBufferCallbackStore.h b/hal/src/main/native/cpp/jni/simulation/SpiReadAutoReceiveBufferCallbackStore.h similarity index 100% rename from hal/src/main/native/sim/jni/SpiReadAutoReceiveBufferCallbackStore.h rename to hal/src/main/native/cpp/jni/simulation/SpiReadAutoReceiveBufferCallbackStore.h diff --git a/hal/src/main/native/include/hal/simulation/SimCallbackRegistry.h b/hal/src/main/native/include/hal/simulation/SimCallbackRegistry.h index bedc81b2ab..bdd6f45611 100644 --- a/hal/src/main/native/include/hal/simulation/SimCallbackRegistry.h +++ b/hal/src/main/native/include/hal/simulation/SimCallbackRegistry.h @@ -152,4 +152,42 @@ class SimCallbackRegistry : public impl::SimCallbackRegistryBase { DATA->LOWERNAME.Cancel(uid); \ } +/** + * Define a stub standard C API for SimCallbackRegistry. + * + * Functions defined: + * - int32 NS_RegisterCAPINAMECallback( + * int32_t index, TYPE callback, void* param) + * - void NS_CancelCAPINAMECallback(int32_t index, int32_t uid) + * + * @param TYPE the underlying callback type (e.g. HAL_BufferCallback) + * @param NS the "namespace" (e.g. HALSIM) + * @param CAPINAME the C API name (usually first letter capitalized) + */ +#define HAL_SIMCALLBACKREGISTRY_STUB_CAPI(TYPE, NS, CAPINAME) \ + int32_t NS##_Register##CAPINAME##Callback(int32_t index, TYPE callback, \ + void* param) { \ + return 0; \ + } \ + \ + void NS##_Cancel##CAPINAME##Callback(int32_t index, int32_t uid) {} + +/** + * Define a stub standard C API for SimCallbackRegistry (no index variant). + * + * Functions defined: + * - int32 NS_RegisterCAPINAMECallback(TYPE callback, void* param) + * - void NS_CancelCAPINAMECallback(int32_t uid) + * + * @param TYPE the underlying callback type (e.g. HAL_BufferCallback) + * @param NS the "namespace" (e.g. HALSIM) + * @param CAPINAME the C API name (usually first letter capitalized) + */ +#define HAL_SIMCALLBACKREGISTRY_STUB_CAPI_NOINDEX(TYPE, NS, CAPINAME) \ + int32_t NS##_Register##CAPINAME##Callback(TYPE callback, void* param) { \ + return 0; \ + } \ + \ + void NS##_Cancel##CAPINAME##Callback(int32_t uid) {} + } // namespace hal diff --git a/hal/src/main/native/include/hal/simulation/SimDataValue.h b/hal/src/main/native/include/hal/simulation/SimDataValue.h index c06363acd2..360664e464 100644 --- a/hal/src/main/native/include/hal/simulation/SimDataValue.h +++ b/hal/src/main/native/include/hal/simulation/SimDataValue.h @@ -224,4 +224,90 @@ class SimDataValue final : public impl::SimDataValueBase { \ void NS##_Set##CAPINAME(TYPE LOWERNAME) { DATA->LOWERNAME = LOWERNAME; } +/** + * 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) + * + * @param TYPE the underlying value type (e.g. double) + * @param NS the "namespace" (e.g. HALSIM) + * @param CAPINAME the C API name (usually first letter capitalized) + * @param RETURN what to return from the Get function + */ +#define HAL_SIMDATAVALUE_STUB_CAPI(TYPE, NS, CAPINAME, RETURN) \ + 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 (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) + * + * @param TYPE the underlying value type (e.g. double) + * @param NS the "namespace" (e.g. HALSIM) + * @param CAPINAME the C API name (usually first letter capitalized) + * @param RETURN what to return from the Get function + */ +#define HAL_SIMDATAVALUE_STUB_CAPI_CHANNEL(TYPE, NS, CAPINAME, RETURN) \ + 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 (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) + * + * @param TYPE the underlying value type (e.g. double) + * @param NS the "namespace" (e.g. HALSIM) + * @param CAPINAME the C API name (usually first letter capitalized) + * @param RETURN what to return from the Get function + */ +#define HAL_SIMDATAVALUE_STUB_CAPI_NOINDEX(TYPE, NS, CAPINAME, RETURN) \ + 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) {} + } // namespace hal diff --git a/shared/jni/setupBuild.gradle b/shared/jni/setupBuild.gradle index 15805d2ba2..369422d4f3 100644 --- a/shared/jni/setupBuild.gradle +++ b/shared/jni/setupBuild.gradle @@ -43,7 +43,7 @@ model { source { srcDirs 'src/main/native/cpp' include '**/*.cpp' - exclude '**/jni/*.cpp' + exclude '**/jni/**/*.cpp' } exportedHeaders { srcDir 'src/main/native/include' @@ -108,7 +108,7 @@ model { cpp { source { srcDirs 'src/main/native/cpp' - include '**/jni/*.cpp' + include '**/jni/**/*.cpp' } exportedHeaders { srcDir 'src/main/native/include' @@ -150,7 +150,7 @@ model { cpp { source { srcDirs 'src/main/native/cpp' - include '**/jni/*.cpp' + include '**/jni/**/*.cpp' } exportedHeaders { srcDir 'src/main/native/include'