JobScheduler  1.1.0
CMJob::AbstractJob Class Referenceabstract

The AbstractJob class provides an interface for jobs. More...

#include <CMJob.h>

Inheritance diagram for CMJob::AbstractJob:
Inheritance graph
Collaboration diagram for CMJob::AbstractJob:
Collaboration graph

Public Member Functions

 AbstractJob (const std::string &name, JobType type, bool sync)
 AbstractJob. More...
 
void setCycleTime (unsigned long cycle)
 setCycleTime More...
 
void setCycleOffset (unsigned long cycle)
 setCycleOffset More...
 
void setTimeoutTime (double time_s)
 setTimeoutTime More...
 
void setExecutionCounter (int count)
 setExecutionCounter More...
 
void skipFirstCycles (unsigned count)
 skipFirstNCycles More...
 
void setCallbackHook (CallbackHook hook)
 setCallbackHook More...
 
virtual void init ()
 Initialization of the job. More...
 
virtual void activate ()
 Activation of the job. More...
 
virtual void prepare ()
 Preperation of the job. More...
 
virtual void execute ()=0
 Execution of the job. More...
 
virtual void suspend ()
 Suspension of the job. More...
 
virtual void timeout ()
 Putting job into timeout. More...
 
virtual void disable ()
 Disable the job. More...
 
virtual void reset ()
 Reset the job. More...
 
void info () const
 Prints job details. More...
 
bool isJobScheduled (unsigned long cycle) const
 function, which returns if the job is scheduled at cycle More...
 
bool isCallbackScheduled (unsigned long cycle) const
 function to check if current callback is scheduled at cycle More...
 
bool isJobTimeout (void) const
 isJobTimeout More...
 
std::string getJobName () const
 
unsigned long getCycleTime () const
 
unsigned long getCycleOffset () const
 
bool isSynchronized () const
 
unsigned long getCycle () const
 
JobType getJobType () const
 
std::string getJobTypeName () const
 
CallbackHook getCallbackHook () const
 
std::string getCallbackHookName () const
 
JobState getJobState () const
 
std::string getJobStateName () const
 
void setCycle (unsigned long cycle)
 
void setJobName (const std::string &name)
 set a job name instead of the argument in constructor More...
 

Protected Member Functions

void setReady ()
 
void setIdle ()
 
void setActive ()
 
void setSuspended ()
 
void setTimeout ()
 
void setDisabled ()
 

Detailed Description

The AbstractJob class provides an interface for jobs.

Constructor & Destructor Documentation

◆ AbstractJob()

AbstractJob::AbstractJob ( const std::string &  name,
JobType  type,
bool  sync 
)

AbstractJob.

Parameters
nameis the job name
typeis the type Cyclic or Trigger
syncis the flag if the job should get syncronized

Member Function Documentation

◆ activate()

void AbstractJob::activate ( )
virtual

Activation of the job.

Function activate() can be provided in the inherited class. Then AbstractJob::activate() has to be called.

Use it to

  • activate an idle job
  • reset variables
Here is the caller graph for this function:

◆ disable()

void AbstractJob::disable ( )
virtual

Disable the job.

Function disable() can be provided in the inherited class. Then AbstractJob::disable() has to be called.

Use it to

  • disable the job

◆ execute()

void AbstractJob::execute ( void  )
pure virtual

Execution of the job.

Function execute() has to be provided in the inherited class. Then AbstractJob::execute() has to be called.

Use it to

  • call the job functionality

Implemented in CMJob::RosSubscriber< T >, and CMJob::RosPublisher< T >.

Here is the caller graph for this function:

◆ info()

void AbstractJob::info ( ) const

Prints job details.

Prints name, cycletime and cycleoffset

◆ init()

void AbstractJob::init ( void  )
virtual

Initialization of the job.

Function init() can be provided in the inherited class. Then AbstractJob::init() has to be called.

Use it to

  • set default job settings
  • external initialization

Reimplemented in CMJob::RosSubscriber< T >.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isCallbackScheduled()

bool AbstractJob::isCallbackScheduled ( unsigned long  cycle) const

function to check if current callback is scheduled at cycle

Parameters
[in]cycle
Returns
state if callback is scheduled

◆ isJobScheduled()

bool AbstractJob::isJobScheduled ( unsigned long  cycle) const

function, which returns if the job is scheduled at cycle

Parameters
[in]cycle
Returns
state if job is scheduled

◆ isJobTimeout()

bool AbstractJob::isJobTimeout ( void  ) const

isJobTimeout

Returns
state if job is in timeout

◆ prepare()

void AbstractJob::prepare ( )
virtual

Preperation of the job.

Function prepare() can be provided in the inherited class. Then AbstractJob::prepare() has to be called.

Useful when you use a cyclic job, because then the execution is scheduled and uses data provided by this function

Use it to

  • update variables used for execution

◆ reset()

void AbstractJob::reset ( )
virtual

Reset the job.

Function reset() can be provided in the inherited class. Then AbstractJob::reset() has to be called.

Use it to

◆ setCallbackHook()

void AbstractJob::setCallbackHook ( CallbackHook  hook)

setCallbackHook

Parameters
hook

◆ setCycleOffset()

void AbstractJob::setCycleOffset ( unsigned long  cycle)

setCycleOffset

Parameters
cycle

◆ setCycleTime()

void AbstractJob::setCycleTime ( unsigned long  cycle)

setCycleTime

Parameters
cycle

◆ setExecutionCounter()

void AbstractJob::setExecutionCounter ( int  count)

setExecutionCounter

Parameters
count

◆ setJobName()

void AbstractJob::setJobName ( const std::string &  name)

set a job name instead of the argument in constructor

with the same argument in the constructor, there can be multiple jobs with the same name.

◆ setTimeoutTime()

void AbstractJob::setTimeoutTime ( double  time_s)

setTimeoutTime

Parameters
time_s

◆ skipFirstCycles()

void AbstractJob::skipFirstCycles ( unsigned  count)

skipFirstNCycles

Parameters
count

◆ suspend()

void AbstractJob::suspend ( )
virtual

Suspension of the job.

Function suspend() can be provided in the inherited class. Then AbstractJob::suspend() has to be called.

Use it to

  • suspend a job, which doesn't meet certain criteria

◆ timeout()

void AbstractJob::timeout ( )
virtual

Putting job into timeout.

Function timeout() can be provided in the inherited class. Then AbstractJob::timeout() has to be called.