BNMR: Adding a new mode

From DaqWiki
Jump to navigation Jump to search


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

Modes are defined in the 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 in
  • Handle the new mode in compute_ppg() in (used by This should generate the cycling_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() in
  • 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() in

Update custom settings page

If there is a new PPG timing scheme or a new feature that is configurable:

  • Update populate_tables() in settings.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 add --odb-path "/path/to/new/setting" --json-value '{"value": true}' etc