prefs¶
System preferences are stored in ~/pvp/prefs.json
Data
bool: flag to indicate whether prefs have been loaded (and thus |
|
Declare all available parameters and set default values. |
|
Directories to ensure are created and added to prefs. |
|
|
Functions
|
Get global configuration value |
|
Initialize prefs. |
|
Load prefs from a .json prefs file, combining (and overwriting) any existing prefs, and then saves. |
ensures _DIRECTORIES are created and added to prefs. |
|
|
|
|
-
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 storageLOG_DIR
: ~/pvp/logs - for storage of event and alarm logsDATA_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
-
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 fileTIME_FIRST_START
- time when the program has been started for the first timeVENT_DIR
: ~/pvp - base directory for user storageLOG_DIR
: ~/pvp/logs - for storage of event and alarm logsDATA_DIR
: ~/pvp/data - for storage of waveform dataLOGGING_MAX_BYTES
: the total storage space for all loggers – each logger getsLOGGING_MAX_BYTES/len(loggers)
spaceLOGGING_MAX_FILES
: number of files to split each logger’s logs acrossGUI_STATE_FN
: Filename of gui control state file, relative toVENT_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 isBREATH_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.
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 ifload_prefs()
is called again at any point it should not change prefs.- Parameters
prefs_fn (str) – path of prefs.json