com.kuka.roboticsAPI.controllerModel.sunrise
Class SunriseExecutionService

java.lang.Object
  extended by com.kuka.roboticsAPI.controllerModel.ControllerService
      extended by com.kuka.roboticsAPI.controllerModel.ExecutionService
          extended by com.kuka.roboticsAPI.controllerModel.sunrise.SunriseExecutionService
All Implemented Interfaces:
IExecutionServicePaused, IPausableExecutionService

public class SunriseExecutionService
extends ExecutionService
implements IPausableExecutionService

Sunrise execution service. Maps commands to SPRs and sends them to Sunrise. It also handles the incoming message from Sunrise concerning SPR states and SPR data.

This class is responsible for handling the main command protocol with Sunrise. Changes in the protocol must be reflected in this class.

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 SunriseExecutionService.IPauseListener
          A listener for the pause.
 
Method Summary
 void addContainerQueuedListener(IContainerQueuedListener listener)
          Adds the specified execution event listener.
 void addExecutionListener(IExecutionListener listener)
          Adds the specified execution event listener.
 void addPauseListener(SunriseExecutionService.IPauseListener listener)
          Adds the specified pause event listener.
 void addSPRHook(ISPRHook hook)
          Adds the given SPRHook to the list.
 ICommandContainer beginExecution(IControllerCommand command, IContainerStateListener listener)
          The execute method should execute the given container in an asynchronous manner.
 void blockExecution()
          Blocks the execution of commands by the execution service.
 void cancel(ICommandContainer container)
          Cancels the given command in the given container.
 void cancelAll()
          Cancels all pending commands for this controller.
 void cancelAllOn(Device device)
          Cancels all pending commands on the given device.
 void cancelPause()
          Cancels the pause state and resets the execution service.
 void clearExecutionContainerQueues()
          Cancels all current active MotionContainers and cancels all currentActiveContainers plus clears both lists.
protected  void dispose()
          Disposes this service.
 void doPausing()
          Handles pausing of the execution after the pausing request.
 ICommandContainer execute(IControllerCommand command, IContainerStateListener listener)
          The execute method should execute the given container in a synchronous manner.
 ICommandContainer executeSPR(SPR spr)
          Executes the specified SPR.
protected  SPRRuntime findSPRRuntime(long sprId)
          Searches for a SPR which is being currently executed.
protected  SPRRuntime findSPRRuntimeByMotionId(long motionId)
          Searches for a SPR which is being currently executed.
 int getActiveContainerCount()
           
protected  ExecutorService getContainerCleanupWorker()
          Returns the container cleanup worker.
protected  ExecutorService getContainerEventWorker()
          Returns the container event worker.
 SunriseController getController()
          Gets the controller associated with this service.
 IErrorHandler getErrorHandler()
          Gets the handler for errors in asynchronous motion commands.
 com.kuka.roboticsAPI.executionModel.ExecutionMode getExecutionMode()
          Gets the actual execution mode.
 SunriseMapperTable getMapperTable()
          Gets the mapper table used by this execution service.
 RecoveryManager getRecovery()
          Returns the recovery interface which can be used: to determine if the application can be resumed, which strategies are available to resume the application and which recovery strategy is used to resume the application.
protected  ExecutorService getSprListenerWorker()
           
protected  void initialize()
          Initializes this service.
 boolean isPaused()
          Returns true if ExecutionService is paused at this moment.
 boolean isPausedAndStopped()
          Returns true if the execution service is in paused state and all motions are already stopped.
static void printSPRs(boolean printSPRs)
          Raises the log level of SPRs from TRACE to INFO.
 void removeContainerQueuedListener(IContainerQueuedListener listener)
          Removes the specified execution event listener.
 void removeExecutionListener(IExecutionListener listener)
          Removes the specified execution event listener.
 void removePauseListener(SunriseExecutionService.IPauseListener listener)
          Removes the specified pause event listener.
 void removeSPRHook(ISPRHook hook)
          Removes the given SPRHook.
 boolean resumeExecution(ResumeMode mode)
          Resumes the paused execution.
 void setAlwaysResetOnMotion(boolean alwaysReset)
          Ensures that every executed motion sets the reset flag for the interpolator to true.
 void setEnforceMsr2Cmd()
          Use to force a Msr2Cmd before the next command.
 void setErrorHandler(IErrorHandler errorHandler)
          Sets the handler for errors in asynchronous motion commands.
 void setExecutionMode(com.kuka.roboticsAPI.executionModel.ExecutionMode newExecutionMode)
          Sets the execution mode.
 void startPause()
          Requests pausing of the execution .
 String toString()
           
 void waitForPaused()
          Wait for paused.
 boolean waitForPaused(long timeout, TimeUnit unit)
           
 void waitForResumed()
          Wait for resumed.
 boolean waitForResumed(long timeout, TimeUnit unit)
           
 
Methods inherited from class com.kuka.roboticsAPI.controllerModel.ControllerService
getContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getController

public SunriseController getController()
Gets the controller associated with this service.

Overrides:
getController in class ControllerService
Returns:
The controller associated with this service.
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.

printSPRs

public static void printSPRs(boolean printSPRs)
Raises the log level of SPRs from TRACE to INFO. The SPRs are logged to a separate log file logs/SPRs.txt.

Parameters:
printSPRs - True if you want to raise the log level of SPRs.
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.

addContainerQueuedListener

public void addContainerQueuedListener(IContainerQueuedListener listener)
Adds the specified execution event listener.

Parameters:
listener - the listener for the execution events.
Throws:
IllegalArgumentException - if listener is null or the same listener is already registered by the execution service

removeContainerQueuedListener

public void removeContainerQueuedListener(IContainerQueuedListener listener)
Removes the specified execution event listener.

Parameters:
listener - execution event listener to remove.

addPauseListener

public void addPauseListener(SunriseExecutionService.IPauseListener listener)
Adds the specified pause event listener.

Parameters:
listener - the listener for the pause events.
Throws:
IllegalArgumentException - if listener is null or the same listener is already registered by the execution service
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.

removePauseListener

public void removePauseListener(SunriseExecutionService.IPauseListener listener)
Removes the specified pause event listener.

Parameters:
listener - execution event 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.

initialize

protected void initialize()
Description copied from class: ControllerService
Initializes this service. May be overridden by subclasses.

Please note that when the method is called, the controller of the service is not yet initialized. This means that there are no guarantees that the controller is operable.

Overrides:
initialize in class ExecutionService

dispose

protected void dispose()
Description copied from class: ControllerService
Disposes this service. May be overridden by subclasses.

Overrides:
dispose in class ExecutionService

execute

public ICommandContainer execute(IControllerCommand command,
                                 IContainerStateListener listener)
The execute method should execute the given container in a synchronous manner. The call will block until execution of the specified command is finished.

Overrides:
execute in class ExecutionService
Parameters:
command - The command to be executed. null is not allowed.
listener - The listener which will be called when the container state changes. May be null.
Returns:
The container created for the execution. This container can be used to synchronize the execution.
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.

beginExecution

public ICommandContainer beginExecution(IControllerCommand command,
                                        IContainerStateListener listener)
The execute method should execute the given container in an asynchronous manner. The call should return as soon as possible, but users of this method are advised that this method may block.

Specified by:
beginExecution in class ExecutionService
Parameters:
command - The command to be executed. null is not allowed.
listener - The listener which will be called when the container state changes. May be null.
Returns:
The container created for the execution. This container can be used to synchronize the execution.
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.

isPaused

public boolean isPaused()
Description copied from interface: IExecutionServicePaused
Returns true if ExecutionService is paused at this moment. Note that the pause state might be changed by the time the calling thread gets to process the result of this method.

Specified by:
isPaused in interface IExecutionServicePaused
Returns:
true if ExecutionService is paused

isPausedAndStopped

public boolean isPausedAndStopped()
Description copied from interface: IExecutionServicePaused
Returns true if the execution service is in paused state and all motions are already stopped.

Specified by:
isPausedAndStopped in interface IExecutionServicePaused
Returns:
true if the execution service is in paused state and all motions are already stopped.

waitForPaused

public void waitForPaused()
Wait for paused.


waitForPaused

public boolean waitForPaused(long timeout,
                             TimeUnit unit)
Parameters:
timeout - wait-time
unit - time-unit
Returns:
true if wait succeeded, false if timeout

waitForResumed

public void waitForResumed()
Wait for resumed.


waitForResumed

public boolean waitForResumed(long timeout,
                              TimeUnit unit)
Parameters:
timeout - wait-time
unit - time-unit
Returns:
true if wait succeeded, false if timeout

startPause

public void startPause()
Requests pausing of the execution .

Specified by:
startPause in interface IPausableExecutionService
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.

doPausing

public void doPausing()
Handles pausing of the execution after the pausing request.

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.

resumeExecution

public boolean resumeExecution(ResumeMode mode)
Description copied from interface: IPausableExecutionService
Resumes the paused execution.

Specified by:
resumeExecution in interface IPausableExecutionService
Parameters:
mode - specifies how execution should be resumed
Returns:
true, if execution could be resumed, false otherwise

cancelPause

public void cancelPause()
Cancels the pause state and resets the execution service.

Specified by:
cancelPause in interface IPausableExecutionService
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.

blockExecution

public void blockExecution()
Blocks the execution of commands by the execution service.

If execution is blocked - exception is thrown by attempt to call the execute method.

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.

cancelAll

public void cancelAll()
Cancels all pending commands for this controller.

Specified by:
cancelAll in class ExecutionService
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.

cancelAllOn

public void cancelAllOn(Device device)
Cancels all pending commands on the given device.

Parameters:
device - the device where to cancel all commands
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 void cancel(ICommandContainer container)
Cancels the given command in the given container.

Specified by:
cancel in class ExecutionService
Parameters:
container - The container to cancel.
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.

getMapperTable

public SunriseMapperTable getMapperTable()
Gets the mapper table used by this execution service.

Returns:
The mapper table used by this execution service.
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.

executeSPR

public ICommandContainer executeSPR(SPR spr)
Executes the specified SPR. Creates a container for the given SPR and returns it.

The execution is asynchronous. However the method can block if the execution service is in paused state. Use the IExecutionContainer.await() method on the returned container to block until the SPR in done.

Parameters:
spr - The SPR to be executed. null is not allowed.
Returns:
The container for the execution.
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.

removeSPRHook

public void removeSPRHook(ISPRHook hook)
Removes the given SPRHook.

Parameters:
hook - The hook which should be removed. 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.

addSPRHook

public void addSPRHook(ISPRHook hook)
Adds the given SPRHook to the list. The hook will be called each time a command was mapped by this service.

Parameters:
hook - The hook which should get called. 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.

findSPRRuntime

protected SPRRuntime findSPRRuntime(long sprId)
Searches for a SPR which is being currently executed.

Parameters:
sprId - The SPR id.
Returns:
A SPR runtime or null if none is found.

findSPRRuntimeByMotionId

protected SPRRuntime findSPRRuntimeByMotionId(long motionId)
Searches for a SPR which is being currently executed.

Parameters:
motionId - The Motion id.
Returns:
A SPR runtime or null if none is found.

getExecutionMode

public com.kuka.roboticsAPI.executionModel.ExecutionMode getExecutionMode()
Gets the actual execution mode.

Returns:
the actual execution mode

setExecutionMode

public void setExecutionMode(com.kuka.roboticsAPI.executionModel.ExecutionMode newExecutionMode)
Sets the execution mode.

Execution mode cannot be changed when the execution is not paused or the application is executed in automatic operation mode.

Parameters:
newExecutionMode - the execution mode to set.
Throws:
IllegalStateException - if changing of the execution mode is not possible at this moment

getContainerEventWorker

protected ExecutorService getContainerEventWorker()
Description copied from class: ExecutionService
Returns the container event worker.

This worker can be used by every execution container to throw its events.

Overrides:
getContainerEventWorker in class ExecutionService
Returns:
the container event worker

getContainerCleanupWorker

protected ExecutorService getContainerCleanupWorker()
Description copied from class: ExecutionService
Returns the container cleanup worker.

This worker can be used by every execution container to perform cleanup actions.

Overrides:
getContainerCleanupWorker in class ExecutionService
Returns:
the container cleanup worker

getSprListenerWorker

protected ExecutorService getSprListenerWorker()
Returns:
the sprListenerWorker

clearExecutionContainerQueues

public void clearExecutionContainerQueues()
Cancels all current active MotionContainers and cancels all currentActiveContainers plus clears both lists. It is used in the tear down methods of the tests.

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.
Only for tests.

getActiveContainerCount

public int getActiveContainerCount()
Returns:
Number of current active Containers
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.
Only for tests.

getErrorHandler

public IErrorHandler getErrorHandler()
Gets the handler for errors in asynchronous motion commands.

Returns:
the handler for errors in asynchronous motion commands.
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.

setErrorHandler

public void setErrorHandler(IErrorHandler errorHandler)
Sets the handler for errors in asynchronous motion commands.

Parameters:
errorHandler - handler of errors in asynchronous motion commands. 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.

setAlwaysResetOnMotion

public void setAlwaysResetOnMotion(boolean alwaysReset)
Ensures that every executed motion sets the reset flag for the interpolator to true. This is used e.g. for jogging.

Parameters:
alwaysReset - when true, the reset flag is always set to true for every motion.
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.

getRecovery

public RecoveryManager getRecovery()
Returns the recovery interface which can be used:

Specified by:
getRecovery in interface IPausableExecutionService
Returns:
the recovery interface.

setEnforceMsr2Cmd

public void setEnforceMsr2Cmd()
Use to force a Msr2Cmd before the next command.


addExecutionListener

public void addExecutionListener(IExecutionListener listener)
Description copied from interface: IPausableExecutionService
Adds the specified execution event listener.

Specified by:
addExecutionListener in interface IPausableExecutionService
Parameters:
listener - the listener for the execution events.

removeExecutionListener

public void removeExecutionListener(IExecutionListener listener)
Description copied from interface: IPausableExecutionService
Removes the specified execution event listener.

Specified by:
removeExecutionListener in interface IPausableExecutionService
Parameters:
listener - execution event listener to remove.

toString

public String toString()
Overrides:
toString in class ExecutionService


Copyright © 2019. All rights reserved.