[sim] Add support for disabling SimDevices (#2568)

This allows disabling/enabling SimDevices via prefix matching.  This can be
used to force devices that normally use SimDevice in simulation mode to
instead talk directly to the hardware as in normal operation.
This commit is contained in:
Peter Johnson
2020-07-04 01:09:49 -07:00
committed by GitHub
parent 1851ba1434
commit 80a1fa9ece
6 changed files with 101 additions and 2 deletions

View File

@@ -150,6 +150,7 @@ class SimDeviceData {
wpi::UidVector<std::shared_ptr<Device>, 4> m_devices;
wpi::StringMap<std::weak_ptr<Device>> m_deviceMap;
std::vector<std::pair<std::string, bool>> m_prefixEnabled;
wpi::recursive_spinlock m_mutex;
@@ -161,6 +162,9 @@ class SimDeviceData {
Value* LookupValue(HAL_SimValueHandle handle);
public:
void SetDeviceEnabled(const char* prefix, bool enabled);
bool IsDeviceEnabled(const char* name);
HAL_SimDeviceHandle CreateDevice(const char* name);
void FreeDevice(HAL_SimDeviceHandle handle);
HAL_SimValueHandle CreateValue(HAL_SimDeviceHandle device, const char* name,