# Beam table schema and queries # CREATE TABLE subrun_info ( # id INTEGER NOT NULL, # timestamp INTEGER, # run INTEGER, # subrun INTEGER, # tstart INTEGER, # tstop INTEGER, # trigger_priority INTEGER, # beb_active INTEGER, # beam_status INTEGER, # mag_current_min FLOAT, # mag_current_max FLOAT, # comment VARCHAR, # PRIMARY KEY (id)) # # Query in the case of beam status 0 queryBeam0:select run, subrun, datetime(tstart,'unixepoch','localtime') as start, datetime(tstop,'unixepoch','localtime') as stop, trigger_priority, beb_active, beam_status, mag_current_min, mag_current_max, comment from subrun_info where beam_status=0 and (trigger_priority&1)=1 and (mag_current_min < 0 or mag_current_min > 2550) and tstart >= %s # Query in the case of beam status != 0 queryBeamNon0:select run, subrun, datetime(tstart,'unixepoch','localtime') as start, datetime(tstop,'unixepoch','localtime') as stop, trigger_priority, beb_active, beam_status, mag_current_min, mag_current_max, comment from subrun_info where beam_status!=0 and (trigger_priority&1)=1 and (mag_current_min < 0 or mag_current_min > 2550) and tstart >= %s # Query in the case of beam status != 0 and tstop < atime queryBeamNon0TE:select run, subrun, datetime(tstart,'unixepoch','localtime') as start, datetime(tstop,'unixepoch','localtime') as stop, trigger_priority, beb_active, beam_status, mag_current_min, mag_current_max, comment from subrun_info where beam_status!=0 and (trigger_priority&1)=1 and (mag_current_min < 0 or mag_current_min > 2550) and tstart >= %s and tstop <= %s # Query in the case of beam status 0 and tstop < atime queryBeam0TE:select run, subrun, datetime(tstart,'unixepoch','localtime') as start, datetime(tstop,'unixepoch','localtime') as stop, trigger_priority, beb_active, beam_status, mag_current_min, mag_current_max, comment from subrun_info where beam_status=0 and (trigger_priority&1)=1 and (mag_current_min < 0 or mag_current_min > 2550) and tstart >= %s and tstop <= %s