mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +00:00
SCRIPT namespace replacements
This commit is contained in:
committed by
Peter Johnson
parent
ae6c043632
commit
9aca8e0fd6
@@ -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;
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
#include "wpi/hal/HALBase.h"
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
std::atomic_bool HAL_IsInitialized{false};
|
||||
void RunInitialize() {
|
||||
HAL_Initialize(500, 0);
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <atomic>
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
extern std::atomic_bool HAL_IsInitialized;
|
||||
extern void RunInitialize();
|
||||
inline void CheckInit() {
|
||||
@@ -59,4 +59,4 @@ extern void InitializeSerialPort();
|
||||
extern void InitializeSimDevice();
|
||||
extern void InitializeThreads();
|
||||
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <string_view>
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
void SetLastError(int32_t* status, std::string_view value);
|
||||
void SetLastErrorIndexOutOfRange(int32_t* status, std::string_view message,
|
||||
int32_t minimum, int32_t maximum,
|
||||
@@ -16,4 +16,4 @@ 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);
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -7,15 +7,15 @@
|
||||
#include "HALInitializer.h"
|
||||
#include "mockdata/I2CDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeI2C() {}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
void HAL_InitializeI2C(HAL_I2CPort port, int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
SimI2CData[port].initialized = true;
|
||||
}
|
||||
int32_t HAL_TransactionI2C(HAL_I2CPort port, int32_t deviceAddress,
|
||||
|
||||
@@ -20,15 +20,15 @@ static std::atomic<uint64_t> programStartTime{0};
|
||||
static std::atomic<uint64_t> programPauseTime{0};
|
||||
static std::atomic<uint64_t> programStepTime{0};
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeMockHooks() {
|
||||
wpi::SetNowImpl(GetFPGATime);
|
||||
wpi::util::SetNowImpl(GetFPGATime);
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
void RestartTiming() {
|
||||
programStartTime = wpi::NowDefault();
|
||||
programStartTime = wpi::util::NowDefault();
|
||||
programStepTime = 0;
|
||||
if (programPauseTime != 0) {
|
||||
programPauseTime = programStartTime.load();
|
||||
@@ -37,13 +37,13 @@ void RestartTiming() {
|
||||
|
||||
void PauseTiming() {
|
||||
if (programPauseTime == 0) {
|
||||
programPauseTime = wpi::NowDefault();
|
||||
programPauseTime = wpi::util::NowDefault();
|
||||
}
|
||||
}
|
||||
|
||||
void ResumeTiming() {
|
||||
if (programPauseTime != 0) {
|
||||
programStartTime += wpi::NowDefault() - programPauseTime;
|
||||
programStartTime += wpi::util::NowDefault() - programPauseTime;
|
||||
programPauseTime = 0;
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ void StepTiming(uint64_t delta) {
|
||||
uint64_t GetFPGATime() {
|
||||
uint64_t curTime = programPauseTime;
|
||||
if (curTime == 0) {
|
||||
curTime = wpi::NowDefault();
|
||||
curTime = wpi::util::NowDefault();
|
||||
}
|
||||
return curTime + programStepTime - programStartTime;
|
||||
}
|
||||
@@ -74,16 +74,16 @@ void SetProgramStarted() {
|
||||
bool GetProgramStarted() {
|
||||
return programStarted;
|
||||
}
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
extern "C" {
|
||||
void HALSIM_WaitForProgramStart(void) {
|
||||
int count = 0;
|
||||
while (!programStarted) {
|
||||
count++;
|
||||
wpi::print("Waiting for program start signal: {}\n", count);
|
||||
wpi::util::print("Waiting for program start signal: {}\n", count);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "wpi/hal/simulation/MockHooks.h"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
void RestartTiming();
|
||||
|
||||
void PauseTiming();
|
||||
@@ -24,4 +24,4 @@ uint64_t GetFPGATime();
|
||||
double GetFPGATimestamp();
|
||||
|
||||
void SetProgramStarted();
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -32,15 +32,15 @@ struct Notifier {
|
||||
bool waitTimeValid = false; // True if waitTime is set and in the future
|
||||
bool waitingForAlarm = false; // True if in HAL_WaitForNotifierAlarm()
|
||||
uint64_t waitCount = 0; // Counts calls to HAL_WaitForNotifierAlarm()
|
||||
wpi::mutex mutex;
|
||||
wpi::condition_variable cond;
|
||||
wpi::util::mutex mutex;
|
||||
wpi::util::condition_variable cond;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
static wpi::mutex notifiersWaiterMutex;
|
||||
static wpi::condition_variable notifiersWaiterCond;
|
||||
static wpi::util::mutex notifiersWaiterMutex;
|
||||
static wpi::util::condition_variable notifiersWaiterCond;
|
||||
|
||||
class NotifierHandleContainer
|
||||
: public UnlimitedHandleResource<HAL_NotifierHandle, Notifier,
|
||||
@@ -62,7 +62,7 @@ class NotifierHandleContainer
|
||||
static NotifierHandleContainer* notifierHandles;
|
||||
static std::atomic<bool> notifiersPaused{false};
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
namespace init {
|
||||
void InitializeNotifier() {
|
||||
static NotifierHandleContainer nH;
|
||||
@@ -87,7 +87,7 @@ void WakeupNotifiers() {
|
||||
|
||||
void WaitNotifiers() {
|
||||
std::unique_lock ulock(notifiersWaiterMutex);
|
||||
wpi::SmallVector<HAL_NotifierHandle, 8> waiters;
|
||||
wpi::util::SmallVector<HAL_NotifierHandle, 8> waiters;
|
||||
|
||||
// Wait for all Notifiers to hit HAL_WaitForNotifierAlarm()
|
||||
notifierHandles->ForEach([&](HAL_NotifierHandle handle, Notifier* notifier) {
|
||||
@@ -123,7 +123,7 @@ void WakeupWaitNotifiers() {
|
||||
std::unique_lock ulock(notifiersWaiterMutex);
|
||||
int32_t status = 0;
|
||||
uint64_t curTime = HAL_GetFPGATime(&status);
|
||||
wpi::SmallVector<std::pair<HAL_NotifierHandle, uint64_t>, 8> waiters;
|
||||
wpi::util::SmallVector<std::pair<HAL_NotifierHandle, uint64_t>, 8> waiters;
|
||||
|
||||
// Wake up Notifiers that have expired timeouts
|
||||
notifierHandles->ForEach([&](HAL_NotifierHandle handle, Notifier* notifier) {
|
||||
@@ -161,12 +161,12 @@ void WakeupWaitNotifiers() {
|
||||
notifiersWaiterCond.wait_for(ulock, std::chrono::duration<double>(1));
|
||||
}
|
||||
}
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
extern "C" {
|
||||
|
||||
HAL_NotifierHandle HAL_InitializeNotifier(int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
std::shared_ptr<Notifier> notifier = std::make_shared<Notifier>();
|
||||
HAL_NotifierHandle handle = notifierHandles->Allocate(notifier);
|
||||
if (handle == HAL_kInvalidHandle) {
|
||||
@@ -318,7 +318,7 @@ int32_t HALSIM_GetNotifierInfo(struct HALSIM_NotifierInfo* arr, int32_t size) {
|
||||
if (num < size) {
|
||||
arr[num].handle = handle;
|
||||
if (notifier->name.empty()) {
|
||||
wpi::format_to_n_c_str(arr[num].name, sizeof(arr[num].name),
|
||||
wpi::util::format_to_n_c_str(arr[num].name, sizeof(arr[num].name),
|
||||
"Notifier{}",
|
||||
static_cast<int>(getHandleIndex(handle)));
|
||||
} else {
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
void PauseNotifiers();
|
||||
void ResumeNotifiers();
|
||||
void WakeupNotifiers();
|
||||
void WaitNotifiers();
|
||||
void WakeupWaitNotifiers();
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -15,22 +15,22 @@
|
||||
#include "mockdata/PWMDataInternal.h"
|
||||
#include "wpi/hal/handles/HandlesInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializePWM() {}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
|
||||
HAL_DigitalHandle HAL_InitializePWMPort(int32_t channel,
|
||||
const char* allocationLocation,
|
||||
int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
|
||||
if (channel < 0 || channel >= kNumPWMChannels) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for PWM", 0,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for PWM", 0,
|
||||
kNumPWMChannels, channel);
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
@@ -50,10 +50,10 @@ HAL_DigitalHandle HAL_InitializePWMPort(int32_t channel,
|
||||
|
||||
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 PWM", 0,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for PWM", 0,
|
||||
kNumPWMChannels, channel);
|
||||
}
|
||||
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
|
||||
#include "PortsInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializePorts() {}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
int32_t HAL_GetNumCanBuses(void) {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
constexpr int32_t kNumCanBuses = 5;
|
||||
constexpr int32_t kAccelerometers = 1;
|
||||
constexpr int32_t kNumAccumulators = 2;
|
||||
@@ -38,4 +38,4 @@ constexpr int32_t kNumREVPHChannels = 16;
|
||||
constexpr int32_t kSPIAccelerometers = 5;
|
||||
constexpr int32_t kSPIPorts = 5;
|
||||
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
|
||||
#include "mockdata/RoboRioDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializePower() {}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
// TODO: Fix the naming in here
|
||||
extern "C" {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "wpi/hal/CANAPI.h"
|
||||
#include "wpi/hal/Errors.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
static constexpr HAL_CANManufacturer manufacturer =
|
||||
HAL_CANManufacturer::HAL_CAN_Man_kCTRE;
|
||||
@@ -22,9 +22,9 @@ static constexpr HAL_CANManufacturer manufacturer =
|
||||
static constexpr HAL_CANDeviceType deviceType =
|
||||
HAL_CANDeviceType::HAL_CAN_Dev_kPowerDistribution;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializePowerDistribution() {}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
HAL_PowerDistributionHandle HAL_InitializePowerDistribution(
|
||||
@@ -33,7 +33,7 @@ HAL_PowerDistributionHandle HAL_InitializePowerDistribution(
|
||||
if (type == HAL_PowerDistributionType_kAutomatic) {
|
||||
if (module != HAL_DEFAULT_POWER_DISTRIBUTION_MODULE) {
|
||||
*status = PARAMETER_OUT_OF_RANGE;
|
||||
hal::SetLastError(
|
||||
wpi::hal::SetLastError(
|
||||
status, "Automatic PowerDistributionType must have default module");
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
@@ -46,15 +46,15 @@ HAL_PowerDistributionHandle HAL_InitializePowerDistribution(
|
||||
if (!HAL_CheckPowerDistributionModule(module, type)) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
if (type == HAL_PowerDistributionType::HAL_PowerDistributionType_kCTRE) {
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for CTRE PDP", 0,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for CTRE PDP", 0,
|
||||
kNumCTREPDPModules - 1, module);
|
||||
} else {
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for REV PDH", 1,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for REV PDH", 1,
|
||||
kNumREVPDHModules, module);
|
||||
}
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
SimPowerDistributionData[module].initialized = true;
|
||||
auto handle =
|
||||
HAL_InitializeCAN(busId, manufacturer, module, deviceType, status);
|
||||
@@ -69,7 +69,7 @@ HAL_PowerDistributionHandle HAL_InitializePowerDistribution(
|
||||
|
||||
int32_t HAL_GetPowerDistributionModuleNumber(HAL_PowerDistributionHandle handle,
|
||||
int32_t* status) {
|
||||
auto module = hal::can::GetCANModuleFromHandle(handle, status);
|
||||
auto module = wpi::hal::can::GetCANModuleFromHandle(handle, status);
|
||||
if (*status != 0) {
|
||||
return 0;
|
||||
}
|
||||
@@ -116,7 +116,7 @@ void HAL_CleanPowerDistribution(HAL_PowerDistributionHandle handle) {
|
||||
|
||||
double HAL_GetPowerDistributionTemperature(HAL_PowerDistributionHandle handle,
|
||||
int32_t* status) {
|
||||
auto module = hal::can::GetCANModuleFromHandle(handle, status);
|
||||
auto module = wpi::hal::can::GetCANModuleFromHandle(handle, status);
|
||||
if (*status != 0) {
|
||||
return 0.0;
|
||||
}
|
||||
@@ -124,7 +124,7 @@ double HAL_GetPowerDistributionTemperature(HAL_PowerDistributionHandle handle,
|
||||
}
|
||||
double HAL_GetPowerDistributionVoltage(HAL_PowerDistributionHandle handle,
|
||||
int32_t* status) {
|
||||
auto module = hal::can::GetCANModuleFromHandle(handle, status);
|
||||
auto module = wpi::hal::can::GetCANModuleFromHandle(handle, status);
|
||||
if (*status != 0) {
|
||||
return 0.0;
|
||||
}
|
||||
@@ -132,7 +132,7 @@ double HAL_GetPowerDistributionVoltage(HAL_PowerDistributionHandle handle,
|
||||
}
|
||||
double HAL_GetPowerDistributionChannelCurrent(
|
||||
HAL_PowerDistributionHandle handle, int32_t channel, int32_t* status) {
|
||||
auto module = hal::can::GetCANModuleFromHandle(handle, status);
|
||||
auto module = wpi::hal::can::GetCANModuleFromHandle(handle, status);
|
||||
if (*status != 0) {
|
||||
return 0.0;
|
||||
}
|
||||
@@ -141,7 +141,7 @@ double HAL_GetPowerDistributionChannelCurrent(
|
||||
void HAL_GetPowerDistributionAllChannelCurrents(
|
||||
HAL_PowerDistributionHandle handle, double* currents,
|
||||
int32_t currentsLength, int32_t* status) {
|
||||
auto module = hal::can::GetCANModuleFromHandle(handle, status);
|
||||
auto module = wpi::hal::can::GetCANModuleFromHandle(handle, status);
|
||||
if (*status != 0) {
|
||||
return;
|
||||
}
|
||||
@@ -154,7 +154,7 @@ void HAL_GetPowerDistributionAllChannelCurrents(
|
||||
}
|
||||
double HAL_GetPowerDistributionTotalCurrent(HAL_PowerDistributionHandle handle,
|
||||
int32_t* status) {
|
||||
auto module = hal::can::GetCANModuleFromHandle(handle, status);
|
||||
auto module = wpi::hal::can::GetCANModuleFromHandle(handle, status);
|
||||
if (*status != 0) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@@ -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,23 +26,23 @@ struct PCM {
|
||||
static IndexedHandleResource<HAL_REVPHHandle, PCM, kNumREVPHModules,
|
||||
HAL_HandleEnum::REVPH>* pcmHandles;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeREVPH() {
|
||||
static IndexedHandleResource<HAL_REVPHHandle, PCM, kNumREVPHModules,
|
||||
HAL_HandleEnum::REVPH>
|
||||
pH;
|
||||
pcmHandles = &pH;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
HAL_REVPHHandle HAL_InitializeREVPH(int32_t busId, int32_t module,
|
||||
const char* allocationLocation,
|
||||
int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
|
||||
if (!HAL_CheckREVPHModuleNumber(module)) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for REV PH", 1,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for REV PH", 1,
|
||||
kNumREVPHModules, module);
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
@@ -53,10 +53,10 @@ HAL_REVPHHandle HAL_InitializeREVPH(int32_t busId, int32_t module,
|
||||
|
||||
if (*status != 0) {
|
||||
if (pcm) {
|
||||
hal::SetLastErrorPreviouslyAllocated(status, "REV PH", module,
|
||||
wpi::hal::SetLastErrorPreviouslyAllocated(status, "REV PH", module,
|
||||
pcm->previousAllocation);
|
||||
} else {
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for REV PH", 1,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for REV PH", 1,
|
||||
kNumREVPHModules, module);
|
||||
}
|
||||
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
|
||||
|
||||
@@ -6,21 +6,21 @@
|
||||
|
||||
#include "HALInitializer.h"
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeSerialPort() {}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
HAL_SerialPortHandle HAL_InitializeSerialPort(HAL_SerialPort port,
|
||||
int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
HAL_SerialPortHandle HAL_InitializeSerialPortDirect(HAL_SerialPort port,
|
||||
const char* portName,
|
||||
int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,16 +9,16 @@
|
||||
#include "HALInitializer.h"
|
||||
#include "mockdata/SimDeviceDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeSimDevice() {}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
|
||||
HAL_SimDeviceHandle HAL_CreateSimDevice(const char* name) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
return SimSimDeviceData->CreateDevice(name);
|
||||
}
|
||||
|
||||
@@ -68,11 +68,11 @@ void HAL_ResetSimValue(HAL_SimValueHandle handle) {
|
||||
SimSimDeviceData->ResetValue(handle);
|
||||
}
|
||||
|
||||
hal::SimDevice::SimDevice(const char* name, int index) {
|
||||
wpi::hal::SimDevice::SimDevice(const char* name, int index) {
|
||||
m_handle = HAL_CreateSimDevice(fmt::format("{}[{}]", name, index).c_str());
|
||||
}
|
||||
|
||||
hal::SimDevice::SimDevice(const char* name, int index, int channel) {
|
||||
wpi::hal::SimDevice::SimDevice(const char* name, int index, int channel) {
|
||||
m_handle = HAL_CreateSimDevice(
|
||||
fmt::format("{}[{},{}]", name, index, channel).c_str());
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
#include "wpi/hal/Threads.h"
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeThreads() {}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
int32_t HAL_GetThreadPriority(NativeThreadHandle handle, HAL_Bool* isRealTime,
|
||||
int32_t* status) {
|
||||
|
||||
@@ -8,19 +8,19 @@
|
||||
#include "../PortsInternal.h"
|
||||
#include "AddressableLEDDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeAddressableLEDData() {
|
||||
static AddressableLEDData sad[kNumAddressableLEDs];
|
||||
::hal::SimAddressableLEDData = sad;
|
||||
::wpi::hal::SimAddressableLEDData = sad;
|
||||
static AddressableLEDDataBuffer buf;
|
||||
::hal::SimAddressableLEDDataBuffer = &buf;
|
||||
::wpi::hal::SimAddressableLEDDataBuffer = &buf;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
AddressableLEDData* hal::SimAddressableLEDData;
|
||||
AddressableLEDDataBuffer* hal::SimAddressableLEDDataBuffer;
|
||||
AddressableLEDData* wpi::hal::SimAddressableLEDData;
|
||||
AddressableLEDDataBuffer* wpi::hal::SimAddressableLEDDataBuffer;
|
||||
|
||||
void AddressableLEDData::ResetData() {
|
||||
initialized.Reset(false);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/hal/simulation/SimDataValue.h"
|
||||
#include "wpi/util/spinlock.hpp"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
class AddressableLEDData {
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Initialized)
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Start)
|
||||
@@ -30,7 +30,7 @@ extern AddressableLEDData* SimAddressableLEDData;
|
||||
class AddressableLEDDataBuffer {
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Data)
|
||||
|
||||
wpi::recursive_spinlock m_dataMutex;
|
||||
wpi::util::recursive_spinlock m_dataMutex;
|
||||
HAL_AddressableLEDData m_data[HAL_kAddressableLEDMaxLength];
|
||||
|
||||
public:
|
||||
@@ -39,4 +39,4 @@ class AddressableLEDDataBuffer {
|
||||
SimCallbackRegistry<HAL_ConstBufferCallback, GetDataName> data;
|
||||
};
|
||||
extern AddressableLEDDataBuffer* SimAddressableLEDDataBuffer;
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -5,16 +5,16 @@
|
||||
#include "../PortsInternal.h"
|
||||
#include "AnalogInDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeAnalogInData() {
|
||||
static AnalogInData sind[kNumAnalogInputs];
|
||||
::hal::SimAnalogInData = sind;
|
||||
::wpi::hal::SimAnalogInData = sind;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
AnalogInData* hal::SimAnalogInData;
|
||||
AnalogInData* wpi::hal::SimAnalogInData;
|
||||
void AnalogInData::ResetData() {
|
||||
initialized.Reset(false);
|
||||
simDevice = 0;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "wpi/hal/simulation/AnalogInData.h"
|
||||
#include "wpi/hal/simulation/SimDataValue.h"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
class AnalogInData {
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Initialized)
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(AverageBits)
|
||||
@@ -25,4 +25,4 @@ class AnalogInData {
|
||||
virtual void ResetData();
|
||||
};
|
||||
extern AnalogInData* SimAnalogInData;
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -5,16 +5,16 @@
|
||||
#include "../PortsInternal.h"
|
||||
#include "CTREPCMDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeCTREPCMData() {
|
||||
static CTREPCMData spd[kNumCTREPCMModules];
|
||||
::hal::SimCTREPCMData = spd;
|
||||
::wpi::hal::SimCTREPCMData = spd;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
CTREPCMData* hal::SimCTREPCMData;
|
||||
CTREPCMData* wpi::hal::SimCTREPCMData;
|
||||
void CTREPCMData::ResetData() {
|
||||
for (int i = 0; i < kNumCTRESolenoidChannels; i++) {
|
||||
solenoidOutput[i].Reset(false);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "wpi/hal/simulation/CTREPCMData.h"
|
||||
#include "wpi/hal/simulation/SimDataValue.h"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
class CTREPCMData {
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Initialized)
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(SolenoidOutput)
|
||||
@@ -40,4 +40,4 @@ class CTREPCMData {
|
||||
virtual void ResetData();
|
||||
};
|
||||
extern CTREPCMData* SimCTREPCMData;
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -4,16 +4,16 @@
|
||||
|
||||
#include "CanDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeCanData() {
|
||||
static CanData scd;
|
||||
::hal::SimCanData = &scd;
|
||||
::wpi::hal::SimCanData = &scd;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
CanData* hal::SimCanData;
|
||||
CanData* wpi::hal::SimCanData;
|
||||
|
||||
void CanData::ResetData() {
|
||||
sendMessage.Reset();
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "wpi/hal/simulation/CanData.h"
|
||||
#include "wpi/hal/simulation/SimCallbackRegistry.h"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
|
||||
class CanData {
|
||||
HAL_SIMCALLBACKREGISTRY_DEFINE_NAME(SendMessage)
|
||||
@@ -36,4 +36,4 @@ class CanData {
|
||||
|
||||
extern CanData* SimCanData;
|
||||
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -5,16 +5,16 @@
|
||||
#include "../PortsInternal.h"
|
||||
#include "DIODataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeDIOData() {
|
||||
static DIOData sdd[kNumDigitalChannels];
|
||||
::hal::SimDIOData = sdd;
|
||||
::wpi::hal::SimDIOData = sdd;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
DIOData* hal::SimDIOData;
|
||||
DIOData* wpi::hal::SimDIOData;
|
||||
void DIOData::ResetData() {
|
||||
initialized.Reset(false);
|
||||
simDevice = 0;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "wpi/hal/simulation/DIOData.h"
|
||||
#include "wpi/hal/simulation/SimDataValue.h"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
class DIOData {
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Initialized)
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Value)
|
||||
@@ -27,4 +27,4 @@ class DIOData {
|
||||
virtual void ResetData();
|
||||
};
|
||||
extern DIOData* SimDIOData;
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -5,16 +5,16 @@
|
||||
#include "../PortsInternal.h"
|
||||
#include "DigitalPWMDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeDigitalPWMData() {
|
||||
static DigitalPWMData sdpd[kNumDigitalPWMOutputs];
|
||||
::hal::SimDigitalPWMData = sdpd;
|
||||
::wpi::hal::SimDigitalPWMData = sdpd;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
DigitalPWMData* hal::SimDigitalPWMData;
|
||||
DigitalPWMData* wpi::hal::SimDigitalPWMData;
|
||||
void DigitalPWMData::ResetData() {
|
||||
initialized.Reset(false);
|
||||
dutyCycle.Reset(0.0);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "wpi/hal/simulation/DigitalPWMData.h"
|
||||
#include "wpi/hal/simulation/SimDataValue.h"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
class DigitalPWMData {
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Initialized)
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(DutyCycle)
|
||||
@@ -22,4 +22,4 @@ class DigitalPWMData {
|
||||
virtual void ResetData();
|
||||
};
|
||||
extern DigitalPWMData* SimDigitalPWMData;
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -6,16 +6,16 @@
|
||||
|
||||
#include "DriverStationDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeDriverStationData() {
|
||||
static DriverStationData dsd;
|
||||
::hal::SimDriverStationData = &dsd;
|
||||
::wpi::hal::SimDriverStationData = &dsd;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
DriverStationData* hal::SimDriverStationData;
|
||||
DriverStationData* wpi::hal::SimDriverStationData;
|
||||
|
||||
DriverStationData::DriverStationData() {
|
||||
ResetData();
|
||||
@@ -215,12 +215,12 @@ void DriverStationData::CallNewDataCallbacks() {
|
||||
m_newDataCallbacks(&empty);
|
||||
}
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
void NewDriverStationData();
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
void DriverStationData::NotifyNewData() {
|
||||
hal::NewDriverStationData();
|
||||
wpi::hal::NewDriverStationData();
|
||||
}
|
||||
|
||||
void DriverStationData::SetJoystickButton(int32_t stick, int32_t button,
|
||||
@@ -528,15 +528,15 @@ void HALSIM_SetJoystickType(int32_t stick, int32_t type) {
|
||||
}
|
||||
|
||||
void HALSIM_SetJoystickName(int32_t stick, const WPI_String* name) {
|
||||
SimDriverStationData->SetJoystickName(stick, wpi::to_string_view(name));
|
||||
SimDriverStationData->SetJoystickName(stick, wpi::util::to_string_view(name));
|
||||
}
|
||||
|
||||
void HALSIM_SetGameSpecificMessage(const WPI_String* message) {
|
||||
SimDriverStationData->SetGameSpecificMessage(wpi::to_string_view(message));
|
||||
SimDriverStationData->SetGameSpecificMessage(wpi::util::to_string_view(message));
|
||||
}
|
||||
|
||||
void HALSIM_SetEventName(const WPI_String* name) {
|
||||
SimDriverStationData->SetEventName(wpi::to_string_view(name));
|
||||
SimDriverStationData->SetEventName(wpi::util::to_string_view(name));
|
||||
}
|
||||
|
||||
void HALSIM_SetMatchType(HAL_MatchType type) {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/hal/simulation/SimDataValue.h"
|
||||
#include "wpi/util/spinlock.hpp"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
|
||||
class DriverStationData {
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Enabled)
|
||||
@@ -157,11 +157,11 @@ class DriverStationData {
|
||||
};
|
||||
|
||||
static constexpr int kNumJoysticks = 6;
|
||||
wpi::spinlock m_joystickDataMutex;
|
||||
wpi::util::spinlock m_joystickDataMutex;
|
||||
JoystickData m_joystickData[kNumJoysticks];
|
||||
|
||||
wpi::spinlock m_matchInfoMutex;
|
||||
wpi::util::spinlock m_matchInfoMutex;
|
||||
HAL_MatchInfo m_matchInfo;
|
||||
};
|
||||
extern DriverStationData* SimDriverStationData;
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -5,16 +5,16 @@
|
||||
#include "../PortsInternal.h"
|
||||
#include "DutyCycleDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeDutyCycleData() {
|
||||
static DutyCycleData sed[kNumDutyCycles];
|
||||
::hal::SimDutyCycleData = sed;
|
||||
::wpi::hal::SimDutyCycleData = sed;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
DutyCycleData* hal::SimDutyCycleData;
|
||||
DutyCycleData* wpi::hal::SimDutyCycleData;
|
||||
|
||||
void DutyCycleData::ResetData() {
|
||||
initialized.Reset(false);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "wpi/hal/simulation/DutyCycleData.h"
|
||||
#include "wpi/hal/simulation/SimDataValue.h"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
class DutyCycleData {
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Initialized)
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Output)
|
||||
@@ -26,4 +26,4 @@ class DutyCycleData {
|
||||
virtual void ResetData();
|
||||
};
|
||||
extern DutyCycleData* SimDutyCycleData;
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -7,16 +7,16 @@
|
||||
#include "../PortsInternal.h"
|
||||
#include "EncoderDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeEncoderData() {
|
||||
static EncoderData sed[kNumEncoders];
|
||||
::hal::SimEncoderData = sed;
|
||||
::wpi::hal::SimEncoderData = sed;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
EncoderData* hal::SimEncoderData;
|
||||
EncoderData* wpi::hal::SimEncoderData;
|
||||
void EncoderData::ResetData() {
|
||||
digitalChannelA = 0;
|
||||
digitalChannelB = 0;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "wpi/hal/simulation/EncoderData.h"
|
||||
#include "wpi/hal/simulation/SimDataValue.h"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
class EncoderData {
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Initialized)
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Count)
|
||||
@@ -44,4 +44,4 @@ class EncoderData {
|
||||
virtual void ResetData();
|
||||
};
|
||||
extern EncoderData* SimEncoderData;
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -5,16 +5,16 @@
|
||||
#include "../PortsInternal.h"
|
||||
#include "I2CDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeI2CData() {
|
||||
static I2CData sid[kI2CPorts];
|
||||
::hal::SimI2CData = sid;
|
||||
::wpi::hal::SimI2CData = sid;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
I2CData* hal::SimI2CData;
|
||||
I2CData* wpi::hal::SimI2CData;
|
||||
|
||||
void I2CData::ResetData() {
|
||||
initialized.Reset(false);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "wpi/hal/simulation/SimCallbackRegistry.h"
|
||||
#include "wpi/hal/simulation/SimDataValue.h"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
class I2CData {
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Initialized)
|
||||
HAL_SIMCALLBACKREGISTRY_DEFINE_NAME(Read)
|
||||
@@ -27,4 +27,4 @@ class I2CData {
|
||||
void ResetData();
|
||||
};
|
||||
extern I2CData* SimI2CData;
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -5,16 +5,16 @@
|
||||
#include "../PortsInternal.h"
|
||||
#include "PWMDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializePWMData() {
|
||||
static PWMData spd[kNumPWMChannels];
|
||||
::hal::SimPWMData = spd;
|
||||
::wpi::hal::SimPWMData = spd;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
PWMData* hal::SimPWMData;
|
||||
PWMData* wpi::hal::SimPWMData;
|
||||
void PWMData::ResetData() {
|
||||
initialized.Reset(false);
|
||||
simDevice = 0;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "wpi/hal/simulation/PWMData.h"
|
||||
#include "wpi/hal/simulation/SimDataValue.h"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
class PWMData {
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Initialized)
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(PulseMicrosecond)
|
||||
@@ -24,4 +24,4 @@ class PWMData {
|
||||
virtual void ResetData();
|
||||
};
|
||||
extern PWMData* SimPWMData;
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -5,16 +5,16 @@
|
||||
#include "../PortsInternal.h"
|
||||
#include "PowerDistributionDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializePowerDistributionData() {
|
||||
static PowerDistributionData spd[kNumPDSimModules];
|
||||
::hal::SimPowerDistributionData = spd;
|
||||
::wpi::hal::SimPowerDistributionData = spd;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
PowerDistributionData* hal::SimPowerDistributionData;
|
||||
PowerDistributionData* wpi::hal::SimPowerDistributionData;
|
||||
void PowerDistributionData::ResetData() {
|
||||
initialized.Reset(false);
|
||||
temperature.Reset(0.0);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "wpi/hal/simulation/PowerDistributionData.h"
|
||||
#include "wpi/hal/simulation/SimDataValue.h"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
|
||||
class PowerDistributionData {
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Initialized)
|
||||
@@ -31,4 +31,4 @@ class PowerDistributionData {
|
||||
virtual void ResetData();
|
||||
};
|
||||
extern PowerDistributionData* SimPowerDistributionData;
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -5,16 +5,16 @@
|
||||
#include "../PortsInternal.h"
|
||||
#include "REVPHDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeREVPHData() {
|
||||
static REVPHData spd[kNumREVPHModules];
|
||||
::hal::SimREVPHData = spd;
|
||||
::wpi::hal::SimREVPHData = spd;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
REVPHData* hal::SimREVPHData;
|
||||
REVPHData* wpi::hal::SimREVPHData;
|
||||
void REVPHData::ResetData() {
|
||||
for (int i = 0; i < kNumREVPHChannels; i++) {
|
||||
solenoidOutput[i].Reset(false);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "wpi/hal/simulation/REVPHData.h"
|
||||
#include "wpi/hal/simulation/SimDataValue.h"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
class REVPHData {
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Initialized)
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(SolenoidOutput)
|
||||
@@ -47,4 +47,4 @@ class REVPHData {
|
||||
virtual void ResetData();
|
||||
};
|
||||
extern REVPHData* SimREVPHData;
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -20,51 +20,51 @@
|
||||
#include "wpi/hal/simulation/SimDeviceData.h"
|
||||
|
||||
extern "C" void HALSIM_ResetAllSimData(void) {
|
||||
for (int32_t i = 0; i < hal::kNumAddressableLEDs; i++) {
|
||||
for (int32_t i = 0; i < wpi::hal::kNumAddressableLEDs; i++) {
|
||||
HALSIM_ResetAddressableLEDData(i);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < hal::kNumAnalogInputs; i++) {
|
||||
for (int32_t i = 0; i < wpi::hal::kNumAnalogInputs; i++) {
|
||||
HALSIM_ResetAnalogInData(i);
|
||||
}
|
||||
|
||||
HALSIM_ResetCanData();
|
||||
|
||||
for (int32_t i = 0; i < hal::kNumCTREPCMModules; i++) {
|
||||
for (int32_t i = 0; i < wpi::hal::kNumCTREPCMModules; i++) {
|
||||
HALSIM_ResetCTREPCMData(i);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < hal::kNumDigitalPWMOutputs; i++) {
|
||||
for (int32_t i = 0; i < wpi::hal::kNumDigitalPWMOutputs; i++) {
|
||||
HALSIM_ResetDigitalPWMData(i);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < hal::kNumDigitalChannels; i++) {
|
||||
for (int32_t i = 0; i < wpi::hal::kNumDigitalChannels; i++) {
|
||||
HALSIM_ResetDIOData(i);
|
||||
}
|
||||
|
||||
HALSIM_ResetDriverStationData();
|
||||
|
||||
for (int32_t i = 0; i < hal::kNumDutyCycles; i++) {
|
||||
for (int32_t i = 0; i < wpi::hal::kNumDutyCycles; i++) {
|
||||
HALSIM_ResetDutyCycleData(i);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < hal::kNumEncoders; i++) {
|
||||
for (int32_t i = 0; i < wpi::hal::kNumEncoders; i++) {
|
||||
HALSIM_ResetEncoderData(i);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < hal::kI2CPorts; i++) {
|
||||
for (int32_t i = 0; i < wpi::hal::kI2CPorts; i++) {
|
||||
HALSIM_ResetI2CData(i);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < hal::kNumPDSimModules; i++) {
|
||||
for (int32_t i = 0; i < wpi::hal::kNumPDSimModules; i++) {
|
||||
HALSIM_ResetPowerDistributionData(i);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < hal::kNumPWMChannels; i++) {
|
||||
for (int32_t i = 0; i < wpi::hal::kNumPWMChannels; i++) {
|
||||
HALSIM_ResetPWMData(i);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < hal::kNumREVPHModules; i++) {
|
||||
for (int32_t i = 0; i < wpi::hal::kNumREVPHModules; i++) {
|
||||
HALSIM_ResetREVPHData(i);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,16 +6,16 @@
|
||||
|
||||
#include "RoboRioDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeRoboRioData() {
|
||||
static RoboRioData srrd;
|
||||
::hal::SimRoboRioData = &srrd;
|
||||
::wpi::hal::SimRoboRioData = &srrd;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
RoboRioData* hal::SimRoboRioData;
|
||||
RoboRioData* wpi::hal::SimRoboRioData;
|
||||
void RoboRioData::ResetData() {
|
||||
vInVoltage.Reset(12.0);
|
||||
userVoltage3V3.Reset(3.3);
|
||||
@@ -121,7 +121,7 @@ void HALSIM_GetRoboRioSerialNumber(struct WPI_String* serialNumber) {
|
||||
SimRoboRioData->GetSerialNumber(serialNumber);
|
||||
}
|
||||
void HALSIM_SetRoboRioSerialNumber(const struct WPI_String* serialNumber) {
|
||||
SimRoboRioData->SetSerialNumber(wpi::to_string_view(serialNumber));
|
||||
SimRoboRioData->SetSerialNumber(wpi::util::to_string_view(serialNumber));
|
||||
}
|
||||
|
||||
int32_t HALSIM_RegisterRoboRioCommentsCallback(
|
||||
@@ -136,7 +136,7 @@ void HALSIM_GetRoboRioComments(struct WPI_String* comments) {
|
||||
SimRoboRioData->GetComments(comments);
|
||||
}
|
||||
void HALSIM_SetRoboRioComments(const struct WPI_String* comments) {
|
||||
SimRoboRioData->SetComments(wpi::to_string_view(comments));
|
||||
SimRoboRioData->SetComments(wpi::util::to_string_view(comments));
|
||||
}
|
||||
|
||||
void HALSIM_RegisterRoboRioAllCallbacks(HAL_NotifyCallback callback,
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/hal/simulation/SimDataValue.h"
|
||||
#include "wpi/util/spinlock.hpp"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
class RoboRioData {
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(VInVoltage)
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(UserVoltage3V3)
|
||||
@@ -54,10 +54,10 @@ class RoboRioData {
|
||||
virtual void ResetData();
|
||||
|
||||
private:
|
||||
wpi::spinlock m_serialNumberMutex;
|
||||
wpi::util::spinlock m_serialNumberMutex;
|
||||
std::string m_serialNumber;
|
||||
|
||||
wpi::spinlock m_commentsMutex;
|
||||
wpi::util::spinlock m_commentsMutex;
|
||||
std::string m_comments;
|
||||
|
||||
SimCallbackRegistry<HAL_RoboRioStringCallback, GetSerialNumberName>
|
||||
@@ -67,4 +67,4 @@ class RoboRioData {
|
||||
m_commentsCallbacks;
|
||||
};
|
||||
extern RoboRioData* SimRoboRioData;
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -11,16 +11,16 @@
|
||||
#include "SimDeviceDataInternal.h"
|
||||
#include "wpi/util/StringExtras.hpp"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeSimDeviceData() {
|
||||
static SimDeviceData sdd;
|
||||
::hal::SimSimDeviceData = &sdd;
|
||||
::wpi::hal::SimSimDeviceData = &sdd;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
SimDeviceData* hal::SimSimDeviceData;
|
||||
SimDeviceData* wpi::hal::SimSimDeviceData;
|
||||
|
||||
SimDeviceData::Device* SimDeviceData::LookupDevice(HAL_SimDeviceHandle handle) {
|
||||
if (handle <= 0) {
|
||||
@@ -74,7 +74,7 @@ void SimDeviceData::SetDeviceEnabled(const char* prefix, bool enabled) {
|
||||
bool SimDeviceData::IsDeviceEnabled(const char* name) {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
for (const auto& elem : m_prefixEnabled) {
|
||||
if (wpi::starts_with(name, elem.first)) {
|
||||
if (wpi::util::starts_with(name, elem.first)) {
|
||||
return elem.second;
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,7 @@ HAL_SimDeviceHandle SimDeviceData::CreateDevice(const char* name) {
|
||||
|
||||
// don't create if disabled
|
||||
for (const auto& elem : m_prefixEnabled) {
|
||||
if (wpi::starts_with(name, elem.first)) {
|
||||
if (wpi::util::starts_with(name, elem.first)) {
|
||||
if (elem.second) {
|
||||
break; // enabled
|
||||
}
|
||||
@@ -275,7 +275,7 @@ int32_t SimDeviceData::RegisterDeviceCreatedCallback(
|
||||
// initial notifications
|
||||
if (initialNotify) {
|
||||
for (auto&& device : m_devices) {
|
||||
if (wpi::starts_with(device->name, prefix)) {
|
||||
if (wpi::util::starts_with(device->name, prefix)) {
|
||||
auto name = device->name;
|
||||
auto handle = device->handle;
|
||||
lock.unlock();
|
||||
@@ -339,7 +339,7 @@ void SimDeviceData::EnumerateDevices(const char* prefix, void* param,
|
||||
HALSIM_SimDeviceCallback callback) {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
for (auto&& device : m_devices) {
|
||||
if (wpi::starts_with(device->name, prefix)) {
|
||||
if (wpi::util::starts_with(device->name, prefix)) {
|
||||
callback(device->name.c_str(), param, device->handle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "wpi/util/UidVector.hpp"
|
||||
#include "wpi/util/spinlock.hpp"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
|
||||
namespace impl {
|
||||
|
||||
@@ -29,7 +29,7 @@ class SimUnnamedCallbackRegistry {
|
||||
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) {
|
||||
@@ -95,7 +95,7 @@ class SimPrefixCallbackRegistry {
|
||||
|
||||
explicit operator bool() const { return callback != nullptr; }
|
||||
};
|
||||
using CallbackVector = wpi::UidVector<CallbackData, 4>;
|
||||
using CallbackVector = wpi::util::UidVector<CallbackData, 4>;
|
||||
|
||||
public:
|
||||
void Cancel(int32_t uid) {
|
||||
@@ -126,7 +126,7 @@ class SimPrefixCallbackRegistry {
|
||||
if (m_callbacks) {
|
||||
for (size_t i = 0; i < m_callbacks->size(); ++i) {
|
||||
auto& cb = (*m_callbacks)[i];
|
||||
if (cb.callback && wpi::starts_with(name, cb.prefix)) {
|
||||
if (cb.callback && wpi::util::starts_with(name, cb.prefix)) {
|
||||
auto callback = cb.callback;
|
||||
auto param = cb.param;
|
||||
lock.unlock();
|
||||
@@ -170,16 +170,16 @@ class SimDeviceData {
|
||||
|
||||
HAL_SimDeviceHandle handle{0};
|
||||
std::string name;
|
||||
wpi::UidVector<std::unique_ptr<Value>, 16> values;
|
||||
wpi::StringMap<Value*> valueMap;
|
||||
wpi::util::UidVector<std::unique_ptr<Value>, 16> values;
|
||||
wpi::util::StringMap<Value*> valueMap;
|
||||
impl::SimUnnamedCallbackRegistry<HALSIM_SimValueCallback> valueCreated;
|
||||
};
|
||||
|
||||
wpi::UidVector<std::shared_ptr<Device>, 4> m_devices;
|
||||
wpi::StringMap<std::weak_ptr<Device>> m_deviceMap;
|
||||
wpi::util::UidVector<std::shared_ptr<Device>, 4> m_devices;
|
||||
wpi::util::StringMap<std::weak_ptr<Device>> m_deviceMap;
|
||||
std::vector<std::pair<std::string, bool>> m_prefixEnabled;
|
||||
|
||||
wpi::recursive_spinlock m_mutex;
|
||||
wpi::util::recursive_spinlock m_mutex;
|
||||
|
||||
impl::SimPrefixCallbackRegistry<HALSIM_SimDeviceCallback> m_deviceCreated;
|
||||
impl::SimPrefixCallbackRegistry<HALSIM_SimDeviceCallback> m_deviceFreed;
|
||||
@@ -253,4 +253,4 @@ class SimDeviceData {
|
||||
void ResetData();
|
||||
};
|
||||
extern SimDeviceData* SimSimDeviceData;
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
Reference in New Issue
Block a user