de.cau.cs.kieler.sim.kiem.automated.execution
Class AutomationManager

java.lang.Object
  extended by de.cau.cs.kieler.sim.kiem.automated.execution.AutomationManager
All Implemented Interfaces:
GenericErrorHandler.StatusListener

public final class AutomationManager
extends Object
implements GenericErrorHandler.StatusListener

The manager for handling the actual execution. It dispatches the execution job, sets up the result list and execution, initializes the DataComponents and the execution, steps through until all components are finished and then gathers results and terminates the execution.

Rating yellow
(2010-03-16) ctr, tam

Nested Class Summary
static interface AutomationManager.ExecutionListener
          Interface for all components that are interested in the state of the current execution.
 
Field Summary
 
Fields inherited from interface de.cau.cs.kieler.core.ui.errorhandler.GenericErrorHandler.StatusListener
DONT_CARE
 
Method Summary
 void addListener(AutomationManager.ExecutionListener listener)
          Add a new listener.
protected  List<IterationResult> doAutomatedExecution(IPath[] executionFiles, List<IPath> modelFiles, List<KiemProperty> properties, IProgressMonitor monitorParam, boolean headless)
          Automated execution of a list of predefined schedules.
protected  List<IterationResult> doAutomatedExecution(List<ScheduleData> schedules, List<IPath> modelFiles, List<KiemProperty> properties, IProgressMonitor monitorParam, boolean headless)
          Automated execution of a list of predefined schedules.
 void executeAsync(IPath[] executionFiles, List<IPath> modelFiles, List<KiemProperty> properties, boolean headless)
           Trigger an execution with a list of execution files, a list of model files and a list of properties.
 void executeAsync(List<ScheduleData> selected, List<IPath> modelFiles, List<KiemProperty> properties, boolean headless)
           Trigger an execution with a list of schedules, a list of model files and a list of properties.
static AutomationManager getInstance()
          Getter for the instance.
 boolean isRunning()
          Determine whether or not the execution manager is currently running an automated execution.
 void notifyExecutionFinished(List<IterationResult> results)
          Notify all observers that the execution has finished.
 void notifyOnErrorPause()
          Tell the automation manager that the execution was paused due to an error.
 void notifyOnErrorStop()
          Tell the automation manager that the execution was stopped due to an error.
 void notifyOnStepFinished()
          Tell the automation manager that a step was processed and that the execution can resume.
 void notifyOnUserPause()
          Tell the automation manager that the user paused the execution.
 void notifyOnUserStop()
          Tell the automation manager that the user stopped the execution.
 void removeListener(AutomationManager.ExecutionListener listener)
          Remove a listener.
 int reroute(StatusAdapter statusAdapter, int style)
          Reroute the exception to the given listener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static AutomationManager getInstance()
Getter for the instance.

Returns:
the instance.

isRunning

public boolean isRunning()
Determine whether or not the execution manager is currently running an automated execution.

Returns:
true if the manager is running.

doAutomatedExecution

protected List<IterationResult> doAutomatedExecution(IPath[] executionFiles,
                                                     List<IPath> modelFiles,
                                                     List<KiemProperty> properties,
                                                     IProgressMonitor monitorParam,
                                                     boolean headless)
Automated execution of a list of predefined schedules.

Parameters:
executionFiles - the list of execution files
modelFiles - the list of model files for which to run the execution
properties - the list of properties that should be set
monitorParam - the progress monitor
headless - true if the run should be headless
Returns:
the list of results

doAutomatedExecution

protected List<IterationResult> doAutomatedExecution(List<ScheduleData> schedules,
                                                     List<IPath> modelFiles,
                                                     List<KiemProperty> properties,
                                                     IProgressMonitor monitorParam,
                                                     boolean headless)
Automated execution of a list of predefined schedules.

Parameters:
schedules - the list of schedules.
modelFiles - the list of model files for which to run the execution
properties - the list of properties that should be set
monitorParam - the progress monitor
headless - true if the run should be headless
Returns:
the list of results

executeAsync

public void executeAsync(IPath[] executionFiles,
                         List<IPath> modelFiles,
                         List<KiemProperty> properties,
                         boolean headless)

Trigger an execution with a list of execution files, a list of model files and a list of properties. Each combination of execution and model file will be stepped through until no component requests another step. After that the execution will be stopped and move on to the next combination unless one of the component requests that this combination is run again.

This method is part of the KIEMAutos API and can be accessed from any plugin.

The method will return asynchronously. Callers that want to be notified of the results must register themselves as a listener on the instance of the execution manager.

Parameters:
executionFiles - the selected locations
modelFiles - the model files
properties - the properties
headless - if true no GUI output will be generated

executeAsync

public void executeAsync(List<ScheduleData> selected,
                         List<IPath> modelFiles,
                         List<KiemProperty> properties,
                         boolean headless)

Trigger an execution with a list of schedules, a list of model files and a list of properties. Each combination of execution and model file will be stepped through until no component requests another step. After that the execution will be stopped and move on to the next combination unless one of the component requests that this combination is run again.

This method is part of the KIEMAutos API and can be accessed from any plugin.

The method will return asynchronously. Callers that want to be notified of the results must register themselves as a listener on the instance of the execution manager.

Parameters:
selected - the selected schedules
modelFiles - the model files
properties - the properties
headless - if true no GUI output will be generated

notifyOnErrorPause

public void notifyOnErrorPause()
Tell the automation manager that the execution was paused due to an error.


notifyOnErrorStop

public void notifyOnErrorStop()
Tell the automation manager that the execution was stopped due to an error.


notifyOnStepFinished

public void notifyOnStepFinished()
Tell the automation manager that a step was processed and that the execution can resume.


notifyOnUserPause

public void notifyOnUserPause()
Tell the automation manager that the user paused the execution.


notifyOnUserStop

public void notifyOnUserStop()
Tell the automation manager that the user stopped the execution.


reroute

public int reroute(StatusAdapter statusAdapter,
                   int style)
Reroute the exception to the given listener. If the listener wants to modify the style it should return the style that it wants the exception to have. If the component doesn't care about that particular exception it should return the GenericErrorHandler.StatusListener.DONT_CARE style.

Specified by:
reroute in interface GenericErrorHandler.StatusListener
Parameters:
statusAdapter - the status adapter
style - the style
Returns:
the style that the status should have

addListener

public void addListener(AutomationManager.ExecutionListener listener)
Add a new listener.

Parameters:
listener - the listener to add

notifyExecutionFinished

public void notifyExecutionFinished(List<IterationResult> results)
Notify all observers that the execution has finished.

Parameters:
results - the results of the execution

removeListener

public void removeListener(AutomationManager.ExecutionListener listener)
Remove a listener.

Parameters:
listener - the listener to remove