pydistsim.network.sensor.CompositeSensor

class CompositeSensor(node: Node, componentSensors: tuple[type[Sensor] | str] | None = None)[source]

Bases: object

Wrap multiple sensors, coalesce results and return composite readout.

This class is not a sensor itself, i.e. subclass of Sensor, instead it serves as a placeholder for multiple sensors that can be attached to a Node.

Parameters:
  • node (Node) – The Node that has this composite sensor attached to.

  • componentSensors (tuple[type[Sensor] | str]) – Tuple of Sensor subclasses or their class names.

Methods

__init__

get_sensor

Get a sensor by its name.

read

Read measurements from all sensors.

Attributes

sensors

Get the sensors associated with the object.

get_sensor(name: str) Sensor[source]

Get a sensor by its name.

Parameters:

name (str) – The name of the sensor.

Returns:

The sensor object.

Return type:

Sensor

Raises:

SensorError – If multiple or no sensors are found with the given name.

read()[source]

Read measurements from all sensors.

Returns:

A dictionary containing the measurements from all sensors.

Return type:

dict

property sensors: tuple[Sensor]

Get the sensors associated with the object.

Returns:

A tuple of Sensor objects.