Features

This section describes all features that are shipped with this package.

Scenario Features

class balderhub.heart.lib.scenario_features.BaseTestCriteriaConfig(**kwargs)

Bases: Feature

base test criteria configuration for beat-per-minute sensor devices in general

class UpdateTimeTestConfig(start_bpm: int, end_bpm: int, max_update_time_sec: float)

Bases: NamedTuple

configuration tupe for BaseTestCriteriaConfig.test_update_time_for()

end_bpm: int

Alias for field number 1

max_update_time_sec: float

Alias for field number 2

start_bpm: int

Alias for field number 0

property allowed_plusminus_deviation_percent
Returns:

allowed deviation in percent (0..1) the BPM and the RR-Value can be different to the expected value

property max_bpm_change_update_time_sec
Returns:

the maximum time the bpm update should need within the whole system

property max_rr_change_update_time_sec
Returns:

the maximum time the RR-Value update should need

property test_accuracy_of_bpms_for: list[int]
Returns:

list of test parametrization runs to do with the given BPM value

property test_noise_with_snr_of
Returns:

list of test parametrization runs that should be done with noise (None is no Noise and all values are SNR in dB)

property test_update_time_for: list[balderhub.heart.lib.scenario_features.base_test_criteria_config.BaseTestCriteriaConfig.UpdateTimeTestConfig]
Returns:

list of test parametrization runs to do Update time validation for specific start and end bpm values

class balderhub.heart.lib.scenario_features.BpmValueReaderFeature(**kwargs)

Bases: Feature

Base scenario-level feature class for reading BPM value remotely from the DUT

cleanup()

method to clean up the resources used by the feature

prepare()

method that prepares the feature

read_last_bpm_value() int

reads the RR-Value from the DUT once

class balderhub.heart.lib.scenario_features.HeartBeatFeature(**kwargs)

Bases: Feature

Base scenario level heart beat feature

fixt_make_sure_heart_beat_established(with_bpm: float = 60, restore_entry_state: bool = True)

Fixture that makes sure that the Heart Beat is established with the given beats-per-minute value. If there is another beat-per-minute value established established, the method will update it to the new one and saves the previous applied value which can be restored within teardown code (if restore_entry_state is True).

Note

You can use this fixture directly by using:

@balder.fixture(...)
def my_fixture(...):
    yield from feat.fixt_make_sure_heart_beat_established(...)
Parameters:
  • with_bpm – the beat-per-minute that should be established

  • restore_entry_state – True if the previous state should be reestablished in the teardown part of this fixture

Returns:

the ready to use fixture generator, but without any values

fixt_make_sure_heart_beat_off(restore_entry_state: bool = True)

Fixture that makes sure that the Heart Beat is put off before finishing the construction part of this fixture.

If restore_entry_state is True, the method will reestablish the state that was given before entering this fixture.

Note

You can use this fixture directly by using:

@balder.fixture(...)
def my_fixture(...):
    yield from feat.fixt_make_sure_heart_beat_off(...)
Parameters:

restore_entry_state – True if the previous state should be reestablished in the teardown part of this fixture

Returns:

the ready to use fixture generator, but without any values

get_current_active_bpm() float | None
Returns:

returns the current active heart beat or None if no heart beat is active at the moment

start(bpm: float, add_noise_with_snr_of=None) None

Starts the heart beat simulation

Parameters:
  • bpm – the beats-per-minute that should be applied

  • add_noise_with_snr_of – adds noise to the signal with the given SNR in dB or None if no noise should be added

stop() None

Stops the heart beat simulation

class balderhub.heart.lib.scenario_features.RRValueReaderFeature(**kwargs)

Bases: Feature

Base scenario-level feature class for reading the RR-Value remotely from the DUT

cleanup()

method to clean up the resources used by the feature

prepare()

method that prepares the feature

read_last_rr_value_in_sec() float | None

reads the RR-Value from the DUT once

Returns:

the rr-value time in seconds or None if measurement was not possible this time

wait_for_next_rr_value_in_sec() float | None

Waits until the next RR-Value is available

Returns:

the rr-value time in seconds or None if measurement was not possible this time

class balderhub.heart.lib.scenario_features.StrapDockingFeature(**kwargs)

Bases: Feature

Feature providing binding to dock and undock a heart beat sensor device at the skin. It is pretty common, that chest staps can detect skin contact and stops working as soon as the skin contact is lost. This feature provides bindings for that.

fixt_make_sure_to_be_attached(restore_entry_state: bool = True)

This is a fixture that ensures that the strap is attached before finishing the construction part of this fixture.

If restore_entry_state is True, it will restore the state that was applied before entering this fixture in teardown part.

Note

You can directly use this fixture within balder like:

@balder.fixture(...)
def my_fixture(...):
    yield from feat.fixt_make_sure_to_be_attached(...)
Parameters:

restore_entry_state – if Ture, the fixture will restore the state of the strap like it was before entering this fixture within the teardown code

Returns:

the generator object to use directly as balder fixture

fixt_make_sure_to_be_not_attached(restore_entry_state: bool = True)

This is a fixture that ensures that the strap is put off before finishing the construction part of this fixture.

If restore_entry_state is True, it will restore the state that was applied before entering this fixture in teardown part.

Note

You can directly use this fixture within balder like:

@balder.fixture(...)
def my_fixture(...):
    yield from feat.fixt_make_sure_to_be_not_attached(...)
Parameters:

restore_entry_state – if Ture, the fixture will restore the state of the strap like it was before entering this fixture within the teardown code

Returns:

the generator object to use directly as balder fixture

is_attached() bool
Returns:

returns True if the stap is attached, otherwise False

put_off() None

Puts strap off

put_on() None

Puts strap on

class balderhub.heart.lib.scenario_features.StrapTestCriteriaConfig(**kwargs)

Bases: BaseTestCriteriaConfig

Special Test Criteria configuration for tests with chest straps

property time_to_sleep_after_no_signal: float | None
Returns:

maximum time device needs to go to sleep if no heart beat signal is active or None if the device will not go asleep if there is no signal anymore (only when there is no skin contact)

property time_to_sleep_after_skin_contact_loss: float
Returns:

maximum time device needs to go to sleep if no connection is established

property timeout_awakening_sec: float
Returns:

maximum time device needs to awake

Setup Features

class balderhub.heart.lib.setup_features.OpticalStrapDockingFeature(**kwargs)

Bases: StrapDockingFeature

Setup Level implementation for simulating the strap by using the optical heart beat feature

class Heart

Bases: VDevice

vdevice of the heart

is_attached()
Returns:

returns True if the stap is attached, otherwise False

put_off()

Puts strap off

put_on()

Puts strap on

class balderhub.heart.lib.setup_features.OpticalHeartBeatFeature(**kwargs)

Bases: HeartBeatFeature

Setup Level feature implementation of the balderhub.heart.lib.scenario_features.HeartBeatFeature for simulating a heart beat optical with the users monitor

property color_config: ColorConfiguration
Returns:

the color configuration object describing the optical visualization

get_current_active_bpm() float | None
Returns:

returns the current active heart beat or None if no heart beat is active at the moment

property position: tuple[int, int]
Returns:

returns a tuple (x, y) with the position of the heart beat simulation and the users monitor

shutdown_application() None

This method shuts the application down. It should be called after leaving the test.

property simulator: TkinterOpticalHeartBeatSimulation | None
Returns:

returns the current active simulator instance or None if no simulator is active

property size: tuple[int, int]
Returns:

returns a tuple (width, height) with the size of the heart beat simulation and the users monitor

start(bpm: float, add_noise_with_snr_of=None) None

Starts the heart beat simulation

Parameters:
  • bpm – the beats-per-minute that should be applied

  • add_noise_with_snr_of – adds noise to the signal with the given SNR in dB or None if no noise should be added

start_application() None

This method starts the application. It should be called before entering the test.

stop()

Stops the heart beat simulation