Using bag valve mask squeeze action in Python

Hi there,

I’m currently trying to implement a tiny bag valve mask squeeze action using Python bindings.
When I try to do the following:

from pulse.cdm.engine import eSerializationFormat, eSwitch
from pulse.cdm.scalars import VolumeUnit, VolumePerTimeUnit, PressureUnit, TimeUnit
from pulse.cdm.patient_actions import SESupplementalOxygen, eDevice
from pulse.engine.PulseEngine import PulseEngine


# BVM
from pulse.cdm.bag_valve_mask import SEBagValveMask
from pulse.cdm.bag_valve_mask_actions import SEBagValveMaskAction, SEBagValveMaskAction, SEBagValveMaskConfiguration, SEBagValveMaskAutomated, SEBagValveMaskInstantaneous, SEBagValveMaskSqueeze

def HowTo_BagValveMask():
        pulse = PulseEngine()
        pulse.set_log_filename("./test_results/howto/HowTo_BagValveMask.py.log")
        pulse.log_to_console(True)

        # NOTE: No data requests are being provided, so Pulse will return the default vitals data
        if not pulse.serialize_from_file("../states/Soldier@0s.json", None):
                print("Unable to load initial state file")
                return

        # Get some data from the engine
        results = pulse.pull_data()
        pulse.print_results()

        # BVM
        cfg = SEBagValveMaskConfiguration()
        cfg.get_configuration().set_connection(eSwitch.On)
        pulse.process_action(cfg)

        squeeze = SEBagValveMaskSqueeze()
        squeeze.get_expiratory_period().set_value(2, TimeUnit.s)
        squeeze.get_inspiratory_period().set_value(3, TimeUnit.s)
        squeeze.get_squeeze_volume().set_value(500, VolumeUnit.mL)
        pulse.process_action(squeeze)

        # Advance some time and print out the vitals
        pulse.advance_time_s(30)
        results = pulse.pull_data()
        pulse.print_results()

HowTo_BagValveMask()

I get the error message “Unknown Equipment Action”. Has anybody a hint for me on how to get that running?

Thanks a lot for your support!

Kind regards,

Chris

Hi @DerChb

It looks like we had not completed the BVM interface in Python.

I updated it for your drive (and included it) into a new branch

https://gitlab.kitware.com/physiology/engine/-/commits/python_testing

You can just pull those python files directly, no need to rebuild any C++

We will also be running futher tests to ensure everything we have supported in python is functional

Thanks!

1 Like

Hey @abray!

Thanks a lot for the quick support - I somehow still had to recompile the sources, but it’s working now like a charme. Thank you :slight_smile:

Cheers,
Chris