Class AbstractDevsPortModel<T extends Number & Comparable<T>>
java.lang.Object
org.djutils.event.LocalEventProducer
nl.tudelft.simulation.dsol.formalisms.devs.esdevs.AbstractDevsModel<T>
nl.tudelft.simulation.dsol.formalisms.devs.esdevs.AbstractDevsPortModel<T>
- Type Parameters:
T
- the time type
- All Implemented Interfaces:
Serializable
,Remote
,org.djutils.event.EventProducer
- Direct Known Subclasses:
AtomicModel
,CoupledModel
public abstract class AbstractDevsPortModel<T extends Number & Comparable<T>>
extends AbstractDevsModel<T>
AbstractDevsPortModel class. Adds named ports to the abstract DEVS model.
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
Nested classes/interfaces inherited from class nl.tudelft.simulation.dsol.formalisms.devs.esdevs.AbstractDevsModel
AbstractDevsModel.StateUpdate
-
Field Summary
Modifier and TypeFieldDescriptionprotected Map<String,
InputPortInterface<T, ?>> the map of input port names to input ports.protected Map<String,
OutputPortInterface<T, ?>> the map of output port names to output ports.Fields inherited from class nl.tudelft.simulation.dsol.formalisms.devs.esdevs.AbstractDevsModel
fullName, modelName, parentModel, simulator, STATE_UPDATE
Fields inherited from interface org.djutils.event.EventProducer
FIRST_POSITION, LAST_POSITION
-
Constructor Summary
ConstructorDescriptionAbstractDevsPortModel
(String modelName, DevsSimulatorInterface<T> simulator, CoupledModel<T> parentModel) Constructor for an abstract DEVS model with ports: we have to indicate the simulator to schedule the events on, and the parent model we are part of. -
Method Summary
Modifier and TypeMethodDescriptionprotected <TYPE> void
addInputPort
(String name, InputPortInterface<T, TYPE> inputPort) Add an input port to the model.protected <TYPE> void
addOutputPort
(String name, OutputPortInterface<T, TYPE> outputPort) Add an output port to the model.Map<String,
InputPortInterface<T, ?>> protected void
removeInputPort
(String name) Remove an input port from the model.protected void
removeOutputPort
(String name) Remove an output port from the model.Methods inherited from class nl.tudelft.simulation.dsol.formalisms.devs.esdevs.AbstractDevsModel
fireUpdatedState, getFullName, getModelName, getParentModel, getSimulator, printModel, setSimulator, 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
-
inputPortMap
the map of input port names to input ports. -
outputPortMap
the map of output port names to output ports.
-
-
Constructor Details
-
AbstractDevsPortModel
public AbstractDevsPortModel(String modelName, DevsSimulatorInterface<T> simulator, CoupledModel<T> parentModel) Constructor for an abstract DEVS model with ports: 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
-
addInputPort
protected <TYPE> void addInputPort(String name, InputPortInterface<T, TYPE> inputPort) throws PortAlreadyDefinedExceptionAdd an input port to the model. Use a name to be able to identify the port later.- Type Parameters:
TYPE
- the type of variable of the input port- Parameters:
name
- String; the (unique) name of the input portinputPort
- InputPortInterface<T,TYPE>; the input port to add- Throws:
PortAlreadyDefinedException
- in case the port name already exist for the model
-
addOutputPort
protected <TYPE> void addOutputPort(String name, OutputPortInterface<T, TYPE> outputPort) throws PortAlreadyDefinedExceptionAdd an output port to the model. Use a name to be able to identify the port later.- Type Parameters:
TYPE
- the type of variable of the output port- Parameters:
name
- String; the (unique) name of the output portoutputPort
- OutputPortInterface<T,TYPE>; the output port to add- Throws:
PortAlreadyDefinedException
- in case the port name already exist for the model
-
removeInputPort
Remove an input port from the model. Note: override this method in classes that extend the behavior, e.g. to remove couplings from this port in case it is removed.- Parameters:
name
- String; the name of the input port to be removed- Throws:
PortNotFoundException
- in case the port name does not exist for the model
-
removeOutputPort
Remove an output port from the model. Note: override this method in classes that extend the behavior, e.g. to remove couplings from this port in case it is removed.- Parameters:
name
- String; the name of the output port to be removed- Throws:
PortNotFoundException
- in case the port name does not exist for the model
-
getInputPortMap
- Returns:
- inputPortMap; the map of input port names to input ports.
-
getOutputPortMap
- Returns:
- outputPortMap; the map of output port names to output ports
-