# Using bag valve mask squeeze action in Python

**URL:** https://discourse.kitware.com/t/using-bag-valve-mask-squeeze-action-in-python/1079
**Category:** Pulse Physiology Engine
**Created:** [August 6, 2023, 10:34pm UTC](https://discourse.kitware.com/t/using-bag-valve-mask-squeeze-action-in-python/1079 "2023-08-06T22:34:59Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![DerChb](https://discourse.kitware.com/user_avatar/discourse.kitware.com/derchb/32/743_2.png) [@DerChb](https://discourse.kitware.com/u/DerChb)
#### Post date: [August 6, 2023, 10:34pm UTC](https://discourse.kitware.com/t/using-bag-valve-mask-squeeze-action-in-python/1079/1 "2023-08-06T22:34:59Z")

</div>

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:

```auto
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

---

<div class="post-metadata">

### Author: ![abray](https://discourse.kitware.com/user_avatar/discourse.kitware.com/abray/32/12_2.png) [@abray](https://discourse.kitware.com/u/abray)
#### Post date: [August 7, 2023, 1:55pm UTC](https://discourse.kitware.com/t/using-bag-valve-mask-squeeze-action-in-python/1079/2 "2023-08-07T13:55:57Z")

</div>

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](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!

---

<div class="post-metadata">

### Author: ![DerChb](https://discourse.kitware.com/user_avatar/discourse.kitware.com/derchb/32/743_2.png) [@DerChb](https://discourse.kitware.com/u/DerChb)
#### Post date: [August 7, 2023, 8:04pm UTC](https://discourse.kitware.com/t/using-bag-valve-mask-squeeze-action-in-python/1079/3 "2023-08-07T20:04:46Z")

</div>

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 🙂

Cheers,  
Chris
