Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | Friends
Component Class Reference

Class component. More...

#include <Component.h>

Inheritance diagram for Component:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 Component (double desired_hz)
 Public constructor.
ReturnValue CreateTask (int prio, double frec, void *(*start_routine)(void *))
 Creates new tasks.
States GetState ()
 Returns the general state of the Component.
virtual char * GetStateString ()
 Returns the general state of the Component as string.
char * GetStateString (States state)
 Returns the general state as string.
double GetUpdateRate ()
 Gets current update rate of the thread.
virtual ReturnValue Setup ()
virtual ReturnValue ShutDown ()
virtual ReturnValue Start ()
virtual ReturnValue Stop ()
virtual ~Component ()
 Public destructor.

Protected Member Functions

virtual ReturnValue Allocate ()
virtual void AllState ()
 Actions performed in all states.
virtual ReturnValue Close ()
virtual ReturnValue Configure ()
virtual void ControlThread ()
 All core component functionality is contained in this thread.
virtual void EmergencyState ()
 Actions performed on the emergency state.
virtual void FailureState ()
 Actions performed on Failure state.
virtual ReturnValue Free ()
ReturnValue GetThreadData (thread_data *data)
 Gets the data of the current thread.
virtual void InitState ()
 Actions performed on initial state.
virtual ReturnValue Open ()
virtual void ReadyState ()
 Actions performed on ready state.
virtual void StandbyState ()
 Actions performed on standby state.
virtual void SwitchToState (States new_state)
 Switches between states.

Protected Attributes

bool bInitialized
 Controls if has been initialized succesfully.
bool bRunning
 Controls the execution of the Component's thread.
States iOldState
 State before.
States iState
 State of the Component.
string sComponentName
 Almacenaremos el nombre del componente para personalizar el log a de cada una de las clases derivadas.
thread_data threadData
 Contains data for the main thread.
vector< thread_datavThreadData
 Contains data for the secondary threads.

Private Attributes

pthread_mutex_t mutexThread
 Mutex to manage the access to the thread's vector.

Friends

void * AuxControlThread (void *threadParam)
 Main function to execute into the thread.

Detailed Description

Class component.

Definition at line 121 of file Component.h.


Constructor & Destructor Documentation

Component::Component ( double  desired_hz)

Public constructor.

Constructor by default.

Parameters:
desired_hzas double, sets the desired frequency of the controlthread

Definition at line 31 of file Component.cc.

Component::~Component ( ) [virtual]

Public destructor.

Destructor by default

Definition at line 52 of file Component.cc.


Member Function Documentation

ReturnValue Component::Allocate ( ) [protected, virtual]

Allocates virtual memory if it's necessary

Returns:
OK

Allocates virtual memory if it's necessary

Returns:
OK

Definition at line 151 of file Component.cc.

void Component::AllState ( ) [protected, virtual]

Actions performed in all states.

Actions performed on all states.

Reimplemented in purepursuit_planner_node.

Definition at line 369 of file Component.cc.

ReturnValue Component::Close ( ) [protected, virtual]

Closes used devices

Returns:
OK
ERROR

Closes used devices

Returns:
OK
ERROR

Definition at line 180 of file Component.cc.

ReturnValue Component::Configure ( ) [protected, virtual]

Configures devices and performance of the component

Returns:
OK
ERROR, if the configuration process fails

Configures devices and performance of the component

Returns:
OK
ERROR if the configuration process fails

Definition at line 142 of file Component.cc.

void Component::ControlThread ( ) [protected, virtual]

All core component functionality is contained in this thread.

All core component functionality is contained in this thread. All of the Component component state machine code can be found here.

Reimplemented in purepursuit_planner_node.

Definition at line 261 of file Component.cc.

ReturnValue Component::CreateTask ( int  prio,
double  frec,
void *(*)(void *)  start_routine 
)

Creates new tasks.

Creates new thread executing specific tasks

Parameters:
prioas int, Thread priority level ( 0[min]-80[max] )
frecas double, thread frequency
start_routineas void*(*)(void*), function wich will execute the task
Returns:
THREAD_NOT_RUNNING if the component is not running
OK if waits successfully
ERROR if an error is produced creating the thread

Definition at line 500 of file Component.cc.

void Component::EmergencyState ( ) [protected, virtual]

Actions performed on the emergency state.

Actions performed on emergency state.

Reimplemented in purepursuit_planner_node.

Definition at line 355 of file Component.cc.

void Component::FailureState ( ) [protected, virtual]

Actions performed on Failure state.

Actions performed on failure state.

Reimplemented in purepursuit_planner_node.

Definition at line 362 of file Component.cc.

ReturnValue Component::Free ( ) [protected, virtual]

Frees allocated memory previously

Returns:
OK

Frees allocated memory previously

Returns:
OK

Definition at line 160 of file Component.cc.

Returns the general state of the Component.

returns the state of the component

Definition at line 384 of file Component.cc.

char * Component::GetStateString ( ) [virtual]

Returns the general state of the Component as string.

Gets the state of the component as string.

Definition at line 391 of file Component.cc.

char * Component::GetStateString ( States  state)

Returns the general state as string.

Gets the state as a string.

Definition at line 420 of file Component.cc.

Gets the data of the current thread.

Gets the data of the current thread

Returns:
OK if the id is OK
ERROR if the id doesn't exist

Definition at line 467 of file Component.cc.

Gets current update rate of the thread.

Method to get current update rate of the thread

Returns:
pthread_hz
real frequency of the thread

Definition at line 377 of file Component.cc.

void Component::InitState ( ) [protected, virtual]

Actions performed on initial state.

Reimplemented in purepursuit_planner_node.

Definition at line 334 of file Component.cc.

ReturnValue Component::Open ( ) [protected, virtual]

Opens used devices

Returns:
OK
ERROR

Opens used devices

Returns:
OK
ERROR

Definition at line 170 of file Component.cc.

void Component::ReadyState ( ) [protected, virtual]

Actions performed on ready state.

Reimplemented in purepursuit_planner_node.

Definition at line 348 of file Component.cc.

Configures and initializes the component

Returns:
OK
INITIALIZED if the component is already intialized
ERROR

Configures and initializes the component

Returns:
OK
INITIALIZED if the component is already intialized
ERROR

Reimplemented in purepursuit_planner_node.

Definition at line 63 of file Component.cc.

Closes and frees the reserved resources

Returns:
OK
ERROR if fails when closes the devices
RUNNING if the component is running
NOT_INITIALIZED if the component is not initialized

Closes and frees the reserved resources

Returns:
OK
ERROR if fails when closes the devices
RUNNING if the component is running
NOT_INITIALIZED if the component is not initialized

Definition at line 107 of file Component.cc.

void Component::StandbyState ( ) [protected, virtual]

Actions performed on standby state.

Actions performed on Standby state.

Reimplemented in purepursuit_planner_node.

Definition at line 341 of file Component.cc.

Starts the control thread of the component and its subcomponents

Returns:
OK
ERROR starting the thread
RUNNING if it's already running
NOT_INITIALIZED if it's not initialized

Starts the control thread of the component and its subcomponents

Returns:
OK
RUNNING if it's already running
NOT_INITIALIZED if the component is not initialized

Reimplemented in purepursuit_planner_node.

Definition at line 191 of file Component.cc.

Stops the main control thread of the component and its subcomponents

Returns:
OK
ERROR if any error has been produced
NOT_RUNNING if the main thread isn't running

Stops the control thread of the Motors

Returns:
OK
ERROR if it can't be stopped
THREAD_NOT_RUNNING if the thread is not running

Reimplemented in purepursuit_planner_node.

Definition at line 237 of file Component.cc.

void Component::SwitchToState ( States  new_state) [protected, virtual]

Switches between states.

function that switches the state of the component into the desired state

Parameters:
new_stateas an integer, the new state of the component

Definition at line 451 of file Component.cc.


Friends And Related Function Documentation

void* AuxControlThread ( void *  threadParam) [friend]

Main function to execute into the thread.

Definition at line 20 of file Component.cc.


Member Data Documentation

bool Component::bInitialized [protected]

Controls if has been initialized succesfully.

Definition at line 125 of file Component.h.

bool Component::bRunning [protected]

Controls the execution of the Component's thread.

Definition at line 127 of file Component.h.

State before.

Definition at line 135 of file Component.h.

State of the Component.

Definition at line 133 of file Component.h.

pthread_mutex_t Component::mutexThread [private]

Mutex to manage the access to the thread's vector.

Definition at line 140 of file Component.h.

string Component::sComponentName [protected]

Almacenaremos el nombre del componente para personalizar el log a de cada una de las clases derivadas.

Definition at line 137 of file Component.h.

Contains data for the main thread.

Definition at line 129 of file Component.h.

vector<thread_data> Component::vThreadData [protected]

Contains data for the secondary threads.

Definition at line 131 of file Component.h.


The documentation for this class was generated from the following files:


purepursuit_planner
Author(s): Román Navarro
autogenerated on Thu Aug 27 2015 12:08:42