Back Midas Rome Roody Rootana
  Midas DAQ System  Not logged in ELOG logo
Entry  22 Nov 2023, Pavel Murat, Forum, run number from an external (*SQL) db? 
    Reply  22 Nov 2023, Ben Smith, Forum, run number from an external (*SQL) db? 
    Reply  22 Nov 2023, Stefan Ritt, Forum, run number from an external (*SQL) db? 
       Reply  01 Dec 2023, Pavel Murat, Forum, run number from an external (*SQL) db? 
          Reply  02 Dec 2023, Stefan Ritt, Forum, run number from an external (*SQL) db? 
             Reply  02 Dec 2023, Pavel Murat, Forum, run number from an external (*SQL) db? 
                Reply  03 Dec 2023, Pavel Murat, Forum, run number from an external (*SQL) db? 
                   Reply  04 Dec 2023, Stefan Ritt, Forum, run number from an external (*SQL) db? 
                Reply  04 Dec 2023, Stefan Ritt, Forum, run number from an external (*SQL) db? 
Message ID: 2634     Entry time: 22 Nov 2023     In reply to: 2633
Author: Ben Smith 
Topic: Forum 
Subject: run number from an external (*SQL) db? 
> I wonder if there is a non-intrusive way to have an external (wrt MIDAS)*SQL database 
> serving as a primary source of the run number information for a MIDAS-based DAQ system? 
> - like a plugin with a getNextRunNumber() function, for example, or a special client?

One of my experiments has special rules for run numbering as well. I created a client that registers a begin-of-run transition handler with sequence 1 (so it's the first client to handle the begin-of-run transition). That client updates "/Runinfo/Run number" in the ODB. 

This mostly works. mlogger will create .mid files based on the new run number, the ODB dumps within those files show the new run number etc.

But there are 2 quirks. Let's say your client changed the number from 11 to 400. The message log will say "Run #11 started" and "Run #400 stopped". And the history system will record the start/stop times the same way. That only matters for when you're viewing history plots on the webpage and zoom in far enough to see the run transitions (represented by green and red vertical dashed lines) - the green line will be labelled 11 and the red line 400.

Depending on the exact logic you need, you may be able to avoid these quirks by also recomputing the run number before the user even tries to start a run (e.g. after the end of the previous run, or when the user changes an important setting in the ODB). If you're changing the run number between runs, make sure to set it to "desired number - 1", as midas will increment the run number automatically before handling the next start run request.
ELOG V3.1.4-2e1708b5