Utils - ptidejteam/tools4cities-metamenth GitHub Wiki
The Utils package in MetamEnTh serves as a collection of utility classes and methods designed to support various operations and functionalities required by other entities within the system. These utility methods encapsulate common, reusable logic, promoting code reusability, maintainability, and modularity throughout MetamEnTh.
EntityInsert
This class provides utility methods for adding entities to other entities that have a one-to-many relationship with the class of the entity being added
Parent Class
None
Relationships
None
Attributes
None
Behaviours (Methods)
insert_zone(entity, zone: Zone, building: Building): this utility method adds a zone to entities that possess thezonesattribute, e.g., roominsert_building_entity(entity_list, entity, entity_type, entity_object): this utility method adds an entity to another entity, e.g., adding a room to a floor, adding a sensor to a room, etc._insert_unique(name: str): this method is used byinsert_building_entitywhen the entity to be added to another entity has to be unique
EntityRemover
This class provides utility methods for removing entities from other entities that have a one-to-many relationship with the class of the entity being removed
Parent Class
None
Relationships
None
Attributes
None
Behaviours (Methods)
remove_building_entity(building_entity_list, entity, entity_type, entity_object): this utility method removes an entity from another entity, e.g., a room from a floor, a damper from a duct
StructureEntitySearch
This class provides utility methods to search for entities that have a many-to-one relationship with the class of the entity they are an attribute of
Parent Class
None
Relationships
None
Attributes
None
Behaviours (Methods)
search_by_id(entity_list, uid): searches an entity with the unique identifier, e.g., a meter from a list of meterssearch_by_name(entity_list, name): searches an entity with its name, e.g., a sensor from a list of sensorssearch(entity_list, search_terms): searches an entity from a list of entities using attributes and their values in a dictionary, e.g., searching for all temperature sensors with{'measure': SensorMeasure.TEMPERATURE }date_range_search(entity_list: Union[List[SensorData], List[TriggerHistory], List[MeterMeasure], List[WeatherData]], from_timestamp: str, to_timestamp: str): searches for time-series data given the start date and time and the end date and timesearch_structure_entity(entity_list, search_field, search_value): searches for entities using a single attribute and its corresponding value
StructureSearch
The StructureSearch class provides utility methods to search for structure-related entities.
Parent Class
None
Relationships
None
Attributes
None
Behaviours (Methods)
search_by_id(entity_list, uid): searches a structure entity with the unique identifier, e.g., a room from a list of rooms on a floorsearch_by_name(entity_list, name): searches a structure entity with its name, e.g., an open space from a list of open spaces on a floorsearch_by_number(entity_list, name): searches a structure entity with its number, e.g., a floor from a list of floors in a buildingsearch(entity_list, search_terms): searches an entity from a list of structure entities using attributes and their values in a dictionary, e.g., searching for all external wall materials made of wood{'material_type': MaterialType.EX_WALL_WOOd }search_structure_entity(entity_list, search_field, search_value): searches for floors, rooms, open spaces, layers, and covers using a single attribute and its corresponding value