omnetpypy.front_end.compound_module
This module implements the CompoundModule()
class.
Compound modules are non-atomic modules that contain other modules and channels.
They do not come with a behavior, but they can be used to organize the simulation model with a hierarchical structure.
Their behavior is intrinsically defined by the behavior of their submodules and how they are connected.
Compund Modules have the same semantic as in omnet++
- class omnetpypy.front_end.compound_module.CompoundModule(name, identifier, port_names, **kwargs)[source]
Bases:
SimulatedEntity
This class represents a compound module in the simulation model. Compound modules are non-atomic modules that contain other modules and channels. They do not come with a behavior, but they can be used to organize the simulation model with a hierarchical structure. Their behavior is intrinsically defined by the behavior of their submodules and how they are connected.
See
SimulatedEntity
for inherited attributes. All kwargs passed to the constructor are also stored as attributes of the module.- Parameters:
- namestr
The name of the module. This name should be unique within the simulation.
- identifierint
The identifier of the module. This identifier should be unique within the simulation.
- port_nameslist of str
The names of the ports of the module.
- **kwargs
Additional, arbitrary attributes of the module, passed as keyword arguments.
- Attributes:
- sub_modulesdict of
SimulatedEntity
The sub-entities of the module, indexed by their names.
- sub_modulesdict of
- add_sub_module(module)[source]
Add a submodule to this compound module.
- Parameters:
- module
SimulatedEntity
The submodule to be added.
- module
- Raises:
- Exception
If a submodule with the same name already exists.
- cancel_scheduled(message)[source]
Cancel a scheduled self message for this entity. Calls internally the method
cancel_scheduled()
.- Parameters:
- message
Message
The message to be cancelled.
- message
- connect(local_port, remote_entity, remote_port, channel=None)[source]
Connect a port of this module to a port of another remote entity.
- Parameters:
- local_portstr
The name of the local port to be connected.
- remote_entity
SimulatedEntity
The remote entity to which the port will be connected.
- remote_portstr
The name of the remote port to be connected.
- channel
Channel
or None, optional The channel through which the connection will be made, if any. If set, the local port is connected to the “A” port of the channel, and the “B” port of the channel is connected to the remote port.
See also
- forward_input(port_container, port_submodule)[source]
Forward the input of a port of this module to a port of a submodule.
- Parameters:
- port_containerstr
The name of the port of this module that will forward the input.
- port_submodule
Port
The port of the submodule that will receive the input.
See also
- forward_output(port_submodule, port_container)[source]
Forward the output of a port of a submodule to a port of this module.
- Parameters:
- port_submodulestr
The name of the port of the submodule that will forward the output.
- port_container
Port
The port of this module that will receive the output.
See also
- get_sub_module(name)[source]
Get a submodule by its name.
- Parameters:
- namestr
The name of the submodule to be retrieved.
- Returns:
SimulatedEntity
The submodule with the given name.
- handle_message(message, port_name)[source]
Process a message received as input to a port.
- Parameters:
- message
Message
The message to be processed.
- port_namestr or None
The name of the port on which the message was received. If
None
, the message was sent by the entity itself (self message).
- message
- is_scheduled(message)[source]
Check if a message is scheduled as a self message for this entity. Calls internally the method
is_scheduled()
.- Parameters:
- message
Message
The message to be checked.
- message
- schedule_message(message, at=None, delay=None)[source]
Schedule a self message to be received by this entity. Calls internally the method
schedule_self_message()
.- Parameters:
- message
Message
The message to be processed.
- atfloat or None, optional
The simulation time at which the message should be processed. If
None
, thedelay
parameter will be used.- delayfloat or None, optional
The time delay from the current simulation time at which the message should be processed. If
None
, theat
parameter will be used.
- message
- send(message, port_name)[source]
Send a message out on a specified port. Calls internally the method
tx_output()
.- Parameters:
- message
Message
The message to be sent.
- port_namestr
The name of the port on which the message should be sent.
- message