[wpilibc] SimDeviceSim: use fmtlib (#3389)

Also clean up several sim classes to use the channel constructor.
This commit is contained in:
Peter Johnson
2021-05-26 07:23:13 -07:00
committed by GitHub
parent a238cec12b
commit cb0051ae60
4 changed files with 9 additions and 34 deletions

View File

@@ -7,10 +7,9 @@
#include <string>
#include <vector>
#include <fmt/format.h>
#include <hal/SimDevice.h>
#include <hal/simulation/SimDeviceData.h>
#include <wpi/SmallString.h>
#include <wpi/raw_ostream.h>
using namespace frc;
using namespace frc::sim;
@@ -19,19 +18,13 @@ SimDeviceSim::SimDeviceSim(const char* name)
: m_handle{HALSIM_GetSimDeviceHandle(name)} {}
SimDeviceSim::SimDeviceSim(const char* name, int index) {
wpi::SmallString<128> fullname;
wpi::raw_svector_ostream os(fullname);
os << name << '[' << index << ']';
m_handle = HALSIM_GetSimDeviceHandle(fullname.c_str());
m_handle =
HALSIM_GetSimDeviceHandle(fmt::format("{}[{}]", name, index).c_str());
}
SimDeviceSim::SimDeviceSim(const char* name, int index, int channel) {
wpi::SmallString<128> fullname;
wpi::raw_svector_ostream os(fullname);
os << name << '[' << index << ',' << channel << ']';
m_handle = HALSIM_GetSimDeviceHandle(fullname.c_str());
m_handle = HALSIM_GetSimDeviceHandle(
fmt::format("{}[{},{}]", name, index, channel).c_str());
}
hal::SimValue SimDeviceSim::GetValue(const char* name) const {