hvl_ccb.dev.sst_luminox.sst_luminox

Inheritance diagram of hvl_ccb.dev.sst_luminox.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: SingleCommDevice

Luminox oxygen sensor device class.

activate_output(mode: 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: str | LuminoxMeasurementType) dict[str | LuminoxMeasurementType, 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:
read_streaming() dict[str | LuminoxMeasurementType, 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:
start() None[source]

Start this device. Opens the communication protocol.

stop() None[source]

Stop the device. Closes also the communication protocol.

class LuminoxConfig(wait_sec_post_activate: int | float = 0.5, wait_sec_trials_activate: int | float = 0.1, nr_trials_activate: int = 5)[source]

Bases: object

Configuration for the SST Luminox oxygen sensor.

clean_values()[source]
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: int | float = 0.5
wait_sec_trials_activate: int | float = 0.1
exception LuminoxError[source]

Bases: DeviceError

General Error for Luminox Device.

class LuminoxMeasurementType(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: 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[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) dict[str | LuminoxMeasurementType, 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.

exception LuminoxMeasurementTypeError[source]

Bases: LuminoxError

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 float | int | str

class LuminoxOutputMode(value)[source]

Bases: Enum

output mode.

polling = 1
streaming = 0
exception LuminoxOutputModeError[source]

Bases: LuminoxError

Wrong output mode for requested data

class LuminoxSerialCommunication(configuration)[source]

Bases: SerialCommunication

Specific communication protocol implementation for the SST Luminox oxygen sensor. Already predefines device-specific protocol parameters in config.

static config_cls()[source]

Return the default configdataclass class.

Returns:

a reference to the default configdataclass class

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: Optional[str] = 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: SerialCommunicationConfig

baudrate: int = 9600

Baudrate for SST Luminox is 9600 baud

bytesize: int | 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: str | 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: int | SerialCommunicationStopbits = 1

SST Luminox does use one stop bit

terminator: bytes = b'\r\n'

The terminator is CR LF

timeout: int | float = 3

use 3 seconds timeout as default