Ports

Ports play the central role in the message passing mechanism. Messages are sent and received through ports. Ports are bi-directional and can serve both for input and output. 

 To create a port
  1. Drag Port  element from the Agent palette onto the diagram of agent.

Properties

General

Name – The name of the port. The name is used to identify and access the port from code.

Show name – If selected, the port name is displayed on a presentation diagram.

Ignore – If selected, the port is excluded from the model.

Visible on upper level – If selected, the port is also visible on the upper level where this agent lives.

Visible – If selected, the port is visible on a presentation at runtime.

Message handling actions

These properties are visible only if the Library Developer Mode is switched on.

On receive
– [Visible if the advanced option Custom port is not selected] The code executed each time a message is received by the port (when the user calls the method receive() of the port, or when this port receives a message from a port of some embedded object). Here you can access just received message as msg (local variable of type Object).*

On send – [Visible if the advanced option Custom port is not selected] The code executed each time a message is sent by the port (when the user calls the method send() of the port, or when this port relays message received "from outside" (i.e. from a port of agent located on the same or higher level in the model hierarchy)). Here you can access the message as msg (local variable of type Object).*

* If the field is left blank, or true is returned, the message is processed further as defined by message routing rules, otherwise it is discarded. 

Advanced

These properties are visible only if the Library Developer Mode is switched on.

Custom port
If selected, the port will be an instance of the custom port class specified in the Constructor code. This is needed, when you have a number of ports with the same custom functionality (e.g. the same On receive message handler) in your model, and you want to define this functionality once in a custom port class and then simply use instances of that port class.

In message type – [Enabled if the Custom port option is not selected] The type of messages that are allowed to be received by the port. If you leave Object here, message type checking will not be performed and all messages will be allowed to be received.

Out message type – [Enabled if the Custom port option is not selected] The type of messages that are allowed to be sent by the port. If you leave Object here, message type checking will not be performed and all messages will be allowed to be sent.

Constructor code – [Visible if the Custom port option is selected] Here you can type the constructor of the created port class, e.g. MyPort(this) 


Related topics

 Message passing

 Connecting ports

Custom port classes

 API reference: Port class