system_assignation/city_model_structure/iot/sensor.py

74 lines
1.5 KiB
Python

"""
Sensor module
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2022 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
"""
import uuid
from city_model_structure.iot.sensor_measure import SensorMeasure
from city_model_structure.iot.sensor_type import SensorType
class Sensor:
"""
Sensor abstract class
"""
def __init__(self, sensor_id=None, model=None, sensor_type=None, indoor=False, board=None):
self._id = sensor_id
self._model = model
self._type = sensor_type
self._indoor = indoor
self._board = board
self._measures = []
@property
def id(self):
"""
Get the sensor id a random uuid will be assigned if no ID was provided to the constructor
:return: Id
"""
if self._id is None:
self._id = uuid.uuid4()
return self._id
@property
def type(self) -> SensorType:
"""
Get sensor type
:return: SensorTypeEnum or Error
"""
if self._type is None:
raise ValueError('Unknown sensor type')
return self._type
@property
def model(self):
"""
Get sensor model is any
:return: str or None
"""
return self._model
@property
def board(self):
"""
Get sensor board if any
:return: str or None
"""
return self._model
@property
def indoor(self):
"""
Get is the sensor it's located indoor or outdoor
:return: boolean
"""
return self._indoor
@property
def measures(self) -> [SensorMeasure]:
"""
Raises not implemented error
"""
return self._measures