41 #include "../ExecutionEngine.hpp" 47 using namespace detail;
53 ,mTaskState(initial_state)
54 ,mInitialState(initial_state)
55 ,mTargetState(initial_state)
56 ,mTriggerOnStart(true)
104 )
CATCH(std::exception
const& e,
105 log(
Error) <<
"in configure(): switching to exception state because of unhandled exception" << endlog();
106 log(
Error) <<
" " << e.what() << endlog();
109 log(
Error) <<
"in configure(): switching to exception state because of unhandled exception" << endlog();
123 )
CATCH(std::exception
const& e,
124 log(
Error) <<
"in cleanup(): switching to exception state because of unhandled exception" << endlog();
125 log(
Error) <<
" " << e.what() << endlog();
128 log(
Error) <<
"in cleanup(): switching to exception state because of unhandled exception" << endlog();
159 )
CATCH(std::exception
const& e,
160 log(
RTT::Error) <<
"stopHook(), cleanupHook() and/or exceptionHook() raised " << e.what() <<
", going into Fatal" << endlog();
163 log(
Error) <<
"stopHook(), cleanupHook() and/or exceptionHook() raised an exception, going into Fatal" << endlog();
191 )
CATCH(std::exception
const& e,
192 log(
Error) <<
"in start(): switching to exception state because of unhandled exception" << endlog();
193 log(
Error) <<
" " << e.what() << endlog();
196 log(
Error) <<
"in start(): switching to exception state because of unhandled exception" << endlog();
208 if (
engine()->stopTask(
this) ) {
216 )
CATCH(std::exception
const& e,
217 log(
Error) <<
"in stop(): switching to exception state because of unhandled exception" << endlog();
218 log(
Error) <<
" " << e.what() << endlog();
221 log(
Error) <<
"in stop(): switching to exception state because of unhandled exception" << endlog();
ActivityInterface * getActivity() const
Query for the task this interface is run in.
virtual bool setPeriod(Seconds s)=0
Set the periodicity of this activity in Seconds.
double Seconds
Seconds are stored as a double precision float.
#define TRY(C)
Contains static global configuration variables and cached entries.
The state indicating the component encountered a C++ exception.
virtual bool trigger()
Invoke this method to trigger the thread of this TaskContext to execute its ExecutionEngine and the u...
virtual bool configureHook()
Implement this method such that it contains the code which will be executed when configure() is calle...
virtual void updateHook()
Function where the user must insert his 'application' code.
virtual bool recover()
Call this method in a RunTimeError or Exception state to indicate that the run-time error conditions ...
virtual TaskState getTargetState() const
Returns the state this TaskCore is going to, or in case no transition is taking place, returns getTaskState().
virtual bool timeout()=0
Requests this Activity to wakeup and call step() + work(Timeout).
virtual bool startHook()
Implement this method such that it contains the code which will be executed when start() is called...
virtual bool isActive() const =0
Query if the activity is started.
The state indicating that a run-time error has occured [red] and needs attention. ...
virtual bool isConfigured() const
Inspect if the component is configured, i.e.
virtual bool activate()
This method starts the ExecutionEngine of this component in case it was not running.
virtual bool setCpuAffinity(unsigned cpu)
Sets the cpu affinity of this component.
virtual void stopHook()
Implement this method such that it contains the code which will be executed when stop() is called...
virtual bool isRunning() const
Inspect if the component is in the Running or RunTimeError state.
virtual bool configure()
This method instructs the component to (re-)read configuration data and try to enter the Stopped stat...
virtual unsigned getCpuAffinity() const =0
Get the cpu affinity of this activity.
The state indicating additional configuration is required.
An execution engine serialises (executes one after the other) the execution of all commands...
virtual void error()
Call this method in a Running state to indicate a run-time error condition.
virtual Seconds getPeriod() const
Get the configured execution period of this component.
virtual bool inException() const
Inspect if the component is in the Exception state.
virtual bool inFatalError() const
Inspect if the component is in the FatalError state.
virtual void errorHook()
Implement this method to contain code that must be executed in the RunTimeError state, instead of updateHook().
bool mTriggerOnStart
Set to false in order to not trigger() when calling start().
virtual bool update()
Invoke this method to execute the ExecutionEngine and the update() method.
virtual bool setCpuAffinity(unsigned cpu)=0
Set the cpu affinity of this activity.
The state indicating the component encountered a fatal error and is unable to execute.
virtual void exceptionHook()
Implement this method to contain code that must be executed when transitioning to the Exception state...
virtual void fatal()
Call this method from any place to indicate that this component encountered a fatal error...
virtual void exception()
Call this method to indicate a run-time exception happend.
TaskState
Describes the different states a component can have.
base::TaskCore * getParent()
The base::TaskCore which created this ExecutionEngine.
virtual bool execute()=0
Execute this activity such that it executes a step or loop of the RunnableInterface.
virtual Seconds getPeriod() const =0
Get the periodicity of this activity in Seconds.
virtual bool breakUpdateHook()
Implement this function if your code might block for long times inside the updateHook() function...
virtual TaskState getTaskState() const
Returns the current state of the TaskCore.
virtual bool isActive() const
Inspect if the component's ExecutionEngine is processing requests.
virtual void cleanupHook()
Implement this method such that it contains the code which will be executed when cleanup() is called...
virtual bool inRunTimeError() const
Inspect if the component is in the RunTimeError state.
The state indicating the component is running [green].
virtual unsigned getCpuAffinity() const
Get the configured cpu affinity of this component.
virtual bool start()=0
Start the activity.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
The state indicating the component is ready to run.
virtual bool stop()
This method stops the execution of updateHook() of this component.
ExecutionEngine * ee
The execution engine which calls update() and processes our commands, events etc. ...
virtual bool setPeriod(Seconds s)
Sets the period of this component.
const ExecutionEngine * engine() const
Get a const pointer to the ExecutionEngine of this Task.
virtual bool cleanup()
This method instructs a stopped component to enter the pre-operational state again.
TaskCore(TaskState initial_state=Stopped)
Create a TaskCore.
virtual bool start()
This method starts the execution of the updateHook() with each trigger or period. ...
virtual bool stop()=0
Stop the activity This will stop the activity by removing it from the 'run-queue' of a thread or call...