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.
- parent
SimulatedEntity
The parent entity of the port, i.e., the entity to which the port belongs.
- Attributes:
- namestr
The name of the port.
- connected_port
Port
or None The remote port to which this port is connected. If
None
, the port is not connected. See alsoconnect()
.- forwarded_input_port
Port
or None The remote port to which the input of this port is forwarded. If
None
, the port does not forward input. See alsoforward_input()
.- forwarded_output_port
Port
or None The remote port to which the output of this port is forwarded. If
None
, the port does not forward output. See alsoforward_output()
.- parent
SimulatedEntity
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:
- port
Port
The remote port to which this port will be connected.
- port
- 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:
- port
Port
The remote port from which this port will be disconnected.
- port
- 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:
- port
Port
The remote port to which the input of this port will be forwarded.
- port
- 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:
- port
Port
The remote port to which the output of this port will be forwarded.
- port
- 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:
- port
Port
The remote port to which this port will be subscribed.
- port
- 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