Package org.eclipse.mosaic.rti.time
Class AbstractTimeManagement
java.lang.Object
java.util.Observable
org.eclipse.mosaic.rti.time.AbstractTimeManagement
- All Implemented Interfaces:
TimeManagement
- Direct Known Subclasses:
MultiThreadedTimeManagement,SequentialTimeManagement
Abstract class providing base functions for initialization, progress printing and finishing of
TimeManagement implementations.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Queue<FederateEvent>Ordered queue holding all requested times of federates.protected ExternalWatchDogprotected final ComponentProviderprotected static final DecimalFormatprotected static final DecimalFormatprotected final org.slf4j.Loggerprotected static final intprotected longThe current simulation time of the federation in nanoseconds.protected WatchDog -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractTimeManagement(ComponentProvider federation, MosaicComponentParameters componentParameters) -
Method Summary
Modifier and TypeMethodDescriptionvoidfinishSimulationRun(int statusCode) The method is called once after the simulation has reached the end time.longGetter for end time.longReturns the time stamp of the next event.longGetter for current simulation time.protected voidThe method is called once before the simulation is started.protected voidprintProgress(long currentRealTimeNs, PerformanceInformation performanceInformation) voidrequestAdvanceTime(String federateId, long time, long lookahead, byte priority) Stores a schedulable event representing the requested time.voidstartExternalWatchDog(String simId, int port) Starts the external watchdog thread.startWatchDog(String simId, int maxIdleTime) Starts the watchdog thread.voidUpdates the watchdog thread to show that wa are still alive.Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChangedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.mosaic.rti.api.TimeManagement
runSimulation
-
Field Details
-
STATUS_CODE_SUCCESS
protected static final int STATUS_CODE_SUCCESS- See Also:
-
FORMAT_ONE_DIGIT
-
FORMAT_TWO_DIGIT
-
logger
protected final org.slf4j.Logger logger -
events
Ordered queue holding all requested times of federates. TODO: the ordering of this queue has to be revisited:FederatePriorityis used as reference valuesFederateEvent.compareTo(org.eclipse.mosaic.rti.api.time.FederateEvent)orders events reversed as described FederatePriority maybe it's enough to just reverse the compareTo logic -
federation
-
time
protected long timeThe current simulation time of the federation in nanoseconds. -
watchDog
-
externalWatchDog
-
-
Constructor Details
-
AbstractTimeManagement
protected AbstractTimeManagement(ComponentProvider federation, MosaicComponentParameters componentParameters)
-
-
Method Details
-
getSimulationTime
public long getSimulationTime()Description copied from interface:TimeManagementGetter for current simulation time.- Specified by:
getSimulationTimein interfaceTimeManagement- Returns:
- the current simulation time
-
getEndTime
public long getEndTime()Description copied from interface:TimeManagementGetter for end time.- Specified by:
getEndTimein interfaceTimeManagement- Returns:
- end time of the running simulation
-
requestAdvanceTime
public void requestAdvanceTime(String federateId, long time, long lookahead, byte priority) throws IllegalValueException Description copied from interface:TimeManagementStores a schedulable event representing the requested time. When the event is scheduled the associated federate ambassador is called by the time management.
This method is to be called only by anRtiAmbassadorinstance!- Specified by:
requestAdvanceTimein interfaceTimeManagement- Parameters:
federateId- unique string identifying the calling federatetime- requested timelookahead- time after the requested time in which the calling federate will not schedule any further events or send any interactionspriority- priority of the event
only events with equal priority are scheduled in parallel even if they have the same time- Throws:
IllegalValueException- an exception if a parameter has an invalid value
-
prepareSimulationRun
The method is called once before the simulation is started. It calls the initialize method of all joined federates.- Throws:
IllegalValueException- a parameter has an invalid valueInternalFederateException- an exception inside of a joined federate occurs
-
finishSimulationRun
Description copied from interface:TimeManagementThe method is called once after the simulation has reached the end time. It calls the finishSimulation method of all joined federates.- Specified by:
finishSimulationRunin interfaceTimeManagement- Parameters:
statusCode- the status code number describing the success or failure of the simulation- Throws:
InternalFederateException- an exception inside of a joined federate occurs
-
getNextEventTimestamp
Description copied from interface:TimeManagementReturns the time stamp of the next event.- Specified by:
getNextEventTimestampin interfaceTimeManagement- Returns:
- time stamp of the next event
- Throws:
IllegalValueException- a parameter has an invalid value
-
startWatchDog
Description copied from interface:TimeManagementStarts the watchdog thread.- Specified by:
startWatchDogin interfaceTimeManagement- Parameters:
simId- Id of the simulationmaxIdleTime- Period of idle time in seconds after which the thread reacts- Returns:
- the new
WatchDog
-
updateWatchDog
public void updateWatchDog()Description copied from interface:TimeManagementUpdates the watchdog thread to show that wa are still alive.- Specified by:
updateWatchDogin interfaceTimeManagement
-
startExternalWatchDog
Description copied from interface:TimeManagementStarts the external watchdog thread.- Specified by:
startExternalWatchDogin interfaceTimeManagement- Parameters:
simId- Id of the simulationport- Connection port.
-
printProgress
-