mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
[sim] Remove index from RoboRIO simulation interface (#2567)
This commit is contained in:
@@ -16,259 +16,242 @@
|
||||
|
||||
namespace frc {
|
||||
namespace sim {
|
||||
|
||||
/**
|
||||
* Class to control a simulated RoboRIO.
|
||||
*/
|
||||
class RoboRioSim {
|
||||
public:
|
||||
explicit RoboRioSim(int index) { m_index = index; }
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterFPGAButtonCallback(
|
||||
static std::unique_ptr<CallbackStore> RegisterFPGAButtonCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioFPGAButtonCallback);
|
||||
-1, callback, &HALSIM_CancelRoboRioFPGAButtonCallback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioFPGAButtonCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
&CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetFPGAButton() const { return HALSIM_GetRoboRioFPGAButton(m_index); }
|
||||
static bool GetFPGAButton() { return HALSIM_GetRoboRioFPGAButton(); }
|
||||
|
||||
void SetFPGAButton(bool fPGAButton) {
|
||||
HALSIM_SetRoboRioFPGAButton(m_index, fPGAButton);
|
||||
static void SetFPGAButton(bool fPGAButton) {
|
||||
HALSIM_SetRoboRioFPGAButton(fPGAButton);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterVInVoltageCallback(
|
||||
static std::unique_ptr<CallbackStore> RegisterVInVoltageCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioVInVoltageCallback);
|
||||
-1, callback, &HALSIM_CancelRoboRioVInVoltageCallback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioVInVoltageCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
&CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetVInVoltage() const { return HALSIM_GetRoboRioVInVoltage(m_index); }
|
||||
static double GetVInVoltage() { return HALSIM_GetRoboRioVInVoltage(); }
|
||||
|
||||
void SetVInVoltage(double vInVoltage) {
|
||||
HALSIM_SetRoboRioVInVoltage(m_index, vInVoltage);
|
||||
static void SetVInVoltage(double vInVoltage) {
|
||||
HALSIM_SetRoboRioVInVoltage(vInVoltage);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterVInCurrentCallback(
|
||||
static std::unique_ptr<CallbackStore> RegisterVInCurrentCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioVInCurrentCallback);
|
||||
-1, callback, &HALSIM_CancelRoboRioVInCurrentCallback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioVInCurrentCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
&CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetVInCurrent() const { return HALSIM_GetRoboRioVInCurrent(m_index); }
|
||||
static double GetVInCurrent() { return HALSIM_GetRoboRioVInCurrent(); }
|
||||
|
||||
void SetVInCurrent(double vInCurrent) {
|
||||
HALSIM_SetRoboRioVInCurrent(m_index, vInCurrent);
|
||||
static void SetVInCurrent(double vInCurrent) {
|
||||
HALSIM_SetRoboRioVInCurrent(vInCurrent);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterUserVoltage6VCallback(
|
||||
static std::unique_ptr<CallbackStore> RegisterUserVoltage6VCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioUserVoltage6VCallback);
|
||||
-1, callback, &HALSIM_CancelRoboRioUserVoltage6VCallback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioUserVoltage6VCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
&CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetUserVoltage6V() const {
|
||||
return HALSIM_GetRoboRioUserVoltage6V(m_index);
|
||||
static double GetUserVoltage6V() { return HALSIM_GetRoboRioUserVoltage6V(); }
|
||||
|
||||
static void SetUserVoltage6V(double userVoltage6V) {
|
||||
HALSIM_SetRoboRioUserVoltage6V(userVoltage6V);
|
||||
}
|
||||
|
||||
void SetUserVoltage6V(double userVoltage6V) {
|
||||
HALSIM_SetRoboRioUserVoltage6V(m_index, userVoltage6V);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterUserCurrent6VCallback(
|
||||
static std::unique_ptr<CallbackStore> RegisterUserCurrent6VCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioUserCurrent6VCallback);
|
||||
-1, callback, &HALSIM_CancelRoboRioUserCurrent6VCallback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioUserCurrent6VCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
&CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetUserCurrent6V() const {
|
||||
return HALSIM_GetRoboRioUserCurrent6V(m_index);
|
||||
static double GetUserCurrent6V() { return HALSIM_GetRoboRioUserCurrent6V(); }
|
||||
|
||||
static void SetUserCurrent6V(double userCurrent6V) {
|
||||
HALSIM_SetRoboRioUserCurrent6V(userCurrent6V);
|
||||
}
|
||||
|
||||
void SetUserCurrent6V(double userCurrent6V) {
|
||||
HALSIM_SetRoboRioUserCurrent6V(m_index, userCurrent6V);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterUserActive6VCallback(
|
||||
static std::unique_ptr<CallbackStore> RegisterUserActive6VCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioUserActive6VCallback);
|
||||
-1, callback, &HALSIM_CancelRoboRioUserActive6VCallback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioUserActive6VCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
&CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetUserActive6V() const {
|
||||
return HALSIM_GetRoboRioUserActive6V(m_index);
|
||||
static bool GetUserActive6V() { return HALSIM_GetRoboRioUserActive6V(); }
|
||||
|
||||
static void SetUserActive6V(bool userActive6V) {
|
||||
HALSIM_SetRoboRioUserActive6V(userActive6V);
|
||||
}
|
||||
|
||||
void SetUserActive6V(bool userActive6V) {
|
||||
HALSIM_SetRoboRioUserActive6V(m_index, userActive6V);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterUserVoltage5VCallback(
|
||||
static std::unique_ptr<CallbackStore> RegisterUserVoltage5VCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioUserVoltage5VCallback);
|
||||
-1, callback, &HALSIM_CancelRoboRioUserVoltage5VCallback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioUserVoltage5VCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
&CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetUserVoltage5V() const {
|
||||
return HALSIM_GetRoboRioUserVoltage5V(m_index);
|
||||
static double GetUserVoltage5V() { return HALSIM_GetRoboRioUserVoltage5V(); }
|
||||
|
||||
static void SetUserVoltage5V(double userVoltage5V) {
|
||||
HALSIM_SetRoboRioUserVoltage5V(userVoltage5V);
|
||||
}
|
||||
|
||||
void SetUserVoltage5V(double userVoltage5V) {
|
||||
HALSIM_SetRoboRioUserVoltage5V(m_index, userVoltage5V);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterUserCurrent5VCallback(
|
||||
static std::unique_ptr<CallbackStore> RegisterUserCurrent5VCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioUserCurrent5VCallback);
|
||||
-1, callback, &HALSIM_CancelRoboRioUserCurrent5VCallback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioUserCurrent5VCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
&CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetUserCurrent5V() const {
|
||||
return HALSIM_GetRoboRioUserCurrent5V(m_index);
|
||||
static double GetUserCurrent5V() { return HALSIM_GetRoboRioUserCurrent5V(); }
|
||||
|
||||
static void SetUserCurrent5V(double userCurrent5V) {
|
||||
HALSIM_SetRoboRioUserCurrent5V(userCurrent5V);
|
||||
}
|
||||
|
||||
void SetUserCurrent5V(double userCurrent5V) {
|
||||
HALSIM_SetRoboRioUserCurrent5V(m_index, userCurrent5V);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterUserActive5VCallback(
|
||||
static std::unique_ptr<CallbackStore> RegisterUserActive5VCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioUserActive5VCallback);
|
||||
-1, callback, &HALSIM_CancelRoboRioUserActive5VCallback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioUserActive5VCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
&CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetUserActive5V() const {
|
||||
return HALSIM_GetRoboRioUserActive5V(m_index);
|
||||
static bool GetUserActive5V() { return HALSIM_GetRoboRioUserActive5V(); }
|
||||
|
||||
static void SetUserActive5V(bool userActive5V) {
|
||||
HALSIM_SetRoboRioUserActive5V(userActive5V);
|
||||
}
|
||||
|
||||
void SetUserActive5V(bool userActive5V) {
|
||||
HALSIM_SetRoboRioUserActive5V(m_index, userActive5V);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterUserVoltage3V3Callback(
|
||||
static std::unique_ptr<CallbackStore> RegisterUserVoltage3V3Callback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioUserVoltage3V3Callback);
|
||||
-1, callback, &HALSIM_CancelRoboRioUserVoltage3V3Callback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioUserVoltage3V3Callback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
&CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetUserVoltage3V3() const {
|
||||
return HALSIM_GetRoboRioUserVoltage3V3(m_index);
|
||||
static double GetUserVoltage3V3() {
|
||||
return HALSIM_GetRoboRioUserVoltage3V3();
|
||||
}
|
||||
|
||||
void SetUserVoltage3V3(double userVoltage3V3) {
|
||||
HALSIM_SetRoboRioUserVoltage3V3(m_index, userVoltage3V3);
|
||||
static void SetUserVoltage3V3(double userVoltage3V3) {
|
||||
HALSIM_SetRoboRioUserVoltage3V3(userVoltage3V3);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterUserCurrent3V3Callback(
|
||||
static std::unique_ptr<CallbackStore> RegisterUserCurrent3V3Callback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioUserCurrent3V3Callback);
|
||||
-1, callback, &HALSIM_CancelRoboRioUserCurrent3V3Callback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioUserCurrent3V3Callback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
&CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
double GetUserCurrent3V3() const {
|
||||
return HALSIM_GetRoboRioUserCurrent3V3(m_index);
|
||||
static double GetUserCurrent3V3() {
|
||||
return HALSIM_GetRoboRioUserCurrent3V3();
|
||||
}
|
||||
|
||||
void SetUserCurrent3V3(double userCurrent3V3) {
|
||||
HALSIM_SetRoboRioUserCurrent3V3(m_index, userCurrent3V3);
|
||||
static void SetUserCurrent3V3(double userCurrent3V3) {
|
||||
HALSIM_SetRoboRioUserCurrent3V3(userCurrent3V3);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterUserActive3V3Callback(
|
||||
static std::unique_ptr<CallbackStore> RegisterUserActive3V3Callback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioUserActive3V3Callback);
|
||||
-1, callback, &HALSIM_CancelRoboRioUserActive3V3Callback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioUserActive3V3Callback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
&CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
bool GetUserActive3V3() const {
|
||||
return HALSIM_GetRoboRioUserActive3V3(m_index);
|
||||
static bool GetUserActive3V3() { return HALSIM_GetRoboRioUserActive3V3(); }
|
||||
|
||||
static void SetUserActive3V3(bool userActive3V3) {
|
||||
HALSIM_SetRoboRioUserActive3V3(userActive3V3);
|
||||
}
|
||||
|
||||
void SetUserActive3V3(bool userActive3V3) {
|
||||
HALSIM_SetRoboRioUserActive3V3(m_index, userActive3V3);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterUserFaults6VCallback(
|
||||
static std::unique_ptr<CallbackStore> RegisterUserFaults6VCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioUserFaults6VCallback);
|
||||
-1, callback, &HALSIM_CancelRoboRioUserFaults6VCallback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioUserFaults6VCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
&CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
int GetUserFaults6V() const { return HALSIM_GetRoboRioUserFaults6V(m_index); }
|
||||
static int GetUserFaults6V() { return HALSIM_GetRoboRioUserFaults6V(); }
|
||||
|
||||
void SetUserFaults6V(int userFaults6V) {
|
||||
HALSIM_SetRoboRioUserFaults6V(m_index, userFaults6V);
|
||||
static void SetUserFaults6V(int userFaults6V) {
|
||||
HALSIM_SetRoboRioUserFaults6V(userFaults6V);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterUserFaults5VCallback(
|
||||
static std::unique_ptr<CallbackStore> RegisterUserFaults5VCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioUserFaults5VCallback);
|
||||
-1, callback, &HALSIM_CancelRoboRioUserFaults5VCallback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioUserFaults5VCallback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
&CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
int GetUserFaults5V() const { return HALSIM_GetRoboRioUserFaults5V(m_index); }
|
||||
static int GetUserFaults5V() { return HALSIM_GetRoboRioUserFaults5V(); }
|
||||
|
||||
void SetUserFaults5V(int userFaults5V) {
|
||||
HALSIM_SetRoboRioUserFaults5V(m_index, userFaults5V);
|
||||
static void SetUserFaults5V(int userFaults5V) {
|
||||
HALSIM_SetRoboRioUserFaults5V(userFaults5V);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RegisterUserFaults3V3Callback(
|
||||
static std::unique_ptr<CallbackStore> RegisterUserFaults3V3Callback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
m_index, -1, callback, &HALSIM_CancelRoboRioUserFaults3V3Callback);
|
||||
-1, callback, &HALSIM_CancelRoboRioUserFaults3V3Callback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioUserFaults3V3Callback(
|
||||
m_index, &CallbackStoreThunk, store.get(), initialNotify));
|
||||
&CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
int GetUserFaults3V3() const {
|
||||
return HALSIM_GetRoboRioUserFaults3V3(m_index);
|
||||
static int GetUserFaults3V3() { return HALSIM_GetRoboRioUserFaults3V3(); }
|
||||
|
||||
static void SetUserFaults3V3(int userFaults3V3) {
|
||||
HALSIM_SetRoboRioUserFaults3V3(userFaults3V3);
|
||||
}
|
||||
|
||||
void SetUserFaults3V3(int userFaults3V3) {
|
||||
HALSIM_SetRoboRioUserFaults3V3(m_index, userFaults3V3);
|
||||
}
|
||||
|
||||
void ResetData() { HALSIM_ResetRoboRioData(m_index); }
|
||||
|
||||
private:
|
||||
int m_index;
|
||||
static void ResetData() { HALSIM_ResetRoboRioData(); }
|
||||
};
|
||||
} // namespace sim
|
||||
} // namespace frc
|
||||
|
||||
Reference in New Issue
Block a user