#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# (c) Copyright 2025 Sensirion AG, Switzerland
#
#     THIS FILE IS AUTOMATICALLY GENERATED!
#
# Generator:     sensirion-driver-generator 1.3.4
# Product:       sfm3505
# Model-Version: 1.2.0
#
"""
The class Sfm3505DeviceBase implements the low level interface of the sensor.
The class Sfm3505Device extends the Sfm3505DeviceBase. It provides additional functions to ease the use of the
sensor.
"""
from sensirion_driver_adapters.transfer import execute_transfer
from sensirion_driver_support_types.mixin_access import MixinAccess
from sensirion_i2c_sfm3505.commands import (ConfigureAveraging, ReadAirMeasurementDataRaw, ReadAllMeasurementDataRaw,
                                            ReadProductIdentifier, StartContinuousMeasurement,
                                            StartContinuousMeasurementWithFilter, StopContinuousMeasurement)
from sensirion_i2c_sfm3505.result_types import (SignalAirFlow, SignalAirFlowRaw, SignalO2Flow, SignalO2FlowRaw)
[docs]class Sfm3505DeviceBase:
    """Low level API implementation of SFM3505"""
[docs]    def __init__(self, channel):
        self._channel = channel 
    @property
    def channel(self):
        return self._channel
[docs]    def start_continuous_measurement(self):
        """Start continuous measurement"""
        transfer = StartContinuousMeasurement()
        return execute_transfer(self._channel, transfer) 
[docs]    def start_continuous_measurement_with_filter(self, a_filter):
        """
        Start continuous measurement with custom filter
        :param a_filter:
            Low pass filter configuration.
        :Example:
            .. code-block:: python
                sensor.start_continuous_measurement_with_filter(50961)
        """
        transfer = StartContinuousMeasurementWithFilter(a_filter)
        return execute_transfer(self._channel, transfer) 
[docs]    def read_all_measurement_data_raw(self):
        """
        Read out the full data from the sensor.
        :return all_flow_bytes_raw:
            Air-calibrated flow signal and O2-calibrated flow signal read from the sensor as Bytes
        """
        transfer = ReadAllMeasurementDataRaw()
        return execute_transfer(self._channel, transfer)[0] 
[docs]    def read_air_measurement_data_raw(self):
        """
        Read out the air flow from the sensor.
        :return air_flow_bytes_raw:
            Air-calibrated flow signal read from the sensor as Bytes.
        """
        transfer = ReadAirMeasurementDataRaw()
        return execute_transfer(self._channel, transfer)[0] 
[docs]    def stop_continuous_measurement(self):
        """This transfer stops the continuous measurement and puts the sensor in idle mode."""
        transfer = StopContinuousMeasurement()
        return execute_transfer(self._channel, transfer) 
[docs]    def read_product_identifier(self):
        """
        Reads the product identifier and serial number
        :return product_identifier:
            32-bit unique product and revision number
        :return serial_number:
            64 bit unique serial number of the device
        """
        transfer = ReadProductIdentifier()
        return execute_transfer(self._channel, transfer)  
[docs]class Sfm3505Device(Sfm3505DeviceBase):
    """Driver class implementation of SFM3505"""
    #: Access to base class
    sfm3505 = MixinAccess()
[docs]    def __init__(self, channel):
        super().__init__(channel) 
[docs]    def read_all_measurement_data(self):
        """
        Read measurement data and apply appropriate scaling.
        :return a_air_flow:
            This signal represents the measured Air flow in slm (at 20°C and 1013.25hPa).
            It is scaled with the corresponding scaling factor and offset.
        :return a_o2_flow:
            This signal represents the measured O2 flow in slm (at 20°C and 1013.25hPa).
            It is scaled with the corresponding scaling factor and offset.
        """
        flow_bytes_raw = self.read_all_measurement_data_raw()
        return (SignalAirFlow(flow_bytes_raw), SignalO2Flow(flow_bytes_raw)) 
[docs]    def read_all_measurement_data_no_float(self):
        """
        Read measurement data without scaling.
        :return a_air_flow_raw:
            This raw signal represents the measured Air flow as returned by the sensor.
            The result needs to be scaled to obtain slm.
        :return a_o2_flow_raw:
            This raw signal represents the measured O2 flow as returned by the sensor.
            The result needs to be scaled to obtain slm.
        """
        flow_bytes_raw = self.read_all_measurement_data_raw()
        return (SignalAirFlowRaw(flow_bytes_raw), SignalO2FlowRaw(flow_bytes_raw)) 
[docs]    def read_air_measurement_data(self):
        """
        Read only the air flow measurement data.
        :return a_air_flow:
            This signal represents the measured Air flow in slm (at 20°C and 1013.25hPa).
            It is scaled with the corresponding scaling factor and offset.
        """
        flow_bytes_raw = self.read_air_measurement_data_raw()
        return SignalAirFlow(flow_bytes_raw) 
[docs]    def read_air_measurement_data_no_float(self):
        """
        Read only the air flow measurement data and does not apply scaling.
        :return a_air_flow_raw:
            This raw signal represents the measured Air flow as returned by the sensor.
            The result needs to be scaled to obtain slm.
        """
        flow_bytes_raw = self.read_air_measurement_data_raw()
        return SignalAirFlowRaw(flow_bytes_raw)