Renaming and merging WPILibC++ into Devices and simulator files

Change-Id: I6f4b94d1f2cbf4196ebcef8bc45799a97bcde1d8
This commit is contained in:
Patrick Plenefisch
2014-09-25 20:36:59 -04:00
parent fa4a39dcc6
commit b6475d0503
29 changed files with 56 additions and 562 deletions

View File

@@ -1,13 +1,16 @@
cmake_minimum_required(VERSION 2.8)
project(All-WPILib)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat=2 -Wall -Wextra -Wno-unused-parameter -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter -fPIC")
SET(CMAKE_SKIP_BUILD_RPATH TRUE)
file(GLOB_RECURSE NI_LIBS ni-libraries/*.so*)
list(REMOVE_ITEM NI_LIBS ${CMAKE_CURRENT_SOURCE_DIR}/ni-libraries/libwpi.so ${CMAKE_CURRENT_SOURCE_DIR}/ni-libraries/libwpi_2015.so)
get_filename_component(WPILIB_INCLUDES wpilibc/wpilibC++/include REALPATH)
get_filename_component(HAL_API_INCLUDES hal/include REALPATH)
get_filename_component(NWT_API_INCLUDES networktables/cpp/include REALPATH)
file(GLOB_RECURSE COM_SRC_FILES wpilibc/wpilibC++/src/*.cpp)
add_subdirectory(hal)
add_subdirectory(networktables/cpp)
add_subdirectory(wpilibc)

View File

@@ -1,3 +1,3 @@
/* GNU ld script */
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( AS_NEEDED ( -lWPILib -lWPILibAthena -lHALAthena -lNetworkTables -lFRC_NetworkCommunication -li2c -lni_emb -lNiFpgaLv -lNiFpga -lnirio_emb_can -lNiRioSrv -lni_rtlog -lRoboRIO_FRC_ChipObject -lspi -lvisa -ldl -lpthread ) )
GROUP ( AS_NEEDED ( -lwpilib_nonshared -lHALAthena -lNetworkTables -lFRC_NetworkCommunication -li2c -lni_emb -lNiFpgaLv -lNiFpga -lnirio_emb_can -lNiRioSrv -lni_rtlog -lRoboRIO_FRC_ChipObject -lspi -lvisa -ldl -lpthread -lrt ) )

View File

@@ -1,13 +1,5 @@
cmake_minimum_required(VERSION 2.8)
project(WPILibC++)
file(GLOB_RECURSE SRC_FILES src/*.cpp)
include_directories(include/ ${NWT_API_INCLUDES} ${HAL_API_INCLUDES})
add_library(WPILib STATIC ${SRC_FILES})
target_link_libraries(WPILib)
INSTALL(TARGETS WPILib ARCHIVE DESTINATION lib COMPONENT lib)
INSTALL(DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT headers)
# lib/ c m gcc_s ld-linux
# usr/lib stdc++
# ni_emb
# HAL NWT

View File

@@ -9,7 +9,7 @@
#include "Task.h"
#include "HAL/cpp/Synchronized.hpp"
typedef void (*TimerEventHandler)(void *param);
typedef void *(*TimerEventHandler)(void *param);
class Notifier : public ErrorBase
{
@@ -22,6 +22,7 @@ public:
private:
static Notifier *timerQueueHead;
static ReentrantSemaphore queueSemaphore;
static void* m_notifier;
static int refcount;
static void ProcessQueue(uint32_t mask, void *params); // process the timer queue on a timer event

View File

@@ -69,6 +69,7 @@ private:
float m_minimumInput; // minimum input - limit setpoint to this
bool m_continuous; // do the endpoints wrap around? eg. Absolute encoder
bool m_enabled; //is the pid controller enabled
bool m_destruct; // should the calculate thread stop running
float m_prevError; // the prior sensor input (used to compute velocity)
double m_totalError; //the sum of the errors for use in the integral calc
enum
@@ -88,12 +89,16 @@ private:
PIDSource *m_pidInput;
PIDOutput *m_pidOutput;
#ifndef FRC_SIMULATOR
pthread_t m_controlLoop;
#else
Notifier* m_controlLoop;
#endif
pthread_mutex_t m_mutex;
void Initialize(float p, float i, float d, float f, PIDSource *source, PIDOutput *output,
float period = 0.05);
static void CallCalculate(void *controller);
static void *CallCalculate(void *controller);
virtual ITable* GetTable();
virtual std::string GetSmartDashboardType();

View File

@@ -3,9 +3,9 @@ project(WPILibC++Devices)
file(GLOB_RECURSE SRC_FILES src/*.cpp)
include_directories(include/ ${WPILIB_INCLUDES} ${HAL_API_INCLUDES} ${NWT_API_INCLUDES})
add_library(WPILibAthena STATIC ${SRC_FILES})
target_link_libraries(WPILibAthena WPILib HALAthena NetworkTables ${NI_LIBS})
INSTALL(TARGETS WPILibAthena ARCHIVE DESTINATION lib COMPONENT lib)
add_library(wpilib_nonshared STATIC ${SRC_FILES} ${COM_SRC_FILES})
target_link_libraries(wpilib_nonshared HALAthena NetworkTables ${NI_LIBS})
INSTALL(TARGETS wpilib_nonshared ARCHIVE DESTINATION lib COMPONENT lib)
INSTALL(DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT headers)
# lib/ c m gcc_s ld-linux
# usr/lib stdc++

View File

@@ -8,6 +8,7 @@
#include "SensorBase.h"
#include "RobotState.h"
#include "Task.h"
#include "HAL/HAL.hpp"
struct HALControlWord;
class AnalogInput;

View File

@@ -1,42 +0,0 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. 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 $(WIND_BASE)/WPILib. */
/*----------------------------------------------------------------------------*/
#pragma once
#include "HAL/HAL.hpp"
#include "ErrorBase.h"
#include "HAL/cpp/Synchronized.hpp"
typedef void (*TimerEventHandler)(void *param);
class Notifier : public ErrorBase
{
public:
Notifier(TimerEventHandler handler, void *param = NULL);
virtual ~Notifier();
void StartSingle(double delay);
void StartPeriodic(double period);
void Stop();
private:
static Notifier *timerQueueHead;
static ReentrantSemaphore queueSemaphore;
static void* m_notifier;
static int refcount;
static void ProcessQueue(uint32_t mask, void *params); // process the timer queue on a timer event
static void UpdateAlarm(); // update the FPGA alarm since the queue has changed
void InsertInQueue(bool reschedule); // insert this Notifier in the timer queue
void DeleteFromQueue(); // delete this Notifier from the timer queue
TimerEventHandler m_handler; // address of the handler
void *m_param; // a parameter to pass to the handler
double m_period; // the relative time (either periodic or single)
double m_expirationTime; // absolute expiration time for the current event
Notifier *m_nextEvent; // next Nofifier event
bool m_periodic; // true if this is a periodic event
bool m_queued; // indicates if this entry is queued
SEMAPHORE_ID m_handlerSemaphore; // held by interrupt manager task while handler call is in progress
DISALLOW_COPY_AND_ASSIGN(Notifier);
};

View File

@@ -1,108 +0,0 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. 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 $(WIND_BASE)/WPILib. */
/*----------------------------------------------------------------------------*/
#pragma once
#include "Base.h"
#include "Controller.h"
#include "LiveWindow/LiveWindow.h"
#include <pthread.h>
class PIDOutput;
class PIDSource;
class Notifier;
/**
* Class implements a PID Control Loop.
*
* Creates a separate thread which reads the given PIDSource and takes
* care of the integral calculations, as well as writing the given
* PIDOutput
*/
class PIDController : public LiveWindowSendable, public Controller, public ITableListener
{
public:
PIDController(float p, float i, float d, PIDSource *source, PIDOutput *output, float period =
0.05);
PIDController(float p, float i, float d, float f, PIDSource *source, PIDOutput *output,
float period = 0.05);
virtual ~PIDController();
virtual float Get();
virtual void SetContinuous(bool continuous = true);
virtual void SetInputRange(float minimumInput, float maximumInput);
virtual void SetOutputRange(float mimimumOutput, float maximumOutput);
virtual void SetPID(float p, float i, float d);
virtual void SetPID(float p, float i, float d, float f);
virtual float GetP();
virtual float GetI();
virtual float GetD();
virtual float GetF();
virtual void SetSetpoint(float setpoint);
virtual float GetSetpoint();
virtual float GetError();
virtual void SetTolerance(float percent);
virtual void SetAbsoluteTolerance(float absValue);
virtual void SetPercentTolerance(float percentValue);
virtual bool OnTarget();
virtual void Enable();
virtual void Disable();
virtual bool IsEnabled();
virtual void Reset();
virtual void InitTable(ITable* table);
private:
float m_P; // factor for "proportional" control
float m_I; // factor for "integral" control
float m_D; // factor for "derivative" control
float m_F; // factor for "feed forward" control
float m_maximumOutput; // |maximum output|
float m_minimumOutput; // |minimum output|
float m_maximumInput; // maximum input - limit setpoint to this
float m_minimumInput; // minimum input - limit setpoint to this
bool m_continuous; // do the endpoints wrap around? eg. Absolute encoder
bool m_enabled; //is the pid controller enabled
bool m_destruct; // should the calculate thread stop running
float m_prevError; // the prior sensor input (used to compute velocity)
double m_totalError; //the sum of the errors for use in the integral calc
enum
{
kAbsoluteTolerance,
kPercentTolerance,
kNoTolerance
} m_toleranceType;
float m_tolerance; //the percetage or absolute error that is considered on target
float m_setpoint;
float m_error;
float m_result;
float m_period;
PIDSource *m_pidInput;
PIDOutput *m_pidOutput;
pthread_t m_controlLoop;
pthread_mutex_t m_mutex;
void Initialize(float p, float i, float d, float f, PIDSource *source, PIDOutput *output,
float period = 0.05);
static void *CallCalculate(void *controller);
virtual ITable* GetTable();
virtual std::string GetSmartDashboardType();
virtual void ValueChanged(ITable* source, const std::string& key, EntryValue value, bool isNew);
virtual void UpdateTable();
virtual void StartLiveWindowMode();
virtual void StopLiveWindowMode();
protected:
ITable* m_table;
void Calculate();
DISALLOW_COPY_AND_ASSIGN(PIDController);
};

View File

@@ -1,52 +0,0 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. 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 $(WIND_BASE)/WPILib. */
/*----------------------------------------------------------------------------*/
#pragma once
#include "ErrorBase.h"
#include "HAL/HAL.hpp"
/**
* WPI task is a wrapper for the native Task object.
* All WPILib tasks are managed by a static task manager for simplified cleanup.
**/
class Task : public ErrorBase
{
public:
static const uint32_t kDefaultPriority = 101;
Task(const char* name, FUNCPTR function, int32_t priority = kDefaultPriority,
uint32_t stackSize = 20000);
virtual ~Task();
bool Start(uint32_t arg0 = 0, uint32_t arg1 = 0, uint32_t arg2 = 0, uint32_t arg3 = 0,
uint32_t arg4 = 0, uint32_t arg5 = 0, uint32_t arg6 = 0, uint32_t arg7 = 0,
uint32_t arg8 = 0, uint32_t arg9 = 0);
bool Restart();
bool Stop();
bool IsReady();
bool IsSuspended();
bool Suspend();
bool Resume();
bool Verify();
int32_t GetPriority();
bool SetPriority(int32_t priority);
const char* GetName();
TASK GetID();
private:
FUNCPTR m_function;
char* m_taskName;
TASK m_taskID;
uint32_t m_stackSize;
int m_priority;
bool HandleError(STATUS results);
DISALLOW_COPY_AND_ASSIGN(Task);
};

View File

@@ -1,44 +0,0 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. 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 $(WIND_BASE)/WPILib. */
/*----------------------------------------------------------------------------*/
#pragma once
#include "HAL/Semaphore.hpp"
#include "Base.h"
typedef void (*TimerInterruptHandler)(void *param);
void Wait(double seconds);
double GetClock();
double GetTime();
/**
* Timer objects measure accumulated time in seconds.
* The timer object functions like a stopwatch. It can be started, stopped, and cleared. When the
* timer is running its value counts up in seconds. When stopped, the timer holds the current
* value. The implementation simply records the time when started and subtracts the current time
* whenever the value is requested.
*/
class Timer
{
public:
Timer();
virtual ~Timer();
double Get();
void Reset();
void Start();
void Stop();
bool HasPeriodPassed(double period);
static double GetFPGATimestamp();
static double GetPPCTimestamp();
private:
double m_startTime;
double m_accumulatedTime;
bool m_running;
MUTEX_ID m_semaphore;
DISALLOW_COPY_AND_ASSIGN(Timer);
};

View File

@@ -8,6 +8,7 @@
#include "Timer.h"
#include "Utility.h"
#include "WPIErrors.h"
#include "HAL/HAL.hpp"
Notifier *Notifier::timerQueueHead = NULL;
ReentrantSemaphore Notifier::queueSemaphore;

View File

@@ -12,6 +12,7 @@
#include <math.h>
#include "HAL/cpp/Synchronized.hpp"
#include "Timer.h"
#include "HAL/HAL.hpp"
static const char *kP = "p";
static const char *kI = "i";

View File

@@ -9,6 +9,7 @@
//#include "NetworkCommunication/UsageReporting.h"
#include "HAL/cpp/Synchronized.hpp"
#include "WPIErrors.h"
#include "HAL/HAL.hpp"
#include <stdio.h>
#include <algorithm>

View File

@@ -11,6 +11,7 @@
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include "HAL/HAL.hpp"
const uint32_t Task::kDefaultPriority;

View File

@@ -3,6 +3,6 @@ project(WPILibC++IntegrationTests)
file(GLOB_RECURSE SRC_FILES src/*.cpp src/gtest/src/gtest-all.cc src/gtest/src/gtest_main.cc)
include_directories(include/ src/gtest/ src/gtest/include/ ../wpilibC++Devices/include/ ${WPILIB_INCLUDES} ${HAL_API_INCLUDES} ${NWT_API_INCLUDES})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -Wno-unused-variable")
add_executable(FRCUserProgram ${SRC_FILES})
target_link_libraries(FRCUserProgram WPILib WPILibAthena WPILib HALAthena NetworkTables ${NI_LIBS} rt)
target_link_libraries(FRCUserProgram wpilib_nonshared HALAthena NetworkTables ${NI_LIBS})

View File

@@ -12,9 +12,10 @@
unsigned notifierCounter;
void notifierHandler(void *)
void *notifierHandler(void *)
{
notifierCounter++;
return nullptr;
}
/**

View File

@@ -1,11 +1,11 @@
cmake_minimum_required(VERSION 2.8)
project(WPILibSim)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat=2 -Wall -Wextra -Wno-unused-parameter -fPIC -std=c++1y")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat=2 -Wall -Wextra -Wno-unused-parameter -fPIC -std=c++1y -DFRC_SIMULATOR")
get_filename_component(HAL_API_INCLUDES $ENV{ALLWPILIB}/hal/include REALPATH)
get_filename_component(NWT_API_INCLUDES $ENV{ALLWPILIB}/networktables/cpp/include REALPATH)
add_subdirectory(build/wpilibC++)
get_filename_component(HAL_API_INCLUDES ../../hal/include REALPATH)
get_filename_component(NWT_API_INCLUDES ../../networktables/cpp/include REALPATH)
add_subdirectory(../wpilibC++ wpilibC++)
include (FindPkgConfig)
if (PKG_CONFIG_FOUND)
@@ -14,17 +14,20 @@ endif()
find_package(gazebo REQUIRED)
file(GLOB_RECURSE SRC_FILES src/*.cpp $ENV{ALLWPILIB}/networktables/cpp/lib/share/*.cpp
$ENV{ALLWPILIB}/networktables/cpp/lib/Athena/*.cpp
$ENV{ALLWPILIB}/hal/lib/Athena/Task.cpp
$ENV{ALLWPILIB}/hal/lib/Athena/Semaphore.cpp
$ENV{ALLWPILIB}/hal/lib/Athena/cpp/*.cpp)
include_directories(include/ $ENV{ALLWPILIB}/wpilibc/wpilibC++/include
$ENV{ALLWPILIB}/networktables/cpp/include
$ENV{ALLWPILIB}/hal/include
file(GLOB_RECURSE SRC_FILES src/*.cpp ../../networktables/cpp/lib/share/*.cpp
../../networktables/cpp/lib/Athena/*.cpp
../../hal/lib/Athena/Task.cpp
../../hal/lib/Athena/Semaphore.cpp
../../hal/lib/Athena/cpp/Synchronized.cpp)
file(GLOB_RECURSE COM_SRC_FILES ../wpilibC++/src/*.cpp)
include_directories(include/ ../../wpilibc/wpilibC++/include
../../networktables/cpp/include
../../hal/include
${Boost_INCLUDE_DIR} ${GAZEBO_INCLUDE_DIRS}) # ${NWT_API_INCLUDES}
add_library(WPILibSim SHARED ${SRC_FILES})
target_link_libraries(WPILibSim WPILib ${GAZEBO_LIBRARIES} -fPIC) # NetworkTables
add_library(WPILibSim SHARED ${SRC_FILES} ${COM_SRC_FILES})
target_link_libraries(WPILibSim ${GAZEBO_LIBRARIES} -fPIC) # NetworkTables
INSTALL(TARGETS WPILibSim LIBRARY DESTINATION src COMPONENT src)
INSTALL(DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT headers)
# ni_emb

View File

@@ -1,12 +1,10 @@
prefix = /usr
lib.dir = $(prefix)/lib
build.dir = build
allwpilib = ../..
all:
mkdir -p $(build.dir)
cp -r $(allwpilib)/wpilibc/wpilibC++ build
cd ${build.dir} && ALLWPILIB=$(allwpilib) cmake .. && make
cd ${build.dir} && cmake .. && make
clean:
rm -rf $(build.dir)

View File

@@ -1,44 +0,0 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. 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 $(WIND_BASE)/WPILib. */
/*----------------------------------------------------------------------------*/
#pragma once
#include "ErrorBase.h"
#include "Task.h"
#include "HAL/cpp/Synchronized.hpp"
typedef void (*TimerEventHandler)(void *param);
class Notifier : public ErrorBase
{
public:
Notifier(TimerEventHandler handler, void *param = NULL);
virtual ~Notifier();
void StartSingle(double delay);
void StartPeriodic(double period);
void Stop();
private:
static Notifier *timerQueueHead;
static ReentrantSemaphore queueSemaphore;
static int refcount;
static void ProcessQueue(uint32_t mask, void *params); // process the timer queue on a timer event
static void UpdateAlarm(); // update the FPGA alarm since the queue has changed
void InsertInQueue(bool reschedule); // insert this Notifier in the timer queue
void DeleteFromQueue(); // delete this Notifier from the timer queue
TimerEventHandler m_handler; // address of the handler
void *m_param; // a parameter to pass to the handler
double m_period; // the relative time (either periodic or single)
double m_expirationTime; // absolute expiration time for the current event
Notifier *m_nextEvent; // next Nofifier event
bool m_periodic; // true if this is a periodic event
bool m_queued; // indicates if this entry is queued
SEMAPHORE_ID m_handlerSemaphore; // held by interrupt manager task while handler call is in progress
DISALLOW_COPY_AND_ASSIGN(Notifier);
static Task *task;
static void Run();
};

View File

@@ -1,107 +0,0 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. 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 $(WIND_BASE)/WPILib. */
/*----------------------------------------------------------------------------*/
#pragma once
#include "Base.h"
#include "Controller.h"
#include "LiveWindow/LiveWindow.h"
#include <pthread.h>
class PIDOutput;
class PIDSource;
class Notifier;
/**
* Class implements a PID Control Loop.
*
* Creates a separate thread which reads the given PIDSource and takes
* care of the integral calculations, as well as writing the given
* PIDOutput
*/
class PIDController : public LiveWindowSendable, public Controller, public ITableListener
{
public:
PIDController(float p, float i, float d, PIDSource *source, PIDOutput *output, float period =
0.05);
PIDController(float p, float i, float d, float f, PIDSource *source, PIDOutput *output,
float period = 0.05);
virtual ~PIDController();
virtual float Get();
virtual void SetContinuous(bool continuous = true);
virtual void SetInputRange(float minimumInput, float maximumInput);
virtual void SetOutputRange(float mimimumOutput, float maximumOutput);
virtual void SetPID(float p, float i, float d);
virtual void SetPID(float p, float i, float d, float f);
virtual float GetP();
virtual float GetI();
virtual float GetD();
virtual float GetF();
virtual void SetSetpoint(float setpoint);
virtual float GetSetpoint();
virtual float GetError();
virtual void SetTolerance(float percent);
virtual void SetAbsoluteTolerance(float absValue);
virtual void SetPercentTolerance(float percentValue);
virtual bool OnTarget();
virtual void Enable();
virtual void Disable();
virtual bool IsEnabled();
virtual void Reset();
virtual void InitTable(ITable* table);
private:
float m_P; // factor for "proportional" control
float m_I; // factor for "integral" control
float m_D; // factor for "derivative" control
float m_F; // factor for "feed forward" control
float m_maximumOutput; // |maximum output|
float m_minimumOutput; // |minimum output|
float m_maximumInput; // maximum input - limit setpoint to this
float m_minimumInput; // minimum input - limit setpoint to this
bool m_continuous; // do the endpoints wrap around? eg. Absolute encoder
bool m_enabled; //is the pid controller enabled
float m_prevError; // the prior sensor input (used to compute velocity)
double m_totalError; //the sum of the errors for use in the integral calc
enum
{
kAbsoluteTolerance,
kPercentTolerance,
kNoTolerance
} m_toleranceType;
float m_tolerance; //the percetage or absolute error that is considered on target
float m_setpoint;
float m_error;
float m_result;
float m_period;
MUTEX_ID m_semaphore;
PIDSource *m_pidInput;
PIDOutput *m_pidOutput;
Notifier *m_controlLoop;
void Initialize(float p, float i, float d, float f, PIDSource *source, PIDOutput *output,
float period = 0.05);
static void CallCalculate(void *controller);
virtual ITable* GetTable();
virtual std::string GetSmartDashboardType();
virtual void ValueChanged(ITable* source, const std::string& key, EntryValue value, bool isNew);
virtual void UpdateTable();
virtual void StartLiveWindowMode();
virtual void StopLiveWindowMode();
protected:
ITable* m_table;
void Calculate();
DISALLOW_COPY_AND_ASSIGN(PIDController);
};

View File

@@ -1,52 +0,0 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. 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 $(WIND_BASE)/WPILib. */
/*----------------------------------------------------------------------------*/
#pragma once
#include "ErrorBase.h"
#include "HAL/Task.hpp"
/**
* WPI task is a wrapper for the native Task object.
* All WPILib tasks are managed by a static task manager for simplified cleanup.
**/
class Task : public ErrorBase
{
public:
static const uint32_t kDefaultPriority = 101;
Task(const char* name, FUNCPTR function, int32_t priority = kDefaultPriority,
uint32_t stackSize = 20000);
virtual ~Task();
bool Start(uint32_t arg0 = 0, uint32_t arg1 = 0, uint32_t arg2 = 0, uint32_t arg3 = 0,
uint32_t arg4 = 0, uint32_t arg5 = 0, uint32_t arg6 = 0, uint32_t arg7 = 0,
uint32_t arg8 = 0, uint32_t arg9 = 0);
bool Restart();
bool Stop();
bool IsReady();
bool IsSuspended();
bool Suspend();
bool Resume();
bool Verify();
int32_t GetPriority();
bool SetPriority(int32_t priority);
const char* GetName();
TASK GetID();
private:
FUNCPTR m_function;
char* m_taskName;
TASK m_taskID;
uint32_t m_stackSize;
int m_priority;
bool HandleError(STATUS results);
DISALLOW_COPY_AND_ASSIGN(Task);
};

View File

@@ -1,50 +0,0 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. 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 $(WIND_BASE)/WPILib. */
/*----------------------------------------------------------------------------*/
#pragma once
#include "HAL/Semaphore.hpp"
#include "Base.h"
typedef void (*TimerInterruptHandler)(void *param);
void Wait(double seconds);
double GetClock();
double GetTime();
namespace wpilib { namespace internal {
extern double simTime;
extern MULTIWAIT_ID time_wait;
// transport::SubscriberPtr time_sub;
}}
/**
* Timer objects measure accumulated time in seconds.
* The timer object functions like a stopwatch. It can be started, stopped, and cleared. When the
* timer is running its value counts up in seconds. When stopped, the timer holds the current
* value. The implementation simply records the time when started and subtracts the current time
* whenever the value is requested.
*/
class Timer
{
public:
Timer();
virtual ~Timer();
double Get();
void Reset();
void Start();
void Stop();
bool HasPeriodPassed(double period);
static double GetFPGATimestamp();
static double GetPPCTimestamp();
private:
double m_startTime;
double m_accumulatedTime;
bool m_running;
MUTEX_ID m_semaphore;
DISALLOW_COPY_AND_ASSIGN(Timer);
};

View File

@@ -1,26 +0,0 @@
/*---------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. 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 $(WIND_BASE)/WPILib. */
/*---------------------------------------------------------------------------*/
#pragma once
#include <stdint.h>
#define wpi_assert(condition) wpi_assert_impl(condition, #condition, NULL, __FILE__, __LINE__, __FUNCTION__)
#define wpi_assertWithMessage(condition, message) wpi_assert_impl(condition, #condition, message, __FILE__, __LINE__, __FUNCTION__)
#define wpi_assertEqual(a, b) wpi_assertEqual_impl(a, b, NULL, __FILE__, __LINE__, __FUNCTION__)
#define wpi_assertEqualWithMessage(a, b, message) wpi_assertEqual_impl(a, b, message, __FILE__, __LINE__, __FUNCTION__)
#define wpi_assertNotEqual(a, b) wpi_assertNotEqual_impl(a, b, NULL, __FILE__, __LINE__, __FUNCTION__)
#define wpi_assertNotEqualWithMessage(a, b, message) wpi_assertNotEqual_impl(a, b, message, __FILE__, __LINE__, __FUNCTION__)
bool wpi_assert_impl(bool conditionValue, const char *conditionText, const char *message, const char *fileName, uint32_t lineNumber, const char *funcName);
bool wpi_assertEqual_impl(int valueA, int valueB, const char *message, const char *fileName,uint32_t lineNumber, const char *funcName);
bool wpi_assertNotEqual_impl(int valueA, int valueB, const char *message, const char *fileName,uint32_t lineNumber, const char *funcName);
void wpi_suspendOnAssertEnabled(bool enabled);
void wpi_stackTraceOnAssertEnable(bool enabled);
uint32_t GetFPGATime();

View File

@@ -0,0 +1,7 @@
#pragma once
namespace wpilib { namespace internal {
extern double simTime;
extern MULTIWAIT_ID time_wait;
// transport::SubscriberPtr time_sub;
}}

View File

@@ -115,10 +115,11 @@ PIDController::~PIDController()
* This method is static and called by the Notifier class.
* @param controller the address of the PID controller object to use in the background loop
*/
void PIDController::CallCalculate(void *controller)
void *PIDController::CallCalculate(void *controller)
{
PIDController *control = (PIDController*) controller;
control->Calculate();
return nullptr;
}
/**

View File

@@ -7,6 +7,7 @@
#include "Solenoid.h"
#include "WPIErrors.h"
#include "LiveWindow/LiveWindow.h"
#include "simulation/simTime.h"
/**
* Common function to implement constructor behavior.

View File

@@ -9,6 +9,7 @@
#include <time.h>
#include "HAL/cpp/Synchronized.hpp"
#include "simulation/simTime.h"
#include "Utility.h"
/**

View File

@@ -8,6 +8,7 @@
#include "Task.h"
#include "Timer.h"
#include "simulation/simTime.h"
#include <stdio.h>
#include <string.h>