prefs

System preferences are stored in ~/pvp/prefs.json

Data

LOADED

bool: flag to indicate whether prefs have been loaded (and thus set_pref() should write to disk.

_DEFAULTS

Declare all available parameters and set default values.

_DIRECTORIES

Directories to ensure are created and added to prefs.

_LOCK

mp.Lock : Locks access to prefs_fn

Functions

get_pref(key)

Get global configuration value

init()

Initialize prefs.

load_prefs(prefs_fn)

Load prefs from a .json prefs file, combining (and overwriting) any existing prefs, and then saves.

make_dirs()

ensures _DIRECTORIES are created and added to prefs.

save_prefs(prefs_fn)

set_pref(key, val)

pvp.common.prefs._LOCK = <Lock(owner=None)>

Locks access to prefs_fn

Type

mp.Lock

pvp.common.prefs._DIRECTORIES = {'DATA_DIR': '/home/docs/pvp/logs', 'LOG_DIR': '/home/docs/pvp/logs', 'VENT_DIR': '/home/docs/pvp'}

Directories to ensure are created and added to prefs.

  • VENT_DIR: ~/pvp - base directory for user storage

  • LOG_DIR: ~/pvp/logs - for storage of event and alarm logs

  • DATA_DIR: ~/pvp/data - for storage of waveform data

pvp.common.prefs.LOADED = <Synchronized wrapper for c_bool(True)>

flag to indicate whether prefs have been loaded (and thus set_pref() should write to disk.

Type

bool

pvp.common.prefs._DEFAULTS = {'BREATH_DETECTION': True, 'BREATH_PRESSURE_DROP': 4, 'CONTROLLER_LOOPS_UNTIL_UPDATE': 1, 'CONTROLLER_LOOP_UPDATE_TIME': 0.0, 'CONTROLLER_LOOP_UPDATE_TIME_SIMULATOR': 0.005, 'CONTROLLER_MAX_FLOW': 10, 'CONTROLLER_MAX_PRESSURE': 100, 'CONTROLLER_MAX_STUCK_SENSOR': 0.2, 'CONTROLLER_RINGBUFFER_SIZE': 100, 'COUGH_DURATION': 0.1, 'ENABLE_DIALOGS': True, 'ENABLE_WARNINGS': True, 'GUI_STATE_FN': 'gui_state.json', 'GUI_UPDATE_TIME': 0.05, 'HEARTBEAT_TIMEOUT': 0.02, 'LOGGING_MAX_BYTES': 2147483648, 'LOGGING_MAX_FILES': 5, 'LOGLEVEL': 'WARNING', 'PREFS_FN': None, 'TIMEOUT': 0.05, 'TIME_FIRST_START': None}

Declare all available parameters and set default values. If no default, set as None.

  • PREFS_FN - absolute path to the prefs file

  • TIME_FIRST_START - time when the program has been started for the first time

  • VENT_DIR: ~/pvp - base directory for user storage

  • LOG_DIR: ~/pvp/logs - for storage of event and alarm logs

  • DATA_DIR: ~/pvp/data - for storage of waveform data

  • LOGGING_MAX_BYTES : the total storage space for all loggers – each logger gets LOGGING_MAX_BYTES/len(loggers) space

  • LOGGING_MAX_FILES : number of files to split each logger’s logs across

  • GUI_STATE_FN: Filename of gui control state file, relative to VENT_DIR

  • BREATH_PRESSURE_DROP : pressure drop below peep that is detected as an attempt to breath.

  • BREATH_DETECTION: (bool) whether the controller allows autonomous breaths (measured pressure is BREATH_PRESSURE_DROP below set PEEP)

  • CONTROLLER_MAX_FLOW: If flows above that, hardware cannot be correct.

  • CONTROLLER_MAX_PRESSURE: If pressure above that, hardware cannot be correct.

  • CONTROLLER_MAX_STUCK_SENSOR: Max amount of time (in s) before considering a sensor stuck

pvp.common.prefs.set_pref(key: str, val)[source]
pvp.common.prefs.get_pref(key: str = None)[source]

Get global configuration value

Parameters

key (str, None) – get configuration value with specific key . if None , return all config values.

pvp.common.prefs.load_prefs(prefs_fn: str)[source]

Load prefs from a .json prefs file, combining (and overwriting) any existing prefs, and then saves.

Note

once this function is called, set_pref() will update the prefs file on disk. So if load_prefs() is called again at any point it should not change prefs.

Parameters

prefs_fn (str) – path of prefs.json

pvp.common.prefs.save_prefs(prefs_fn: str = None)[source]
pvp.common.prefs.make_dirs()[source]

ensures _DIRECTORIES are created and added to prefs.

pvp.common.prefs.init()[source]

Initialize prefs. Called in pvp.__init__.py to ensure prefs are initialized before anything else.