com.kuka.roboticsAPI.executionModel
Class ExecutionContainer

java.lang.Object
  extended by com.kuka.roboticsAPI.executionModel.ExecutionContainer
All Implemented Interfaces:
com.kuka.common.concurrent.IWaitToken, ICommandContainer, IExecutionContainer
Direct Known Subclasses:
SunriseExecutionContainer

public abstract class ExecutionContainer
extends Object
implements ICommandContainer

A container serves as execution context for a command.

It contains a execution state and has methods to synchronize the container with it's execution. Provides methods to access runtime data for the associated command.

This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

Field Summary
protected  String _containerTypeName
          String describing the type of the execution container.
 
Constructor Summary
protected ExecutionContainer(IControllerCommand command, ExecutorService eventWorker, IContainerStateListener stateListener)
          Creates a new container for the execution of a command and prepares it.
 
Method Summary
 void acquireResources()
          Acquires the resources of the command which is encapsulated in the container.
 void addStateListener(IContainerStateListener stateListener)
          Adds a state listener for the container.
protected  void appendErrorMessage(String additionalMessage)
          Appends the current error message with the specified string.
 void await()
          Blocks the calling thread until the container has finished it's execution.
 void await(long timeout, TimeUnit unit)
          Blocks the calling thread until the container has finished it's execution.
 void cancel()
          Cancels the command in this container.
 IControllerCommand getCommand()
          Gets the command which was executed within this container.
 RoboticsAPIContext getContext()
          Gets the context in which this container was created.
 com.kuka.common.params.IParameterSet getDefaultParams()
          Returns the default parameters that will be used for the command.
 String getErrorMessage()
          Gets the error message for the container.
 IFiredConditionInfo getFiredBreakConditionInfo()
          Gets the stop condition that has fired.
 ICommandRuntimeData getRuntimeData()
          Gets the custom runtime data associated with this container.
 ExecutionState getState()
          Gets the current ExecutionState of the container.
 boolean hasError()
          Checks if this container is in an error state.
 boolean hasFired(ICondition condition)
          Tests whether the given condition has fired for this container. this is equivalent to
{@code getFiredConditionInfo() !
 boolean isFinished()
          Checks if the container has finished it's execution either with a successful execution or with an error.
 void removeStateListener(IContainerStateListener stateListener)
          Removes the specified state listener from the container.
 void setDefaultParams(com.kuka.common.params.IParameterSet defaultParams)
          Set default parameters that will be used for the command.
protected  void setErrorMessage(String errorMessage)
          Sets an error message for the container which describes the error when the state is invalid.
protected  void setFiredStopCondition(IFiredConditionInfo stopCondition)
          Sets the fired stop condition for this container.
protected  void setState(ExecutionState state)
          Changes the state of the container to the given state.
protected  void throwContainerException(ExecutionContainer executionContainer, ExecutionException ex, boolean b)
          awrg.
 String toString()
           
 void validate()
          Validates this container and throws an exception if the container is invalid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_containerTypeName

protected final String _containerTypeName
String describing the type of the execution container.

Constructor Detail

ExecutionContainer

protected ExecutionContainer(IControllerCommand command,
                             ExecutorService eventWorker,
                             IContainerStateListener stateListener)
Creates a new container for the execution of a command and prepares it.

An execution container should not be created manually. The framework will do this for the user.

Parameters:
command - The command which should be executed. null is not allowed.
eventWorker - event worker that is used to send container state events. May be null, in this case no events will be fired.
stateListener - A state listener which will be called when the state of the container changes. May be null.
Throws:
IllegalArgumentException - if command is null or container is not set for the command.
Method Detail

toString

public final String toString()
Overrides:
toString in class Object

setState

protected void setState(ExecutionState state)
Changes the state of the container to the given state. This should only be used by controller implementations.

Parameters:
state - The new state of the container.

cancel

public void cancel()
Cancels the command in this container.

Specified by:
cancel in interface IExecutionContainer
This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

await

public void await()
Blocks the calling thread until the container has finished it's execution. If the container is invalid or was canceled, an appropriate exception will be thrown.

Specified by:
await in interface com.kuka.common.concurrent.IWaitToken
Specified by:
await in interface IExecutionContainer
This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

await

public void await(long timeout,
                  TimeUnit unit)
           throws TimeoutException
Blocks the calling thread until the container has finished it's execution. Only blocks the thread until the timeout is reached. If the container is invalid or was canceled, an appropriate exception will be thrown.

Specified by:
await in interface com.kuka.common.concurrent.IWaitToken
Specified by:
await in interface IExecutionContainer
Parameters:
timeout - The timeout.
unit - The unit of the timeout.
Throws:
TimeoutException - the wait timed out
This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

validate

public void validate()
Validates this container and throws an exception if the container is invalid.

Specified by:
validate in interface IExecutionContainer
Throws:
CommandInvalidException - if container command goes into invalid state (controller error).
ExternalStopException - if command was stopped because of some external signal.
ApplicationExitException - if application was asked to exit during execution of the container command
This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

throwContainerException

protected void throwContainerException(ExecutionContainer executionContainer,
                                       ExecutionException ex,
                                       boolean b)
awrg.

Parameters:
executionContainer -
ex -
b -

getContext

public RoboticsAPIContext getContext()
Gets the context in which this container was created. This is the context of the command to which this container belongs.

Returns:
The context of this container.
This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

isFinished

public boolean isFinished()
Checks if the container has finished it's execution either with a successful execution or with an error. If you like to see if an error occurred, you have to check the error message or call the method hasError.

Specified by:
isFinished in interface com.kuka.common.concurrent.IWaitToken
Specified by:
isFinished in interface IExecutionContainer
Returns:
True if the container execution is finished, otherwise false.
This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

hasError

public boolean hasError()
Checks if this container is in an error state. An error state is Invalid or ExternalStop.

Specified by:
hasError in interface IExecutionContainer
Returns:
True if this container is in an error state.
This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

getState

public ExecutionState getState()
Gets the current ExecutionState of the container.

Specified by:
getState in interface ICommandContainer
Returns:
The current state of the container.
This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

addStateListener

public void addStateListener(IContainerStateListener stateListener)
Adds a state listener for the container.

Parameters:
stateListener - The state listener.
This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

removeStateListener

public void removeStateListener(IContainerStateListener stateListener)
Removes the specified state listener from the container.

Parameters:
stateListener - listener to remove
This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

getCommand

public IControllerCommand getCommand()
Gets the command which was executed within this container.

Specified by:
getCommand in interface ICommandContainer
Returns:
The command.
This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

setErrorMessage

protected void setErrorMessage(String errorMessage)
Sets an error message for the container which describes the error when the state is invalid.

Parameters:
errorMessage - The error message.

appendErrorMessage

protected void appendErrorMessage(String additionalMessage)
Appends the current error message with the specified string.

Parameters:
additionalMessage - additional error message to append to the existing one.

getErrorMessage

public String getErrorMessage()
Gets the error message for the container.

Specified by:
getErrorMessage in interface IExecutionContainer
Returns:
The error message.
This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

setFiredStopCondition

protected void setFiredStopCondition(IFiredConditionInfo stopCondition)
Sets the fired stop condition for this container.

Not intended to be called manually.

Parameters:
stopCondition - The fired stop condition.

hasFired

public boolean hasFired(ICondition condition)
Tests whether the given condition has fired for this container. this is equivalent to
getFiredConditionInfo() != null && getFiredConditionInfo().getFiredCondition() == condition

Specified by:
hasFired in interface IExecutionContainer
Parameters:
condition - the condition to test if it has fired.
Returns:
true if the condition has fired, false otherwise.
This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

getFiredBreakConditionInfo

public IFiredConditionInfo getFiredBreakConditionInfo()
Gets the stop condition that has fired. May be null if no user defined stop condition has fired.

Specified by:
getFiredBreakConditionInfo in interface IExecutionContainer
Returns:
The stop condition that has fired. May be null.
This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

acquireResources

public void acquireResources()
Acquires the resources of the command which is encapsulated in the container.

Do not call this method directly. This is done during the creation process of the container.

This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

getDefaultParams

public com.kuka.common.params.IParameterSet getDefaultParams()
Returns the default parameters that will be used for the command.

Returns:
the parameter set. can be null.
This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

setDefaultParams

public void setDefaultParams(com.kuka.common.params.IParameterSet defaultParams)
Set default parameters that will be used for the command.

Parameters:
defaultParams - a parameter set. Can be null.
This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

getRuntimeData

public ICommandRuntimeData getRuntimeData()
Gets the custom runtime data associated with this container.

Specified by:
getRuntimeData in interface IExecutionContainer
Returns:
the custom runtime data associated with this container. Can be null.
This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.


Copyright © 2019. All rights reserved.