"""
Acquisition service for Sentinel.
"""

from sentinel.acquisition.measurement import EquipmentMeasurement
from sentinel.sensors.base import CurrentSensor, TemperatureSensor


class AcquisitionService:
    """
    Coordinate all sensor readings for one monitored equipment.

    This service reads the temperature and current sensors and
    creates one complete equipment measurement.
    """

    def __init__(
        self,
        ambient_sensor: TemperatureSensor,
        internal_sensor: TemperatureSensor,
        evaporator_sensor: TemperatureSensor,
        compressor_sensor: TemperatureSensor,
        current_sensor: CurrentSensor,
    ) -> None:
        """
        Initialize the acquisition service.

        Args:
            ambient_sensor: Sensor measuring ambient temperature.
            internal_sensor: Sensor measuring internal temperature.
            evaporator_sensor: Sensor measuring evaporator temperature.
            compressor_sensor: Sensor measuring compressor temperature.
            current_sensor: Sensor measuring compressor current.
        """
        self._ambient_sensor = ambient_sensor
        self._internal_sensor = internal_sensor
        self._evaporator_sensor = evaporator_sensor
        self._compressor_sensor = compressor_sensor
        self._current_sensor = current_sensor

    def acquire(self) -> EquipmentMeasurement:
        """
        Read all sensors and create one complete measurement.

        Returns:
            Complete timestamped equipment measurement.
        """
        return EquipmentMeasurement.create(
            ambient_temperature_c=(
                self._ambient_sensor.read_temperature_c()
            ),
            internal_temperature_c=(
                self._internal_sensor.read_temperature_c()
            ),
            evaporator_temperature_c=(
                self._evaporator_sensor.read_temperature_c()
            ),
            compressor_temperature_c=(
                self._compressor_sensor.read_temperature_c()
            ),
            compressor_current_a=(
                self._current_sensor.read_current_a()
            ),
            health_score=100.0,
        )