system_assignation/city_model_structure/city_objects_cluster.py

73 lines
1.6 KiB
Python
Raw Normal View History

2021-06-03 11:23:09 -04:00
"""
CityObjectsCluster module
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
from abc import ABC
from typing import List
from city_model_structure.iot.sensor import Sensor
from city_model_structure.city_object import CityObject
2021-06-03 11:23:09 -04:00
class CityObjectsCluster(ABC, CityObject):
2021-06-03 11:23:09 -04:00
"""
CityObjectsCluster(ABC) class
"""
def __init__(self, name, cluster_type, city_objects):
self._name = name
self._cluster_type = cluster_type
self._city_objects = city_objects
self._sensors = []
self._lod = ''
super().__init__(name, self._lod, None, None)
2021-06-03 11:23:09 -04:00
@property
def name(self):
"""
Get cluster name
:return: str
"""
2021-06-03 11:23:09 -04:00
return self._name
@property
def type(self):
"""
raises not implemented error
"""
2021-06-03 11:23:09 -04:00
raise NotImplementedError
@property
def city_objects(self):
"""
raises not implemented error
"""
2021-06-03 11:23:09 -04:00
raise NotImplementedError
def add_city_object(self, city_object) -> List[CityObject]:
"""
add new object to the cluster
:return: [CityObjects]
"""
2021-06-03 11:23:09 -04:00
if self._city_objects is None:
self._city_objects = [city_object]
else:
self._city_objects.append(city_object)
return self._city_objects
@property
def sensors(self) -> List[Sensor]:
"""
Get sensors belonging to the city objects cluster
:return: [Sensor]
"""
return self._sensors
@sensors.setter
def sensors(self, value):
"""
Set sensors belonging to the city objects cluster
:param value: [Sensor]
"""
self._sensors = value