Class SimulationService
- java.lang.Object
-
- jadex.platform.service.simulation.SimulationService
-
- All Implemented Interfaces:
ISimulationService
,IPropertiesProvider
public class SimulationService extends java.lang.Object implements ISimulationService, IPropertiesProvider
The execution control is the access point for controlling the execution of one application. It provides basic features for starting, stopping and stepwise execution.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
SimulationService.IdleListener
Listener on the execution service.
-
Field Summary
Fields Modifier and Type Field Description protected IInternalAccess
access
The containing component.protected java.util.List<IFuture<?>>
advanceblockers
Blockers that prevent the clock from advancing.protected IClockService
clockservice
The clock service.protected boolean
executing
The executing flag.protected IExecutionService
exeservice
The execution service.protected SimulationService.IdleListener
idlelistener
The idle future listener.protected java.util.List
listeners
The listeners.protected java.lang.String
mode
The execution mode.protected static java.util.Map<Future<?>,java.lang.String>
openfuts
protected boolean
startoninit
Flag to indicate that simulation should be started after service is inited.protected Future
stepfuture
The future (if any) indicating when a step is finished.protected long
timesteptime
The time of a time step.-
Fields inherited from interface jadex.bridge.service.types.simulation.ISimulationService
MODE_ACTION_STEP, MODE_NORMAL, MODE_TIME_STEP
-
-
Constructor Summary
Constructors Constructor Description SimulationService()
Create a new execution control.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IFuture<java.lang.Void>
addAdvanceBlocker(IFuture<?> blocker)
Adds a blocker to the clock that prevents the clock from advancing until the future is triggered either by result or exception.void
addChangeListener(IChangeListener listener)
Add a change listener.protected void
advanceClock()
Trigger clock execution.IClockService
getClockService()
Get the platform clock.IExecutionService
getExecutorService()
Get the executor service.IFuture<java.lang.String>
getMode()
Get the execution mode.IFuture<Properties>
getProperties()
Write current state into properties.IFuture<java.lang.Boolean>
isExecuting()
Test if context is executing.protected void
notifyListeners(ChangeEvent event)
Notify the listeners.IFuture<java.lang.Void>
pause()
Pause the execution (can be resumed via start or step).void
removeChangeListener(IChangeListener listener)
Remove a change listener.protected void
scheduleAdvanceClock()
Start clock execution.IFuture<java.lang.Void>
setClockType(java.lang.String type)
Set the clock type.void
setExecuting(boolean executing)
Set the executing state.protected void
setIdle()
Stop execution.void
setMode(java.lang.String mode)
Set the execution mode.IFuture<java.lang.Void>
setProperties(Properties props)
Update from given properties.IFuture<java.lang.Void>
shutdownService()
Shutdown the service.IFuture<java.lang.Void>
start()
Restart the execution after pause.IFuture<java.lang.Void>
startService()
Start (and run) the execution.IFuture<java.lang.Void>
stepEvent()
Perform one event.IFuture<java.lang.Void>
stepTime()
Perform all actions belonging to one time point.protected IFuture<java.lang.Void>
waitForBlockers()
Waits for blockers
-
-
-
Field Detail
-
access
protected IInternalAccess access
The containing component.
-
mode
protected java.lang.String mode
The execution mode.
-
executing
protected boolean executing
The executing flag.
-
listeners
protected java.util.List listeners
The listeners.
-
timesteptime
protected long timesteptime
The time of a time step.
-
clockservice
protected IClockService clockservice
The clock service.
-
exeservice
protected IExecutionService exeservice
The execution service.
-
stepfuture
protected Future stepfuture
The future (if any) indicating when a step is finished.
-
advanceblockers
protected java.util.List<IFuture<?>> advanceblockers
Blockers that prevent the clock from advancing.
-
idlelistener
protected SimulationService.IdleListener idlelistener
The idle future listener.
-
startoninit
protected boolean startoninit
Flag to indicate that simulation should be started after service is inited.
-
openfuts
protected static final java.util.Map<Future<?>,java.lang.String> openfuts
-
-
Method Detail
-
shutdownService
public IFuture<java.lang.Void> shutdownService()
Shutdown the service.- Parameters:
listener
- The listener.
-
startService
public IFuture<java.lang.Void> startService()
Start (and run) the execution.
-
pause
public IFuture<java.lang.Void> pause()
Pause the execution (can be resumed via start or step).- Specified by:
pause
in interfaceISimulationService
-
start
public IFuture<java.lang.Void> start()
Restart the execution after pause.- Specified by:
start
in interfaceISimulationService
-
stepEvent
public IFuture<java.lang.Void> stepEvent()
Perform one event.- Specified by:
stepEvent
in interfaceISimulationService
-
stepTime
public IFuture<java.lang.Void> stepTime()
Perform all actions belonging to one time point.- Specified by:
stepTime
in interfaceISimulationService
-
getMode
public IFuture<java.lang.String> getMode()
Get the execution mode.- Specified by:
getMode
in interfaceISimulationService
- Returns:
- The mode.
-
setMode
public void setMode(java.lang.String mode)
Set the execution mode.- Parameters:
mode
- The mode.
-
setClockType
public IFuture<java.lang.Void> setClockType(java.lang.String type)
Set the clock type.- Specified by:
setClockType
in interfaceISimulationService
- Parameters:
type
- The clock type.
-
isExecuting
public IFuture<java.lang.Boolean> isExecuting()
Test if context is executing.- Specified by:
isExecuting
in interfaceISimulationService
-
addChangeListener
public void addChangeListener(IChangeListener listener)
Add a change listener.- Specified by:
addChangeListener
in interfaceISimulationService
- Parameters:
listener
- The change listener.
-
removeChangeListener
public void removeChangeListener(IChangeListener listener)
Remove a change listener.- Specified by:
removeChangeListener
in interfaceISimulationService
- Parameters:
listener
- The change listener.
-
setExecuting
public void setExecuting(boolean executing)
Set the executing state.
-
notifyListeners
protected void notifyListeners(ChangeEvent event)
Notify the listeners.
-
getClockService
public IClockService getClockService()
Get the platform clock.- Specified by:
getClockService
in interfaceISimulationService
- Returns:
- The clock.
-
getExecutorService
public IExecutionService getExecutorService()
Get the executor service.- Specified by:
getExecutorService
in interfaceISimulationService
- Returns:
- The executor service.
-
addAdvanceBlocker
public IFuture<java.lang.Void> addAdvanceBlocker(IFuture<?> blocker)
Adds a blocker to the clock that prevents the clock from advancing until the future is triggered either by result or exception.- Specified by:
addAdvanceBlocker
in interfaceISimulationService
- Parameters:
blocker
- The blocking future.- Returns:
- Null, when added.
-
setIdle
protected void setIdle()
Stop execution.
-
scheduleAdvanceClock
protected void scheduleAdvanceClock()
Start clock execution.
-
advanceClock
protected void advanceClock()
Trigger clock execution.
-
waitForBlockers
protected IFuture<java.lang.Void> waitForBlockers()
Waits for blockers- Returns:
-
setProperties
public IFuture<java.lang.Void> setProperties(Properties props)
Update from given properties.- Specified by:
setProperties
in interfaceIPropertiesProvider
-
getProperties
public IFuture<Properties> getProperties()
Write current state into properties.- Specified by:
getProperties
in interfaceIPropertiesProvider
-
-