omnetpypy.front_end.port

This module implements the Port class. Every port is an object that can receive and send messages. Ports are the interface of modules with the outside world.

Ports have the same semantic as in omnet++, except that every port is an object itself and does not have to be input or output only.

class omnetpypy.front_end.port.Port(name, parent)[source]

Bases: object

This class represents a port in the simulation model. Ports are the interface of modules with the outside world. Every port is an object that can receive and send messages.

Parameters:
namestr

The name of the port. This name should be unique within the parent module.

parentSimulatedEntity

The parent entity of the port, i.e., the entity to which the port belongs.

Attributes:
namestr

The name of the port.

connected_portPort or None

The remote port to which this port is connected. If None, the port is not connected. See also connect().

forwarded_input_portPort or None

The remote port to which the input of this port is forwarded. If None, the port does not forward input. See also forward_input().

forwarded_output_portPort or None

The remote port to which the output of this port is forwarded. If None, the port does not forward output. See also forward_output().

parentSimulatedEntity

The parent entity of the port.

subscribed_portslist of Port

The list of ports that are subscribed to this port. Every subscribed port receives a copy of each message sent to this port.

is_subscribedbool

A flag indicating whether this port is subscribed to another port. See also subscribe_to().

connect(port)[source]

Connect this port to another remote port. The output of this port will be fed as input to the other port, and vice versa.

Parameters:
portPort

The remote port to which this port will be connected.

Raises:
ValueError

If this port is already connected to another port, if the remote port is already connected to another port, if this port is already subscribed to another port, or if this port output is already forwarded to another port.

disconnect(port)[source]

Disconnect this port from another remote port. If the two ports are not connected to any other port, this does nothing.

Parameters:
portPort

The remote port from which this port will be disconnected.

Raises:
ValueError

If this or the other port are connected to a third port and not mutually connected.

forward_input(port)[source]

Forward the input of this port to another remote port. The input of this port will be sent as input to the other port.

Parameters:
portPort

The remote port to which the input of this port will be forwarded.

Raises:
ValueError

If this port is already connected to another port, or if the remote port is already connected to another port,

forward_output(port)[source]

Forward the output of this port to another remote port. The output of this port will be sent as output to the other port.

Parameters:
portPort

The remote port to which the output of this port will be forwarded.

Raises:
ValueError

If this port is already connected to another port, or if the remote port is already connected to another port,

subscribe_to(port)[source]

Subscribe this port to another remote port. This port will receive a copy of each message sent to the remote port.

Parameters:
portPort

The remote port to which this port will be subscribed.

Raises:
ValueError

If this port is already connected to another port, if the remote port is already connected to another port, or if the remote port is forwarding output

tx_input(message)[source]

Receive a message as input of this port.

Parameters:
messageMessage

The message to be received.

tx_output(message)[source]

Send a message as output of this port.

Parameters:
messageMessage

The message to be sent.