pvp.io package

Subpackages

Submodules

pvp.io.hal module

Module for interacting with physical and/or simulated devices installed on the ventilator.

Classes:

Hal([config_file])

Hardware Abstraction Layer for ventilator hardware.

Sensor()

Abstract base Class describing generalized sensors.

Functions:

import_module(name[, package])

Import a module.

literal_eval(node_or_string)

Safely evaluate an expression node or a string containing a Python expression.

class pvp.io.hal.Hal(config_file='pvp/io/config/devices.ini')[source]

Bases: object

Hardware Abstraction Layer for ventilator hardware. Defines a common API for interacting with the sensors & actuators on the ventilator. The types of devices installed on the ventilator (real or simulated) are specified in a configuration file.

Initializes HAL from config_file.

For each section in config_file, imports the class <type> from module <module>, and sets attribute self.<section> = <type>(**opts), where opts is a dict containing all of the options in <section> that are not <type> or <section>. For example, upon encountering the following entry in config_file.ini:

[adc] type = ADS1115 module = devices i2c_address = 0x48 i2c_bus = 1

The Hal will:
  1. Import pvp.io.devices.ADS1115 (or ADS1015) as a local variable:

    class_ = getattr(import_module(‘.devices’, ‘pvp.io’), ‘ADS1115’)

  2. Instantiate an ADS1115 object with the arguments defined in config_file and set it as an attribute:

    self._adc = class_(pig=self.-pig,address=0x48,i2c_bus=1)

Note: RawConfigParser.optionxform() is overloaded here s.t. options are case sensitive (they are by default case insensitive). This is necessary due to the kwarg MUX which is so named for consistency with the config registry documentation in the ADS1115 datasheet. For example, A P4vMini pressure_sensor on pin A0 (MUX=0) of the ADC is passed arguments like:

analog_sensor = AnalogSensor(

pig=self._pig, adc=self._adc, MUX=0, offset_voltage=0.25, output_span = 4.0, conversion_factor=2.54*20

)

Note: ast.literal_eval(opt) interprets integers, 0xFF, (a, b) etc. correctly. It does not interpret strings correctly, nor does it know ‘adc’ -> self._adc; therefore, these special cases are explicitly handled.

Parameters

config_file (str) – Path to the configuration file containing the definitions of specific components on the ventilator machine. (e.g., config_file = “pvp/io/config/devices.ini”)

Methods:

__init__([config_file])

Initializes HAL from config_file.

Attributes:

aux_pressure

Returns the pressure from the auxiliary pressure sensor, if so equipped.

flow_ex

The measured flow rate expiratory side.

flow_in

The measured flow rate inspiratory side.

oxygen

Returns the oxygen concentration from the primary oxygen sensor.

pressure

Returns the pressure from the primary pressure sensor.

setpoint_ex

The currently requested flow on the expiratory side as a proportion of the maximum.

setpoint_in

The currently requested flow for the inspiratory proportional control valve as a proportion of maximum.

__init__(config_file='pvp/io/config/devices.ini')[source]
Initializes HAL from config_file.

For each section in config_file, imports the class <type> from module <module>, and sets attribute self.<section> = <type>(**opts), where opts is a dict containing all of the options in <section> that are not <type> or <section>. For example, upon encountering the following entry in config_file.ini:

[adc] type = ADS1115 module = devices i2c_address = 0x48 i2c_bus = 1

The Hal will:
  1. Import pvp.io.devices.ADS1115 (or ADS1015) as a local variable:

    class_ = getattr(import_module(‘.devices’, ‘pvp.io’), ‘ADS1115’)

  2. Instantiate an ADS1115 object with the arguments defined in config_file and set it as an attribute:

    self._adc = class_(pig=self.-pig,address=0x48,i2c_bus=1)

Note: RawConfigParser.optionxform() is overloaded here s.t. options are case sensitive (they are by default case insensitive). This is necessary due to the kwarg MUX which is so named for consistency with the config registry documentation in the ADS1115 datasheet. For example, A P4vMini pressure_sensor on pin A0 (MUX=0) of the ADC is passed arguments like:

analog_sensor = AnalogSensor(

pig=self._pig, adc=self._adc, MUX=0, offset_voltage=0.25, output_span = 4.0, conversion_factor=2.54*20

)

Note: ast.literal_eval(opt) interprets integers, 0xFF, (a, b) etc. correctly. It does not interpret strings correctly, nor does it know ‘adc’ -> self._adc; therefore, these special cases are explicitly handled.

Parameters

config_file (str) – Path to the configuration file containing the definitions of specific components on the ventilator machine. (e.g., config_file = “pvp/io/config/devices.ini”)

property pressure

Returns the pressure from the primary pressure sensor.

property oxygen

Returns the oxygen concentration from the primary oxygen sensor.

property aux_pressure

Returns the pressure from the auxiliary pressure sensor, if so equipped. If a secondary pressure sensor is not defined, raises a RuntimeWarning.

property flow_in

The measured flow rate inspiratory side.

property flow_ex

The measured flow rate expiratory side.

property setpoint_in

The currently requested flow for the inspiratory proportional control valve as a proportion of maximum.

property setpoint_ex

The currently requested flow on the expiratory side as a proportion of the maximum.

Module contents

Classes:

Hal([config_file])

Hardware Abstraction Layer for ventilator hardware.