2021-06-01 18:31:50 -04:00
|
|
|
"""
|
|
|
|
Sensor module
|
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
2022-04-08 09:35:33 -04:00
|
|
|
Copyright © 2022 Concordia CERC group
|
|
|
|
Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
2021-06-01 18:31:50 -04:00
|
|
|
"""
|
|
|
|
|
2022-03-08 19:19:52 -05:00
|
|
|
from helpers.location import Location
|
2022-03-29 06:53:55 -04:00
|
|
|
from city_model_structure.iot.sensor_measure import SensorMeasure
|
|
|
|
from city_model_structure.iot.sensor_type import SensorType
|
2021-06-09 14:23:45 -04:00
|
|
|
|
2021-06-01 19:03:55 -04:00
|
|
|
|
2021-06-01 18:31:50 -04:00
|
|
|
class Sensor:
|
2021-06-02 09:30:01 -04:00
|
|
|
"""
|
|
|
|
Sensor abstract class
|
|
|
|
"""
|
2022-03-08 19:19:52 -05:00
|
|
|
def __init__(self):
|
|
|
|
self._name = None
|
|
|
|
self._type = None
|
|
|
|
self._units = None
|
|
|
|
self._location = None
|
2021-06-01 18:31:50 -04:00
|
|
|
|
|
|
|
@property
|
2022-03-08 19:19:52 -05:00
|
|
|
def name(self):
|
2021-06-01 18:31:50 -04:00
|
|
|
"""
|
2022-03-08 19:19:52 -05:00
|
|
|
Get sensor name
|
|
|
|
:return: str
|
2021-06-01 18:31:50 -04:00
|
|
|
"""
|
2022-03-08 19:19:52 -05:00
|
|
|
if self._name is None:
|
|
|
|
raise ValueError('Undefined sensor name')
|
|
|
|
return self._name
|
|
|
|
|
|
|
|
@name.setter
|
|
|
|
def name(self, value):
|
|
|
|
"""
|
|
|
|
Set sensor name
|
|
|
|
:param value: str
|
|
|
|
"""
|
|
|
|
if value is not None:
|
|
|
|
self._name = str(value)
|
2021-06-01 18:31:50 -04:00
|
|
|
|
|
|
|
@property
|
2022-03-29 06:53:55 -04:00
|
|
|
def type(self) -> SensorType:
|
2021-06-01 18:31:50 -04:00
|
|
|
"""
|
|
|
|
Get sensor type
|
2022-03-08 19:19:52 -05:00
|
|
|
:return: str
|
2021-06-01 18:31:50 -04:00
|
|
|
"""
|
|
|
|
return self._type
|
|
|
|
|
|
|
|
@property
|
2022-03-08 19:19:52 -05:00
|
|
|
def units(self):
|
2021-06-01 18:31:50 -04:00
|
|
|
"""
|
2022-03-08 19:19:52 -05:00
|
|
|
Get sensor units
|
|
|
|
:return: str
|
2021-06-01 18:31:50 -04:00
|
|
|
"""
|
2022-03-08 19:19:52 -05:00
|
|
|
return self._units
|
2021-06-01 18:31:50 -04:00
|
|
|
|
|
|
|
@property
|
2022-03-08 19:19:52 -05:00
|
|
|
def location(self) -> Location:
|
2021-06-01 18:31:50 -04:00
|
|
|
"""
|
2022-03-08 19:19:52 -05:00
|
|
|
Get sensor location
|
|
|
|
:return: Location
|
2021-06-01 18:31:50 -04:00
|
|
|
"""
|
2022-03-08 19:19:52 -05:00
|
|
|
return self._location
|
2021-06-01 18:31:50 -04:00
|
|
|
|
2022-03-08 19:19:52 -05:00
|
|
|
@location.setter
|
|
|
|
def location(self, value):
|
2021-06-01 18:31:50 -04:00
|
|
|
"""
|
2022-03-08 19:19:52 -05:00
|
|
|
Set sensor location
|
|
|
|
:param value: Location
|
2021-06-01 18:31:50 -04:00
|
|
|
"""
|
2022-03-08 19:19:52 -05:00
|
|
|
self._location = value
|
2021-06-01 18:31:50 -04:00
|
|
|
|
|
|
|
@property
|
2022-03-29 06:53:55 -04:00
|
|
|
def measures(self) -> [SensorMeasure]:
|
2021-08-26 09:19:38 -04:00
|
|
|
"""
|
2021-09-01 09:39:27 -04:00
|
|
|
Raises not implemented error
|
2021-08-26 09:19:38 -04:00
|
|
|
"""
|
2022-03-08 19:19:52 -05:00
|
|
|
raise NotImplementedError
|