mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[hal] Implement stub mockdata on RoboRIO (#2575)
This makes it much more user-friendly to use simulation classes without needing to ifdef for C++ to avoid linker errors or be very careful about construction to avoid runtime errors in Java.
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 <jni.h>'
|
||||
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<void **>(&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<void **>(&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 '}'
|
||||
}
|
||||
}
|
||||
}
|
||||
28
hal/src/main/native/athena/mockdata/AccelerometerData.cpp
Normal file
28
hal/src/main/native/athena/mockdata/AccelerometerData.cpp
Normal file
@@ -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"
|
||||
45
hal/src/main/native/athena/mockdata/AddressableLEDData.cpp
Normal file
45
hal/src/main/native/athena/mockdata/AddressableLEDData.cpp
Normal file
@@ -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"
|
||||
26
hal/src/main/native/athena/mockdata/AnalogGyroData.cpp
Normal file
26
hal/src/main/native/athena/mockdata/AnalogGyroData.cpp
Normal file
@@ -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"
|
||||
33
hal/src/main/native/athena/mockdata/AnalogInData.cpp
Normal file
33
hal/src/main/native/athena/mockdata/AnalogInData.cpp
Normal file
@@ -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"
|
||||
25
hal/src/main/native/athena/mockdata/AnalogOutData.cpp
Normal file
25
hal/src/main/native/athena/mockdata/AnalogOutData.cpp
Normal file
@@ -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"
|
||||
31
hal/src/main/native/athena/mockdata/AnalogTriggerData.cpp
Normal file
31
hal/src/main/native/athena/mockdata/AnalogTriggerData.cpp
Normal file
@@ -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"
|
||||
25
hal/src/main/native/athena/mockdata/CanDataInternal.cpp
Normal file
25
hal/src/main/native/athena/mockdata/CanDataInternal.cpp
Normal file
@@ -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"
|
||||
28
hal/src/main/native/athena/mockdata/DIOData.cpp
Normal file
28
hal/src/main/native/athena/mockdata/DIOData.cpp
Normal file
@@ -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"
|
||||
28
hal/src/main/native/athena/mockdata/DigitalPWMData.cpp
Normal file
28
hal/src/main/native/athena/mockdata/DigitalPWMData.cpp
Normal file
@@ -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"
|
||||
51
hal/src/main/native/athena/mockdata/DriverStationData.cpp
Normal file
51
hal/src/main/native/athena/mockdata/DriverStationData.cpp
Normal file
@@ -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"
|
||||
33
hal/src/main/native/athena/mockdata/DutyCycleData.cpp
Normal file
33
hal/src/main/native/athena/mockdata/DutyCycleData.cpp
Normal file
@@ -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"
|
||||
47
hal/src/main/native/athena/mockdata/EncoderData.cpp
Normal file
47
hal/src/main/native/athena/mockdata/EncoderData.cpp
Normal file
@@ -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"
|
||||
27
hal/src/main/native/athena/mockdata/I2CData.cpp
Normal file
27
hal/src/main/native/athena/mockdata/I2CData.cpp
Normal file
@@ -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"
|
||||
34
hal/src/main/native/athena/mockdata/MockHooks.cpp
Normal file
34
hal/src/main/native/athena/mockdata/MockHooks.cpp
Normal file
@@ -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"
|
||||
20
hal/src/main/native/athena/mockdata/NotifierData.cpp
Normal file
20
hal/src/main/native/athena/mockdata/NotifierData.cpp
Normal file
@@ -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"
|
||||
40
hal/src/main/native/athena/mockdata/PCMData.cpp
Normal file
40
hal/src/main/native/athena/mockdata/PCMData.cpp
Normal file
@@ -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"
|
||||
34
hal/src/main/native/athena/mockdata/PDPData.cpp
Normal file
34
hal/src/main/native/athena/mockdata/PDPData.cpp
Normal file
@@ -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"
|
||||
27
hal/src/main/native/athena/mockdata/PWMData.cpp
Normal file
27
hal/src/main/native/athena/mockdata/PWMData.cpp
Normal file
@@ -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"
|
||||
26
hal/src/main/native/athena/mockdata/RelayData.cpp
Normal file
26
hal/src/main/native/athena/mockdata/RelayData.cpp
Normal file
@@ -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"
|
||||
36
hal/src/main/native/athena/mockdata/RoboRioData.cpp
Normal file
36
hal/src/main/native/athena/mockdata/RoboRioData.cpp
Normal file
@@ -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"
|
||||
28
hal/src/main/native/athena/mockdata/SPIAccelerometerData.cpp
Normal file
28
hal/src/main/native/athena/mockdata/SPIAccelerometerData.cpp
Normal file
@@ -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"
|
||||
28
hal/src/main/native/athena/mockdata/SPIData.cpp
Normal file
28
hal/src/main/native/athena/mockdata/SPIData.cpp
Normal file
@@ -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"
|
||||
78
hal/src/main/native/athena/mockdata/SimDeviceData.cpp
Normal file
78
hal/src/main/native/athena/mockdata/SimDeviceData.cpp
Normal file
@@ -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"
|
||||
@@ -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
|
||||
|
||||
@@ -224,4 +224,90 @@ class SimDataValue final : public impl::SimDataValueBase<T, MakeValue> {
|
||||
\
|
||||
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
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user