- java.lang.Object
 
- com.anylogic.engine.Port<InMessageType,
 
- Type Parameters:
 InMessageType- the type of messages being received by the portOutMessageType- the type of messages being sent by the port
- All Implemented Interfaces:
 com.anylogic.engine.internal.Child,Serializable
- Direct Known Subclasses:
 FlowchartPort
public class Port<InMessageType,OutMessageType> extends Object implements Serializable, com.anylogic.engine.internal.Child
Port is a universal interface of an agent via which it can send and
 receive messages - arbitrary objects. Ports are used to graphically connect 
 objects that do not need to know anything about each other type or structure.
 There are two major types of links a port maintains: connections to the
 ports of objects on the same hierarchy level (embedded in the same agent)
 or "mappings" to the ports of embedded objects or statecharts. In the first 
 case a message sent at one port is received at the other. In case of mapping
 the message sent at the inner port is forwarded out at the outer port, and vice
 versa: message received at the outer port is received by the inner port or by
 the statechart. The user may define his own actions that are executed upon
 reception or sending the message that may prevent the port from continuing
 the message processing. The port class is generic with two parameters - the
 classes of messages being received and sent. Once instantiated and parameterized,
 it will only accept the messages of those classes. Moreover, the port can only
 be connected / mapped to a port with the corresponding message types.
Memory: sizeof(Object) + 20 bytes = 34 bytes + sizeof up to 4 LinkedList's
Memory: sizeof(Object) + 20 bytes = 34 bytes + sizeof up to 4 LinkedList's
- Author:
 - AnyLogic North America, LLC https://anylogic.com
 - See Also:
 - Serialized Form
 
| Constructor | Description | 
|---|---|
Port | 
| Modifier and Type | Method | Description | 
|---|---|---|
void | connect | 
 Connects the port to another port of an object on the same level. 
 | 
void | disconnect | 
 Disconnects the port from another port of an object on the same level. 
 | 
void | disconnectAndUnmapAll() | 
 Disconnects and unmaps the port from all ports and statechart it is
 connected and/or mapped to. 
 | 
Agent | getActiveObject() | 
 Deprecated.
 
 | 
Agent | getAgent() | 
 Returns the agent that owns the port. 
 | 
List<Port<InMessageType, | getDownLinks() | 
 Returns an unmodifiable list with mapped ports on agents
 embedded in the current agent (owner of port) 
 | 
List<Port<OutMessageType, | getFlatLinks() | 
 Returns an unmodifiable list with connected ports 
 | 
String | getFullName() | 
 Returns the name of the port prefixed by the full name
 of its agent. 
 | 
String | getName() | 
 Returns the name of the port as specified by the user. 
 | 
List<Statechart> | getStatechartLinks() | 
 Returns an unmodifiable list with mapped statecharts of the
 current agent (owner of this port) 
 | 
List<Port<InMessageType, | getUpLinks() | 
 Returns an unmodifiable list with mapped ports on agents
 which own the current agent (owner of port) 
 | 
void | map | 
 Maps (connects) the port to a port of an embedded object. 
 | 
void | map | 
 Maps (connects) the port to a statechart of the same agent. 
 | 
void | onDestroy() | 
 Should be called when the port is destroyed, e.g. 
 | 
void | receive | 
 Receives an incoming message. 
 | 
void | restoreOwner | 
 Deprecated. 
 | 
void | send | 
 Send the message out. 
 | 
String | toString() | |
void | unmap | 
 Unmaps (disconnects) the port from a port of an embedded object. 
 | 
void | unmap | 
 Unmaps (disconnects) the port from the statechart of the same agent. 
 | 
public Port(Agent ao) 
public String getName()
Returns the name of the port as specified by the user.
- Returns:
 - The name of the port
 
public String getFullName()
Returns the name of the port prefixed by the full name
 of its agent.
- Returns:
 - The full name of the port.
 
public String toString()
public Agent getAgent()
Returns the agent that owns the port.
- Returns:
 - The agent owning this port.
 
@Deprecated public Agent getActiveObject()
Deprecated.
Use 
getAgent() insteadpublic void connect(Port<OutMessageType, InMessageType> port) 
Connects the port to another port of an object on the same level.
 If the ports are already connected, does nothing.
 send(msg) called on either of the ports will result in receive(msg) called
 on another
- Parameters:
 port- another port
public void disconnect(Port<OutMessageType, InMessageType> port) 
Disconnects the port from another port of an object on the same level.
- Parameters:
 port- another port
public void map(Port<InMessageType, OutMessageType> port) 
Maps (connects) the port to a port of an embedded object.
 send(msg) called on another port will result in send(msg) called on this port
 and receive(msg) called on this port will result in receive(msg) called on
 another port.
- Parameters:
 port- port of an embedded object
public void unmap(Port<InMessageType, OutMessageType> port) 
Unmaps (disconnects) the port from a port of an embedded object.
- Parameters:
 port- port of an embedded object
public void map(Statechart statechart) 
Maps (connects) the port to a statechart of the same agent.
 receive(msg) called on this port will result in receiveMessage(msg) called on
 the statechart.
- Parameters:
 statechart- the statechart
public void unmap(Statechart statechart) 
Unmaps (disconnects) the port from the statechart of the same agent.
- Parameters:
 statechart- the statechart
public void disconnectAndUnmapAll()
Disconnects and unmaps the port from all ports and statechart it is
 connected and/or mapped to.
public void send(OutMessageType msg) 
Send the message out. First, calls user's on send code, and, if it
 returns 
true, forwards the message to all connected ports on the same
 level and to all container agent ports mapped to this one.- Parameters:
 msg- the message being sent.
public void receive(InMessageType msg) 
Receives an incoming message. First, calls user's on receive code, and, if
 it returns 
true, forwards the message to all ports of embedded objects
 and to all statecharts this port is mapped to.- Parameters:
 msg- the message being received
public List<Port<OutMessageType,InMessageType>> getFlatLinks()
Returns an unmodifiable list with connected ports
- Returns:
 - unmodifiable list with connected ports
 
public List<Port<InMessageType,OutMessageType>> getUpLinks()
Returns an unmodifiable list with mapped ports on agents
 which own the current agent (owner of port)
- Returns:
 - unmodifiable list with mapped ports on agents which own current agent (owner of port)
 - See Also:
 - 
map(Port) 
public List<Port<InMessageType,OutMessageType>> getDownLinks()
Returns an unmodifiable list with mapped ports on agents
 embedded in the current agent (owner of port)
- Returns:
 - unmodifiable list with mapped ports on agents embedded in the current agent (owner of port)
 - See Also:
 - 
map(Port) 
public List<Statechart> getStatechartLinks()
Returns an unmodifiable list with mapped statecharts of the
 current agent (owner of this port)
- Returns:
 - unmodifiable list with mapped statecharts of the current agent (owner of this port)
 - See Also:
 - 
map(Statechart) 
@AnyLogicInternalCodegenAPI public void onDestroy()
Should be called when the port is destroyed, e.g. when the owner agent is destroyed. Disconnects and unmaps the port from all other ports 
 and statecharts.
@AnyLogicInternalCodegenAPI @Deprecated public void restoreOwner(Object owner) 
Deprecated.
This method normally should not be called by user
This method restores owner of this object
The method is used in snapshot saving/loading
This method restores owner of this object
The method is used in snapshot saving/loading
- Specified by:
 restoreOwnerin interfacecom.anylogic.engine.internal.Child- Parameters:
 owner- owner of this object, usuallyAgent,ExperimentorShapeGroup
getAgent()instead