com.kuka.roboticsAPI.applicationModel.tasks
Class RoboticsAPICyclicBackgroundTask

java.lang.Object
  extended by com.kuka.roboticsAPI.applicationModel.tasks.RoboticsAPITask
      extended by com.kuka.roboticsAPI.applicationModel.tasks.RoboticsAPIBackgroundTask
          extended by com.kuka.roboticsAPI.applicationModel.tasks.RoboticsAPICyclicBackgroundTask
All Implemented Interfaces:
ILegacyRoboticsAPITask, com.kuka.task.IRoboticsAPITask

public abstract class RoboticsAPICyclicBackgroundTask
extends RoboticsAPIBackgroundTask

Base class for cyclic background tasks.

Can be used to define a background task which should be triggered cyclically. Instead of run method of the RoboticsAPIBackgroundTask provides runCyclic() method which will be called cyclically with the specified period.
Cycle period and initial delay can be set by calling initializeCyclic(long, long, java.util.concurrent.TimeUnit, com.kuka.roboticsAPI.applicationModel.tasks.CycleBehavior) method in the RoboticsAPITask.initialize() method of the inheriting class.
The cyclic background task can be terminated via Future.cancel(boolean) on the return value of getCyclicFuture() or by stopping the task.


Constructor Summary
protected RoboticsAPICyclicBackgroundTask()
          Creates a new instance of the class with context from file "RoboticsAPI.config.xml".
protected RoboticsAPICyclicBackgroundTask(RoboticsAPIContext context)
          Creates a new instance of the class with specified context.
 
Method Summary
 void dispose()
          Disposes this task.
 ScheduledFuture<?> getCyclicFuture()
          Gets the future object which controls the execution of the task.
protected  void initializeCyclic(long initialDelay, long period, TimeUnit timeUnit, CycleBehavior behavior)
          Initializes the parameters of the cyclic task.
 void run()
           
protected abstract  void runCyclic()
          Code in this method executes a periodic action that becomes enabled first after the initial delay, and subsequently with the period that can be set by calling initializeCyclic(long, long, java.util.concurrent.TimeUnit, com.kuka.roboticsAPI.applicationModel.tasks.CycleBehavior) method.
 
Methods inherited from class com.kuka.roboticsAPI.applicationModel.tasks.RoboticsAPIBackgroundTask
getApplicationUI
 
Methods inherited from class com.kuka.roboticsAPI.applicationModel.tasks.RoboticsAPITask
getApplicationData, getContext, getController, getDevice, getDevice, getLogger, getObserverManager, getRecovery, getRobot, getRobot, getTaskFunction, getTaskManager, initialize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.kuka.roboticsAPI.applicationModel.tasks.ILegacyRoboticsAPITask
getContext, getLogger
 
Methods inherited from interface com.kuka.task.IRoboticsAPITask
initialize
 

Constructor Detail

RoboticsAPICyclicBackgroundTask

protected RoboticsAPICyclicBackgroundTask()
Creates a new instance of the class with context from file "RoboticsAPI.config.xml".


RoboticsAPICyclicBackgroundTask

protected RoboticsAPICyclicBackgroundTask(RoboticsAPIContext context)
Creates a new instance of the class with specified context.

Parameters:
context - context of the task.
Method Detail

initializeCyclic

protected final void initializeCyclic(long initialDelay,
                                      long period,
                                      TimeUnit timeUnit,
                                      CycleBehavior behavior)
Initializes the parameters of the cyclic task.

It is recommended to call this method in the IRoboticsAPITask.initialize() method of the inheriting class.

Parameters:
initialDelay - the time to delay first execution
period - the period between successive executions
timeUnit - the time unit of the initialDelay and period parameters
behavior - Defines the behavior of a cyclic task if the execution of a cyclic method takes longer than the given period time.

runCyclic

protected abstract void runCyclic()
Code in this method executes a periodic action that becomes enabled first after the initial delay, and subsequently with the period that can be set by calling initializeCyclic(long, long, java.util.concurrent.TimeUnit, com.kuka.roboticsAPI.applicationModel.tasks.CycleBehavior) method.
If any execution of the method encounters an exception, subsequent executions are suppressed and the task is terminated. If any execution of this method takes longer than the specified period, then if CycleBehavior.BestEffort is set, subsequent executions may start late, but will not concurrently execute. If CycleBehavior.Strict behavior is set and this method takes longer than the specified period, cyclic task will be terminated with CycleExceededException.


run

public final void run()

dispose

public void dispose()
Disposes this task.

Use this to dispose the cyclic task and all of your resources.

Basic implementation calls getContext().dispose() and stops and disposes the cyclic worker.

It is strongly recommended to call super.dispose() when overriding this method.

Specified by:
dispose in interface com.kuka.task.IRoboticsAPITask
Overrides:
dispose in class RoboticsAPITask

getCyclicFuture

public ScheduledFuture<?> getCyclicFuture()
Gets the future object which controls the execution of the task.

Returns:
the future object which controls the execution of the task.


Copyright © 2019. All rights reserved.