#!/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 RF WHERE system = 'ST'") rf_rows = cur.fetchall() if len(rf_rows) != 0: print 'RF signal already moved from PS to ST' sys.exit(-1) #ORIGINAL: # FADC250 PS: rocps2, slot 13, channel 15 # rocid = 84, crateid = 13, moduleid = 1022, chanid = 27122 #EARLIER MOVED (when adding tpol): #UPDATE: RF was moved from rocps2, but not clear where yet. set channel to -1 until it is known #cur.execute("UPDATE Channel SET channel=16 WHERE chanid='27122'") #NEW: # FADC250 ST: rocst, slot 13, channel 15 (ONLY THE ROC CHANGED) # rocid = 94, crateid = 10, moduleid = 1024, chanid = 27122 #Add new ST Module: cur.execute("INSERT INTO Module Values (1024, 10, 13, 'FADC250', '')") #rocst #Move channel from PS to new ST Module cur.execute("UPDATE Channel SET moduleid='1024', name='RF-ST-FADC250', channel='15' WHERE chanid='27122'") #Update RF table Row #CREATE TABLE RF(system TEXT, type TEXT, tdc_chanid INT, adc_chanid INT); cur.execute("UPDATE RF SET system='ST' WHERE system='PS'") # https://logbooks.jlab.org/entry/3322743 # https://halldweb.jlab.org/wiki/index.php/HallD_Online_IP_Name_And_Address_Conventions