sensor

Modules

sensor_system module

class SensorSystem(filename=None, df=None, uuid=None, name=None, dbconfig=None, useSpreadsheet=False, useDatabase=False, **kwargs)[source]

Bases: System

A system representing a physical or virtual sensor in the building.

This class implements sensor functionality, supporting both physical sensors (reading from time series data) and virtual sensors (computing values from other inputs). It integrates with TimeSeriesInputSystem for data handling.

Parameters:
  • filename (Optional[str]) – Path to sensor readings file. Defaults to None.

  • df (Optional[DataFrame]) – DataFrame containing readings. Defaults to None.

  • useSpreadsheet (bool) – Whether to use a spreadsheet for input. Defaults to False.

  • useDatabase (bool) – Whether to use a database for input. Defaults to False.

  • **kwargs – Additional keyword arguments passed to parent class.

Note

A sensor must either have connections to other systems (virtual sensor) or have data input through filename/df (physical sensor).

do_step(secondTime=None, dateTime=None, step_size=None, stepIndex=None)[source]

Execute one time step of the sensor system.

Updates sensor outputs based on either physical readings or virtual calculations.

Parameters:
  • secondTime (Optional[float]) – Current simulation time in seconds.

  • dateTime (Optional[datetime.datetime]) – Current simulation datetime.

  • step_size (Optional[float]) – Time step size in seconds.

Return type:

None

get_physical_readings(start_time, end_time, step_size, simulator)[source]

Retrieve physical sensor readings for a specified time period.

Parameters:
  • start_time (Optional[datetime.datetime]) – Start time for readings.

  • end_time (Optional[datetime.datetime]) – End time for readings.

  • step_size (Optional[float]) – Time step size in seconds.

Returns:

DataFrame containing sensor readings.

Return type:

pd.DataFrame

Raises:

AssertionError – If called on a virtual sensor (no physical readings available).

initialize(start_time=None, end_time=None, step_size=None, simulator=None)[source]

Initialize the sensor system.

Sets up the physical or virtual sensor system and initializes the step instance.

Parameters:
  • start_time (Optional[datetime.datetime]) – Start time for the simulation.

  • end_time (Optional[datetime.datetime]) – End time for the simulation.

  • step_size (Optional[float]) – Time step size in seconds.

  • model (Optional[Any]) – Model object (not used in this class).

Return type:

None

validate(p)[source]

Validate the sensor system configuration.

Checks if the sensor has proper inputs for different operational modes.

Parameters:

p – Logging function for validation messages.

Returns:

Validation status for:
  • Simulator

  • Estimator

  • Evaluator

  • Monitor

Return type:

tuple[bool, bool, bool, bool]

validate_connections(p)[source]
Return type:

bool

property config
property datecolumn: int

Get the column index for datetime values.

property dbconfig: Dict[str, Any] | None

Get the database configuration parameters.

property df: DataFrame | None

Get the direct DataFrame input of sensor readings.

property filename: str | None

Get the path to sensor readings file.

property input: dict

Get the input ports of the sensor system.

Returns:

Dictionary containing input ports:
  • ”measuredValue”: Measured value input for virtual sensors

Return type:

dict

property is_leaf: bool

Get whether the sensor reads from file/DataFrame (True) or is virtual (False).

property name: str | None

Get the name for database operations.

property output: dict

Get the output ports of the sensor system.

Returns:

Dictionary containing output ports:
  • ”measuredValue”: Measured value output [units depend on sensor type]

Return type:

dict

property physicalSystem: TimeSeriesInputSystem | None

Get the data handling system for physical sensors.

sp = [<twin4build.translator.translator.SignaturePattern object>, <twin4build.translator.translator.SignaturePattern object>, <twin4build.translator.translator.SignaturePattern object>, <twin4build.translator.translator.SignaturePattern object>, <twin4build.translator.translator.SignaturePattern object>, <twin4build.translator.translator.SignaturePattern object>, <twin4build.translator.translator.SignaturePattern object>, <twin4build.translator.translator.SignaturePattern object>, <twin4build.translator.translator.SignaturePattern object>, <twin4build.translator.translator.SignaturePattern object>, <twin4build.translator.translator.SignaturePattern object>]
property useDatabase: bool

Get whether to use a database for input.

property useSpreadsheet: bool

Get whether to use a spreadsheet for input.

property uuid: str | None

Get the UUID for database operations.

property valuecolumn: int

Get the column index for sensor readings.

get_flow_signature_pattern_after_coil_air_side()[source]
get_flow_signature_pattern_after_coil_air_side_simple()[source]
get_flow_signature_pattern_after_coil_water_side()[source]
get_flow_signature_pattern_before_coil_water_side()[source]
get_position_signature_pattern()[source]
get_signature_pattern_input()[source]
get_space_co2_signature_pattern()[source]
get_space_temperature_signature_pattern()[source]
get_temperature_after_air_to_air_exhaust_side()[source]
get_temperature_after_air_to_air_supply_side()[source]
get_temperature_before_air_to_air_exhaust_side()[source]
get_temperature_before_air_to_air_supply_side()[source]