2021-06-03 11:23:09 -04:00
|
|
|
"""
|
|
|
|
CityObjectsCluster module
|
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
2022-04-08 09:35:33 -04:00
|
|
|
Copyright © 2022 Concordia CERC group
|
|
|
|
Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
2021-06-03 11:23:09 -04:00
|
|
|
"""
|
|
|
|
|
|
|
|
from abc import ABC
|
2021-06-03 13:34:41 -04:00
|
|
|
from typing import List
|
2021-08-06 12:28:20 -04:00
|
|
|
from city_model_structure.iot.sensor import Sensor
|
2021-06-03 15:56:59 -04:00
|
|
|
from city_model_structure.city_object import CityObject
|
2021-06-03 11:23:09 -04:00
|
|
|
|
|
|
|
|
2021-06-03 15:56:59 -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
|
2021-06-03 13:34:41 -04:00
|
|
|
self._sensors = []
|
2022-11-28 13:44:02 -05:00
|
|
|
super().__init__(name, None)
|
2021-06-03 11:23:09 -04:00
|
|
|
|
|
|
|
@property
|
|
|
|
def name(self):
|
2021-06-09 14:23:45 -04:00
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Get cluster name
|
2021-06-09 14:23:45 -04:00
|
|
|
:return: str
|
|
|
|
"""
|
2021-06-03 11:23:09 -04:00
|
|
|
return self._name
|
|
|
|
|
|
|
|
@property
|
|
|
|
def type(self):
|
2021-08-26 09:19:38 -04:00
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
raises not implemented error
|
2021-08-26 09:19:38 -04:00
|
|
|
"""
|
2021-06-03 11:23:09 -04:00
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
@property
|
|
|
|
def city_objects(self):
|
2021-08-26 09:19:38 -04:00
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
raises not implemented error
|
2021-08-26 09:19:38 -04:00
|
|
|
"""
|
2021-06-03 11:23:09 -04:00
|
|
|
raise NotImplementedError
|
|
|
|
|
2021-06-09 14:23:45 -04:00
|
|
|
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
|
2021-06-03 13:34:41 -04:00
|
|
|
|
|
|
|
@property
|
|
|
|
def sensors(self) -> List[Sensor]:
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Get sensors belonging to the city objects cluster
|
2021-06-03 13:34:41 -04:00
|
|
|
:return: [Sensor]
|
|
|
|
"""
|
|
|
|
return self._sensors
|
|
|
|
|
|
|
|
@sensors.setter
|
|
|
|
def sensors(self, value):
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Set sensors belonging to the city objects cluster
|
2021-06-03 13:34:41 -04:00
|
|
|
:param value: [Sensor]
|
|
|
|
"""
|
|
|
|
self._sensors = value
|