mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
SCRIPT namespace replacements
This commit is contained in:
committed by
Peter Johnson
parent
ae6c043632
commit
9aca8e0fd6
@@ -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