#!/usr/bin/python # # # 3/30/2015 Paul Mattione # # # This script adds the RF signal channels to the translation table. # import sqlite3 as lite import sys import os import re import datetime if len(sys.argv) != 2: print "You must supply a SQLite DB file to modify!" sys.exit(0); # Connect to SQLite DB file db_filename = sys.argv[1] print "" print "opening SQLite DB file: %s" % db_filename print "---------------------------------------------" con = lite.connect(db_filename) with con: # Specify that next cursor should be "dictionary" # (i.e. python's hash map) so columns can be indexed # by name con.row_factory = lite.Row # Create Cursor cur = con.cursor() # Check that this TT file has not already been updated cur.execute("SELECT * FROM sqlite_master WHERE type = 'table' AND name = 'RF'") rf_rows = cur.fetchall() if len(rf_rows) != 0: print 'RF table was already created' sys.exit(-1) # make RF table cur.execute("CREATE TABLE RF(system TEXT, type TEXT, tdc_chanid INT, adc_chanid INT)") cur.execute("INSERT INTO RF VALUES ('TAGH', 'F1TDCV2', 880, 0)") cur.execute("INSERT INTO RF VALUES ('FDC', 'F1TDCV2', 27121, 0)") cur.execute("INSERT INTO RF VALUES ('PSC', 'F1TDCV2', 1824, 0)") cur.execute("INSERT INTO RF VALUES ('TOF', 'VX1290A', 23925, 0)") cur.execute("INSERT INTO RF VALUES ('PS', 'FADC250', 0, 27122)") cur.execute("INSERT INTO RF VALUES ('TAGH', 'FADC250', 0, 368)") # Add modules for RF (moduleid|crateid|slot|type|SN) #others already exist cur.execute("INSERT INTO Module Values (1021, 43, 17, 'F1TDCV2', '')") #rocfdc1 cur.execute("INSERT INTO Module Values (1022, 13, 13, 'FADC250', '')") #rocps2 # Add channels for RF (chanid|moduleid|name|channel|system|col_name|enable) cur.execute("INSERT INTO Channel Values (27121, 1021, 'RF-FDC-F1TDCV2', 31, 'RF', 'tdc_chanid', 1)") #rocfdc1 cur.execute("INSERT INTO Channel Values (27122, 1022, 'RF-PS-FADC250', 15, 'RF', 'adc_chanid', 1)") #rocps2 # Update other channels for RF (were SPARE) cur.execute("UPDATE Channel SET name='RF-PSC-F1TDCV2', system='RF', col_name='tdc_chanid' WHERE chanid='1824'") #rocstpsc1 cur.execute("UPDATE Channel SET name='RF-TOF-VX1290A', system='RF', col_name='tdc_chanid' WHERE chanid='23925'") #roctof2 cur.execute("UPDATE Channel SET name='RF-TAGH-F1TDCV2', system='RF', col_name='tdc_chanid' WHERE chanid='880'") #roctagmh cur.execute("UPDATE Channel SET name='RF-TAGH-FADC250', system='RF', col_name='adc_chanid' WHERE chanid='368'") #roctagh1 print 'Done' # https://logbooks.jlab.org/entry/3322743 # https://halldweb.jlab.org/wiki/index.php/HallD_Online_IP_Name_And_Address_Conventions # F1TDC TAGH: roctagmh, slot 16, channel 31 #rocid = 75, crateid = 4, moduleid = 54, chanid = 880 #select * from Crate where rocid = "75"; #select * from Module where crateid = '4'; #select * from Channel where moduleid = 54; # VX1290A TOF: roctof2, slot 8, channel 31 #rocid = 78, crateid = 62, moduleid = 771, chanid = 23925 #select * from Crate where rocid = "78"; #select * from Module where crateid = '62'; #select * from Channel where moduleid = 771; # F1TDC FDC: rocfdc1, slot 17, channel 31 # rocid = 51, crateid = 43, moduleid = 1021 (new), chanid = 27121 (new) #select * from Crate where rocid = "51"; #select * from Module where crateid = '43'; #select * from Channel where moduleid = 1021; # F1TDC PSC: rocstpsc1, slot 4, channel 31 # rocid = 95, crateid = 14, moduleid = 124, chanid = 1824 #select * from Crate where rocid = "95"; #select * from Module where crateid = '14'; #select * from Channel where moduleid = 124; # FADC250 TAGH: roctagh1, slot 19, channel 15 #rocid = 73, crateid = 2, moduleid = 30, chanid = 368 #select * from Crate where rocid = "73"; #select * from Module where crateid = '2'; #select * from Channel where moduleid = 30; # FADC250 PS: rocps2, slot 13, channel 15 # rocid = 84, crateid = 13, moduleid = 1022, chanid = 27122 #select * from Crate where rocid = "84"; #select * from Module where crateid = '13'; #select * from Channel where moduleid = 1022; #check to see if it worked: #select * from Channel where moduleid = 54; #select * from Channel where moduleid = 771; #select * from Channel where moduleid = 1021; #select * from Channel where moduleid = 124; #select * from Channel where moduleid = 1022; #select * from Channel where moduleid = 30; # TRIGGER SUPERVISOR TIME # FDC: rocfdc1, slot 17, channel 15 # rocid = 51, crateid = 43, moduleid = 1021 (new), chanid = 27122 (new) #select * from Crate where rocid = "51"; #select * from Module where crateid = '43'; #select * from Channel where moduleid = 1021; # cur.execute("INSERT INTO RF VALUES ('FDC', 1, 27122)") # cur.execute("INSERT INTO Channel Values (27122, 1021, 'RF-FDC-Trig', 15, 'RF', 'tdc_chanid', 1)") #rocfdc1 trigger supervisor