pvp.io package¶
pvp.io.hal module¶
Module for interacting with physical and/or simulated devices installed on the ventilator.
Classes:
|
Hardware Abstraction Layer for ventilator hardware. |
- 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:
- Import pvp.io.devices.ADS1115 (or ADS1015) as a local variable:
class_ = getattr(import_module(‘.devices’, ‘pvp.io’), ‘ADS1115’)
- 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:
Returns the pressure from the primary pressure sensor.
Returns the oxygen concentration from the primary oxygen sensor.
Returns the pressure from the auxiliary pressure sensor, if so equipped.
The measured flow rate inspiratory side.
The measured flow rate expiratory side.
The currently requested flow for the inspiratory proportional control valve as a proportion of maximum.
The currently requested flow on the expiratory side as a proportion of the 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:
- Import pvp.io.devices.ADS1115 (or ADS1015) as a local variable:
class_ = getattr(import_module(‘.devices’, ‘pvp.io’), ‘ADS1115’)
- 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 aux_pressure: float¶
Returns the pressure from the auxiliary pressure sensor, if so equipped. If a secondary pressure sensor is not defined, raises a RuntimeWarning.
devices¶
A module for ventilator hardware device drivers