hvl_ccb.dev.sst_luminox¶
Device class for a SST Luminox Oxygen sensor. This device can measure the oxygen concentration between 0 % and 25 %.
Furthermore, it measures the barometric pressure and internal temperature. The device supports two operating modes: in streaming mode the device measures all parameters every second, in polling mode the device measures only after a query.
Technical specification and documentation for the device can be found a the manufacturer’s page: https://www.sstsensing.com/product/luminox-optical-oxygen-sensors-2/
- class Luminox(com, dev_config=None)[source]¶
Bases:
hvl_ccb.dev.base.SingleCommDevice
Luminox oxygen sensor device class.
- activate_output(mode: hvl_ccb.dev.sst_luminox.LuminoxOutputMode) → None[source]¶
activate the selected output mode of the Luminox Sensor. :param mode: polling or streaming
- static config_cls()[source]¶
Return the default configdataclass class.
- Returns
a reference to the default configdataclass class
- static default_com_cls()[source]¶
Get the class for the default communication protocol used with this device.
- Returns
the type of the standard communication protocol for this device
- query_polling(measurement: Union[str, hvl_ccb.dev.sst_luminox.LuminoxMeasurementType]) → Union[Dict[Union[str, hvl_ccb.dev.sst_luminox.LuminoxMeasurementType], Union[float, int, str]], float, int, str][source]¶
Query a value or values of Luminox measurements in the polling mode, according to a given measurement type.
- Parameters
measurement – type of measurement
- Returns
value of requested measurement
- Raises
ValueError – when a wrong key for LuminoxMeasurementType is provided
LuminoxOutputModeError – when polling mode is not activated
LuminoxMeasurementTypeError – when expected measurement value is not read
- read_streaming() → Dict[Union[str, hvl_ccb.dev.sst_luminox.LuminoxMeasurementType], Union[float, int, str]][source]¶
Read values of Luminox in the streaming mode. Convert the single string into separate values.
- Returns
dictionary with LuminoxMeasurementType.all_measurements_types() keys and accordingly type-parsed values.
- Raises
LuminoxOutputModeError – when streaming mode is not activated
LuminoxMeasurementTypeError – when any of expected measurement values is not read
- class LuminoxConfig(wait_sec_post_activate: Union[int, float] = 0.5, wait_sec_trials_activate: Union[int, float] = 0.1, nr_trials_activate: int = 5)[source]¶
Bases:
object
Configuration for the SST Luminox oxygen sensor.
- force_value(fieldname, value)¶
Forces a value to a dataclass field despite the class being frozen.
NOTE: you can define post_force_value method with same signature as this method to do extra processing after value has been forced on fieldname.
- Parameters
fieldname – name of the field
value – value to assign
- is_configdataclass = True¶
- classmethod keys() → Sequence[str]¶
Returns a list of all configdataclass fields key-names.
- Returns
a list of strings containing all keys.
- nr_trials_activate: int = 5¶
- classmethod optional_defaults() → Dict[str, object]¶
Returns a list of all configdataclass fields, that have a default value assigned and may be optionally specified on instantiation.
- Returns
a list of strings containing all optional keys.
- classmethod required_keys() → Sequence[str]¶
Returns a list of all configdataclass fields, that have no default value assigned and need to be specified on instantiation.
- Returns
a list of strings containing all required keys.
- wait_sec_post_activate: Union[int, float] = 0.5¶
- wait_sec_trials_activate: Union[int, float] = 0.1¶
- class LuminoxMeasurementType(value=<no_arg>, names=None, module=None, type=None, start=1, boundary=None)[source]¶
Bases:
hvl_ccb.utils.enum.ValueEnum
Measurement types for LuminoxOutputMode.polling.
The all_measurements type will read values for the actual measurement types as given in LuminoxOutputMode.all_measurements_types(); it parses multiple single values using regexp’s for other measurement types, therefore, no regexp is defined for this measurement type.
- all_measurements = 'A'¶
- classmethod all_measurements_types() → Tuple[hvl_ccb.dev.sst_luminox.LuminoxMeasurementType, ...][source]¶
A tuple of LuminoxMeasurementType enum instances which are actual measurements, i.e. not date of manufacture or software revision.
- barometric_pressure = 'P'¶
- property command: str¶
- date_of_manufacture = '# 0'¶
- parse_read_measurement_value(read_txt: str) → Union[Dict[Union[str, hvl_ccb.dev.sst_luminox.LuminoxMeasurementType], Union[float, int, str]], float, int, str][source]¶
- partial_pressure_o2 = 'O'¶
- percent_o2 = '%'¶
- sensor_status = 'e'¶
- serial_number = '# 1'¶
- software_revision = '# 2'¶
- temperature_sensor = 'T'¶
- LuminoxMeasurementTypeDict¶
A typing hint for a dictionary holding LuminoxMeasurementType values. Keys are allowed as strings because LuminoxMeasurementType is of a StrEnumBase type.
alias of
Dict
[Union
[str
,LuminoxMeasurementType
],Union
[float
,int
,str
]]
- exception LuminoxMeasurementTypeError[source]¶
Bases:
Exception
Wrong measurement type for requested data
- LuminoxMeasurementTypeValue¶
A typing hint for all possible LuminoxMeasurementType values as read in either streaming mode or in a polling mode with LuminoxMeasurementType.all_measurements.
Beware: has to be manually kept in sync with LuminoxMeasurementType instances cast_type attribute values.
alias of
Union
[float
,int
,str
]
- class LuminoxSerialCommunication(configuration)[source]¶
Bases:
hvl_ccb.comm.serial.SerialCommunication
Specific communication protocol implementation for the SST Luminox oxygen sensor. Already predefines device-specific protocol parameters in config.
- class LuminoxSerialCommunicationConfig(terminator: bytes = b'\r\n', encoding: str = 'utf-8', encoding_error_handling: str = 'strict', wait_sec_read_text_nonempty: Union[int, float] = 0.5, default_n_attempts_read_text_nonempty: int = 10, port: Union[str, NoneType] = None, baudrate: int = 9600, parity: Union[str, hvl_ccb.comm.serial.SerialCommunicationParity] = <SerialCommunicationParity.NONE: 'N'>, stopbits: Union[int, hvl_ccb.comm.serial.SerialCommunicationStopbits] = <SerialCommunicationStopbits.ONE: 1>, bytesize: Union[int, hvl_ccb.comm.serial.SerialCommunicationBytesize] = <SerialCommunicationBytesize.EIGHTBITS: 8>, timeout: Union[int, float] = 3)[source]¶
Bases:
hvl_ccb.comm.serial.SerialCommunicationConfig
- baudrate: int = 9600¶
Baudrate for SST Luminox is 9600 baud
- bytesize: Union[int, hvl_ccb.comm.serial.SerialCommunicationBytesize] = 8¶
One byte is eight bits long
- force_value(fieldname, value)¶
Forces a value to a dataclass field despite the class being frozen.
NOTE: you can define post_force_value method with same signature as this method to do extra processing after value has been forced on fieldname.
- Parameters
fieldname – name of the field
value – value to assign
- classmethod keys() → Sequence[str]¶
Returns a list of all configdataclass fields key-names.
- Returns
a list of strings containing all keys.
- classmethod optional_defaults() → Dict[str, object]¶
Returns a list of all configdataclass fields, that have a default value assigned and may be optionally specified on instantiation.
- Returns
a list of strings containing all optional keys.
- parity: Union[str, hvl_ccb.comm.serial.SerialCommunicationParity] = 'N'¶
SST Luminox does not use parity
- classmethod required_keys() → Sequence[str]¶
Returns a list of all configdataclass fields, that have no default value assigned and need to be specified on instantiation.
- Returns
a list of strings containing all required keys.
- stopbits: Union[int, hvl_ccb.comm.serial.SerialCommunicationStopbits] = 1¶
SST Luminox does use one stop bit
- terminator: bytes = b'\r\n'¶
The terminator is CR LF
- timeout: Union[int, float] = 3¶
use 3 seconds timeout as default