Adds RobotController class (#828)

Unifies random functionality from other classes
Deprecates all old functions.
This commit is contained in:
Thad House
2017-12-10 21:52:49 -08:00
committed by Peter Johnson
parent 88a6b4ac38
commit 8b7aa61091
21 changed files with 668 additions and 19 deletions

View File

@@ -7,23 +7,39 @@
#pragma once
#include <support/deprecated.h>
namespace frc {
class ControllerPower {
public:
WPI_DEPRECATED("Use RobotController static class method")
static double GetInputVoltage();
WPI_DEPRECATED("Use RobotController static class method")
static double GetInputCurrent();
WPI_DEPRECATED("Use RobotController static class method")
static double GetVoltage3V3();
WPI_DEPRECATED("Use RobotController static class method")
static double GetCurrent3V3();
WPI_DEPRECATED("Use RobotController static class method")
static bool GetEnabled3V3();
WPI_DEPRECATED("Use RobotController static class method")
static int GetFaultCount3V3();
WPI_DEPRECATED("Use RobotController static class method")
static double GetVoltage5V();
WPI_DEPRECATED("Use RobotController static class method")
static double GetCurrent5V();
WPI_DEPRECATED("Use RobotController static class method")
static bool GetEnabled5V();
WPI_DEPRECATED("Use RobotController static class method")
static int GetFaultCount5V();
WPI_DEPRECATED("Use RobotController static class method")
static double GetVoltage6V();
WPI_DEPRECATED("Use RobotController static class method")
static double GetCurrent6V();
WPI_DEPRECATED("Use RobotController static class method")
static bool GetEnabled6V();
WPI_DEPRECATED("Use RobotController static class method")
static int GetFaultCount6V();
};

View File

@@ -15,6 +15,7 @@
#include <HAL/DriverStation.h>
#include <llvm/Twine.h>
#include <support/deprecated.h>
#include <support/mutex.h>
#include "ErrorBase.h"
@@ -68,7 +69,9 @@ class DriverStation : public ErrorBase, public RobotStateInterface {
bool IsDSAttached() const;
bool IsNewControlData() const;
bool IsFMSAttached() const;
WPI_DEPRECATED("Use RobotController static class method")
bool IsSysActive() const;
WPI_DEPRECATED("Use RobotController static class method")
bool IsBrownedOut() const;
std::string GetGameSpecificMessage() const;

View File

@@ -0,0 +1,47 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2017 FIRST. All Rights Reserved. */
/* 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 <stdint.h>
namespace frc {
struct CANStatus {
float percentBusUtilization;
int busOffCount;
int txFullCount;
int receiveErrorCount;
int transmitErrorCount;
};
class RobotController {
public:
RobotController() = delete;
static int GetFPGAVersion();
static int64_t GetFPGARevision();
static uint64_t GetFPGATime();
static bool GetUserButton();
static bool IsSysActive();
static bool IsBrownedOut();
static double GetInputVoltage();
static double GetInputCurrent();
static double GetVoltage3V3();
static double GetCurrent3V3();
static bool GetEnabled3V3();
static int GetFaultCount3V3();
static double GetVoltage5V();
static double GetCurrent5V();
static bool GetEnabled5V();
static int GetFaultCount5V();
static double GetVoltage6V();
static double GetCurrent6V();
static bool GetEnabled6V();
static int GetFaultCount6V();
static CANStatus GetCANStatus();
};
} // namespace frc

View File

@@ -17,6 +17,7 @@
#include <llvm/StringRef.h>
#include <llvm/Twine.h>
#include <support/deprecated.h>
#define wpi_assert(condition) \
wpi_assert_impl(condition, #condition, "", __FILE__, __LINE__, __FUNCTION__)
@@ -54,9 +55,13 @@ void wpi_suspendOnAssertEnabled(bool enabled);
namespace frc {
WPI_DEPRECATED("Use RobotController static class method")
int GetFPGAVersion();
WPI_DEPRECATED("Use RobotController static class method")
int64_t GetFPGARevision();
WPI_DEPRECATED("Use RobotController static class method")
uint64_t GetFPGATime();
WPI_DEPRECATED("Use RobotController static class method")
bool GetUserButton();
std::string GetStackTrace(int offset);

View File

@@ -67,6 +67,7 @@
#include "Preferences.h"
#include "Relay.h"
#include "RobotBase.h"
#include "RobotController.h"
#include "RobotDrive.h"
#include "SD540.h"
#include "SPI.h"