OpenDevice
Open IoT (Internet Of Things) Platform and Framework http://opendevice.io
Task Class Reference

Public Member Functions

 Task (unsigned long aInterval=0, long aIterations=0, void(*aCallback)()=NULL, Scheduler *aScheduler=NULL, bool aEnable=false, bool(*aOnEnable)()=NULL, void(*aOnDisable)()=NULL)
 
void enable ()
 
bool enableIfNot ()
 
void enableDelayed (unsigned long aDelay=0)
 
void delay (unsigned long aDelay=0)
 
void forceNextIteration ()
 
void restart ()
 
void restartDelayed (unsigned long aDelay=0)
 
bool disable ()
 
bool isEnabled ()
 
void set (unsigned long aInterval, long aIterations, void(*aCallback)(), bool(*aOnEnable)()=NULL, void(*aOnDisable)()=NULL)
 
void setInterval (unsigned long aInterval)
 
unsigned long getInterval ()
 
void setIterations (long aIterations)
 
long getIterations ()
 
unsigned long getRunCounter ()
 
void setCallback (void(*aCallback)())
 
void setOnEnable (bool(*aCallback)())
 
void setOnDisable (void(*aCallback)())
 
bool isFirstIteration ()
 
bool isLastIteration ()
 

Friends

class Scheduler
 

Constructor & Destructor Documentation

◆ Task()

Task::Task ( unsigned long  aInterval = 0,
long  aIterations = 0,
void(*)()  aCallback = NULL,
Scheduler aScheduler = NULL,
bool  aEnable = false,
bool(*)()  aOnEnable = NULL,
void(*)()  aOnDisable = NULL 
)

Constructor, uses default values for the parameters so could be called with no parameters.

Member Function Documentation

◆ delay()

void Task::delay ( unsigned long  aDelay = 0)

Delays Task for execution after a delay = aInterval (if task is enabled). leaves task enabled or disabled if aDelay is zero, delays for the original scheduling interval from now

◆ disable()

bool Task::disable ( )

Disables task Task will no longer be executed by the scheduler Returns status of the task before disable was called (i.e., if the task was already disabled)

◆ enable()

void Task::enable ( )

Enables the task schedules it for execution as soon as possible, and resets the RunCounter back to zero

◆ enableDelayed()

void Task::enableDelayed ( unsigned long  aDelay = 0)

Enables the task and schedules it for execution after a delay = aInterval

◆ enableIfNot()

bool Task::enableIfNot ( )

Enables the task only if it was not enabled already Returns previous state (true if was already enabled, false if was not)

◆ forceNextIteration()

void Task::forceNextIteration ( )

Schedules next iteration of Task for execution immediately (if enabled) leaves task enabled or disabled Task's original schedule is shifted, and all subsequent iterations will continue from this point in time

◆ restart()

void Task::restart ( )

Restarts task Task will run number of iterations again

◆ restartDelayed()

void Task::restartDelayed ( unsigned long  aDelay = 0)

Restarts task delayed Task will run number of iterations again

◆ set()

void Task::set ( unsigned long  aInterval,
long  aIterations,
void(*)()  aCallback,
bool(*)()  aOnEnable = NULL,
void(*)()  aOnDisable = NULL 
)

Explicitly set Task execution parameters

Parameters
aInterval- execution interval in ms
aIterations- number of iterations, use -1 for no limit
aCallback- pointer to the callback method which executes the task actions
aOnEnable- pointer to the callback method which is called on enable()
aOnDisable- pointer to the callback method which is called on disable()

◆ setInterval()

void Task::setInterval ( unsigned long  aInterval)

Sets the execution interval. Task execution is delayed for aInterval Use enable() to schedule execution ASAP

Parameters
aInterval- new execution interval

◆ setIterations()

void Task::setIterations ( long  aIterations)

Sets number of iterations for the task if task is enabled, schedule for immediate execution

Parameters
aIterations- number of iterations, use -1 for no limit

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