Interface Port
- All Known Implementing Classes:
AbstractPort
,MultiPort
,SinglePort
,SwitchPort
In the phase of model building, ports are connected with each others via the
connectTo
method. The sending entity puts a message on its outport.
The message is then routed along the established connections. A port that has
no further connection is always an end-point (destination of delivery). Thus,
connections are always directed from outport (source) to inport
(destination).
Each port must also implement its own copyMessages
strategy to
support message forwarding during the simulation run.
- See Also:
-
SinglePort
MultiPort
SwitchPort
RoutingPort
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Clears message queue of this port.void
Connects this port to another one.int
Counts messages in queue of this port.void
disconnect
(Port target) Disconnects this port from another one.Implements a message forwarding strategy specific for the port class.boolean
Checks if the port has messages.boolean
isConnectedTo
(Port port) Tests if the port is connected to another one.boolean
Tests if the port is the end point of a connection.<M extends AbstractMessage<?>>
Mpoll()
Returns and removes the last element in the message queue.<M extends AbstractMessage<?>>
Collection<M>readAll()
Returns the message queue.void
write
(AbstractMessage<?> msg) Puts a message to be forwarded on this port.void
writeAll
(Collection<AbstractMessage<?>> msg) Puts several messages to be forwarded on this port.
-
Method Details
-
connect
Connects this port to another one.Note that connections are directed.
- Parameters:
target
- the other part of the connection
-
disconnect
Disconnects this port from another one.- Parameters:
target
- the port to be removed- Throws:
ModelEntity.PortConnectionException
- if the port is not connected with the target or the simulation is running
-
isEndPoint
boolean isEndPoint()Tests if the port is the end point of a connection.- Returns:
- true if it is end point (destination port)
-
isConnectedTo
Tests if the port is connected to another one.- Parameters:
port
- the port to test- Returns:
- true if this port is connected to the other port
-
forwardMessages
Collection<Port> forwardMessages()Implements a message forwarding strategy specific for the port class.Port must be connected to other ports, please check if it is an end point beforehand!
Note: Only to be used by an implementation of
MessageForwardingStrategy
- Returns:
- list of destination ports that need further forwarding
-
clearMessages
void clearMessages()Clears message queue of this port. -
countMessages
int countMessages()Counts messages in queue of this port.- Returns:
- number of messages, can be zero
-
hasMessages
boolean hasMessages()Checks if the port has messages.- Returns:
- true if there are messages
-
poll
Returns and removes the last element in the message queue.- Returns:
- last element in message list or null if list is empty
-
readAll
Returns the message queue.Elements must be removed manually by calling the
clearMessages()
method- Returns:
- the message queue
-
write
Puts a message to be forwarded on this port.- Parameters:
msg
- the message
-
writeAll
Puts several messages to be forwarded on this port.- Parameters:
msg
- collection of messages
-
getParent
ModelEntity getParent()
-