BNMR: Adding a new mode
Introduction
Adding a new experimental mode takes several steps. The exact changes depend on whether a new feature is required, or if the mode is just enabling a new combination of existing features.
Decide on a new name for the mode
Historically all BNMR/BNQR modes are named as 2-character strings, starting with a 1 for TI modes and a 2 for TD modes. There is no significant logic to the second character, but the first character is important for user comprehension!
Add the mode to mode_changer.py
Modes are defined in the mode_changer.py
script. Most other code doesn't refer explicitly to mode names, and only looks at which features are enabled for a given mode (by looking at the flags in /CurrentMode in the ODB).
- If a new feature is required, add a new flag to the
ModeFeatures
class. Set the default value such that existing classes will NOT enable the new feature. - In all cases, add the definition of the new mode to the
self.modes
dictionary.
Create a new PPG timing scheme
If a new PPG timing scheme is required:
- Define any "questions" that the user should answer to configure the timing scheme in
self.default_ppg_questions
inmode_changer.py
. - Handle the new mode in
compute_ppg()
inppg_prog_helper.py
(used byrf_calculator_fe.py
). This should generate thecycling_framework.ppg.compiler.Program
that defines the PPG timing.
Write the new feature
If a new feature is required, write the code for the new feature. Use the ODB for any settings that the user might want to configure.
Handle storing settings in MUD files
If there is a new PPG timing scheme or a new feature that is configurable, any settings the user can configure should be stored in the MUD file as "independent variables":
- Store the new settings by calling
set_mud_ind_vars()
inppg_prog_helper.py
. - If some custom logic was needed when storing the variable (e.g. the ODB flag is a bool, but was stored as a string in the MUD file), edit
load_from_old_run()
inmode_changer.py
Update custom settings page
If there is a new PPG timing scheme or a new feature that is configurable:
- Update
populate_tables()
insettings.js
to build the new interface.
Update saved settings
If there is a new feature that is configurable, update any saved settings for other modes to ensure that the feature is not enabled when those settings are loaded. This command must be run on the main DAQ PC, and run separately for each experiment (BNMR/BNQR).
python save_load.py add --odb-path "/path/to/new/setting" --json-value '{"value": true}'
etc