com.kuka.roboticsAPI.controllerModel.sunrise
Class SPRRuntime

java.lang.Object
  extended by com.kuka.roboticsAPI.controllerModel.sunrise.SPRRuntime

public class SPRRuntime
extends Object

Class managing all runtime issues of the associated SPR.

Works together with SunriseExecutionService class to manage all aspects of the SPR execution including pausing and canceling.
The class will be automatically created for every new SPR instance.

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.

Nested Class Summary
static interface SPRRuntime.ISPRCancelListener
          Listener which is called if nobody has canceled the SPR so far and the cancel process is started.
 
Constructor Summary
SPRRuntime(SPR spr)
          Creates an instance of the class for the specified SPR.
 
Method Summary
 void addAsyncCompoundEventListener(ICompoundEventListener listener)
          Adds a listener for this SPR.
 void addIdListener(ISPRIdListener listener)
          Adds a listener for this SPR.
 void addStateListener(ISPRStateListener listener)
          Adds a listener for this SPR.
 void addSyncCompoundEventListener(ICompoundEventListener listener)
          Adds a synchronous compound event listener for this SPR.
 void addSyncStateListener(ISPRStateListener listener)
          Adds a synchronous SPR state listener for this SPR.
 void callCompoundEventListeners(Message eventMessage)
          Calls all listeners and informs them that a new compound event was thrown.
 boolean cancel()
          Cancels the associated SPR.
 boolean cancel(SPRRuntime.ISPRCancelListener cancelStartedListener)
          Cancels the associated SPR.
 ISPRCancelBehavior cancelBehavior()
          Gets the cancel behavior for the associated SPR.
 void cancelOnController()
          Sends cancel request to the controller.
 boolean cancelOnControllerAndWait(int time, TimeUnit unit)
          Sends a cancel request to Sunrise and waits the SPR will be finished.
 void cancelOnExit(boolean sendToController)
          Cancels the SPR on application exit (dispose of the ExecutionService).
 String getErrorMessage()
          Gets the error message for this SPR if applicable.
 SunriseStopCondition getFiredStopCondition()
          Gets the stop condition which has finished this SPR.
 long getId()
          Gets the id of this SPR.
 SPR getSPR()
          Gets the SPR with which this runtime object is associated.
 String getSPRIdString()
          Gets the readable string representation of thisSPR id.
 long getStackId()
          Gets the id of the stack to which belongs the associated SPR.
 SPR getStackRepresentative()
          Returns the SPR that is the representative for a SPR stack.
 SPRState getState()
          Gets the state of the associated SPR.
 void handleReturnStateMessage(Message message)
          Sets the return values associated with the change of the SPR state.
 boolean hasStopEvaluator()
          States if the SPR possess a StopEvaluator module.
 void initialize(ISunriseCommandExecutor execService, long id)
          Initializes the associated SPR for execution.
 void invalidateSPR(String errorMessage)
          Makes the associated SPR invalid for listeners with the specified error message.
 boolean isApplicationExit()
          Returns true if the SPR was finished due to the application exiting.
 boolean isCanceled()
          Return true, if the canceled flag is set.
 boolean isCancelledBeforePreActive()
          States whether the SPR was canceled before 'PreActive' or not.
 boolean isObserverSPR()
          Returns true if the SPR is an observer SPR.
 boolean isStoppedWithStack()
          Returns true if the SPR was or will be stopped because another SPR in the stack was stopped.
 void removeAsyncCompoundEventListener(ICompoundEventListener listener)
          Removes the listener from this SPR.
 void removeIdListener(ISPRIdListener listener)
          Removes the listener from this SPR.
 void removeStateListener(ISPRStateListener listener)
          Removes the listener from this SPR.
 void removeSyncCompoundEventListener(ICompoundEventListener listener)
          Removes the given synchronous compound event listener from this SPR.
 void removeSyncStateListener(ISPRStateListener listener)
          Removes the given synchronous state listener from this SPR.
 void setCancelBehavior(ISPRCancelBehavior cancelBehavior)
          Sets the cancel behavior for the SPR.
 void setObserverSPR(boolean isObserverSPR)
          Should be set to true if the SPR is an observer SPR.
 void setStackIdFromRepresentative()
          Sets the stack id of this SPR.
 void setStackRepresentative(SPR stackRepresentative)
          Sets the SPR that is the representative for a SPR stack.
 void setState(SPRState newState)
          Sets the SPR State of the runtime.
 void setState(SPRState newState, StopConditionType stopCondition)
          Sets the SPR State of the runtime.
 void setState(SPRState newState, StopConditionType stopCondition, String errorString)
          Sets the SPR State of the runtime.
 String toString()
           
 void update()
          Updates the associated SPR.
 boolean waitForActive(long timeout, TimeUnit unit)
          Blocks the calling thread until the SPR is active.
 boolean waitForFinished(int timeout, TimeUnit unit)
          Blocks the calling thread until the SPR is in finished.
 boolean waitForMaintaining(int timeout, TimeUnit unit)
          Blocks the calling thread until the SPR is in maintaining.
 boolean waitForPreparationFinished(int timeout, TimeUnit unit)
          Blocks the calling thread until the SPR is in preparation finished.
 boolean waitForTransferred(int timeout, TimeUnit unit)
          Blocks the calling thread until the SPR was transferred to Sunrise.
 boolean waitForTuning(long timeout, TimeUnit unit)
          Blocks the calling thread until the SPR is tuning.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SPRRuntime

public SPRRuntime(SPR spr)
Creates an instance of the class for the specified SPR.

Parameters:
spr - SPR to associate with the runtime.
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.
Method Detail

getSPR

public SPR getSPR()
Gets the SPR with which this runtime object is associated.

Returns:
the SPR with which this runtime object is associated.
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 final SPRState getState()
Gets the state of the associated SPR.

Returns:
The state of this SPR.
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.

setState

public final void setState(SPRState newState)
Sets the SPR State of the runtime.

Parameters:
newState - new SPR state

setState

public final void setState(SPRState newState,
                           StopConditionType stopCondition)
Sets the SPR State of the runtime.

Parameters:
newState - new SPR state
stopCondition - id of the fired user stop condition

setState

public final void setState(SPRState newState,
                           StopConditionType stopCondition,
                           String errorString)
Sets the SPR State of the runtime. Is public only because of PrimitiveTests and SPRBuildingTests.

Parameters:
newState - new SPR state
stopCondition - id of the fired user stop condition
errorString - e.g. Invalidation of SPR

isCancelledBeforePreActive

public boolean isCancelledBeforePreActive()
States whether the SPR was canceled before 'PreActive' or not.

Returns:
True if the SPR was canceled before 'PreActive', otherwise false.

isCanceled

public final boolean isCanceled()
Return true, if the canceled flag is set.

Returns:
true, if the canceled flag is set
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.

isStoppedWithStack

public boolean isStoppedWithStack()
Returns true if the SPR was or will be stopped because another SPR in the stack was stopped. Caution: This flag can be true even if this SPR is still running, due delays in message reception from Sunrise.

Returns:
true if stopped with other SPR in the stack
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.

isApplicationExit

public boolean isApplicationExit()
Returns true if the SPR was finished due to the application exiting.

Returns:
true if the application should terminate.
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 final void addStateListener(ISPRStateListener listener)
Adds a listener for this SPR.

Parameters:
listener - The state listener for this SPR. null is not allowed.
Throws:
IllegalArgumentException - if listener is null or the same listener is already registered
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 final void removeStateListener(ISPRStateListener listener)
Removes the listener from this SPR.

Parameters:
listener - The state listener for this SPR. null is not allowed.
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.

addSyncStateListener

public final void addSyncStateListener(ISPRStateListener listener)
Adds a synchronous SPR state listener for this SPR.

Parameters:
listener - The synchronous compound event listener for this SPR.
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.

removeSyncStateListener

public final void removeSyncStateListener(ISPRStateListener listener)
Removes the given synchronous state listener from this SPR.

Parameters:
listener - The synchronous compound event listener which should be removed.
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.

addSyncCompoundEventListener

public final void addSyncCompoundEventListener(ICompoundEventListener listener)
Adds a synchronous compound event listener for this SPR.

Parameters:
listener - The synchronous compound event listener for this SPR.
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.

removeSyncCompoundEventListener

public final void removeSyncCompoundEventListener(ICompoundEventListener listener)
Removes the given synchronous compound event listener from this SPR.

Parameters:
listener - The synchronous compound event listener which should be removed.
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.

addAsyncCompoundEventListener

public final void addAsyncCompoundEventListener(ICompoundEventListener listener)
Adds a listener for this SPR.

Parameters:
listener - The compound event listener for this SPR. null is not allowed.
Throws:
IllegalArgumentException - if listener is null or the same listener is already registered
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.

removeAsyncCompoundEventListener

public final void removeAsyncCompoundEventListener(ICompoundEventListener listener)
Removes the listener from this SPR.

Parameters:
listener - The compound event listener for this SPR. null is not allowed.
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.

addIdListener

public final void addIdListener(ISPRIdListener listener)
Adds a listener for this SPR.

Parameters:
listener - The state listener for this SPR. null is not allowed.
Throws:
IllegalArgumentException - if listener is null or the same listener is already registered
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.

removeIdListener

public final void removeIdListener(ISPRIdListener listener)
Removes the listener from this SPR.

Parameters:
listener - The state listener for this SPR. null is not allowed.
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.

waitForTransferred

public final boolean waitForTransferred(int timeout,
                                        TimeUnit unit)
Blocks the calling thread until the SPR was transferred to Sunrise. Only blocks the thread until the timeout is reached.

Parameters:
timeout - The timeout.
unit - The unit of the timeout.
Returns:
True if the command was transferred, false if an interrupted exception occurred while waiting for finishing or the timeout took place.
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.

waitForTuning

public final boolean waitForTuning(long timeout,
                                   TimeUnit unit)
Blocks the calling thread until the SPR is tuning. Only blocks the thread until the timeout is reached.

Parameters:
timeout - The timeout.
unit - The unit of the timeout.
Returns:
True if the command is tuning, false if an interrupted exception occurred while waiting for finishing or the timeout took place.
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.

waitForActive

public final boolean waitForActive(long timeout,
                                   TimeUnit unit)
Blocks the calling thread until the SPR is active. Only blocks the thread until the timeout is reached.

Parameters:
timeout - The timeout.
unit - The unit of the timeout.
Returns:
True if the command is active, false if an interrupted exception occurred while waiting for finishing or the timeout took place.
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.

waitForMaintaining

public final boolean waitForMaintaining(int timeout,
                                        TimeUnit unit)
Blocks the calling thread until the SPR is in maintaining. Only blocks the thread until the timeout is reached.

Parameters:
timeout - The timeout.
unit - The unit of the timeout.
Returns:
True if the command is maintaining, false if an interrupted exception occurred while waiting for finishing or the timeout took place.
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.

waitForPreparationFinished

public final boolean waitForPreparationFinished(int timeout,
                                                TimeUnit unit)
Blocks the calling thread until the SPR is in preparation finished. Only blocks the thread until the timeout is reached.

Parameters:
timeout - The timeout.
unit - The unit of the timeout.
Returns:
True if the command is preparation finished, false if an interrupted exception occurred while waiting for finishing or the timeout took place.
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.

waitForFinished

public final boolean waitForFinished(int timeout,
                                     TimeUnit unit)
Blocks the calling thread until the SPR is in finished. Only blocks the thread until the timeout is reached.

Parameters:
timeout - The timeout.
unit - The unit of the timeout.
Returns:
True if the command is finished, false if an interrupted exception occurred while waiting for finishing or the timeout took place.
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.

callCompoundEventListeners

public final void callCompoundEventListeners(Message eventMessage)
Calls all listeners and informs them that a new compound event was thrown.

Parameters:
eventMessage - The event 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.

getFiredStopCondition

public final SunriseStopCondition getFiredStopCondition()
Gets the stop condition which has finished this SPR.

Returns:
The stop condition which has finished the SPR. Returns null if no stop condition has fired.
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.

getId

public final long getId()
Gets the id of this SPR.

Returns:
The id of this SPR.
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.

setStackIdFromRepresentative

public final void setStackIdFromRepresentative()
Sets the stack id of this SPR.

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.

getStackId

public final long getStackId()
Gets the id of the stack to which belongs the associated SPR.

Returns:
the id of the stack to which belongs the associated SPR.
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.

initialize

public final void initialize(ISunriseCommandExecutor execService,
                             long id)
Initializes the associated SPR for execution.

Is only possible in created and finished state.

Parameters:
execService - execution service which processes the execution of the associated SPR.
id - the SPR id
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.

cancel

public boolean cancel()
Cancels the associated SPR.

If the SPR is paused - does not send cancel request to controller - just sets the SPR state and notifies listeners. Otherwise uses the cancel behavior set for the SPR to cancel it.

Returns:
true, when SPR canceled now, false when SPR was already canceled
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.

cancel

public boolean cancel(SPRRuntime.ISPRCancelListener cancelStartedListener)
Cancels the associated SPR.

If the SPR is paused - does not send cancel request to controller - just sets the SPR state and notifies listeners. Otherwise uses the cancel behavior set for the SPR to cancel it.

Parameters:
cancelStartedListener - Listener which is called if nobody has canceled the SPR so far and the cancel process is started.
Returns:
true, when SPR canceled now, false when SPR was already canceled.
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.

cancelOnExit

public void cancelOnExit(boolean sendToController)
Cancels the SPR on application exit (dispose of the ExecutionService).

Parameters:
sendToController - cancel should be sent to the controller if this parameter is set to true.
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.

cancelOnController

public void cancelOnController()
Sends cancel request to the controller.

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.

cancelBehavior

public ISPRCancelBehavior cancelBehavior()
Gets the cancel behavior for the associated SPR.

if behavior was never set by user - default behavior DefaultCancelBehavior will be returned (and used by the SPR).

Returns:
the cancel behavior for the associated SPR.
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.

setCancelBehavior

public void setCancelBehavior(ISPRCancelBehavior cancelBehavior)
Sets the cancel behavior for the SPR.

Parameters:
cancelBehavior - cancel behavior to set. Can not 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.

cancelOnControllerAndWait

public boolean cancelOnControllerAndWait(int time,
                                         TimeUnit unit)
Sends a cancel request to Sunrise and waits the SPR will be finished.

Parameters:
time - time to wait for finished.
unit - time unit for time parameter.
Returns:
true if SPR was finished before the specified timeout expired; 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.

isObserverSPR

public boolean isObserverSPR()
Returns true if the SPR is an observer SPR.

Returns:
true if the SPR is an observer SPR.
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.

setObserverSPR

public void setObserverSPR(boolean isObserverSPR)
Should be set to true if the SPR is an observer SPR.

Observer SPR automatically gets special pause behavior: ObserverSPRPauseBehavior. And a "false" stop condition.

Parameters:
isObserverSPR - true if the SPR is an observer SPR.
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.

toString

public String toString()
Overrides:
toString in class Object

invalidateSPR

public void invalidateSPR(String errorMessage)
Makes the associated SPR invalid for listeners with the specified error message.

The SPR will be canceled on the controller and all listeners of the SPR state get the information that the SPR is invalid.

Parameters:
errorMessage - 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.

getErrorMessage

public String getErrorMessage()
Gets the error message for this SPR if applicable.

Returns:
the error message for this SPR if applicable or 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.

update

public void update()
Updates the associated SPR. Blocks until the update call is finished.

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.

getSPRIdString

public String getSPRIdString()
Gets the readable string representation of thisSPR id.

Returns:
the readable string representation of thisSPR id.
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.

getStackRepresentative

public SPR getStackRepresentative()
Returns the SPR that is the representative for a SPR stack. This will be the SPR that is placed in the lowest layer.

Returns:
the representative for the SPR stack
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.

setStackRepresentative

public void setStackRepresentative(SPR stackRepresentative)
Sets the SPR that is the representative for a SPR stack. This will be the SPR that is placed in the lowest layer.

Parameters:
stackRepresentative - the representative for the SPR stack
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.

handleReturnStateMessage

public void handleReturnStateMessage(Message message)
Sets the return values associated with the change of the SPR state. Not intended to be called by users.

Parameters:
message - The new return values 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.

hasStopEvaluator

public boolean hasStopEvaluator()
States if the SPR possess a StopEvaluator module.

Returns:
True if the SPR possess a StopEvalutor module, otherwise false;


Copyright © 2019. All rights reserved.