2016-01-02 03:02:34 -08:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2018-01-02 09:20:21 -08:00
|
|
|
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
2016-01-02 03:02:34 -08: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. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
2014-05-02 17:54:01 -04:00
|
|
|
#pragma once
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2017-11-16 00:33:51 -08:00
|
|
|
/**
|
|
|
|
|
* @file Contains global utility functions
|
2015-01-12 22:44:02 -08:00
|
|
|
*/
|
|
|
|
|
|
2014-08-08 17:05:49 -04:00
|
|
|
#include <stdint.h>
|
2016-09-25 16:50:13 -07:00
|
|
|
|
2014-07-28 16:25:37 -04:00
|
|
|
#include <string>
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2018-04-29 23:33:19 -07:00
|
|
|
#include <wpi/StringRef.h>
|
|
|
|
|
#include <wpi/Twine.h>
|
|
|
|
|
#include <wpi/deprecated.h>
|
2016-12-20 22:08:24 -08:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
#define wpi_assert(condition) \
|
2015-06-30 15:01:20 -04:00
|
|
|
wpi_assert_impl(condition, #condition, "", __FILE__, __LINE__, __FUNCTION__)
|
2015-06-25 15:07:55 -04:00
|
|
|
#define wpi_assertWithMessage(condition, message) \
|
|
|
|
|
wpi_assert_impl(condition, #condition, message, __FILE__, __LINE__, \
|
|
|
|
|
__FUNCTION__)
|
|
|
|
|
|
|
|
|
|
#define wpi_assertEqual(a, b) \
|
2015-06-30 15:01:20 -04:00
|
|
|
wpi_assertEqual_impl(a, b, #a, #b, "", __FILE__, __LINE__, __FUNCTION__)
|
2015-06-25 15:07:55 -04:00
|
|
|
#define wpi_assertEqualWithMessage(a, b, message) \
|
|
|
|
|
wpi_assertEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, __FUNCTION__)
|
|
|
|
|
|
|
|
|
|
#define wpi_assertNotEqual(a, b) \
|
2015-06-30 15:01:20 -04:00
|
|
|
wpi_assertNotEqual_impl(a, b, #a, #b, "", __FILE__, __LINE__, __FUNCTION__)
|
2015-06-25 15:07:55 -04:00
|
|
|
#define wpi_assertNotEqualWithMessage(a, b, message) \
|
|
|
|
|
wpi_assertNotEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, \
|
|
|
|
|
__FUNCTION__)
|
|
|
|
|
|
2018-05-31 20:47:15 -07:00
|
|
|
/**
|
|
|
|
|
* Assert implementation.
|
|
|
|
|
*
|
|
|
|
|
* This allows breakpoints to be set on an assert. The users don't call this,
|
|
|
|
|
* but instead use the wpi_assert macros in Utility.h.
|
|
|
|
|
*/
|
2018-04-29 23:33:19 -07:00
|
|
|
bool wpi_assert_impl(bool conditionValue, const wpi::Twine& conditionText,
|
|
|
|
|
const wpi::Twine& message, wpi::StringRef fileName,
|
|
|
|
|
int lineNumber, wpi::StringRef funcName);
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Assert equal implementation.
|
|
|
|
|
*
|
|
|
|
|
* This determines whether the two given integers are equal. If not, the value
|
|
|
|
|
* of each is printed along with an optional message string. The users don't
|
|
|
|
|
* call this, but instead use the wpi_assertEqual macros in Utility.h.
|
|
|
|
|
*/
|
2017-12-01 22:12:50 -08:00
|
|
|
bool wpi_assertEqual_impl(int valueA, int valueB,
|
2018-04-29 23:33:19 -07:00
|
|
|
const wpi::Twine& valueAString,
|
|
|
|
|
const wpi::Twine& valueBString,
|
|
|
|
|
const wpi::Twine& message, wpi::StringRef fileName,
|
|
|
|
|
int lineNumber, wpi::StringRef funcName);
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Assert not equal implementation.
|
|
|
|
|
*
|
|
|
|
|
* This determines whether the two given integers are equal. If so, the value of
|
|
|
|
|
* each is printed along with an optional message string. The users don't call
|
|
|
|
|
* this, but instead use the wpi_assertNotEqual macros in Utility.h.
|
|
|
|
|
*/
|
2016-12-20 22:08:24 -08:00
|
|
|
bool wpi_assertNotEqual_impl(int valueA, int valueB,
|
2018-04-29 23:33:19 -07:00
|
|
|
const wpi::Twine& valueAString,
|
|
|
|
|
const wpi::Twine& valueBString,
|
2018-05-13 17:09:56 -07:00
|
|
|
const wpi::Twine& message, wpi::StringRef fileName,
|
|
|
|
|
int lineNumber, wpi::StringRef funcName);
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2016-11-01 22:33:12 -07:00
|
|
|
namespace frc {
|
|
|
|
|
|
2018-05-31 20:47:15 -07:00
|
|
|
/**
|
|
|
|
|
* Return the FPGA Version number.
|
|
|
|
|
*
|
|
|
|
|
* For now, expect this to be competition year.
|
|
|
|
|
*
|
|
|
|
|
* @return FPGA Version number.
|
|
|
|
|
* @deprecated Use RobotController static class method
|
|
|
|
|
*/
|
2017-12-10 21:52:49 -08:00
|
|
|
WPI_DEPRECATED("Use RobotController static class method")
|
2016-09-06 00:01:45 -07:00
|
|
|
int GetFPGAVersion();
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return the FPGA Revision number.
|
|
|
|
|
*
|
|
|
|
|
* The format of the revision is 3 numbers. The 12 most significant bits are the
|
|
|
|
|
* Major Revision. The next 8 bits are the Minor Revision. The 12 least
|
|
|
|
|
* significant bits are the Build Number.
|
|
|
|
|
*
|
|
|
|
|
* @return FPGA Revision number.
|
|
|
|
|
* @deprecated Use RobotController static class method
|
|
|
|
|
*/
|
2017-12-10 21:52:49 -08:00
|
|
|
WPI_DEPRECATED("Use RobotController static class method")
|
2016-07-12 10:45:14 -07:00
|
|
|
int64_t GetFPGARevision();
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Read the microsecond-resolution timer on the FPGA.
|
|
|
|
|
*
|
|
|
|
|
* @return The current time in microseconds according to the FPGA (since FPGA
|
|
|
|
|
* reset).
|
|
|
|
|
* @deprecated Use RobotController static class method
|
|
|
|
|
*/
|
2017-12-10 21:52:49 -08:00
|
|
|
WPI_DEPRECATED("Use RobotController static class method")
|
2015-12-30 19:06:47 -08:00
|
|
|
uint64_t GetFPGATime();
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the state of the "USER" button on the roboRIO.
|
|
|
|
|
*
|
|
|
|
|
* @return True if the button is currently pressed down
|
|
|
|
|
* @deprecated Use RobotController static class method
|
|
|
|
|
*/
|
2017-12-10 21:52:49 -08:00
|
|
|
WPI_DEPRECATED("Use RobotController static class method")
|
2014-07-29 14:34:52 -04:00
|
|
|
bool GetUserButton();
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get a stack trace, ignoring the first "offset" symbols.
|
|
|
|
|
*
|
|
|
|
|
* @param offset The number of symbols at the top of the stack to ignore
|
|
|
|
|
*/
|
2016-09-06 00:01:45 -07:00
|
|
|
std::string GetStackTrace(int offset);
|
2016-11-01 22:33:12 -07:00
|
|
|
|
|
|
|
|
} // namespace frc
|