Skip to content

Commit

Permalink
[wpilib] Revert throw on nonexistent SimDevice name in SimDeviceSim (#…
Browse files Browse the repository at this point in the history
…5053)

This breaks current vendor use of SimDeviceSim.

This reverts commit d991f6e (#5041).
  • Loading branch information
PeterJohnson authored Feb 5, 2023
1 parent b879a6f commit 8230fc6
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 21 deletions.
19 changes: 1 addition & 18 deletions wpilibc/src/main/native/cpp/simulation/SimDeviceSim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,20 @@
#include <hal/SimDevice.h>
#include <hal/simulation/SimDeviceData.h>

#include "frc/Errors.h"

using namespace frc;
using namespace frc::sim;

SimDeviceSim::SimDeviceSim(const char* name)
: m_handle{HALSIM_GetSimDeviceHandle(name)} {
if (m_handle == 0) {
throw FRC_MakeError(err::InvalidParameter,
"No sim device exists with name '{}'.", name);
}
}
: m_handle{HALSIM_GetSimDeviceHandle(name)} {}

SimDeviceSim::SimDeviceSim(const char* name, int index) {
m_handle =
HALSIM_GetSimDeviceHandle(fmt::format("{}[{}]", name, index).c_str());
if (m_handle == 0) {
throw FRC_MakeError(err::InvalidParameter,
"No sim device exists with name '{}[{}]'.", name,
index);
}
}

SimDeviceSim::SimDeviceSim(const char* name, int index, int channel) {
m_handle = HALSIM_GetSimDeviceHandle(
fmt::format("{}[{},{}]", name, index, channel).c_str());
if (m_handle == 0) {
throw FRC_MakeError(err::InvalidParameter,
"No sim device exists with name '{}[{},{}]'.", name,
index, channel);
}
}

SimDeviceSim::SimDeviceSim(HAL_SimDeviceHandle handle) : m_handle(handle) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ public class SimDeviceSim {
*/
public SimDeviceSim(String name) {
this(SimDeviceDataJNI.getSimDeviceHandle(name));
if (m_handle == 0) {
throw new IllegalArgumentException("No sim device exists with name '" + name + "'.");
}
}

/**
Expand Down

0 comments on commit 8230fc6

Please sign in to comment.