com.kuka.task
Interface ITask


public interface ITask

Represents a task control interface that can be used in other tasks.

With this interface it is possible to start/stop instances of the other tasks loaded at task manager.

It is also possible to get task functions provided by the wrapped task.

See Also:
ITaskManager

Method Summary
 Collection<ITaskInstance> getInstances()
          Gets all running instances of the task.
<F> F
getTaskFunction(Class<F> 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 this task.
 ITaskInstance startInstance(Object... parameter)
          Starts a new instance of the corresponding task with the specified parameters.
 void stopAllInstances()
          Stops all running instances of this task.
 void stopInstance(ITaskInstance taskInstance)
          Stops the given task instance which was previously started by startInstance(Object...).
 

Method Detail

startInstance

ITaskInstance startInstance(Object... parameter)
                            throws InterruptedException
Starts a new instance of the corresponding task with the specified parameters.

The new instance is started as new task instance independent from the starting task. This instance does not depend on the status or lifecycle of other tasks.
This methods blocks until the started instance reached the "running" state or timeout of 5 seconds has expired.

Parameters:
parameter - The parameter to start the new instance with.
Returns:
The TaskInstance wrapper.
Throws:
InterruptedException - if the calling thread was interrupted while waiting
TaskRuntimeInitializationException - if exception was thrown during creation and initialization of the task, or task did not reached "running" state in 5seconds.

stopInstance

void stopInstance(ITaskInstance taskInstance)
                  throws InterruptedException
Stops the given task instance which was previously started by startInstance(Object...).

Blocks until the instance is stopped.

Parameters:
taskInstance - The task instance to stop.
Throws:
InterruptedException - if the calling thread interrupted during waiting

stopAllInstances

void stopAllInstances()
                      throws InterruptedException
Stops all running instances of this task.

Blocks until all instances are stopped.

Throws:
InterruptedException - if the calling thread interrupted during waiting

getInstances

Collection<ITaskInstance> getInstances()
Gets all running instances of the task.

Returns all task instances that are not finished at the moment when the method is called.

Returns:
Collection containing all running instances of one task class.

getTaskFunction

<F> F getTaskFunction(Class<F> 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 this task. 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 category does not allow multiple task instances to be started simultaneously.

Type Parameters:
F - The type of the task function.
Parameters:
functionClass - The task function class.
Returns:
a proxy to the task function
Throws:
FunctionNotAvailableException - if this task does not declare task functions of the given type
AmbiguousInstanceException - if the task allows multiple instances to be started simultaneously


Copyright © 2019. All rights reserved.