2018-05-11 12:38:23 -07:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2020-06-27 22:11:24 -07:00
|
|
|
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
2018-05-11 12:38:23 -07:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <utility>
|
|
|
|
|
|
2020-06-27 22:11:24 -07:00
|
|
|
#include <hal/simulation/RoboRioData.h>
|
|
|
|
|
|
2018-05-11 12:38:23 -07:00
|
|
|
#include "CallbackStore.h"
|
|
|
|
|
|
|
|
|
|
namespace frc {
|
|
|
|
|
namespace sim {
|
2020-07-04 00:44:56 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class to control a simulated RoboRIO.
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
class RoboRioSim {
|
|
|
|
|
public:
|
2020-07-04 00:44:56 -07:00
|
|
|
static std::unique_ptr<CallbackStore> RegisterFPGAButtonCallback(
|
2018-05-11 12:38:23 -07:00
|
|
|
NotifyCallback callback, bool initialNotify) {
|
|
|
|
|
auto store = std::make_unique<CallbackStore>(
|
2020-07-04 00:44:56 -07:00
|
|
|
-1, callback, &HALSIM_CancelRoboRioFPGAButtonCallback);
|
2018-05-11 12:38:23 -07:00
|
|
|
store->SetUid(HALSIM_RegisterRoboRioFPGAButtonCallback(
|
2020-07-04 00:44:56 -07:00
|
|
|
&CallbackStoreThunk, store.get(), initialNotify));
|
2018-05-16 19:45:46 -07:00
|
|
|
return store;
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static bool GetFPGAButton() { return HALSIM_GetRoboRioFPGAButton(); }
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static void SetFPGAButton(bool fPGAButton) {
|
|
|
|
|
HALSIM_SetRoboRioFPGAButton(fPGAButton);
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
|
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static std::unique_ptr<CallbackStore> RegisterVInVoltageCallback(
|
2018-05-11 12:38:23 -07:00
|
|
|
NotifyCallback callback, bool initialNotify) {
|
|
|
|
|
auto store = std::make_unique<CallbackStore>(
|
2020-07-04 00:44:56 -07:00
|
|
|
-1, callback, &HALSIM_CancelRoboRioVInVoltageCallback);
|
2018-05-11 12:38:23 -07:00
|
|
|
store->SetUid(HALSIM_RegisterRoboRioVInVoltageCallback(
|
2020-07-04 00:44:56 -07:00
|
|
|
&CallbackStoreThunk, store.get(), initialNotify));
|
2018-05-16 19:45:46 -07:00
|
|
|
return store;
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static double GetVInVoltage() { return HALSIM_GetRoboRioVInVoltage(); }
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static void SetVInVoltage(double vInVoltage) {
|
|
|
|
|
HALSIM_SetRoboRioVInVoltage(vInVoltage);
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
|
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static std::unique_ptr<CallbackStore> RegisterVInCurrentCallback(
|
2018-05-11 12:38:23 -07:00
|
|
|
NotifyCallback callback, bool initialNotify) {
|
|
|
|
|
auto store = std::make_unique<CallbackStore>(
|
2020-07-04 00:44:56 -07:00
|
|
|
-1, callback, &HALSIM_CancelRoboRioVInCurrentCallback);
|
2018-05-11 12:38:23 -07:00
|
|
|
store->SetUid(HALSIM_RegisterRoboRioVInCurrentCallback(
|
2020-07-04 00:44:56 -07:00
|
|
|
&CallbackStoreThunk, store.get(), initialNotify));
|
2018-05-16 19:45:46 -07:00
|
|
|
return store;
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static double GetVInCurrent() { return HALSIM_GetRoboRioVInCurrent(); }
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static void SetVInCurrent(double vInCurrent) {
|
|
|
|
|
HALSIM_SetRoboRioVInCurrent(vInCurrent);
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
|
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static std::unique_ptr<CallbackStore> RegisterUserVoltage6VCallback(
|
2018-05-11 12:38:23 -07:00
|
|
|
NotifyCallback callback, bool initialNotify) {
|
|
|
|
|
auto store = std::make_unique<CallbackStore>(
|
2020-07-04 00:44:56 -07:00
|
|
|
-1, callback, &HALSIM_CancelRoboRioUserVoltage6VCallback);
|
2018-05-11 12:38:23 -07:00
|
|
|
store->SetUid(HALSIM_RegisterRoboRioUserVoltage6VCallback(
|
2020-07-04 00:44:56 -07:00
|
|
|
&CallbackStoreThunk, store.get(), initialNotify));
|
2018-05-16 19:45:46 -07:00
|
|
|
return store;
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static double GetUserVoltage6V() { return HALSIM_GetRoboRioUserVoltage6V(); }
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static void SetUserVoltage6V(double userVoltage6V) {
|
|
|
|
|
HALSIM_SetRoboRioUserVoltage6V(userVoltage6V);
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
|
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static std::unique_ptr<CallbackStore> RegisterUserCurrent6VCallback(
|
2018-05-11 12:38:23 -07:00
|
|
|
NotifyCallback callback, bool initialNotify) {
|
|
|
|
|
auto store = std::make_unique<CallbackStore>(
|
2020-07-04 00:44:56 -07:00
|
|
|
-1, callback, &HALSIM_CancelRoboRioUserCurrent6VCallback);
|
2018-05-11 12:38:23 -07:00
|
|
|
store->SetUid(HALSIM_RegisterRoboRioUserCurrent6VCallback(
|
2020-07-04 00:44:56 -07:00
|
|
|
&CallbackStoreThunk, store.get(), initialNotify));
|
2018-05-16 19:45:46 -07:00
|
|
|
return store;
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static double GetUserCurrent6V() { return HALSIM_GetRoboRioUserCurrent6V(); }
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static void SetUserCurrent6V(double userCurrent6V) {
|
|
|
|
|
HALSIM_SetRoboRioUserCurrent6V(userCurrent6V);
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
|
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static std::unique_ptr<CallbackStore> RegisterUserActive6VCallback(
|
2018-05-11 12:38:23 -07:00
|
|
|
NotifyCallback callback, bool initialNotify) {
|
|
|
|
|
auto store = std::make_unique<CallbackStore>(
|
2020-07-04 00:44:56 -07:00
|
|
|
-1, callback, &HALSIM_CancelRoboRioUserActive6VCallback);
|
2018-05-11 12:38:23 -07:00
|
|
|
store->SetUid(HALSIM_RegisterRoboRioUserActive6VCallback(
|
2020-07-04 00:44:56 -07:00
|
|
|
&CallbackStoreThunk, store.get(), initialNotify));
|
2018-05-16 19:45:46 -07:00
|
|
|
return store;
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static bool GetUserActive6V() { return HALSIM_GetRoboRioUserActive6V(); }
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static void SetUserActive6V(bool userActive6V) {
|
|
|
|
|
HALSIM_SetRoboRioUserActive6V(userActive6V);
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
|
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static std::unique_ptr<CallbackStore> RegisterUserVoltage5VCallback(
|
2018-05-11 12:38:23 -07:00
|
|
|
NotifyCallback callback, bool initialNotify) {
|
|
|
|
|
auto store = std::make_unique<CallbackStore>(
|
2020-07-04 00:44:56 -07:00
|
|
|
-1, callback, &HALSIM_CancelRoboRioUserVoltage5VCallback);
|
2018-05-11 12:38:23 -07:00
|
|
|
store->SetUid(HALSIM_RegisterRoboRioUserVoltage5VCallback(
|
2020-07-04 00:44:56 -07:00
|
|
|
&CallbackStoreThunk, store.get(), initialNotify));
|
2018-05-16 19:45:46 -07:00
|
|
|
return store;
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static double GetUserVoltage5V() { return HALSIM_GetRoboRioUserVoltage5V(); }
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static void SetUserVoltage5V(double userVoltage5V) {
|
|
|
|
|
HALSIM_SetRoboRioUserVoltage5V(userVoltage5V);
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
|
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static std::unique_ptr<CallbackStore> RegisterUserCurrent5VCallback(
|
2018-05-11 12:38:23 -07:00
|
|
|
NotifyCallback callback, bool initialNotify) {
|
|
|
|
|
auto store = std::make_unique<CallbackStore>(
|
2020-07-04 00:44:56 -07:00
|
|
|
-1, callback, &HALSIM_CancelRoboRioUserCurrent5VCallback);
|
2018-05-11 12:38:23 -07:00
|
|
|
store->SetUid(HALSIM_RegisterRoboRioUserCurrent5VCallback(
|
2020-07-04 00:44:56 -07:00
|
|
|
&CallbackStoreThunk, store.get(), initialNotify));
|
2018-05-16 19:45:46 -07:00
|
|
|
return store;
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static double GetUserCurrent5V() { return HALSIM_GetRoboRioUserCurrent5V(); }
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static void SetUserCurrent5V(double userCurrent5V) {
|
|
|
|
|
HALSIM_SetRoboRioUserCurrent5V(userCurrent5V);
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
|
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static std::unique_ptr<CallbackStore> RegisterUserActive5VCallback(
|
2018-05-11 12:38:23 -07:00
|
|
|
NotifyCallback callback, bool initialNotify) {
|
|
|
|
|
auto store = std::make_unique<CallbackStore>(
|
2020-07-04 00:44:56 -07:00
|
|
|
-1, callback, &HALSIM_CancelRoboRioUserActive5VCallback);
|
2018-05-11 12:38:23 -07:00
|
|
|
store->SetUid(HALSIM_RegisterRoboRioUserActive5VCallback(
|
2020-07-04 00:44:56 -07:00
|
|
|
&CallbackStoreThunk, store.get(), initialNotify));
|
2018-05-16 19:45:46 -07:00
|
|
|
return store;
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static bool GetUserActive5V() { return HALSIM_GetRoboRioUserActive5V(); }
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static void SetUserActive5V(bool userActive5V) {
|
|
|
|
|
HALSIM_SetRoboRioUserActive5V(userActive5V);
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
|
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static std::unique_ptr<CallbackStore> RegisterUserVoltage3V3Callback(
|
2018-05-11 12:38:23 -07:00
|
|
|
NotifyCallback callback, bool initialNotify) {
|
|
|
|
|
auto store = std::make_unique<CallbackStore>(
|
2020-07-04 00:44:56 -07:00
|
|
|
-1, callback, &HALSIM_CancelRoboRioUserVoltage3V3Callback);
|
2018-05-11 12:38:23 -07:00
|
|
|
store->SetUid(HALSIM_RegisterRoboRioUserVoltage3V3Callback(
|
2020-07-04 00:44:56 -07:00
|
|
|
&CallbackStoreThunk, store.get(), initialNotify));
|
2018-05-16 19:45:46 -07:00
|
|
|
return store;
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static double GetUserVoltage3V3() {
|
|
|
|
|
return HALSIM_GetRoboRioUserVoltage3V3();
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static void SetUserVoltage3V3(double userVoltage3V3) {
|
|
|
|
|
HALSIM_SetRoboRioUserVoltage3V3(userVoltage3V3);
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
|
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static std::unique_ptr<CallbackStore> RegisterUserCurrent3V3Callback(
|
2018-05-11 12:38:23 -07:00
|
|
|
NotifyCallback callback, bool initialNotify) {
|
|
|
|
|
auto store = std::make_unique<CallbackStore>(
|
2020-07-04 00:44:56 -07:00
|
|
|
-1, callback, &HALSIM_CancelRoboRioUserCurrent3V3Callback);
|
2018-05-11 12:38:23 -07:00
|
|
|
store->SetUid(HALSIM_RegisterRoboRioUserCurrent3V3Callback(
|
2020-07-04 00:44:56 -07:00
|
|
|
&CallbackStoreThunk, store.get(), initialNotify));
|
2018-05-16 19:45:46 -07:00
|
|
|
return store;
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static double GetUserCurrent3V3() {
|
|
|
|
|
return HALSIM_GetRoboRioUserCurrent3V3();
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static void SetUserCurrent3V3(double userCurrent3V3) {
|
|
|
|
|
HALSIM_SetRoboRioUserCurrent3V3(userCurrent3V3);
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
|
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static std::unique_ptr<CallbackStore> RegisterUserActive3V3Callback(
|
2018-05-11 12:38:23 -07:00
|
|
|
NotifyCallback callback, bool initialNotify) {
|
|
|
|
|
auto store = std::make_unique<CallbackStore>(
|
2020-07-04 00:44:56 -07:00
|
|
|
-1, callback, &HALSIM_CancelRoboRioUserActive3V3Callback);
|
2018-05-11 12:38:23 -07:00
|
|
|
store->SetUid(HALSIM_RegisterRoboRioUserActive3V3Callback(
|
2020-07-04 00:44:56 -07:00
|
|
|
&CallbackStoreThunk, store.get(), initialNotify));
|
2018-05-16 19:45:46 -07:00
|
|
|
return store;
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static bool GetUserActive3V3() { return HALSIM_GetRoboRioUserActive3V3(); }
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static void SetUserActive3V3(bool userActive3V3) {
|
|
|
|
|
HALSIM_SetRoboRioUserActive3V3(userActive3V3);
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
|
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static std::unique_ptr<CallbackStore> RegisterUserFaults6VCallback(
|
2018-05-11 12:38:23 -07:00
|
|
|
NotifyCallback callback, bool initialNotify) {
|
|
|
|
|
auto store = std::make_unique<CallbackStore>(
|
2020-07-04 00:44:56 -07:00
|
|
|
-1, callback, &HALSIM_CancelRoboRioUserFaults6VCallback);
|
2018-05-11 12:38:23 -07:00
|
|
|
store->SetUid(HALSIM_RegisterRoboRioUserFaults6VCallback(
|
2020-07-04 00:44:56 -07:00
|
|
|
&CallbackStoreThunk, store.get(), initialNotify));
|
2018-05-16 19:45:46 -07:00
|
|
|
return store;
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static int GetUserFaults6V() { return HALSIM_GetRoboRioUserFaults6V(); }
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static void SetUserFaults6V(int userFaults6V) {
|
|
|
|
|
HALSIM_SetRoboRioUserFaults6V(userFaults6V);
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
|
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static std::unique_ptr<CallbackStore> RegisterUserFaults5VCallback(
|
2018-05-11 12:38:23 -07:00
|
|
|
NotifyCallback callback, bool initialNotify) {
|
|
|
|
|
auto store = std::make_unique<CallbackStore>(
|
2020-07-04 00:44:56 -07:00
|
|
|
-1, callback, &HALSIM_CancelRoboRioUserFaults5VCallback);
|
2018-05-11 12:38:23 -07:00
|
|
|
store->SetUid(HALSIM_RegisterRoboRioUserFaults5VCallback(
|
2020-07-04 00:44:56 -07:00
|
|
|
&CallbackStoreThunk, store.get(), initialNotify));
|
2018-05-16 19:45:46 -07:00
|
|
|
return store;
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static int GetUserFaults5V() { return HALSIM_GetRoboRioUserFaults5V(); }
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static void SetUserFaults5V(int userFaults5V) {
|
|
|
|
|
HALSIM_SetRoboRioUserFaults5V(userFaults5V);
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
|
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static std::unique_ptr<CallbackStore> RegisterUserFaults3V3Callback(
|
2018-05-11 12:38:23 -07:00
|
|
|
NotifyCallback callback, bool initialNotify) {
|
|
|
|
|
auto store = std::make_unique<CallbackStore>(
|
2020-07-04 00:44:56 -07:00
|
|
|
-1, callback, &HALSIM_CancelRoboRioUserFaults3V3Callback);
|
2018-05-11 12:38:23 -07:00
|
|
|
store->SetUid(HALSIM_RegisterRoboRioUserFaults3V3Callback(
|
2020-07-04 00:44:56 -07:00
|
|
|
&CallbackStoreThunk, store.get(), initialNotify));
|
2018-05-16 19:45:46 -07:00
|
|
|
return store;
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static int GetUserFaults3V3() { return HALSIM_GetRoboRioUserFaults3V3(); }
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static void SetUserFaults3V3(int userFaults3V3) {
|
|
|
|
|
HALSIM_SetRoboRioUserFaults3V3(userFaults3V3);
|
2018-05-11 12:38:23 -07:00
|
|
|
}
|
|
|
|
|
|
2020-07-04 00:44:56 -07:00
|
|
|
static void ResetData() { HALSIM_ResetRoboRioData(); }
|
2018-05-11 12:38:23 -07:00
|
|
|
};
|
|
|
|
|
} // namespace sim
|
|
|
|
|
} // namespace frc
|