Class AbstractDevsModel<T extends Number & Comparable<T>>
java.lang.Object
org.djutils.event.LocalEventProducer
nl.tudelft.simulation.dsol.formalisms.devs.esdevs.AbstractDevsModel<T>
- Type Parameters:
T
- the time type
- All Implemented Interfaces:
Serializable
,Remote
,org.djutils.event.EventProducer
- Direct Known Subclasses:
AbstractDevsPortModel
,AbstractEntity
public abstract class AbstractDevsModel<T extends Number & Comparable<T>>
extends org.djutils.event.LocalEventProducer
AbstractDevsModel class. The basic model or component from which the AtomicModel, the CoupledModel, and the AbstractEntity
are derived. The DevsModel provides basic functionality for reporting its state changes through the publish/subscribe
mechanism.
Copyright (c) 2009-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://simulation.tudelft.nl. The DSOL project is distributed under a three-clause BSD-style license, which can be found at https://https://simulation.tudelft.nl/dsol/docs/latest/license.html.
- Since:
- 1.5
- Author:
- Mamadou Seck
, Alexander Verbraeck - See Also:
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
all DEVS models are named - this is the full name with dot notation.protected String
all DEVS models are named - this is the component name.protected CoupledModel<T>
the parent model we are part of.protected DevsSimulatorInterface<T>
the simulator this model or component will schedule its events on.static final org.djutils.event.EventType
event for listeners about state update.Fields inherited from interface org.djutils.event.EventProducer
FIRST_POSITION, LAST_POSITION
-
Constructor Summary
ConstructorDescriptionAbstractDevsModel
(String modelName, DevsSimulatorInterface<T> simulator, CoupledModel<T> parentModel) Constructor for an abstract DEVS model: we have to indicate the simulator to schedule the events on, and the parent model we are part of. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Fire a state update.abstract void
printModel
(String header) Print the model, preceded by a user provided string.void
setSimulator
(DevsSimulatorInterface<T> simulator) toString()
Methods inherited from class org.djutils.event.LocalEventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, getEventListenerMap, getEventTypesWithListeners, getListenerReferences, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListener
-
Field Details
-
parentModel
the parent model we are part of. -
simulator
the simulator this model or component will schedule its events on. -
modelName
all DEVS models are named - this is the component name. -
fullName
all DEVS models are named - this is the full name with dot notation. -
STATE_UPDATE
public static final org.djutils.event.EventType STATE_UPDATEevent for listeners about state update.
-
-
Constructor Details
-
AbstractDevsModel
public AbstractDevsModel(String modelName, DevsSimulatorInterface<T> simulator, CoupledModel<T> parentModel) Constructor for an abstract DEVS model: we have to indicate the simulator to schedule the events on, and the parent model we are part of. A parent model of null means that we are the top model.- Parameters:
modelName
- String; the name of this componentsimulator
- DevsSimulatorInterface<T>; the simulator to schedule the events on.parentModel
- CoupledModel<T>; the parent model we are part of.
-
-
Method Details
-
getSimulator
- Returns:
- the simulator this model schedules its events on.
-
setSimulator
- Parameters:
simulator
- DevsSimulatorInterface<T>; the simulator to use from now on
-
getParentModel
- Returns:
- the parent model we are part of.
-
getModelName
- Returns:
- the name of the model.
-
getFullName
- Returns:
- the full name of the model in dot notation.
-
toString
-
printModel
Print the model, preceded by a user provided string.- Parameters:
header
- String; the user provided string to print in front of the model (e.g. newlines, header).
-
fireUpdatedState
protected void fireUpdatedState()Fire a state update. At this moment, all state variables are reported for an atomic model when it fires its delta_internal or delta_external method. More intelligence can be added here later. For simple types, a comparison with the old value (state map) is possible. For complex variables (objects) this is more difficult as a deep clone should be saved as old state, followed by a full comparison. This does not seem practical, and more expensive than firing the state change of all state variables. The intelligence to detect real state changes then has to be built in at the receiver's side.
-