mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-02 02:51:42 +00:00
SCRIPT namespace replacements
This commit is contained in:
committed by
Peter Johnson
parent
ae6c043632
commit
9aca8e0fd6
@@ -11,7 +11,7 @@
|
||||
namespace {
|
||||
struct LastErrorStorage {
|
||||
int32_t status;
|
||||
wpi::SmallString<512> message;
|
||||
wpi::util::SmallString<512> message;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
@@ -20,7 +20,7 @@ static LastErrorStorage& GetThreadLastError() {
|
||||
return lastError;
|
||||
}
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
void SetLastError(int32_t* status, std::string_view value) {
|
||||
LastErrorStorage& lastError = GetThreadLastError();
|
||||
lastError.message = value;
|
||||
@@ -40,13 +40,13 @@ void SetLastErrorIndexOutOfRange(int32_t* status, std::string_view message,
|
||||
void SetLastErrorPreviouslyAllocated(int32_t* status, std::string_view message,
|
||||
int32_t channel,
|
||||
std::string_view previousAllocation) {
|
||||
hal::SetLastError(status,
|
||||
wpi::hal::SetLastError(status,
|
||||
fmt::format("{} {} previously allocated.\n"
|
||||
"Location of the previous allocation:\n{}\n"
|
||||
"Location of the current allocation:",
|
||||
message, channel, previousAllocation));
|
||||
}
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
extern "C" {
|
||||
const char* HAL_GetLastError(int32_t* status) {
|
||||
|
||||
@@ -16,8 +16,8 @@ static void (*gMainFunc)(void*) = DefaultMain;
|
||||
static void (*gExitFunc)(void*) = DefaultExit;
|
||||
static bool gExited = false;
|
||||
struct MainObj {
|
||||
wpi::mutex gExitMutex;
|
||||
wpi::condition_variable gExitCv;
|
||||
wpi::util::mutex gExitMutex;
|
||||
wpi::util::condition_variable gExitCv;
|
||||
};
|
||||
|
||||
static MainObj* mainObj;
|
||||
@@ -33,12 +33,12 @@ static void DefaultExit(void*) {
|
||||
mainObj->gExitCv.notify_all();
|
||||
}
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeMain() {
|
||||
static MainObj mO;
|
||||
mainObj = &mO;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "wpi/hal/HALBase.h"
|
||||
#include "wpi/util/print.hpp"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
const fpga_clock::time_point fpga_clock::min_time =
|
||||
fpga_clock::time_point(fpga_clock::duration(
|
||||
std::numeric_limits<fpga_clock::duration::rep>::min()));
|
||||
@@ -19,7 +19,7 @@ fpga_clock::time_point fpga_clock::now() noexcept {
|
||||
int32_t status = 0;
|
||||
uint64_t currentTime = HAL_GetFPGATime(&status);
|
||||
if (status != 0) {
|
||||
wpi::print(
|
||||
wpi::util::print(
|
||||
stderr,
|
||||
"Call to HAL_GetFPGATime failed in fpga_clock::now() with status {}. "
|
||||
"Initialization might have failed. Time will not be correct\n",
|
||||
@@ -29,4 +29,4 @@ fpga_clock::time_point fpga_clock::now() noexcept {
|
||||
}
|
||||
return time_point(std::chrono::microseconds(currentTime));
|
||||
}
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
#include "wpi/util/SmallVector.hpp"
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace hal {
|
||||
static wpi::SmallVector<HandleBase*, 32>* globalHandles = nullptr;
|
||||
static wpi::mutex globalHandleMutex;
|
||||
namespace wpi::hal {
|
||||
static wpi::util::SmallVector<HandleBase*, 32>* globalHandles = nullptr;
|
||||
static wpi::util::mutex globalHandleMutex;
|
||||
HandleBase::HandleBase() {
|
||||
static wpi::SmallVector<HandleBase*, 32> gH;
|
||||
static wpi::util::SmallVector<HandleBase*, 32> gH;
|
||||
std::scoped_lock lock(globalHandleMutex);
|
||||
if (!globalHandles) {
|
||||
globalHandles = &gH;
|
||||
@@ -67,4 +67,4 @@ HAL_Handle createHandle(int16_t index, HAL_HandleEnum handleType,
|
||||
handle += index;
|
||||
return handle;
|
||||
}
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#include "wpi/hal/AddressableLED.h"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::java;
|
||||
using namespace wpi::hal;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
static_assert(sizeof(jbyte) * 3 == sizeof(HAL_AddressableLEDData));
|
||||
|
||||
@@ -38,7 +38,7 @@ Java_org_wpilib_hardware_hal_AddressableLEDJNI_initialize
|
||||
(JNIEnv* env, jclass, jint channel)
|
||||
{
|
||||
int32_t status = 0;
|
||||
auto stack = wpi::java::GetJavaStackTrace(env, "edu.wpi.first");
|
||||
auto stack = wpi::util::java::GetJavaStackTrace(env, "edu.wpi.first");
|
||||
auto ret = HAL_InitializeAddressableLED(channel, stack.c_str(), &status);
|
||||
CheckStatusForceThrow(env, status);
|
||||
return ret;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "wpi/hal/handles/HandlesInternal.h"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -27,7 +27,7 @@ Java_org_wpilib_hardware_hal_AnalogJNI_initializeAnalogInputPort
|
||||
(JNIEnv* env, jclass, jint channel)
|
||||
{
|
||||
int32_t status = 0;
|
||||
auto stack = wpi::java::GetJavaStackTrace(env, "edu.wpi.first");
|
||||
auto stack = wpi::util::java::GetJavaStackTrace(env, "edu.wpi.first");
|
||||
auto analog = HAL_InitializeAnalogInputPort(channel, stack.c_str(), &status);
|
||||
CheckStatusForceThrow(env, status);
|
||||
return (jint)analog;
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
#include "wpi/hal/Errors.h"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::java;
|
||||
using namespace wpi::hal;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
#include "wpi/hal/Errors.h"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::java;
|
||||
using namespace wpi::hal;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -180,7 +180,7 @@ Java_org_wpilib_hardware_hal_can_CANJNI_readCANStreamSession
|
||||
uint32_t handle = static_cast<uint32_t>(sessionHandle);
|
||||
uint32_t messagesRead = 0;
|
||||
|
||||
wpi::SmallVector<HAL_CANStreamMessage, 16> messageBuffer;
|
||||
wpi::util::SmallVector<HAL_CANStreamMessage, 16> messageBuffer;
|
||||
messageBuffer.resize_for_overwrite(messagesToRead);
|
||||
|
||||
int32_t status = 0;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/hal/handles/HandlesInternal.h"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -25,7 +25,7 @@ Java_org_wpilib_hardware_hal_CTREPCMJNI_initialize
|
||||
(JNIEnv* env, jclass, jint busId, jint module)
|
||||
{
|
||||
int32_t status = 0;
|
||||
auto stack = wpi::java::GetJavaStackTrace(env, "edu.wpi.first");
|
||||
auto stack = wpi::util::java::GetJavaStackTrace(env, "edu.wpi.first");
|
||||
auto handle = HAL_InitializeCTREPCM(busId, module, stack.c_str(), &status);
|
||||
CheckStatusForceThrow(env, status);
|
||||
return handle;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "org_wpilib_hardware_hal_ConstantsJNI.h"
|
||||
#include "wpi/hal/Constants.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
extern "C" {
|
||||
/*
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "wpi/hal/Errors.h"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -26,7 +26,7 @@ Java_org_wpilib_hardware_hal_CounterJNI_initializeCounter
|
||||
(JNIEnv* env, jclass, jint channel, jboolean risingEdge)
|
||||
{
|
||||
int32_t status = 0;
|
||||
auto stack = wpi::java::GetJavaStackTrace(env, "edu.wpi.first");
|
||||
auto stack = wpi::util::java::GetJavaStackTrace(env, "edu.wpi.first");
|
||||
auto counter =
|
||||
HAL_InitializeCounter(channel, risingEdge, stack.c_str(), &status);
|
||||
CheckStatusForceThrow(env, status);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "wpi/hal/handles/HandlesInternal.h"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -28,7 +28,7 @@ Java_org_wpilib_hardware_hal_DIOJNI_initializeDIOPort
|
||||
(JNIEnv* env, jclass, jint channel, jboolean input)
|
||||
{
|
||||
int32_t status = 0;
|
||||
auto stack = wpi::java::GetJavaStackTrace(env, "edu.wpi.first");
|
||||
auto stack = wpi::util::java::GetJavaStackTrace(env, "edu.wpi.first");
|
||||
auto dio = HAL_InitializeDIOPort(channel, static_cast<uint8_t>(input),
|
||||
stack.c_str(), &status);
|
||||
CheckStatusForceThrow(env, status);
|
||||
|
||||
@@ -37,8 +37,8 @@ static_assert(org_wpilib_hardware_hal_DriverStationJNI_kMaxJoystickPOVs ==
|
||||
static_assert(org_wpilib_hardware_hal_DriverStationJNI_kMaxJoysticks ==
|
||||
HAL_kMaxJoysticks);
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::java;
|
||||
using namespace wpi::hal;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -216,7 +216,7 @@ Java_org_wpilib_hardware_hal_DriverStationJNI_getJoystickName
|
||||
{
|
||||
WPI_String joystickName;
|
||||
HAL_GetJoystickName(&joystickName, port);
|
||||
jstring str = MakeJString(env, wpi::to_string_view(&joystickName));
|
||||
jstring str = MakeJString(env, wpi::util::to_string_view(&joystickName));
|
||||
WPI_FreeString(&joystickName);
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "wpi/hal/DutyCycle.h"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
extern "C" {
|
||||
/*
|
||||
@@ -22,7 +22,7 @@ Java_org_wpilib_hardware_hal_DutyCycleJNI_initialize
|
||||
(JNIEnv* env, jclass, jint channel)
|
||||
{
|
||||
int32_t status = 0;
|
||||
auto stack = wpi::java::GetJavaStackTrace(env, "edu.wpi.first");
|
||||
auto stack = wpi::util::java::GetJavaStackTrace(env, "edu.wpi.first");
|
||||
auto handle = HAL_InitializeDutyCycle(channel, stack.c_str(), &status);
|
||||
CheckStatus(env, status);
|
||||
return handle;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/hal/Encoder.h"
|
||||
#include "wpi/hal/Errors.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
#include "wpi/hal/Main.h"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::java;
|
||||
using namespace wpi::hal;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "wpi/hal/HAL.h"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace wpi::java;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
#define kRioStatusOffset -63000
|
||||
#define kRioStatusSuccess 0
|
||||
@@ -78,7 +78,7 @@ static const JExceptionInit exceptions[] = {
|
||||
&uncleanStatusExCls},
|
||||
{"java/lang/NullPointerException", &nullPointerEx}};
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
|
||||
void ThrowUncleanStatusException(JNIEnv* env, std::string_view msg,
|
||||
int32_t status) {
|
||||
@@ -312,9 +312,9 @@ jint SimOnLoad(JavaVM* vm, void* reserved);
|
||||
void SimOnUnload(JavaVM* vm, void* reserved);
|
||||
} // namespace sim
|
||||
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -375,7 +375,7 @@ Java_org_wpilib_hardware_hal_HALUtil_getSerialNumber
|
||||
{
|
||||
WPI_String serialNum;
|
||||
HAL_GetSerialNumber(&serialNum);
|
||||
jstring ret = MakeJString(env, wpi::to_string_view(&serialNum));
|
||||
jstring ret = MakeJString(env, wpi::util::to_string_view(&serialNum));
|
||||
WPI_FreeString(&serialNum);
|
||||
return ret;
|
||||
}
|
||||
@@ -391,7 +391,7 @@ Java_org_wpilib_hardware_hal_HALUtil_getComments
|
||||
{
|
||||
WPI_String comments;
|
||||
HAL_GetComments(&comments);
|
||||
jstring ret = MakeJString(env, wpi::to_string_view(&comments));
|
||||
jstring ret = MakeJString(env, wpi::util::to_string_view(&comments));
|
||||
WPI_FreeString(&comments);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
struct HAL_MatchInfo;
|
||||
struct HAL_Value;
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
|
||||
void ReportError(JNIEnv* env, int32_t status, bool doThrow = true);
|
||||
|
||||
@@ -84,6 +84,6 @@ jobject CreateCANStreamMessage(JNIEnv* env);
|
||||
|
||||
JavaVM* GetJVM();
|
||||
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
#endif // HAL_HAL_SRC_MAIN_NATIVE_CPP_JNI_HALUTIL_H_
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
#include "wpi/hal/I2C.h"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::java;
|
||||
using namespace wpi::hal;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -73,7 +73,7 @@ Java_org_wpilib_hardware_hal_I2CJNI_i2CTransactionB
|
||||
return 0;
|
||||
}
|
||||
|
||||
wpi::SmallVector<uint8_t, 128> recvBuf;
|
||||
wpi::util::SmallVector<uint8_t, 128> recvBuf;
|
||||
recvBuf.resize(receiveSize);
|
||||
jint returnValue =
|
||||
HAL_TransactionI2C(static_cast<HAL_I2CPort>(port), address,
|
||||
@@ -156,7 +156,7 @@ Java_org_wpilib_hardware_hal_I2CJNI_i2CReadB
|
||||
return 0;
|
||||
}
|
||||
|
||||
wpi::SmallVector<uint8_t, 128> recvBuf;
|
||||
wpi::util::SmallVector<uint8_t, 128> recvBuf;
|
||||
recvBuf.resize(receiveSize);
|
||||
jint returnValue = HAL_ReadI2C(static_cast<HAL_I2CPort>(port), address,
|
||||
recvBuf.data(), receiveSize);
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "org_wpilib_hardware_hal_IMUJNI.h"
|
||||
#include "wpi/hal/IMU.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace {
|
||||
void assertArraySize(JNIEnv* env, jarray array, int minimumSize,
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "wpi/hal/Notifier.h"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -59,7 +59,7 @@ Java_org_wpilib_hardware_hal_NotifierJNI_setNotifierName
|
||||
{
|
||||
int32_t status = 0;
|
||||
HAL_SetNotifierName((HAL_NotifierHandle)notifierHandle,
|
||||
wpi::java::JStringRef{env, name}.c_str(), &status);
|
||||
wpi::util::java::JStringRef{env, name}.c_str(), &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "wpi/hal/handles/HandlesInternal.h"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -28,7 +28,7 @@ Java_org_wpilib_hardware_hal_PWMJNI_initializePWMPort
|
||||
(JNIEnv* env, jclass, jint channel)
|
||||
{
|
||||
int32_t status = 0;
|
||||
auto stack = wpi::java::GetJavaStackTrace(env, "edu.wpi.first");
|
||||
auto stack = wpi::util::java::GetJavaStackTrace(env, "edu.wpi.first");
|
||||
auto pwm = HAL_InitializePWMPort(channel, stack.c_str(), &status);
|
||||
CheckStatusForceThrow(env, status);
|
||||
return (jint)pwm;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "org_wpilib_hardware_hal_PortsJNI.h"
|
||||
#include "wpi/hal/Ports.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
extern "C" {
|
||||
/*
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "wpi/hal/PowerDistribution.h"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
static_assert(org_wpilib_hardware_hal_PowerDistributionJNI_AUTOMATIC_TYPE ==
|
||||
HAL_PowerDistributionType::HAL_PowerDistributionType_kAutomatic);
|
||||
@@ -33,7 +33,7 @@ Java_org_wpilib_hardware_hal_PowerDistributionJNI_initialize
|
||||
(JNIEnv* env, jclass, jint busId, jint module, jint type)
|
||||
{
|
||||
int32_t status = 0;
|
||||
auto stack = wpi::java::GetJavaStackTrace(env, "edu.wpi.first");
|
||||
auto stack = wpi::util::java::GetJavaStackTrace(env, "edu.wpi.first");
|
||||
auto handle = HAL_InitializePowerDistribution(
|
||||
busId, module, static_cast<HAL_PowerDistributionType>(type),
|
||||
stack.c_str(), &status);
|
||||
@@ -182,7 +182,7 @@ Java_org_wpilib_hardware_hal_PowerDistributionJNI_getAllCurrents
|
||||
{
|
||||
int32_t status = 0;
|
||||
int32_t size = HAL_GetPowerDistributionNumChannels(handle, &status);
|
||||
wpi::SmallVector<double, 24> storage;
|
||||
wpi::util::SmallVector<double, 24> storage;
|
||||
storage.resize_for_overwrite(size);
|
||||
|
||||
HAL_GetPowerDistributionAllChannelCurrents(handle, storage.data(), size,
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "org_wpilib_hardware_hal_PowerJNI.h"
|
||||
#include "wpi/hal/Power.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ static_assert(
|
||||
org_wpilib_hardware_hal_REVPHJNI_COMPRESSOR_CONFIG_TYPE_HYBRID ==
|
||||
HAL_REVPHCompressorConfigType::HAL_REVPHCompressorConfigType_kHybrid);
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -38,7 +38,7 @@ Java_org_wpilib_hardware_hal_REVPHJNI_initialize
|
||||
(JNIEnv* env, jclass, jint busId, jint module)
|
||||
{
|
||||
int32_t status = 0;
|
||||
auto stack = wpi::java::GetJavaStackTrace(env, "edu.wpi.first");
|
||||
auto stack = wpi::util::java::GetJavaStackTrace(env, "edu.wpi.first");
|
||||
auto handle = HAL_InitializeREVPH(busId, module, stack.c_str(), &status);
|
||||
CheckStatusForceThrow(env, status);
|
||||
return handle;
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
#include "wpi/hal/SerialPort.h"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::java;
|
||||
using namespace wpi::hal;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -239,7 +239,7 @@ JNIEXPORT jint JNICALL
|
||||
Java_org_wpilib_hardware_hal_SerialPortJNI_serialRead
|
||||
(JNIEnv* env, jclass, jint handle, jbyteArray dataReceived, jint size)
|
||||
{
|
||||
wpi::SmallVector<char, 128> recvBuf;
|
||||
wpi::util::SmallVector<char, 128> recvBuf;
|
||||
recvBuf.resize(size);
|
||||
int32_t status = 0;
|
||||
jint retVal = HAL_ReadSerial(static_cast<HAL_SerialPortHandle>(handle),
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "wpi/hal/SimDevice.h"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace wpi::java;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
static HAL_Value ValueFromJava(jint type, jlong value1, jdouble value2) {
|
||||
HAL_Value value;
|
||||
@@ -114,7 +114,7 @@ Java_org_wpilib_hardware_hal_SimDeviceJNI_createSimValueEnum
|
||||
}
|
||||
arr.emplace_back(JStringRef{env, elem}.str());
|
||||
}
|
||||
wpi::SmallVector<const char*, 8> carr;
|
||||
wpi::util::SmallVector<const char*, 8> carr;
|
||||
for (auto&& val : arr) {
|
||||
carr.push_back(val.c_str());
|
||||
}
|
||||
@@ -148,7 +148,7 @@ Java_org_wpilib_hardware_hal_SimDeviceJNI_createSimValueEnumDouble
|
||||
arr.emplace_back(JStringRef{env, elem}.str());
|
||||
}
|
||||
|
||||
wpi::SmallVector<const char*, 8> carr;
|
||||
wpi::util::SmallVector<const char*, 8> carr;
|
||||
for (auto&& val : arr) {
|
||||
carr.push_back(val.c_str());
|
||||
}
|
||||
@@ -166,7 +166,7 @@ JNIEXPORT jobject JNICALL
|
||||
Java_org_wpilib_hardware_hal_SimDeviceJNI_getSimValue
|
||||
(JNIEnv* env, jclass, jint handle)
|
||||
{
|
||||
return hal::CreateHALValue(env, HAL_GetSimValue(handle));
|
||||
return wpi::hal::CreateHALValue(env, HAL_GetSimValue(handle));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "org_wpilib_hardware_hal_ThreadsJNI.h"
|
||||
#include "wpi/hal/Threads.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
extern "C" {
|
||||
/*
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
#include "wpi/util/string.h"
|
||||
|
||||
using namespace wpi::java;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -26,8 +26,8 @@ Java_org_wpilib_hardware_hal_UsageReportingJNI_report
|
||||
{
|
||||
JStringRef resourceStr{env, resource};
|
||||
JStringRef dataStr{env, data};
|
||||
WPI_String resourceWpiStr = wpi::make_string(resourceStr);
|
||||
WPI_String dataWpiStr = wpi::make_string(dataStr);
|
||||
WPI_String resourceWpiStr = wpi::util::make_string(resourceStr);
|
||||
WPI_String dataWpiStr = wpi::util::make_string(dataStr);
|
||||
return HAL_ReportUsage(&resourceWpiStr, &dataWpiStr);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
|
||||
static_assert(sizeof(jbyte) * 3 == sizeof(HAL_AddressableLEDData));
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::java;
|
||||
using namespace wpi::hal;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "org_wpilib_hardware_hal_simulation_AnalogInDataJNI.h"
|
||||
#include "wpi/hal/simulation/AnalogInData.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -14,22 +14,22 @@
|
||||
#include "wpi/hal/handles/UnlimitedHandleResource.h"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace hal;
|
||||
using namespace hal::sim;
|
||||
using namespace wpi::java;
|
||||
using namespace wpi::hal;
|
||||
using namespace wpi::hal::sim;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
static hal::UnlimitedHandleResource<SIM_JniHandle, BufferCallbackStore,
|
||||
hal::HAL_HandleEnum::SimulationJni>*
|
||||
static wpi::hal::UnlimitedHandleResource<SIM_JniHandle, BufferCallbackStore,
|
||||
wpi::hal::HAL_HandleEnum::SimulationJni>*
|
||||
callbackHandles;
|
||||
|
||||
namespace hal::sim {
|
||||
namespace wpi::hal::sim {
|
||||
void InitializeBufferStore() {
|
||||
static hal::UnlimitedHandleResource<SIM_JniHandle, BufferCallbackStore,
|
||||
hal::HAL_HandleEnum::SimulationJni>
|
||||
static wpi::hal::UnlimitedHandleResource<SIM_JniHandle, BufferCallbackStore,
|
||||
wpi::hal::HAL_HandleEnum::SimulationJni>
|
||||
cb;
|
||||
callbackHandles = &cb;
|
||||
}
|
||||
} // namespace hal::sim
|
||||
} // namespace wpi::hal::sim
|
||||
|
||||
void BufferCallbackStore::create(JNIEnv* env, jobject obj) {
|
||||
m_call = JGlobal<jobject>(env, obj);
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "wpi/hal/simulation/NotifyListener.h"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
namespace hal::sim {
|
||||
namespace wpi::hal::sim {
|
||||
class BufferCallbackStore {
|
||||
public:
|
||||
void create(JNIEnv* env, jobject obj);
|
||||
@@ -23,7 +23,7 @@ class BufferCallbackStore {
|
||||
int32_t getCallbackId() { return callbackId; }
|
||||
|
||||
private:
|
||||
wpi::java::JGlobal<jobject> m_call;
|
||||
wpi::util::java::JGlobal<jobject> m_call;
|
||||
int32_t callbackId;
|
||||
};
|
||||
|
||||
@@ -38,4 +38,4 @@ SIM_JniHandle AllocateBufferCallback(JNIEnv* env, jint index, jobject callback,
|
||||
RegisterBufferCallbackFunc createCallback);
|
||||
void FreeBufferCallback(JNIEnv* env, SIM_JniHandle handle, jint index,
|
||||
FreeBufferCallbackFunc freeCallback);
|
||||
} // namespace hal::sim
|
||||
} // namespace wpi::hal::sim
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "org_wpilib_hardware_hal_simulation_CTREPCMDataJNI.h"
|
||||
#include "wpi/hal/simulation/CTREPCMData.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -15,22 +15,22 @@
|
||||
#include "wpi/hal/handles/UnlimitedHandleResource.h"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace hal;
|
||||
using namespace hal::sim;
|
||||
using namespace wpi::java;
|
||||
using namespace wpi::hal;
|
||||
using namespace wpi::hal::sim;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
static hal::UnlimitedHandleResource<SIM_JniHandle, CallbackStore,
|
||||
hal::HAL_HandleEnum::SimulationJni>*
|
||||
static wpi::hal::UnlimitedHandleResource<SIM_JniHandle, CallbackStore,
|
||||
wpi::hal::HAL_HandleEnum::SimulationJni>*
|
||||
callbackHandles;
|
||||
|
||||
namespace hal::sim {
|
||||
namespace wpi::hal::sim {
|
||||
void InitializeStore() {
|
||||
static hal::UnlimitedHandleResource<SIM_JniHandle, CallbackStore,
|
||||
hal::HAL_HandleEnum::SimulationJni>
|
||||
static wpi::hal::UnlimitedHandleResource<SIM_JniHandle, CallbackStore,
|
||||
wpi::hal::HAL_HandleEnum::SimulationJni>
|
||||
cb;
|
||||
callbackHandles = &cb;
|
||||
}
|
||||
} // namespace hal::sim
|
||||
} // namespace wpi::hal::sim
|
||||
|
||||
void CallbackStore::create(JNIEnv* env, jobject obj) {
|
||||
m_call = JGlobal<jobject>(env, obj);
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "wpi/hal/simulation/NotifyListener.h"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
namespace hal::sim {
|
||||
namespace wpi::hal::sim {
|
||||
class CallbackStore {
|
||||
public:
|
||||
void create(JNIEnv* env, jobject obj);
|
||||
@@ -23,7 +23,7 @@ class CallbackStore {
|
||||
int32_t getCallbackId() { return callbackId; }
|
||||
|
||||
private:
|
||||
wpi::java::JGlobal<jobject> m_call;
|
||||
wpi::util::java::JGlobal<jobject> m_call;
|
||||
int32_t callbackId;
|
||||
};
|
||||
|
||||
@@ -59,4 +59,4 @@ void FreeChannelCallback(JNIEnv* env, SIM_JniHandle handle, jint index,
|
||||
jint channel, FreeChannelCallbackFunc freeCallback);
|
||||
void FreeCallbackNoIndex(JNIEnv* env, SIM_JniHandle handle,
|
||||
FreeCallbackNoIndexFunc freeCallback);
|
||||
} // namespace hal::sim
|
||||
} // namespace wpi::hal::sim
|
||||
|
||||
@@ -14,22 +14,22 @@
|
||||
#include "wpi/hal/handles/UnlimitedHandleResource.h"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace hal;
|
||||
using namespace hal::sim;
|
||||
using namespace wpi::java;
|
||||
using namespace wpi::hal;
|
||||
using namespace wpi::hal::sim;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
static hal::UnlimitedHandleResource<SIM_JniHandle, ConstBufferCallbackStore,
|
||||
hal::HAL_HandleEnum::SimulationJni>*
|
||||
static wpi::hal::UnlimitedHandleResource<SIM_JniHandle, ConstBufferCallbackStore,
|
||||
wpi::hal::HAL_HandleEnum::SimulationJni>*
|
||||
callbackHandles;
|
||||
|
||||
namespace hal::sim {
|
||||
namespace wpi::hal::sim {
|
||||
void InitializeConstBufferStore() {
|
||||
static hal::UnlimitedHandleResource<SIM_JniHandle, ConstBufferCallbackStore,
|
||||
hal::HAL_HandleEnum::SimulationJni>
|
||||
static wpi::hal::UnlimitedHandleResource<SIM_JniHandle, ConstBufferCallbackStore,
|
||||
wpi::hal::HAL_HandleEnum::SimulationJni>
|
||||
cb;
|
||||
callbackHandles = &cb;
|
||||
}
|
||||
} // namespace hal::sim
|
||||
} // namespace wpi::hal::sim
|
||||
|
||||
void ConstBufferCallbackStore::create(JNIEnv* env, jobject obj) {
|
||||
m_call = JGlobal<jobject>(env, obj);
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "wpi/hal/simulation/NotifyListener.h"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
namespace hal::sim {
|
||||
namespace wpi::hal::sim {
|
||||
class ConstBufferCallbackStore {
|
||||
public:
|
||||
void create(JNIEnv* env, jobject obj);
|
||||
@@ -24,7 +24,7 @@ class ConstBufferCallbackStore {
|
||||
int32_t getCallbackId() { return callbackId; }
|
||||
|
||||
private:
|
||||
wpi::java::JGlobal<jobject> m_call;
|
||||
wpi::util::java::JGlobal<jobject> m_call;
|
||||
int32_t callbackId;
|
||||
};
|
||||
|
||||
@@ -39,4 +39,4 @@ SIM_JniHandle AllocateConstBufferCallback(
|
||||
RegisterConstBufferCallbackFunc createCallback);
|
||||
void FreeConstBufferCallback(JNIEnv* env, SIM_JniHandle handle, jint index,
|
||||
FreeConstBufferCallbackFunc freeCallback);
|
||||
} // namespace hal::sim
|
||||
} // namespace wpi::hal::sim
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "org_wpilib_hardware_hal_simulation_DIODataJNI.h"
|
||||
#include "wpi/hal/simulation/DIOData.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "org_wpilib_hardware_hal_simulation_DigitalPWMDataJNI.h"
|
||||
#include "wpi/hal/simulation/DigitalPWMData.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
#include "wpi/util/StringExtras.hpp"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::java;
|
||||
using namespace wpi::hal;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -537,9 +537,9 @@ Java_org_wpilib_hardware_hal_simulation_DriverStationDataJNI_setMatchInfo
|
||||
JStringRef gameSpecificMessageRef{env, gameSpecificMessage};
|
||||
|
||||
HAL_MatchInfo halMatchInfo;
|
||||
wpi::format_to_n_c_str(halMatchInfo.eventName, sizeof(halMatchInfo.eventName),
|
||||
wpi::util::format_to_n_c_str(halMatchInfo.eventName, sizeof(halMatchInfo.eventName),
|
||||
"{}", eventNameRef.str());
|
||||
wpi::format_to_n_c_str(
|
||||
wpi::util::format_to_n_c_str(
|
||||
reinterpret_cast<char*>(halMatchInfo.gameSpecificMessage),
|
||||
sizeof(halMatchInfo.gameSpecificMessage), "{}",
|
||||
gameSpecificMessageRef.str());
|
||||
@@ -732,7 +732,7 @@ Java_org_wpilib_hardware_hal_simulation_DriverStationDataJNI_setJoystickName
|
||||
(JNIEnv* env, jclass, jint stick, jstring name)
|
||||
{
|
||||
JStringRef nameJString{env, name};
|
||||
auto str = wpi::make_string(nameJString);
|
||||
auto str = wpi::util::make_string(nameJString);
|
||||
HALSIM_SetJoystickName(stick, &str);
|
||||
}
|
||||
|
||||
@@ -746,7 +746,7 @@ Java_org_wpilib_hardware_hal_simulation_DriverStationDataJNI_setGameSpecificMess
|
||||
(JNIEnv* env, jclass, jstring message)
|
||||
{
|
||||
JStringRef messageJString{env, message};
|
||||
auto str = wpi::make_string(messageJString);
|
||||
auto str = wpi::util::make_string(messageJString);
|
||||
HALSIM_SetGameSpecificMessage(&str);
|
||||
}
|
||||
|
||||
@@ -760,7 +760,7 @@ Java_org_wpilib_hardware_hal_simulation_DriverStationDataJNI_setEventName
|
||||
(JNIEnv* env, jclass, jstring name)
|
||||
{
|
||||
JStringRef nameJString{env, name};
|
||||
auto str = wpi::make_string(nameJString);
|
||||
auto str = wpi::util::make_string(nameJString);
|
||||
HALSIM_SetEventName(&str);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "org_wpilib_hardware_hal_simulation_DutyCycleDataJNI.h"
|
||||
#include "wpi/hal/simulation/DutyCycleData.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "org_wpilib_hardware_hal_simulation_EncoderDataJNI.h"
|
||||
#include "wpi/hal/simulation/EncoderData.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "org_wpilib_hardware_hal_simulation_I2CDataJNI.h"
|
||||
#include "wpi/hal/simulation/I2CData.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "org_wpilib_hardware_hal_simulation_PWMDataJNI.h"
|
||||
#include "wpi/hal/simulation/PWMData.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "org_wpilib_hardware_hal_simulation_PowerDistributionDataJNI.h"
|
||||
#include "wpi/hal/simulation/PowerDistributionData.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "org_wpilib_hardware_hal_simulation_REVPHDataJNI.h"
|
||||
#include "wpi/hal/simulation/REVPHData.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#include "wpi/hal/simulation/RoboRioData.h"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::java;
|
||||
using namespace wpi::hal;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -430,7 +430,7 @@ Java_org_wpilib_hardware_hal_simulation_RoboRioDataJNI_getSerialNumber
|
||||
{
|
||||
WPI_String str;
|
||||
HALSIM_GetRoboRioSerialNumber(&str);
|
||||
auto jstr = MakeJString(env, wpi::to_string_view(&str));
|
||||
auto jstr = MakeJString(env, wpi::util::to_string_view(&str));
|
||||
WPI_FreeString(&str);
|
||||
return jstr;
|
||||
}
|
||||
@@ -445,7 +445,7 @@ Java_org_wpilib_hardware_hal_simulation_RoboRioDataJNI_setSerialNumber
|
||||
(JNIEnv* env, jclass, jstring serialNumber)
|
||||
{
|
||||
JStringRef serialNumberJString{env, serialNumber};
|
||||
auto str = wpi::make_string(serialNumberJString);
|
||||
auto str = wpi::util::make_string(serialNumberJString);
|
||||
HALSIM_SetRoboRioSerialNumber(&str);
|
||||
}
|
||||
|
||||
@@ -460,7 +460,7 @@ Java_org_wpilib_hardware_hal_simulation_RoboRioDataJNI_getComments
|
||||
{
|
||||
WPI_String str;
|
||||
HALSIM_GetRoboRioComments(&str);
|
||||
auto jstr = MakeJString(env, wpi::to_string_view(&str));
|
||||
auto jstr = MakeJString(env, wpi::util::to_string_view(&str));
|
||||
WPI_FreeString(&str);
|
||||
return jstr;
|
||||
}
|
||||
@@ -475,7 +475,7 @@ Java_org_wpilib_hardware_hal_simulation_RoboRioDataJNI_setComments
|
||||
(JNIEnv* env, jclass, jstring comments)
|
||||
{
|
||||
JStringRef commentsJString{env, comments};
|
||||
auto str = wpi::make_string(commentsJString);
|
||||
auto str = wpi::util::make_string(commentsJString);
|
||||
HALSIM_SetRoboRioComments(&str);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
#include "wpi/hal/simulation/SimDeviceData.h"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::java;
|
||||
using namespace wpi::hal;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
static JClass simDeviceInfoCls;
|
||||
static JClass simValueInfoCls;
|
||||
@@ -105,7 +105,7 @@ class DeviceCallbackStore {
|
||||
int32_t getCallbackId() { return callbackId; }
|
||||
|
||||
private:
|
||||
wpi::java::JGlobal<jobject> m_call;
|
||||
wpi::util::java::JGlobal<jobject> m_call;
|
||||
int32_t callbackId;
|
||||
};
|
||||
|
||||
@@ -119,7 +119,7 @@ class ValueCallbackStore {
|
||||
int32_t getCallbackId() { return m_callbackId; }
|
||||
|
||||
private:
|
||||
wpi::java::JGlobal<jobject> m_call;
|
||||
wpi::util::java::JGlobal<jobject> m_call;
|
||||
int32_t m_callbackId;
|
||||
};
|
||||
|
||||
@@ -193,8 +193,8 @@ void ValueCallbackStore::performCallback(const char* name,
|
||||
}
|
||||
}
|
||||
|
||||
static hal::UnlimitedHandleResource<SIM_JniHandle, DeviceCallbackStore,
|
||||
hal::HAL_HandleEnum::SimulationJni>*
|
||||
static wpi::hal::UnlimitedHandleResource<SIM_JniHandle, DeviceCallbackStore,
|
||||
wpi::hal::HAL_HandleEnum::SimulationJni>*
|
||||
deviceCallbackHandles;
|
||||
|
||||
namespace {
|
||||
@@ -250,8 +250,8 @@ static void FreeDeviceCallback(JNIEnv* env, SIM_JniHandle handle,
|
||||
callback->free(env);
|
||||
}
|
||||
|
||||
static hal::UnlimitedHandleResource<SIM_JniHandle, ValueCallbackStore,
|
||||
hal::HAL_HandleEnum::SimulationJni>*
|
||||
static wpi::hal::UnlimitedHandleResource<SIM_JniHandle, ValueCallbackStore,
|
||||
wpi::hal::HAL_HandleEnum::SimulationJni>*
|
||||
valueCallbackHandles;
|
||||
|
||||
namespace {
|
||||
@@ -307,7 +307,7 @@ static void FreeValueCallback(JNIEnv* env, SIM_JniHandle handle,
|
||||
callback->free(env);
|
||||
}
|
||||
|
||||
namespace hal::sim {
|
||||
namespace wpi::hal::sim {
|
||||
|
||||
bool InitializeSimDeviceDataJNI(JNIEnv* env) {
|
||||
simDeviceInfoCls = JClass(
|
||||
@@ -346,13 +346,13 @@ bool InitializeSimDeviceDataJNI(JNIEnv* env) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static hal::UnlimitedHandleResource<SIM_JniHandle, DeviceCallbackStore,
|
||||
hal::HAL_HandleEnum::SimulationJni>
|
||||
static wpi::hal::UnlimitedHandleResource<SIM_JniHandle, DeviceCallbackStore,
|
||||
wpi::hal::HAL_HandleEnum::SimulationJni>
|
||||
cbDevice;
|
||||
deviceCallbackHandles = &cbDevice;
|
||||
|
||||
static hal::UnlimitedHandleResource<SIM_JniHandle, ValueCallbackStore,
|
||||
hal::HAL_HandleEnum::SimulationJni>
|
||||
static wpi::hal::UnlimitedHandleResource<SIM_JniHandle, ValueCallbackStore,
|
||||
wpi::hal::HAL_HandleEnum::SimulationJni>
|
||||
cbValue;
|
||||
valueCallbackHandles = &cbValue;
|
||||
|
||||
@@ -366,7 +366,7 @@ void FreeSimDeviceDataJNI(JNIEnv* env) {
|
||||
simValueCallbackCls.free(env);
|
||||
}
|
||||
|
||||
} // namespace hal::sim
|
||||
} // namespace wpi::hal::sim
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
namespace hal::sim {
|
||||
namespace wpi::hal::sim {
|
||||
bool InitializeSimDeviceDataJNI(JNIEnv* env);
|
||||
void FreeSimDeviceDataJNI(JNIEnv* env);
|
||||
} // namespace hal::sim
|
||||
} // namespace wpi::hal::sim
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "wpi/hal/simulation/MockHooks.h"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace wpi::java;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
static JavaVM* jvm = nullptr;
|
||||
static JClass notifyCallbackCls;
|
||||
@@ -24,7 +24,7 @@ static jmethodID notifyCallbackCallback;
|
||||
static jmethodID bufferCallbackCallback;
|
||||
static jmethodID constBufferCallbackCallback;
|
||||
|
||||
namespace hal::sim {
|
||||
namespace wpi::hal::sim {
|
||||
jint SimOnLoad(JavaVM* vm, void* reserved) {
|
||||
jvm = vm;
|
||||
|
||||
@@ -108,7 +108,7 @@ jmethodID GetConstBufferCallback() {
|
||||
return constBufferCallbackCallback;
|
||||
}
|
||||
|
||||
} // namespace hal::sim
|
||||
} // namespace wpi::hal::sim
|
||||
|
||||
extern "C" {
|
||||
/*
|
||||
@@ -240,6 +240,6 @@ JNIEXPORT void JNICALL
|
||||
Java_org_wpilib_hardware_hal_simulation_SimulatorJNI_resetHandles
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
hal::HandleBase::ResetGlobalHandles();
|
||||
wpi::hal::HandleBase::ResetGlobalHandles();
|
||||
}
|
||||
} // extern "C"
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
|
||||
using SIM_JniHandle = HAL_Handle; // NOLINT
|
||||
|
||||
namespace hal::sim {
|
||||
namespace wpi::hal::sim {
|
||||
JavaVM* GetJVM();
|
||||
|
||||
jmethodID GetNotifyCallback();
|
||||
jmethodID GetBufferCallback();
|
||||
jmethodID GetConstBufferCallback();
|
||||
} // namespace hal::sim
|
||||
} // namespace wpi::hal::sim
|
||||
|
||||
@@ -60,9 +60,9 @@ constexpr mrc::ControlFlags ToControlWord(uint32_t Word) {
|
||||
|
||||
} // namespace
|
||||
|
||||
std::optional<mrc::ControlData> wpi::Protobuf<mrc::ControlData>::Unpack(
|
||||
std::optional<mrc::ControlData> wpi::util::Protobuf<mrc::ControlData>::Unpack(
|
||||
InputStream& Stream) {
|
||||
wpi::UnpackCallback<mrc::Joystick, MRC_MAX_NUM_JOYSTICKS> JoystickCb;
|
||||
wpi::util::UnpackCallback<mrc::Joystick, MRC_MAX_NUM_JOYSTICKS> JoystickCb;
|
||||
|
||||
mrc_proto_ProtobufControlData Msg{
|
||||
.ControlWord = 0,
|
||||
@@ -91,10 +91,10 @@ std::optional<mrc::ControlData> wpi::Protobuf<mrc::ControlData>::Unpack(
|
||||
return ControlData;
|
||||
}
|
||||
|
||||
bool wpi::Protobuf<mrc::ControlData>::Pack(OutputStream& Stream,
|
||||
bool wpi::util::Protobuf<mrc::ControlData>::Pack(OutputStream& Stream,
|
||||
const mrc::ControlData& Value) {
|
||||
std::span<const mrc::Joystick> Sticks = Value.Joysticks();
|
||||
wpi::PackCallback Joysticks{Sticks};
|
||||
wpi::util::PackCallback Joysticks{Sticks};
|
||||
|
||||
mrc_proto_ProtobufControlData Msg{
|
||||
.ControlWord = FromControlWord(Value.ControlWord),
|
||||
@@ -106,9 +106,9 @@ bool wpi::Protobuf<mrc::ControlData>::Pack(OutputStream& Stream,
|
||||
return Stream.Encode(Msg);
|
||||
}
|
||||
|
||||
std::optional<mrc::Joystick> wpi::Protobuf<mrc::Joystick>::Unpack(
|
||||
std::optional<mrc::Joystick> wpi::util::Protobuf<mrc::Joystick>::Unpack(
|
||||
InputStream& Stream) {
|
||||
wpi::UnpackCallback<int16_t, MRC_MAX_NUM_AXES> AxesCb;
|
||||
wpi::util::UnpackCallback<int16_t, MRC_MAX_NUM_AXES> AxesCb;
|
||||
|
||||
mrc_proto_ProtobufJoystickData Msg{
|
||||
.AvailableButtons = 0,
|
||||
@@ -148,9 +148,9 @@ std::optional<mrc::Joystick> wpi::Protobuf<mrc::Joystick>::Unpack(
|
||||
return Joystick;
|
||||
}
|
||||
|
||||
bool wpi::Protobuf<mrc::Joystick>::Pack(OutputStream& Stream,
|
||||
bool wpi::util::Protobuf<mrc::Joystick>::Pack(OutputStream& Stream,
|
||||
const mrc::Joystick& Value) {
|
||||
wpi::PackCallback AxesCb{Value.Axes.Axes()};
|
||||
wpi::util::PackCallback AxesCb{Value.Axes.Axes()};
|
||||
|
||||
uint32_t PovsStore = 0;
|
||||
for (int i = static_cast<int>(Value.Povs.GetCount()) - 1; i >= 0; i--) {
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
#include "wpi/hal/proto/ErrorInfo.h"
|
||||
#include "wpi/util/protobuf/ProtobufCallbacks.hpp"
|
||||
|
||||
std::optional<mrc::ErrorInfo> wpi::Protobuf<mrc::ErrorInfo>::Unpack(
|
||||
std::optional<mrc::ErrorInfo> wpi::util::Protobuf<mrc::ErrorInfo>::Unpack(
|
||||
InputStream& Stream) {
|
||||
wpi::UnpackCallback<std::string> DetailsCb;
|
||||
wpi::UnpackCallback<std::string> LocationCb;
|
||||
wpi::UnpackCallback<std::string> CallStackCb;
|
||||
wpi::util::UnpackCallback<std::string> DetailsCb;
|
||||
wpi::util::UnpackCallback<std::string> LocationCb;
|
||||
wpi::util::UnpackCallback<std::string> CallStackCb;
|
||||
|
||||
mrc_proto_ProtobufErrorInfo Msg{
|
||||
.IsError = false,
|
||||
@@ -49,14 +49,14 @@ std::optional<mrc::ErrorInfo> wpi::Protobuf<mrc::ErrorInfo>::Unpack(
|
||||
return ToRet;
|
||||
}
|
||||
|
||||
bool wpi::Protobuf<mrc::ErrorInfo>::Pack(OutputStream& Stream,
|
||||
bool wpi::util::Protobuf<mrc::ErrorInfo>::Pack(OutputStream& Stream,
|
||||
const mrc::ErrorInfo& Value) {
|
||||
std::string_view DetailsView = Value.GetDetails();
|
||||
std::string_view LocationView = Value.GetLocation();
|
||||
std::string_view CallStackView = Value.GetCallStack();
|
||||
wpi::PackCallback DetailsCb{&DetailsView};
|
||||
wpi::PackCallback LocationCb{&LocationView};
|
||||
wpi::PackCallback CallStackCb{&CallStackView};
|
||||
wpi::util::PackCallback DetailsCb{&DetailsView};
|
||||
wpi::util::PackCallback LocationCb{&LocationView};
|
||||
wpi::util::PackCallback CallStackCb{&CallStackView};
|
||||
|
||||
mrc_proto_ProtobufErrorInfo Msg{
|
||||
.IsError = Value.IsError,
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
#include "wpi/util/protobuf/ProtobufCallbacks.hpp"
|
||||
|
||||
std::optional<mrc::JoystickDescriptor>
|
||||
wpi::Protobuf<mrc::JoystickDescriptor>::Unpack(InputStream& Stream) {
|
||||
wpi::UnpackCallback<std::string> JoystickNameCb;
|
||||
wpi::UnpackCallback<uint8_t, MRC_MAX_NUM_AXES> AxisTypesCb;
|
||||
wpi::util::Protobuf<mrc::JoystickDescriptor>::Unpack(InputStream& Stream) {
|
||||
wpi::util::UnpackCallback<std::string> JoystickNameCb;
|
||||
wpi::util::UnpackCallback<uint8_t, MRC_MAX_NUM_AXES> AxisTypesCb;
|
||||
|
||||
mrc_proto_ProtobufJoystickDescriptor Msg;
|
||||
Msg.JoystickName = JoystickNameCb.Callback();
|
||||
@@ -47,13 +47,13 @@ wpi::Protobuf<mrc::JoystickDescriptor>::Unpack(InputStream& Stream) {
|
||||
return OutputData;
|
||||
}
|
||||
|
||||
bool wpi::Protobuf<mrc::JoystickDescriptor>::Pack(
|
||||
bool wpi::util::Protobuf<mrc::JoystickDescriptor>::Pack(
|
||||
OutputStream& Stream, const mrc::JoystickDescriptor& Value) {
|
||||
std::string_view JoystickName = Value.GetName();
|
||||
wpi::PackCallback JoystickNameCb{&JoystickName};
|
||||
wpi::util::PackCallback JoystickNameCb{&JoystickName};
|
||||
|
||||
std::span<const uint8_t> AxisTypes = Value.AxesTypes();
|
||||
wpi::PackCallback AxisTypesCb{AxisTypes};
|
||||
wpi::util::PackCallback AxisTypesCb{AxisTypes};
|
||||
|
||||
mrc_proto_ProtobufJoystickDescriptor Msg{
|
||||
.JoystickName = JoystickNameCb.Callback(),
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#include "wpi/util/protobuf/ProtobufCallbacks.hpp"
|
||||
|
||||
std::optional<mrc::JoystickRumbleData>
|
||||
wpi::Protobuf<mrc::JoystickRumbleData>::Unpack(InputStream& Stream) {
|
||||
wpi::UnpackCallback<uint16_t, MRC_MAX_NUM_RUMBLE> RumbleCb;
|
||||
wpi::util::Protobuf<mrc::JoystickRumbleData>::Unpack(InputStream& Stream) {
|
||||
wpi::util::UnpackCallback<uint16_t, MRC_MAX_NUM_RUMBLE> RumbleCb;
|
||||
|
||||
mrc_proto_ProtobufJoystickRumbleData Msg{
|
||||
.Value = RumbleCb.Callback(),
|
||||
@@ -29,9 +29,9 @@ wpi::Protobuf<mrc::JoystickRumbleData>::Unpack(InputStream& Stream) {
|
||||
return Rumble;
|
||||
}
|
||||
|
||||
bool wpi::Protobuf<mrc::JoystickRumbleData>::Pack(
|
||||
bool wpi::util::Protobuf<mrc::JoystickRumbleData>::Pack(
|
||||
OutputStream& Stream, const mrc::JoystickRumbleData& Value) {
|
||||
wpi::PackCallback RumbleCb{Value.Rumbles()};
|
||||
wpi::util::PackCallback RumbleCb{Value.Rumbles()};
|
||||
|
||||
mrc_proto_ProtobufJoystickRumbleData Msg{
|
||||
.Value = RumbleCb.Callback(),
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
#include "wpi/hal/proto/MatchInfo.h"
|
||||
#include "wpi/util/protobuf/ProtobufCallbacks.hpp"
|
||||
|
||||
std::optional<mrc::MatchInfo> wpi::Protobuf<mrc::MatchInfo>::Unpack(
|
||||
std::optional<mrc::MatchInfo> wpi::util::Protobuf<mrc::MatchInfo>::Unpack(
|
||||
InputStream& Stream) {
|
||||
wpi::UnpackCallback<std::string> NameCb;
|
||||
wpi::util::UnpackCallback<std::string> NameCb;
|
||||
|
||||
mrc_proto_ProtobufMatchInfo Msg;
|
||||
Msg.EventName = NameCb.Callback();
|
||||
@@ -35,10 +35,10 @@ std::optional<mrc::MatchInfo> wpi::Protobuf<mrc::MatchInfo>::Unpack(
|
||||
return OutputData;
|
||||
}
|
||||
|
||||
bool wpi::Protobuf<mrc::MatchInfo>::Pack(OutputStream& Stream,
|
||||
bool wpi::util::Protobuf<mrc::MatchInfo>::Pack(OutputStream& Stream,
|
||||
const mrc::MatchInfo& Value) {
|
||||
std::string_view EventNameStr = Value.GetEventName();
|
||||
wpi::PackCallback EventName{&EventNameStr};
|
||||
wpi::util::PackCallback EventName{&EventNameStr};
|
||||
|
||||
mrc_proto_ProtobufMatchInfo Msg{
|
||||
.EventName = EventName.Callback(),
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
#include "wpi/hal/proto/OpMode.h"
|
||||
#include "wpi/util/protobuf/ProtobufCallbacks.hpp"
|
||||
|
||||
std::optional<mrc::OpMode> wpi::Protobuf<mrc::OpMode>::Unpack(
|
||||
std::optional<mrc::OpMode> wpi::util::Protobuf<mrc::OpMode>::Unpack(
|
||||
InputStream& Stream) {
|
||||
wpi::UnpackCallback<std::string> NameCb;
|
||||
wpi::util::UnpackCallback<std::string> NameCb;
|
||||
|
||||
mrc_proto_ProtobufOpMode Msg;
|
||||
Msg.Name = NameCb.Callback();
|
||||
@@ -34,10 +34,10 @@ std::optional<mrc::OpMode> wpi::Protobuf<mrc::OpMode>::Unpack(
|
||||
return OutputData;
|
||||
}
|
||||
|
||||
bool wpi::Protobuf<mrc::OpMode>::Pack(OutputStream& Stream,
|
||||
bool wpi::util::Protobuf<mrc::OpMode>::Pack(OutputStream& Stream,
|
||||
const mrc::OpMode& Value) {
|
||||
std::string_view EventNameStr = Value.GetName();
|
||||
wpi::PackCallback EventName{&EventNameStr};
|
||||
wpi::util::PackCallback EventName{&EventNameStr};
|
||||
|
||||
mrc_proto_ProtobufOpMode Msg{
|
||||
.Hash = Value.Hash.ToValue(),
|
||||
@@ -48,8 +48,8 @@ bool wpi::Protobuf<mrc::OpMode>::Pack(OutputStream& Stream,
|
||||
}
|
||||
|
||||
std::optional<std::vector<mrc::OpMode>>
|
||||
wpi::Protobuf<std::vector<mrc::OpMode>>::Unpack(InputStream& Stream) {
|
||||
wpi::StdVectorUnpackCallback<mrc::OpMode> ModesCb;
|
||||
wpi::util::Protobuf<std::vector<mrc::OpMode>>::Unpack(InputStream& Stream) {
|
||||
wpi::util::StdVectorUnpackCallback<mrc::OpMode> ModesCb;
|
||||
ModesCb.SetLimits(DecodeLimits::Add);
|
||||
|
||||
mrc_proto_ProtobufAvailableOpModes Msg;
|
||||
@@ -62,10 +62,10 @@ wpi::Protobuf<std::vector<mrc::OpMode>>::Unpack(InputStream& Stream) {
|
||||
return ModesCb.Vec();
|
||||
}
|
||||
|
||||
bool wpi::Protobuf<std::vector<mrc::OpMode>>::Pack(
|
||||
bool wpi::util::Protobuf<std::vector<mrc::OpMode>>::Pack(
|
||||
OutputStream& Stream, const std::vector<mrc::OpMode>& Value) {
|
||||
std::span<const mrc::OpMode> ModesSpan = Value;
|
||||
wpi::PackCallback Modes{ModesSpan};
|
||||
wpi::util::PackCallback Modes{ModesSpan};
|
||||
|
||||
mrc_proto_ProtobufAvailableOpModes Msg{
|
||||
.Modes = Modes.Callback(),
|
||||
|
||||
@@ -394,7 +394,7 @@ void HAL_ResetSimValue(HAL_SimValueHandle handle);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
|
||||
/**
|
||||
* C++ wrapper around a HAL simulator value handle.
|
||||
@@ -944,5 +944,5 @@ class SimDevice {
|
||||
HAL_SimDeviceHandle m_handle = HAL_kInvalidHandle;
|
||||
};
|
||||
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
#endif // __cplusplus
|
||||
|
||||
@@ -88,7 +88,7 @@ typedef int32_t HAL_Bool;
|
||||
#define HAL_ENUM(name) HAL_ENUM_WITH_UNDERLYING_TYPE(name, int32_t)
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
/**
|
||||
* A move-only C++ wrapper around a HAL handle.
|
||||
* Will free the handle if FreeFunction is provided
|
||||
@@ -137,6 +137,6 @@ class Handle {
|
||||
CType m_handle = CInvalid;
|
||||
};
|
||||
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
@@ -46,8 +46,8 @@ int32_t HAL_ReportUsage(const struct WPI_String* resource,
|
||||
*/
|
||||
inline int32_t HAL_ReportUsage(std::string_view resource,
|
||||
std::string_view data) {
|
||||
WPI_String resourceStr = wpi::make_string(resource);
|
||||
WPI_String dataStr = wpi::make_string(data);
|
||||
WPI_String resourceStr = wpi::util::make_string(resource);
|
||||
WPI_String dataStr = wpi::util::make_string(data);
|
||||
return HAL_ReportUsage(&resourceStr, &dataStr);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <chrono>
|
||||
|
||||
/** WPILib Hardware Abstraction Layer (HAL) namespace */
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
|
||||
/**
|
||||
* A std::chrono compatible wrapper around the FPGA Timer.
|
||||
@@ -28,4 +28,4 @@ class fpga_clock {
|
||||
|
||||
static const time_point min_time;
|
||||
};
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "wpi/hal/handles/HandlesInternal.h"
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
|
||||
/**
|
||||
* The DigitalHandleResource class is a way to track handles. This version
|
||||
@@ -48,7 +48,7 @@ class DigitalHandleResource : public HandleBase {
|
||||
|
||||
private:
|
||||
std::array<std::shared_ptr<TStruct>, size> m_structures;
|
||||
std::array<wpi::mutex, size> m_handleMutexes;
|
||||
std::array<wpi::util::mutex, size> m_handleMutexes;
|
||||
};
|
||||
|
||||
template <typename THandle, typename TStruct, int16_t size>
|
||||
@@ -70,7 +70,7 @@ DigitalHandleResource<THandle, TStruct, size>::Allocate(
|
||||
}
|
||||
m_structures[index] = std::make_shared<TStruct>();
|
||||
*handle =
|
||||
static_cast<THandle>(hal::createHandle(index, enumValue, m_version));
|
||||
static_cast<THandle>(wpi::hal::createHandle(index, enumValue, m_version));
|
||||
*status = HAL_SUCCESS;
|
||||
return m_structures[index];
|
||||
}
|
||||
@@ -110,4 +110,4 @@ void DigitalHandleResource<THandle, TStruct, size>::ResetHandles() {
|
||||
}
|
||||
HandleBase::ResetHandles();
|
||||
}
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
* always reserved for type and error handling.
|
||||
*/
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
|
||||
/**
|
||||
* Base for all HAL Handles.
|
||||
@@ -44,7 +44,7 @@ constexpr int16_t InvalidHandleIndex = -1;
|
||||
*/
|
||||
enum class HAL_HandleEnum {
|
||||
Undefined = 0,
|
||||
DIO = wpi::kHandleTypeHALBase,
|
||||
DIO = wpi::util::kHandleTypeHALBase,
|
||||
Port = 2,
|
||||
Notifier = 3,
|
||||
Interrupt = 4,
|
||||
@@ -165,4 +165,4 @@ inline int16_t getHandleTypedIndex(HAL_Handle handle, HAL_HandleEnum enumType,
|
||||
*/
|
||||
HAL_Handle createHandle(int16_t index, HAL_HandleEnum handleType,
|
||||
int16_t version);
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "wpi/hal/handles/HandlesInternal.h"
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
|
||||
/**
|
||||
* The IndexedClassedHandleResource class is a way to track handles. This
|
||||
@@ -52,7 +52,7 @@ class IndexedClassedHandleResource : public HandleBase {
|
||||
|
||||
private:
|
||||
std::array<std::shared_ptr<TStruct>, size> m_structures;
|
||||
std::array<wpi::mutex, size> m_handleMutexes;
|
||||
std::array<wpi::util::mutex, size> m_handleMutexes;
|
||||
};
|
||||
|
||||
template <typename THandle, typename TStruct, int16_t size,
|
||||
@@ -72,7 +72,7 @@ IndexedClassedHandleResource<THandle, TStruct, size, enumValue>::Allocate(
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
m_structures[index] = toSet;
|
||||
return static_cast<THandle>(hal::createHandle(index, enumValue, m_version));
|
||||
return static_cast<THandle>(wpi::hal::createHandle(index, enumValue, m_version));
|
||||
}
|
||||
|
||||
template <typename THandle, typename TStruct, int16_t size,
|
||||
@@ -115,4 +115,4 @@ void IndexedClassedHandleResource<THandle, TStruct, size,
|
||||
}
|
||||
HandleBase::ResetHandles();
|
||||
}
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "wpi/hal/handles/HandlesInternal.h"
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
|
||||
/**
|
||||
* The IndexedHandleResource class is a way to track handles. This version
|
||||
@@ -49,7 +49,7 @@ class IndexedHandleResource : public HandleBase {
|
||||
|
||||
private:
|
||||
std::array<std::shared_ptr<TStruct>, size> m_structures;
|
||||
std::array<wpi::mutex, size> m_handleMutexes;
|
||||
std::array<wpi::util::mutex, size> m_handleMutexes;
|
||||
};
|
||||
|
||||
template <typename THandle, typename TStruct, int16_t size,
|
||||
@@ -72,7 +72,7 @@ IndexedHandleResource<THandle, TStruct, size, enumValue>::Allocate(
|
||||
}
|
||||
m_structures[index] = std::make_shared<TStruct>();
|
||||
*handle =
|
||||
static_cast<THandle>(hal::createHandle(index, enumValue, m_version));
|
||||
static_cast<THandle>(wpi::hal::createHandle(index, enumValue, m_version));
|
||||
*status = HAL_SUCCESS;
|
||||
return m_structures[index];
|
||||
}
|
||||
@@ -115,4 +115,4 @@ void IndexedHandleResource<THandle, TStruct, size, enumValue>::ResetHandles() {
|
||||
}
|
||||
HandleBase::ResetHandles();
|
||||
}
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "wpi/hal/handles/HandlesInternal.h"
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
|
||||
/**
|
||||
* The LimitedClassedHandleResource class is a way to track handles. This
|
||||
@@ -47,8 +47,8 @@ class LimitedClassedHandleResource : public HandleBase {
|
||||
|
||||
private:
|
||||
std::array<std::shared_ptr<TStruct>, size> m_structures;
|
||||
std::array<wpi::mutex, size> m_handleMutexes;
|
||||
wpi::mutex m_allocateMutex;
|
||||
std::array<wpi::util::mutex, size> m_handleMutexes;
|
||||
wpi::util::mutex m_allocateMutex;
|
||||
};
|
||||
|
||||
template <typename THandle, typename TStruct, int16_t size,
|
||||
@@ -114,4 +114,4 @@ void LimitedClassedHandleResource<THandle, TStruct, size,
|
||||
}
|
||||
HandleBase::ResetHandles();
|
||||
}
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "wpi/hal/Types.h"
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
|
||||
/**
|
||||
* The LimitedHandleResource class is a way to track handles. This version
|
||||
@@ -45,8 +45,8 @@ class LimitedHandleResource : public HandleBase {
|
||||
|
||||
private:
|
||||
std::array<std::shared_ptr<TStruct>, size> m_structures;
|
||||
std::array<wpi::mutex, size> m_handleMutexes;
|
||||
wpi::mutex m_allocateMutex;
|
||||
std::array<wpi::util::mutex, size> m_handleMutexes;
|
||||
wpi::util::mutex m_allocateMutex;
|
||||
};
|
||||
|
||||
template <typename THandle, typename TStruct, int16_t size,
|
||||
@@ -108,4 +108,4 @@ void LimitedHandleResource<THandle, TStruct, size, enumValue>::ResetHandles() {
|
||||
}
|
||||
HandleBase::ResetHandles();
|
||||
}
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "wpi/hal/handles/HandlesInternal.h"
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
|
||||
/**
|
||||
* The UnlimitedHandleResource class is a way to track handles. This version
|
||||
@@ -56,7 +56,7 @@ class UnlimitedHandleResource : public HandleBase {
|
||||
|
||||
private:
|
||||
std::vector<std::shared_ptr<TStruct>> m_structures;
|
||||
wpi::mutex m_handleMutex;
|
||||
wpi::util::mutex m_handleMutex;
|
||||
};
|
||||
|
||||
template <typename THandle, typename TStruct, HAL_HandleEnum enumValue>
|
||||
@@ -126,4 +126,4 @@ void UnlimitedHandleResource<THandle, TStruct, enumValue>::ForEach(
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -11,19 +11,19 @@
|
||||
#include "wpi/util/protobuf/Protobuf.hpp"
|
||||
|
||||
template <>
|
||||
struct wpi::Protobuf<mrc::ControlData> {
|
||||
struct wpi::util::Protobuf<mrc::ControlData> {
|
||||
using MessageStruct = mrc_proto_ProtobufControlData;
|
||||
using InputStream = wpi::ProtoInputStream<mrc::ControlData>;
|
||||
using OutputStream = wpi::ProtoOutputStream<mrc::ControlData>;
|
||||
using InputStream = wpi::util::ProtoInputStream<mrc::ControlData>;
|
||||
using OutputStream = wpi::util::ProtoOutputStream<mrc::ControlData>;
|
||||
static std::optional<mrc::ControlData> Unpack(InputStream& Stream);
|
||||
static bool Pack(OutputStream& Stream, const mrc::ControlData& Value);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct wpi::Protobuf<mrc::Joystick> {
|
||||
struct wpi::util::Protobuf<mrc::Joystick> {
|
||||
using MessageStruct = mrc_proto_ProtobufJoystickData;
|
||||
using InputStream = wpi::ProtoInputStream<mrc::Joystick>;
|
||||
using OutputStream = wpi::ProtoOutputStream<mrc::Joystick>;
|
||||
using InputStream = wpi::util::ProtoInputStream<mrc::Joystick>;
|
||||
using OutputStream = wpi::util::ProtoOutputStream<mrc::Joystick>;
|
||||
static std::optional<mrc::Joystick> Unpack(InputStream& Stream);
|
||||
static bool Pack(OutputStream& Stream, const mrc::Joystick& Value);
|
||||
};
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
#include "wpi/util/protobuf/Protobuf.hpp"
|
||||
|
||||
template <>
|
||||
struct wpi::Protobuf<mrc::ErrorInfo> {
|
||||
struct wpi::util::Protobuf<mrc::ErrorInfo> {
|
||||
using MessageStruct = mrc_proto_ProtobufErrorInfo;
|
||||
using InputStream = wpi::ProtoInputStream<mrc::ErrorInfo>;
|
||||
using OutputStream = wpi::ProtoOutputStream<mrc::ErrorInfo>;
|
||||
using InputStream = wpi::util::ProtoInputStream<mrc::ErrorInfo>;
|
||||
using OutputStream = wpi::util::ProtoOutputStream<mrc::ErrorInfo>;
|
||||
static std::optional<mrc::ErrorInfo> Unpack(InputStream& Stream);
|
||||
static bool Pack(OutputStream& Stream, const mrc::ErrorInfo& Value);
|
||||
};
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
#include "wpi/util/protobuf/Protobuf.hpp"
|
||||
|
||||
template <>
|
||||
struct wpi::Protobuf<mrc::JoystickDescriptor> {
|
||||
struct wpi::util::Protobuf<mrc::JoystickDescriptor> {
|
||||
using MessageStruct = mrc_proto_ProtobufJoystickDescriptor;
|
||||
using InputStream = wpi::ProtoInputStream<mrc::JoystickDescriptor>;
|
||||
using OutputStream = wpi::ProtoOutputStream<mrc::JoystickDescriptor>;
|
||||
using InputStream = wpi::util::ProtoInputStream<mrc::JoystickDescriptor>;
|
||||
using OutputStream = wpi::util::ProtoOutputStream<mrc::JoystickDescriptor>;
|
||||
static std::optional<mrc::JoystickDescriptor> Unpack(InputStream& Stream);
|
||||
static bool Pack(OutputStream& Stream, const mrc::JoystickDescriptor& Value);
|
||||
};
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
#include "wpi/util/protobuf/Protobuf.hpp"
|
||||
|
||||
template <>
|
||||
struct wpi::Protobuf<mrc::JoystickRumbleData> {
|
||||
struct wpi::util::Protobuf<mrc::JoystickRumbleData> {
|
||||
using MessageStruct = mrc_proto_ProtobufJoystickRumbleData;
|
||||
using InputStream = wpi::ProtoInputStream<mrc::JoystickRumbleData>;
|
||||
using OutputStream = wpi::ProtoOutputStream<mrc::JoystickRumbleData>;
|
||||
using InputStream = wpi::util::ProtoInputStream<mrc::JoystickRumbleData>;
|
||||
using OutputStream = wpi::util::ProtoOutputStream<mrc::JoystickRumbleData>;
|
||||
static std::optional<mrc::JoystickRumbleData> Unpack(InputStream& Stream);
|
||||
static bool Pack(OutputStream& Stream, const mrc::JoystickRumbleData& Value);
|
||||
};
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
#include "wpi/util/protobuf/Protobuf.hpp"
|
||||
|
||||
template <>
|
||||
struct wpi::Protobuf<mrc::MatchInfo> {
|
||||
struct wpi::util::Protobuf<mrc::MatchInfo> {
|
||||
using MessageStruct = mrc_proto_ProtobufMatchInfo;
|
||||
using InputStream = wpi::ProtoInputStream<mrc::MatchInfo>;
|
||||
using OutputStream = wpi::ProtoOutputStream<mrc::MatchInfo>;
|
||||
using InputStream = wpi::util::ProtoInputStream<mrc::MatchInfo>;
|
||||
using OutputStream = wpi::util::ProtoOutputStream<mrc::MatchInfo>;
|
||||
static std::optional<mrc::MatchInfo> Unpack(InputStream& Stream);
|
||||
static bool Pack(OutputStream& Stream, const mrc::MatchInfo& Value);
|
||||
};
|
||||
|
||||
@@ -13,19 +13,19 @@
|
||||
#include "wpi/util/protobuf/Protobuf.hpp"
|
||||
|
||||
template <>
|
||||
struct wpi::Protobuf<mrc::OpMode> {
|
||||
struct wpi::util::Protobuf<mrc::OpMode> {
|
||||
using MessageStruct = mrc_proto_ProtobufOpMode;
|
||||
using InputStream = wpi::ProtoInputStream<mrc::OpMode>;
|
||||
using OutputStream = wpi::ProtoOutputStream<mrc::OpMode>;
|
||||
using InputStream = wpi::util::ProtoInputStream<mrc::OpMode>;
|
||||
using OutputStream = wpi::util::ProtoOutputStream<mrc::OpMode>;
|
||||
static std::optional<mrc::OpMode> Unpack(InputStream& Stream);
|
||||
static bool Pack(OutputStream& Stream, const mrc::OpMode& Value);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct wpi::Protobuf<std::vector<mrc::OpMode>> {
|
||||
struct wpi::util::Protobuf<std::vector<mrc::OpMode>> {
|
||||
using MessageStruct = mrc_proto_ProtobufAvailableOpModes;
|
||||
using InputStream = wpi::ProtoInputStream<std::vector<mrc::OpMode>>;
|
||||
using OutputStream = wpi::ProtoOutputStream<std::vector<mrc::OpMode>>;
|
||||
using InputStream = wpi::util::ProtoInputStream<std::vector<mrc::OpMode>>;
|
||||
using OutputStream = wpi::util::ProtoOutputStream<std::vector<mrc::OpMode>>;
|
||||
static std::optional<std::vector<mrc::OpMode>> Unpack(InputStream& Stream);
|
||||
static bool Pack(OutputStream& Stream, const std::vector<mrc::OpMode>& Value);
|
||||
};
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
#include "wpi/util/protobuf/Protobuf.hpp"
|
||||
|
||||
template <>
|
||||
struct wpi::Protobuf<mrc::VersionInfo> {
|
||||
struct wpi::util::Protobuf<mrc::VersionInfo> {
|
||||
using MessageStruct = mrc_proto_ProtobufVersionInfo;
|
||||
using InputStream = wpi::ProtoInputStream<mrc::VersionInfo>;
|
||||
using OutputStream = wpi::ProtoOutputStream<mrc::VersionInfo>;
|
||||
using InputStream = wpi::util::ProtoInputStream<mrc::VersionInfo>;
|
||||
using OutputStream = wpi::util::ProtoOutputStream<mrc::VersionInfo>;
|
||||
static std::optional<mrc::VersionInfo> Unpack(InputStream& Stream);
|
||||
static bool Pack(OutputStream& Stream, const mrc::VersionInfo& Value);
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@ typedef void (*HAL_ConstBufferCallback)(const char* name, void* param,
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
|
||||
template <typename CallbackFunction>
|
||||
struct HalCallbackListener {
|
||||
@@ -32,6 +32,6 @@ struct HalCallbackListener {
|
||||
void* param = nullptr;
|
||||
};
|
||||
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "wpi/util/UidVector.hpp"
|
||||
#include "wpi/util/spinlock.hpp"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
|
||||
namespace impl {
|
||||
|
||||
@@ -21,7 +21,7 @@ class SimCallbackRegistryBase {
|
||||
using RawFunctor = void (*)();
|
||||
|
||||
protected:
|
||||
using CallbackVector = wpi::UidVector<HalCallbackListener<RawFunctor>, 4>;
|
||||
using CallbackVector = wpi::util::UidVector<HalCallbackListener<RawFunctor>, 4>;
|
||||
|
||||
public:
|
||||
void Cancel(int32_t uid) {
|
||||
@@ -36,7 +36,7 @@ class SimCallbackRegistryBase {
|
||||
DoReset();
|
||||
}
|
||||
|
||||
wpi::recursive_spinlock& GetMutex() { return m_mutex; }
|
||||
wpi::util::recursive_spinlock& GetMutex() { return m_mutex; }
|
||||
|
||||
protected:
|
||||
int32_t DoRegister(RawFunctor callback, void* param) {
|
||||
@@ -56,7 +56,7 @@ class SimCallbackRegistryBase {
|
||||
}
|
||||
}
|
||||
|
||||
mutable wpi::recursive_spinlock m_mutex;
|
||||
mutable wpi::util::recursive_spinlock m_mutex;
|
||||
std::unique_ptr<CallbackVector> m_callbacks;
|
||||
};
|
||||
|
||||
@@ -191,4 +191,4 @@ class SimCallbackRegistry : public impl::SimCallbackRegistryBase {
|
||||
\
|
||||
void NS##_Cancel##CAPINAME##Callback(int32_t uid) {}
|
||||
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "wpi/util/UidVector.hpp"
|
||||
#include "wpi/util/spinlock.hpp"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
|
||||
namespace impl {
|
||||
template <typename T, HAL_Value (*MakeValue)(T)>
|
||||
@@ -35,7 +35,7 @@ class SimDataValueBase : protected SimCallbackRegistryBase {
|
||||
m_value = value;
|
||||
}
|
||||
|
||||
wpi::recursive_spinlock& GetMutex() { return m_mutex; }
|
||||
wpi::util::recursive_spinlock& GetMutex() { return m_mutex; }
|
||||
|
||||
protected:
|
||||
int32_t DoRegisterCallback(HAL_NotifyCallback callback, void* param,
|
||||
@@ -333,4 +333,4 @@ class SimDataValue final : public impl::SimDataValueBase<T, MakeValue> {
|
||||
\
|
||||
void NS##_Set##CAPINAME(TYPE) {}
|
||||
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -15,20 +15,20 @@
|
||||
#include "wpi/hal/handles/HandlesInternal.h"
|
||||
#include "wpi/hal/handles/IndexedHandleResource.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeAddressableLED() {}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
HAL_AddressableLEDHandle HAL_InitializeAddressableLED(
|
||||
int32_t channel, const char* allocationLocation, int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
|
||||
if (channel < 0 || channel >= kNumAddressableLEDs) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for AddressableLED",
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for AddressableLED",
|
||||
0, kNumAddressableLEDs, channel);
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
@@ -40,10 +40,10 @@ HAL_AddressableLEDHandle HAL_InitializeAddressableLED(
|
||||
|
||||
if (*status != 0) {
|
||||
if (port) {
|
||||
hal::SetLastErrorPreviouslyAllocated(status, "PWM or DIO", channel,
|
||||
wpi::hal::SetLastErrorPreviouslyAllocated(status, "PWM or DIO", channel,
|
||||
port->previousAllocation);
|
||||
} else {
|
||||
hal::SetLastErrorIndexOutOfRange(status,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status,
|
||||
"Invalid Index for AddressableLED", 0,
|
||||
kNumAddressableLEDs, channel);
|
||||
}
|
||||
@@ -81,7 +81,7 @@ void HAL_SetAddressableLEDStart(HAL_AddressableLEDHandle handle, int32_t start,
|
||||
}
|
||||
if (start > HAL_kAddressableLEDMaxLength || start < 0) {
|
||||
*status = PARAMETER_OUT_OF_RANGE;
|
||||
hal::SetLastError(
|
||||
wpi::hal::SetLastError(
|
||||
status,
|
||||
fmt::format(
|
||||
"LED start must be less than or equal to {}. {} was requested",
|
||||
@@ -101,7 +101,7 @@ void HAL_SetAddressableLEDLength(HAL_AddressableLEDHandle handle,
|
||||
}
|
||||
if (length > HAL_kAddressableLEDMaxLength || length < 0) {
|
||||
*status = PARAMETER_OUT_OF_RANGE;
|
||||
hal::SetLastError(
|
||||
wpi::hal::SetLastError(
|
||||
status,
|
||||
fmt::format(
|
||||
"LED length must be less than or equal to {}. {} was requested",
|
||||
|
||||
@@ -11,19 +11,19 @@
|
||||
#include "mockdata/AnalogInDataInternal.h"
|
||||
#include "wpi/hal/handles/HandlesInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeAnalogInput() {}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
HAL_AnalogInputHandle HAL_InitializeAnalogInputPort(
|
||||
int32_t channel, const char* allocationLocation, int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
if (channel < 0 || channel >= kNumAnalogInputs) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Analog Input",
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Analog Input",
|
||||
0, kNumAnalogInputs, channel);
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
@@ -33,10 +33,10 @@ HAL_AnalogInputHandle HAL_InitializeAnalogInputPort(
|
||||
|
||||
if (*status != 0) {
|
||||
if (analog_port) {
|
||||
hal::SetLastErrorPreviouslyAllocated(status, "Analog Input", channel,
|
||||
wpi::hal::SetLastErrorPreviouslyAllocated(status, "Analog Input", channel,
|
||||
analog_port->previousAllocation);
|
||||
} else {
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Analog Input",
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Analog Input",
|
||||
0, kNumAnalogInputs, channel);
|
||||
}
|
||||
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
|
||||
|
||||
@@ -7,16 +7,16 @@
|
||||
#include "PortsInternal.h"
|
||||
#include "wpi/hal/handles/IndexedHandleResource.h"
|
||||
|
||||
namespace hal {
|
||||
IndexedHandleResource<HAL_AnalogInputHandle, hal::AnalogPort, kNumAnalogInputs,
|
||||
namespace wpi::hal {
|
||||
IndexedHandleResource<HAL_AnalogInputHandle, wpi::hal::AnalogPort, kNumAnalogInputs,
|
||||
HAL_HandleEnum::AnalogInput>* analogInputHandles;
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeAnalogInternal() {
|
||||
static IndexedHandleResource<HAL_AnalogInputHandle, hal::AnalogPort,
|
||||
static IndexedHandleResource<HAL_AnalogInputHandle, wpi::hal::AnalogPort,
|
||||
kNumAnalogInputs, HAL_HandleEnum::AnalogInput>
|
||||
aiH;
|
||||
analogInputHandles = &aiH;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "wpi/hal/handles/HandlesInternal.h"
|
||||
#include "wpi/hal/handles/IndexedHandleResource.h"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
constexpr int32_t kTimebase = 40000000; ///< 40 MHz clock
|
||||
constexpr int32_t kDefaultOversampleBits = 0;
|
||||
constexpr int32_t kDefaultAverageBits = 7;
|
||||
@@ -25,7 +25,7 @@ struct AnalogPort {
|
||||
std::string previousAllocation;
|
||||
};
|
||||
|
||||
extern IndexedHandleResource<HAL_AnalogInputHandle, hal::AnalogPort,
|
||||
extern IndexedHandleResource<HAL_AnalogInputHandle, wpi::hal::AnalogPort,
|
||||
kNumAnalogInputs, HAL_HandleEnum::AnalogInput>*
|
||||
analogInputHandles;
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
|
||||
#include "mockdata/CanDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeCAN() {}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "wpi/util/mutex.hpp"
|
||||
#include "wpi/util/timestamp.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace {
|
||||
struct CANStorage {
|
||||
@@ -24,17 +24,17 @@ struct CANStorage {
|
||||
HAL_CANDeviceType deviceType;
|
||||
int32_t busId;
|
||||
uint8_t deviceId;
|
||||
wpi::mutex periodicSendsMutex;
|
||||
wpi::SmallDenseMap<int32_t, int32_t> periodicSends;
|
||||
wpi::mutex receivesMutex;
|
||||
wpi::SmallDenseMap<int32_t, HAL_CANReceiveMessage> receives;
|
||||
wpi::util::mutex periodicSendsMutex;
|
||||
wpi::util::SmallDenseMap<int32_t, int32_t> periodicSends;
|
||||
wpi::util::mutex receivesMutex;
|
||||
wpi::util::SmallDenseMap<int32_t, HAL_CANReceiveMessage> receives;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
static UnlimitedHandleResource<HAL_CANHandle, CANStorage, HAL_HandleEnum::CAN>*
|
||||
canHandles;
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
namespace init {
|
||||
void InitializeCANAPI() {
|
||||
static UnlimitedHandleResource<HAL_CANHandle, CANStorage, HAL_HandleEnum::CAN>
|
||||
@@ -52,7 +52,7 @@ int32_t GetCANModuleFromHandle(HAL_CANHandle handle, int32_t* status) {
|
||||
return can->deviceId;
|
||||
}
|
||||
} // namespace can
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
static int32_t CreateCANId(CANStorage* storage, int32_t apiId) {
|
||||
int32_t createdId = 0;
|
||||
@@ -68,9 +68,9 @@ extern "C" {
|
||||
HAL_CANHandle HAL_InitializeCAN(int32_t busId, HAL_CANManufacturer manufacturer,
|
||||
int32_t deviceId, HAL_CANDeviceType deviceType,
|
||||
int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
|
||||
if (busId < 0 || busId > hal::kNumCanBuses) {
|
||||
if (busId < 0 || busId > wpi::hal::kNumCanBuses) {
|
||||
*status = PARAMETER_OUT_OF_RANGE;
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
@@ -243,7 +243,7 @@ void HAL_ReadCANPacketTimeout(HAL_CANHandle handle, int32_t apiId,
|
||||
auto i = can->receives.find(messageId);
|
||||
if (i != can->receives.end()) {
|
||||
// Found, check if new enough
|
||||
uint64_t now = wpi::Now();
|
||||
uint64_t now = wpi::util::Now();
|
||||
if (now - i->second.timeStamp >
|
||||
(static_cast<uint64_t>(timeoutMs) * 1000)) {
|
||||
// Timeout, return bad status
|
||||
|
||||
@@ -6,6 +6,6 @@
|
||||
|
||||
#include "wpi/hal/Types.h"
|
||||
|
||||
namespace hal::can {
|
||||
namespace wpi::hal::can {
|
||||
int32_t GetCANModuleFromHandle(HAL_CANHandle handle, int32_t* status);
|
||||
} // namespace hal::can
|
||||
} // namespace wpi::hal::can
|
||||
|
||||
@@ -13,12 +13,12 @@
|
||||
#include "wpi/hal/Errors.h"
|
||||
#include "wpi/hal/handles/IndexedHandleResource.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace {
|
||||
struct PCM {
|
||||
int32_t module;
|
||||
wpi::mutex lock;
|
||||
wpi::util::mutex lock;
|
||||
std::string previousAllocation;
|
||||
};
|
||||
} // namespace
|
||||
@@ -26,29 +26,29 @@ struct PCM {
|
||||
static IndexedHandleResource<HAL_CTREPCMHandle, PCM, kNumCTREPCMModules,
|
||||
HAL_HandleEnum::CTREPCM>* pcmHandles;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeCTREPCM() {
|
||||
static IndexedHandleResource<HAL_CTREPCMHandle, PCM, kNumCTREPCMModules,
|
||||
HAL_HandleEnum::CTREPCM>
|
||||
pH;
|
||||
pcmHandles = &pH;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
HAL_CTREPCMHandle HAL_InitializeCTREPCM(int32_t busId, int32_t module,
|
||||
const char* allocationLocation,
|
||||
int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
|
||||
HAL_CTREPCMHandle handle;
|
||||
auto pcm = pcmHandles->Allocate(module, &handle, status);
|
||||
|
||||
if (*status != 0) {
|
||||
if (pcm) {
|
||||
hal::SetLastErrorPreviouslyAllocated(status, "CTRE PCM", module,
|
||||
wpi::hal::SetLastErrorPreviouslyAllocated(status, "CTRE PCM", module,
|
||||
pcm->previousAllocation);
|
||||
} else {
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for CTRE PCM", 0,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for CTRE PCM", 0,
|
||||
kNumCTREPCMModules - 1, module);
|
||||
}
|
||||
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
|
||||
#include "ConstantsInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeConstants() {}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
int32_t HAL_GetSystemClockTicksPerMicrosecond(void) {
|
||||
|
||||
@@ -6,6 +6,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
constexpr int32_t kSystemClockTicksPerMicrosecond = 40;
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -10,26 +10,26 @@
|
||||
#include "wpi/hal/handles/HandlesInternal.h"
|
||||
#include "wpi/hal/handles/LimitedHandleResource.h"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
|
||||
LimitedHandleResource<HAL_CounterHandle, Counter, kNumCounters,
|
||||
HAL_HandleEnum::Counter>* counterHandles;
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeCounter() {
|
||||
static LimitedHandleResource<HAL_CounterHandle, Counter, kNumCounters,
|
||||
HAL_HandleEnum::Counter>
|
||||
cH;
|
||||
counterHandles = &cH;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
HAL_CounterHandle HAL_InitializeCounter(int channel, HAL_Bool risingEdge,
|
||||
const char* allocationLocation,
|
||||
int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
return 0;
|
||||
}
|
||||
void HAL_FreeCounter(HAL_CounterHandle counterHandle) {}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "wpi/hal/handles/HandlesInternal.h"
|
||||
#include "wpi/hal/handles/LimitedHandleResource.h"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
|
||||
struct Counter {
|
||||
uint8_t index;
|
||||
@@ -17,4 +17,4 @@ struct Counter {
|
||||
extern LimitedHandleResource<HAL_CounterHandle, Counter, kNumCounters,
|
||||
HAL_HandleEnum::Counter>* counterHandles;
|
||||
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -13,13 +13,13 @@
|
||||
#include "wpi/hal/handles/HandlesInternal.h"
|
||||
#include "wpi/hal/handles/LimitedHandleResource.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
static LimitedHandleResource<HAL_DigitalPWMHandle, uint8_t,
|
||||
kNumDigitalPWMOutputs, HAL_HandleEnum::DigitalPWM>*
|
||||
digitalPWMHandles;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeDIO() {
|
||||
static LimitedHandleResource<HAL_DigitalPWMHandle, uint8_t,
|
||||
kNumDigitalPWMOutputs,
|
||||
@@ -27,18 +27,18 @@ void InitializeDIO() {
|
||||
dpH;
|
||||
digitalPWMHandles = &dpH;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
|
||||
HAL_DigitalHandle HAL_InitializeDIOPort(int32_t channel, HAL_Bool input,
|
||||
const char* allocationLocation,
|
||||
int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
|
||||
if (channel < 0 || channel >= kNumDigitalChannels) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for DIO", 0,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for DIO", 0,
|
||||
kNumDigitalChannels, channel);
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
@@ -50,10 +50,10 @@ HAL_DigitalHandle HAL_InitializeDIOPort(int32_t channel, HAL_Bool input,
|
||||
|
||||
if (*status != 0) {
|
||||
if (port) {
|
||||
hal::SetLastErrorPreviouslyAllocated(status, "PWM or DIO", channel,
|
||||
wpi::hal::SetLastErrorPreviouslyAllocated(status, "PWM or DIO", channel,
|
||||
port->previousAllocation);
|
||||
} else {
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for DIO", 0,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for DIO", 0,
|
||||
kNumDigitalChannels, channel);
|
||||
}
|
||||
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
|
||||
@@ -190,7 +190,7 @@ void HAL_SetDIO(HAL_DigitalHandle dioPortHandle, HAL_Bool value,
|
||||
}
|
||||
if (SimDIOData[port->channel].isInput) {
|
||||
*status = PARAMETER_OUT_OF_RANGE;
|
||||
hal::SetLastError(status, "Cannot set output of an input channel");
|
||||
wpi::hal::SetLastError(status, "Cannot set output of an input channel");
|
||||
return;
|
||||
}
|
||||
SimDIOData[port->channel].value = value;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "wpi/hal/handles/DigitalHandleResource.h"
|
||||
#include "wpi/hal/handles/HandlesInternal.h"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
|
||||
DigitalHandleResource<HAL_DigitalHandle, DigitalPort,
|
||||
kNumDigitalChannels + kNumPWMHeaders>*
|
||||
@@ -45,4 +45,4 @@ int32_t GetDigitalInputChannel(HAL_DigitalHandle handle, int32_t* status) {
|
||||
|
||||
return digital->channel;
|
||||
}
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "PortsInternal.h"
|
||||
#include "wpi/hal/handles/DigitalHandleResource.h"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
/**
|
||||
* MXP channels when used as digital output PWM are offset from actual value
|
||||
*/
|
||||
@@ -57,4 +57,4 @@ int32_t remapMXPChannel(int32_t channel);
|
||||
int32_t remapMXPPWMChannel(int32_t channel);
|
||||
|
||||
int32_t GetDigitalInputChannel(HAL_DigitalHandle handle, int32_t* status);
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -25,12 +25,12 @@
|
||||
#include "wpi/util/condition_variable.hpp"
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
static wpi::mutex msgMutex;
|
||||
static wpi::util::mutex msgMutex;
|
||||
static std::atomic<HALSIM_SendErrorHandler> sendErrorHandler{nullptr};
|
||||
static std::atomic<HALSIM_SendConsoleLineHandler> sendConsoleLineHandler{
|
||||
nullptr};
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
static constexpr int kJoystickPorts = 6;
|
||||
|
||||
@@ -53,9 +53,9 @@ static std::atomic_bool gShutdown{false};
|
||||
|
||||
struct FRCDriverStation {
|
||||
~FRCDriverStation() { gShutdown = true; }
|
||||
wpi::EventVector newDataEvents;
|
||||
wpi::mutex cacheMutex;
|
||||
wpi::mutex tcpCacheMutex;
|
||||
wpi::util::EventVector newDataEvents;
|
||||
wpi::util::mutex cacheMutex;
|
||||
wpi::util::mutex tcpCacheMutex;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
@@ -116,21 +116,21 @@ void TcpCache::Update() {
|
||||
|
||||
static ::FRCDriverStation* driverStation;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeDriverStation() {
|
||||
static FRCDriverStation ds;
|
||||
driverStation = &ds;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
static void DefaultPrintErrorImpl(const char* line, size_t size) {
|
||||
std::fwrite(line, size, 1, stderr);
|
||||
}
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
static std::atomic<void (*)(const char* line, size_t size)> gPrintErrorImpl{
|
||||
hal::DefaultPrintErrorImpl};
|
||||
wpi::hal::DefaultPrintErrorImpl};
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -205,7 +205,7 @@ int32_t HAL_SendError(HAL_Bool isError, int32_t errorCode, HAL_Bool isLVCode,
|
||||
}
|
||||
|
||||
void HAL_SetPrintErrorImpl(void (*func)(const char* line, size_t size)) {
|
||||
gPrintErrorImpl.store(func ? func : hal::DefaultPrintErrorImpl);
|
||||
gPrintErrorImpl.store(func ? func : wpi::hal::DefaultPrintErrorImpl);
|
||||
}
|
||||
|
||||
int32_t HAL_SendConsoleLine(const char* line) {
|
||||
@@ -404,7 +404,7 @@ void HAL_ProvideNewDataEventHandle(WPI_EventHandle handle) {
|
||||
if (gShutdown) {
|
||||
return;
|
||||
}
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
driverStation->newDataEvents.Add(handle);
|
||||
}
|
||||
|
||||
@@ -425,7 +425,7 @@ HAL_Bool HAL_GetOutputsEnabled(void) {
|
||||
|
||||
} // extern "C"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
void NewDriverStationData() {
|
||||
if (gShutdown) {
|
||||
return;
|
||||
@@ -451,4 +451,4 @@ void NewDriverStationData() {
|
||||
void InitializeDriverStation() {
|
||||
SimDriverStationData->ResetData();
|
||||
}
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "wpi/hal/handles/HandlesInternal.h"
|
||||
#include "wpi/hal/handles/IndexedHandleResource.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace {
|
||||
struct DutyCycle {
|
||||
@@ -27,30 +27,30 @@ struct Empty {};
|
||||
static IndexedHandleResource<HAL_DutyCycleHandle, DutyCycle, kNumDutyCycles,
|
||||
HAL_HandleEnum::DutyCycle>* dutyCycleHandles;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeDutyCycle() {
|
||||
static IndexedHandleResource<HAL_DutyCycleHandle, DutyCycle, kNumDutyCycles,
|
||||
HAL_HandleEnum::DutyCycle>
|
||||
dcH;
|
||||
dutyCycleHandles = &dcH;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
HAL_DutyCycleHandle HAL_InitializeDutyCycle(int32_t channel,
|
||||
const char* allocationLocation,
|
||||
int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
|
||||
HAL_DutyCycleHandle handle = HAL_kInvalidHandle;
|
||||
auto dutyCycle = dutyCycleHandles->Allocate(channel, &handle, status);
|
||||
|
||||
if (*status != 0) {
|
||||
if (dutyCycle) {
|
||||
hal::SetLastErrorPreviouslyAllocated(status, "SmartIo", channel,
|
||||
wpi::hal::SetLastErrorPreviouslyAllocated(status, "SmartIo", channel,
|
||||
dutyCycle->previousAllocation);
|
||||
} else {
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Duty Cycle",
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Duty Cycle",
|
||||
0, kNumDutyCycles, channel);
|
||||
}
|
||||
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "wpi/hal/handles/HandlesInternal.h"
|
||||
#include "wpi/hal/handles/LimitedHandleResource.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace {
|
||||
struct Encoder {
|
||||
@@ -36,7 +36,7 @@ static LimitedHandleResource<HAL_EncoderHandle, Encoder,
|
||||
static LimitedHandleResource<HAL_FPGAEncoderHandle, Empty, kNumEncoders,
|
||||
HAL_HandleEnum::FPGAEncoder>* fpgaEncoderHandles;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeEncoder() {
|
||||
static LimitedHandleResource<HAL_FPGAEncoderHandle, Empty, kNumEncoders,
|
||||
HAL_HandleEnum::FPGAEncoder>
|
||||
@@ -48,9 +48,9 @@ void InitializeEncoder() {
|
||||
eH;
|
||||
encoderHandles = &eH;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
bool GetEncoderBaseHandle(HAL_EncoderHandle handle,
|
||||
HAL_FPGAEncoderHandle* fpgaHandle,
|
||||
HAL_CounterHandle* counterHandle) {
|
||||
@@ -63,14 +63,14 @@ bool GetEncoderBaseHandle(HAL_EncoderHandle handle,
|
||||
*counterHandle = encoder->counterHandle;
|
||||
return true;
|
||||
}
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
extern "C" {
|
||||
HAL_EncoderHandle HAL_InitializeEncoder(int32_t aChannel, int32_t bChannel,
|
||||
HAL_Bool reverseDirection,
|
||||
HAL_EncoderEncodingType encodingType,
|
||||
int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
HAL_Handle nativeHandle = HAL_kInvalidHandle;
|
||||
if (encodingType == HAL_EncoderEncodingType::HAL_Encoder_k4X) {
|
||||
// k4x, allocate encoder
|
||||
@@ -272,7 +272,7 @@ void HAL_SetEncoderMinRate(HAL_EncoderHandle encoderHandle, double minRate,
|
||||
|
||||
if (minRate == 0.0) {
|
||||
*status = PARAMETER_OUT_OF_RANGE;
|
||||
hal::SetLastError(status, "minRate must not be 0");
|
||||
wpi::hal::SetLastError(status, "minRate must not be 0");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ void HAL_SetEncoderDistancePerPulse(HAL_EncoderHandle encoderHandle,
|
||||
|
||||
if (distancePerPulse == 0.0) {
|
||||
*status = PARAMETER_OUT_OF_RANGE;
|
||||
hal::SetLastError(status, "distancePerPulse must not be 0");
|
||||
wpi::hal::SetLastError(status, "distancePerPulse must not be 0");
|
||||
return;
|
||||
}
|
||||
encoder->distancePerPulse = distancePerPulse;
|
||||
|
||||
@@ -38,14 +38,14 @@
|
||||
#define DLERROR dlerror()
|
||||
#endif
|
||||
|
||||
static wpi::recursive_spinlock gExtensionRegistryMutex;
|
||||
static wpi::util::recursive_spinlock gExtensionRegistryMutex;
|
||||
static std::vector<std::pair<const char*, void*>> gExtensionRegistry;
|
||||
static std::vector<std::pair<void*, void (*)(void*, const char*, void*)>>
|
||||
gExtensionListeners;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeExtensions() {}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
static bool& GetShowNotFoundMessage() {
|
||||
static bool showMsg = true;
|
||||
@@ -56,7 +56,7 @@ extern "C" {
|
||||
|
||||
int HAL_LoadOneExtension(const char* library) {
|
||||
int rc = 1; // It is expected and reasonable not to find an extra simulation
|
||||
wpi::print("HAL Extensions: Attempting to load: {}\n",
|
||||
wpi::util::print("HAL Extensions: Attempting to load: {}\n",
|
||||
fs::path{library}.stem().string());
|
||||
std::fflush(stdout);
|
||||
HTYPE handle = DLOPEN(library);
|
||||
@@ -67,14 +67,14 @@ int HAL_LoadOneExtension(const char* library) {
|
||||
#else
|
||||
auto libraryName = fmt::format("lib{}.so", library);
|
||||
#endif
|
||||
wpi::print("HAL Extensions: Load failed: {}\nTrying modified name: {}\n",
|
||||
wpi::util::print("HAL Extensions: Load failed: {}\nTrying modified name: {}\n",
|
||||
DLERROR, fs::path{libraryName}.stem().string());
|
||||
std::fflush(stdout);
|
||||
handle = DLOPEN(libraryName.c_str());
|
||||
}
|
||||
#endif
|
||||
if (!handle) {
|
||||
wpi::print("HAL Extensions: Failed to load library: {}\n", DLERROR);
|
||||
wpi::util::print("HAL Extensions: Failed to load library: {}\n", DLERROR);
|
||||
std::fflush(stdout);
|
||||
return rc;
|
||||
}
|
||||
@@ -107,7 +107,7 @@ int HAL_LoadExtensions(void) {
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
wpi::split(e, DELIM, -1, false, [&](auto library) {
|
||||
wpi::util::split(e, DELIM, -1, false, [&](auto library) {
|
||||
if (rc >= 0) {
|
||||
rc = HAL_LoadOneExtension(std::string(library).c_str());
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ NtQueryTimerResolution(PULONG MinimumResolution, PULONG MaximumResolution,
|
||||
#include "wpi/util/mutex.hpp"
|
||||
#include "wpi/util/spinlock.hpp"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace {
|
||||
class SimPeriodicCallbackRegistry : public impl::SimCallbackRegistryBase {
|
||||
@@ -54,16 +54,16 @@ class SimPeriodicCallbackRegistry : public impl::SimCallbackRegistryBase {
|
||||
} // namespace
|
||||
|
||||
static HAL_RuntimeType runtimeType{HAL_Runtime_Simulation};
|
||||
static wpi::spinlock gOnShutdownMutex;
|
||||
static wpi::util::spinlock gOnShutdownMutex;
|
||||
static std::vector<std::pair<void*, void (*)(void*)>> gOnShutdown;
|
||||
static SimPeriodicCallbackRegistry gSimPeriodicBefore;
|
||||
static SimPeriodicCallbackRegistry gSimPeriodicAfter;
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
void InitializeDriverStation();
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeHAL() {
|
||||
InitializeAddressableLEDData();
|
||||
InitializeAnalogInData();
|
||||
@@ -107,7 +107,7 @@ void InitializeHAL() {
|
||||
InitializeSimDevice();
|
||||
InitializeThreads();
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -253,7 +253,7 @@ int32_t HAL_GetTeamNumber(void) {
|
||||
}
|
||||
|
||||
uint64_t HAL_GetFPGATime(int32_t* status) {
|
||||
return hal::GetFPGATime();
|
||||
return wpi::hal::GetFPGATime();
|
||||
}
|
||||
|
||||
uint64_t HAL_ExpandFPGATime(uint32_t unexpandedLower, int32_t* status) {
|
||||
@@ -302,7 +302,7 @@ HAL_Bool HAL_GetSystemTimeValid(int32_t* status) {
|
||||
|
||||
HAL_Bool HAL_Initialize(int32_t timeout, int32_t mode) {
|
||||
static std::atomic_bool initialized{false};
|
||||
static wpi::mutex initializeMutex;
|
||||
static wpi::util::mutex initializeMutex;
|
||||
// Initial check, as if it's true initialization has finished
|
||||
if (initialized) {
|
||||
return true;
|
||||
@@ -314,12 +314,12 @@ HAL_Bool HAL_Initialize(int32_t timeout, int32_t mode) {
|
||||
return true;
|
||||
}
|
||||
|
||||
hal::init::InitializeHAL();
|
||||
wpi::hal::init::InitializeHAL();
|
||||
|
||||
hal::init::HAL_IsInitialized.store(true);
|
||||
wpi::hal::init::HAL_IsInitialized.store(true);
|
||||
|
||||
hal::RestartTiming();
|
||||
hal::InitializeDriverStation();
|
||||
wpi::hal::RestartTiming();
|
||||
wpi::hal::InitializeDriverStation();
|
||||
|
||||
initialized = true;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user