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>
|
|
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
#include <hal/DriverStationTypes.h>
|
2020-06-27 22:11:24 -07:00
|
|
|
|
2020-07-15 00:33:57 -07:00
|
|
|
#include "frc/DriverStation.h"
|
2020-07-15 23:48:09 -07:00
|
|
|
#include "frc/simulation/CallbackStore.h"
|
2018-05-11 12:38:23 -07:00
|
|
|
|
|
|
|
|
namespace frc {
|
|
|
|
|
namespace sim {
|
2020-07-04 10:10:43 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class to control a simulated driver station.
|
|
|
|
|
*/
|
2018-05-11 12:38:23 -07:00
|
|
|
class DriverStationSim {
|
|
|
|
|
public:
|
2020-07-04 10:10:43 -07:00
|
|
|
static std::unique_ptr<CallbackStore> RegisterEnabledCallback(
|
2020-07-15 23:48:09 -07:00
|
|
|
NotifyCallback callback, bool initialNotify);
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
static bool GetEnabled();
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
static void SetEnabled(bool enabled);
|
2018-05-11 12:38:23 -07:00
|
|
|
|
2020-07-04 10:10:43 -07:00
|
|
|
static std::unique_ptr<CallbackStore> RegisterAutonomousCallback(
|
2020-07-15 23:48:09 -07:00
|
|
|
NotifyCallback callback, bool initialNotify);
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
static bool GetAutonomous();
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
static void SetAutonomous(bool autonomous);
|
2018-05-11 12:38:23 -07:00
|
|
|
|
2020-07-04 10:10:43 -07:00
|
|
|
static std::unique_ptr<CallbackStore> RegisterTestCallback(
|
2020-07-15 23:48:09 -07:00
|
|
|
NotifyCallback callback, bool initialNotify);
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
static bool GetTest();
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
static void SetTest(bool test);
|
2018-05-11 12:38:23 -07:00
|
|
|
|
2020-07-04 10:10:43 -07:00
|
|
|
static std::unique_ptr<CallbackStore> RegisterEStopCallback(
|
2020-07-15 23:48:09 -07:00
|
|
|
NotifyCallback callback, bool initialNotify);
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
static bool GetEStop();
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
static void SetEStop(bool eStop);
|
2018-05-11 12:38:23 -07:00
|
|
|
|
2020-07-04 10:10:43 -07:00
|
|
|
static std::unique_ptr<CallbackStore> RegisterFmsAttachedCallback(
|
2020-07-15 23:48:09 -07:00
|
|
|
NotifyCallback callback, bool initialNotify);
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
static bool GetFmsAttached();
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
static void SetFmsAttached(bool fmsAttached);
|
2018-05-11 12:38:23 -07:00
|
|
|
|
2020-07-04 10:10:43 -07:00
|
|
|
static std::unique_ptr<CallbackStore> RegisterDsAttachedCallback(
|
2020-07-15 23:48:09 -07:00
|
|
|
NotifyCallback callback, bool initialNotify);
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
static bool GetDsAttached();
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
static void SetDsAttached(bool dsAttached);
|
2018-05-11 12:38:23 -07:00
|
|
|
|
2020-07-15 00:33:57 -07:00
|
|
|
static std::unique_ptr<CallbackStore> RegisterAllianceStationIdCallback(
|
2020-07-15 23:48:09 -07:00
|
|
|
NotifyCallback callback, bool initialNotify);
|
|
|
|
|
|
|
|
|
|
static HAL_AllianceStationID GetAllianceStationId();
|
|
|
|
|
|
|
|
|
|
static void SetAllianceStationId(HAL_AllianceStationID allianceStationId);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
|
|
|
|
static std::unique_ptr<CallbackStore> RegisterMatchTimeCallback(
|
2020-07-15 23:48:09 -07:00
|
|
|
NotifyCallback callback, bool initialNotify);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
static double GetMatchTime();
|
2020-07-15 00:33:57 -07:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
static void SetMatchTime(double matchTime);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Updates DriverStation data so that new values are visible to the user
|
|
|
|
|
* program.
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
static void NotifyNewData();
|
2020-07-15 00:33:57 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets suppression of DriverStation::ReportError and ReportWarning messages.
|
|
|
|
|
*
|
|
|
|
|
* @param shouldSend If false then messages will be suppressed.
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
static void SetSendError(bool shouldSend);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets suppression of DriverStation::SendConsoleLine messages.
|
|
|
|
|
*
|
|
|
|
|
* @param shouldSend If false then messages will be suppressed.
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
static void SetSendConsoleLine(bool shouldSend);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the joystick outputs.
|
|
|
|
|
*
|
|
|
|
|
* @param stick The joystick number
|
|
|
|
|
* @return The joystick outputs
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
static int64_t GetJoystickOutputs(int stick);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the joystick rumble.
|
|
|
|
|
*
|
|
|
|
|
* @param stick The joystick number
|
|
|
|
|
* @param rumbleNum Rumble to get (0=left, 1=right)
|
|
|
|
|
* @return The joystick rumble value
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
static int GetJoystickRumble(int stick, int rumbleNum);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the state of one joystick button. Button indexes begin at 1.
|
|
|
|
|
*
|
|
|
|
|
* @param stick The joystick number
|
|
|
|
|
* @param button The button index, beginning at 1
|
|
|
|
|
* @param state The state of the joystick button
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
static void SetJoystickButton(int stick, int button, bool state);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the value of the axis on a joystick.
|
|
|
|
|
*
|
|
|
|
|
* @param stick The joystick number
|
|
|
|
|
* @param axis The analog axis number
|
|
|
|
|
* @param value The value of the axis on the joystick
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
static void SetJoystickAxis(int stick, int axis, double value);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the state of a POV on a joystick.
|
|
|
|
|
*
|
|
|
|
|
* @param stick The joystick number
|
|
|
|
|
* @param pov The POV number
|
|
|
|
|
* @param value the angle of the POV in degrees, or -1 for not pressed
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
static void SetJoystickPOV(int stick, int pov, int value);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the state of all the buttons on a joystick.
|
|
|
|
|
*
|
|
|
|
|
* @param stick The joystick number
|
|
|
|
|
* @param buttons The bitmap state of the buttons on the joystick
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
static void SetJoystickButtons(int stick, uint32_t buttons);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the number of axes for a joystick.
|
|
|
|
|
*
|
|
|
|
|
* @param stick The joystick number
|
|
|
|
|
* @param count The number of axes on the indicated joystick
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
static void SetJoystickAxisCount(int stick, int count);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the number of POVs for a joystick.
|
|
|
|
|
*
|
|
|
|
|
* @param stick The joystick number
|
|
|
|
|
* @param count The number of POVs on the indicated joystick
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
static void SetJoystickPOVCount(int stick, int count);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the number of buttons for a joystick.
|
|
|
|
|
*
|
|
|
|
|
* @param stick The joystick number
|
|
|
|
|
* @param count The number of buttons on the indicated joystick
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
static void SetJoystickButtonCount(int stick, int count);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the value of isXbox for a joystick.
|
|
|
|
|
*
|
|
|
|
|
* @param stick The joystick number
|
|
|
|
|
* @param isXbox The value of isXbox
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
static void SetJoystickIsXbox(int stick, bool isXbox);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the value of type for a joystick.
|
|
|
|
|
*
|
|
|
|
|
* @param stick The joystick number
|
|
|
|
|
* @param type The value of type
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
static void SetJoystickType(int stick, int type);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the name of a joystick.
|
|
|
|
|
*
|
|
|
|
|
* @param stick The joystick number
|
|
|
|
|
* @param name The value of name
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
static void SetJoystickName(int stick, const char* name);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the types of Axes for a joystick.
|
|
|
|
|
*
|
|
|
|
|
* @param stick The joystick number
|
|
|
|
|
* @param axis The target axis
|
|
|
|
|
* @param type The type of axis
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
static void SetJoystickAxisType(int stick, int axis, int type);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the game specific message.
|
|
|
|
|
*
|
|
|
|
|
* @param message the game specific message
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
static void SetGameSpecificMessage(const char* message);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the event name.
|
|
|
|
|
*
|
|
|
|
|
* @param name the event name
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
static void SetEventName(const char* name);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the match type.
|
|
|
|
|
*
|
|
|
|
|
* @param type the match type
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
static void SetMatchType(DriverStation::MatchType type);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the match number.
|
|
|
|
|
*
|
|
|
|
|
* @param matchNumber the match number
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
static void SetMatchNumber(int matchNumber);
|
2020-07-15 00:33:57 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the replay number.
|
|
|
|
|
*
|
|
|
|
|
* @param replayNumber the replay number
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
static void SetReplayNumber(int replayNumber);
|
2019-01-09 23:47:42 -08:00
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
static void ResetData();
|
2018-05-11 12:38:23 -07:00
|
|
|
};
|
|
|
|
|
} // namespace sim
|
|
|
|
|
} // namespace frc
|