omnetpypy.backends.connector
This module implements the Connector class, which is an interface to the simulation engine. Connectors provide a set of functions to interact with the simulation engine, such as starting and stopping the simulation, adding and removing entities from the simulation, supporting event generation and management.
- class omnetpypy.backends.connector.Connector(simulation, metrics=None, output_dir=None, repetition=0)[source]
Bases:
ABC
This class is an interface to the simulation engine. This is an abstract class, and it is meant to be subclassed by connectors to specific simulation engines.
- Parameters:
- simulation
Simulation
The simulation object that describes the simulation configuration and its context. Used for example to access the random number generators for the simulation.
- metricslist of
FutureMetric
or None, optional A list of metrics to be recorded during the simulation.
- output_dirstr, optional
The output directory where the simulation data will be stored. Default is None, which means that the simulation data will not be stored.
- repetitionint, optional
The repetition index of the simulation. Default is 0.
- simulation
- Attributes:
- simulation
Simulation
The simulation object that describes the simulation configuration and its context. Used for example to access the random number generators for the simulation.
- metricslist of
FutureMetric
or None A list of metrics to be collected during the simulation. If
None
, no metrics will be collected.- output_dirstr
The output directory where the simulation data will be stored.
- repetitionint
The repetition index of the simulation.
- simulation
- abstract add_entity(entity)[source]
Add an entity to the simulation.
- Parameters:
- entity
SimulatedEntity
The simulation entity to be added to the simulation.
- entity
- abstract cancel_scheduled(message, entity)[source]
Cancel a scheduled self message for an entity. If the message is not scheduled, nothing happens.
- dump_metric(metric)[source]
Dump the metric data to the temporary output file for this repetition.
- Parameters:
- metricstr
The name of the metric to be dumped.
- abstract get_time()[source]
Return the current simulation time. The time unit is determined by the simulation configuration.
- abstract is_scheduled(message, entity)[source]
Check if a message is scheduled as a self message for an entity.
- Parameters:
- message
Message
The message to be checked.
- entity
SimulatedEntity
The entity to check, that should receive the self message.
- message
- random()[source]
Return the random number generator instantiated for the current simulation.
- Returns:
MultiRandom
A random number generator that supports multiple independent streams, powered by an independent seed for each stream.
- record_metric(metric, value)[source]
Record a metric value for the current simulation.
- Parameters:
- metricstr
The name of the metric to be recorded.
- valuefloat
The value of the metric to be recorded. If value is a dict or a list and the output file format is csv, it will be turned into a string and stored as is under the “sample” column.
- abstract schedule_port_input(port, message)[source]
Schedule the event of a message received by a port.
- abstract schedule_self_message(message, entity, at=None, delay=None)[source]
Schedule a self message to be processed by an entity.
- Parameters:
- message
Message
The message to be processed.
- entity
SimulatedEntity
The entity that will process the message.
- atfloat or None, optional
The simulation time at which the message should be processed. If None, the
delay
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, the
at
parameter will be used.
- message