com.kuka.roboticsAPI.applicationModel.tasks
Class RoboticsAPITask

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

public abstract class RoboticsAPITask
extends Object
implements ILegacyRoboticsAPITask

Base class for RoboticsAPI tasks.

See Also:
Available types for Dependency Injection

Constructor Summary
protected RoboticsAPITask()
          This constructor is meant to be used with dependency injection.
protected RoboticsAPITask(RoboticsAPIContext context, com.kuka.task.ITaskLogger logger, com.kuka.task.ITaskManager taskManager, boolean createAppControl)
          Creates a new instance of the class with specified context.
 
Method Summary
 void dispose()
          Disposes this task.
 IApplicationData getApplicationData()
          Gets the application data interface.
protected  ITaskUI getApplicationUI()
          Gets the application UI interface for the application or background task.
 RoboticsAPIContext getContext()
          Gets the context of this task.
 Controller getController(String controllerName)
          Gets the controller instance of the given controller name.
 Device getDevice(Controller controller, String deviceName)
          Gets the device with the given name on the given controller.
 Device getDevice(String controllerName, String deviceName)
          Gets the device with the given name on the given controller.
 com.kuka.task.ITaskLogger getLogger()
          Gets the logger of this task.
 ObserverManager getObserverManager()
          Gets the observer manager of this task.
protected  IRecovery getRecovery()
          Gets the application recovery interface for the application or background task.
 Robot getRobot(Controller controller, String robotName)
          Gets the robot with the given name from the given controller instance.
 Robot getRobot(String controllerName, String robotName)
          Returns a robot with the specified name from the controller with the specified name.
<T> T
getTaskFunction(Class<T> functionClass)
          Returns an instance of the type represented by the given task function class that allows access to the task function provided by an instance of one of the registered tasks.
 com.kuka.task.ITaskManager getTaskManager()
          Gets the task manager.
 void initialize()
          Initializes this task.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.kuka.task.IRoboticsAPITask
run
 

Constructor Detail

RoboticsAPITask

protected RoboticsAPITask()
This constructor is meant to be used with dependency injection. When using this constructor, the class depends on fields to be injected.


RoboticsAPITask

protected RoboticsAPITask(RoboticsAPIContext context,
                          com.kuka.task.ITaskLogger logger,
                          com.kuka.task.ITaskManager taskManager,
                          boolean createAppControl)
Creates a new instance of the class with specified context.

Parameters:
context - context of the task. It will be disposed when this task is disposed.
logger - the logger that will be returned by getLogger()
taskManager - the task manager that will be returned by getTaskManager() and is used by getTaskFunction(Class)
createAppControl - if set to true - IApplicationControl will be created for this task
Method Detail

getContext

public RoboticsAPIContext getContext()
Gets the context of this task.

Specified by:
getContext in interface ILegacyRoboticsAPITask
Returns:
The context of this task.
Throws:
IllegalStateException - if the context is not available because the task was not properly initialized
This element is not in its final state and might change in future versions.

getLogger

public final com.kuka.task.ITaskLogger getLogger()
Gets the logger of this task.

May be used to log information for diagnostics and visualization purposes.

Specified by:
getLogger in interface ILegacyRoboticsAPITask
Returns:
The logger of this task.
Throws:
IllegalStateException - if the logger is not available because the task was not properly initialized
This element is not in its final state and might change in future versions.

initialize

public void initialize()
Initializes this task. Use this to initialize the RoboticsAPI and your task.

Specified by:
initialize in interface com.kuka.task.IRoboticsAPITask

dispose

public void dispose()
Disposes this task. Use this to dispose the RoboticsAPI and all of your resources.

Basic implementation calls getContext().dispose().

It is imperative that you call super.dispose() when you override this method like this:

 @Override
 public void dispose()
 {
     try
     {
         // ... your code ...
     }
     finally
     {
         super.dispose();
     }
 }
 

Specified by:
dispose in interface com.kuka.task.IRoboticsAPITask

getRobot

public final Robot getRobot(String controllerName,
                            String robotName)
Returns a robot with the specified name from the controller with the specified name.

Parameters:
controllerName - The name of the controller.
robotName - The name of the robot.
Returns:
The robot with the specified name from the controller with the specified name.
Throws:
IllegalStateException - if the context is not available because the application was not properly initialized

getRobot

public final Robot getRobot(Controller controller,
                            String robotName)
Gets the robot with the given name from the given controller instance.

Parameters:
controller - The controller instance.
robotName - The name of the robot.
Returns:
The robot instance.

getDevice

public final Device getDevice(String controllerName,
                              String deviceName)
Gets the device with the given name on the given controller. If no such controller or device is found, this method throws an exception.

Parameters:
controllerName - The controller name.
deviceName - The name of the device.
Returns:
The device with the given name on the specified controller.
Throws:
IllegalStateException - if the context is not available because the task was not properly initialized

getDevice

public final Device getDevice(Controller controller,
                              String deviceName)
Gets the device with the given name on the given controller. If no such controller or device is found, this method throws an exception.

Parameters:
controller - The controller.
deviceName - The name of the device.
Returns:
The device with the given name on the specified controller.

getController

public final Controller getController(String controllerName)
Gets the controller instance of the given controller name.

Parameters:
controllerName - The name of the controller.
Returns:
The controller instance.
Throws:
IllegalStateException - if the context is not available because the task was not properly initialized

getApplicationData

public IApplicationData getApplicationData()
Gets the application data interface.

Returns:
the application data interface.
Throws:
IllegalStateException - if the context is not available because the task was not properly initialized

getObserverManager

public ObserverManager getObserverManager()
Gets the observer manager of this task.

Returns:
The observer manager.
Throws:
IllegalStateException - if the context is not available because the task was not properly initialized

getApplicationUI

protected ITaskUI getApplicationUI()
Gets the application UI interface for the application or background task.

Returns:
the application UI interface for the application or background task.
Throws:
IllegalArgumentException - if UI engine is not configured for the application.
IllegalStateException - if the context is not available because the task was not properly initialized

getTaskFunction

public <T> T getTaskFunction(Class<T> functionClass)
Returns an instance of the type represented by the given task function class that allows access to the task function provided by an instance of one of the registered tasks. The instance returned will be a proxy for the actual task function instance.

This proxy allows the methods of the task function to be called only when the providing task instance is running. If you access the task function methods while the providing instance is not running yet or has stopped running, an InstanceNotRunningException will be thrown from the method. If you need to wait for the availability of the task function, you can create a TaskFunctionMonitor.

This function can only be called if the task declaring it does not allow multiple task instances to be started simultaneously.

Type Parameters:
T - The type of the task function.
Parameters:
functionClass - The task function class.
Returns:
a proxy to the task function
Throws:
com.kuka.task.FunctionNotAvailableException - if no registered task declares task functions of the given type
com.kuka.task.AmbiguousInstanceException - if the task providing the task function exists but allows multiple instances to be started simultaneously

getTaskManager

public final com.kuka.task.ITaskManager getTaskManager()
Gets the task manager.

Returns:
task manager.
Throws:
IllegalStateException - if the task manager is not available because the task was not properly initialized
This element is not in its final state and might change in future versions.

getRecovery

protected IRecovery getRecovery()
Gets the application recovery interface for the application or background task.

Returns:
the application recovery interface for the application or background task.
Throws:
IllegalStateException - if the context is not available because the task was not properly initialized


Copyright © 2019. All rights reserved.