#!/usr/bin/python # # # 4/23/2015 Paul Mattione # # # This script adds the Triplet Polarimeter 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 = 'TPOL'") rf_rows = cur.fetchall() if len(rf_rows) != 0: print 'TPOL table was already created' sys.exit(-1) # make TPOL table //sector 1 -> 32 //ring 1 -> 24 cur.execute("CREATE TABLE TPOL(sector INT, ring INT, adc_chanid INT)") # sectors cur.execute("INSERT INTO TPOL VALUES (1, 0, 27123)") cur.execute("INSERT INTO TPOL VALUES (2, 0, 27124)") cur.execute("INSERT INTO TPOL VALUES (3, 0, 27125)") cur.execute("INSERT INTO TPOL VALUES (4, 0, 27126)") cur.execute("INSERT INTO TPOL VALUES (5, 0, 27127)") cur.execute("INSERT INTO TPOL VALUES (6, 0, 27128)") cur.execute("INSERT INTO TPOL VALUES (7, 0, 27129)") cur.execute("INSERT INTO TPOL VALUES (8, 0, 27130)") cur.execute("INSERT INTO TPOL VALUES (9, 0, 27131)") cur.execute("INSERT INTO TPOL VALUES (10, 0, 27132)") cur.execute("INSERT INTO TPOL VALUES (11, 0, 27133)") cur.execute("INSERT INTO TPOL VALUES (12, 0, 27134)") cur.execute("INSERT INTO TPOL VALUES (13, 0, 27135)") cur.execute("INSERT INTO TPOL VALUES (14, 0, 27136)") cur.execute("INSERT INTO TPOL VALUES (15, 0, 27137)") cur.execute("INSERT INTO TPOL VALUES (16, 0, 27138)") cur.execute("INSERT INTO TPOL VALUES (17, 0, 27139)") cur.execute("INSERT INTO TPOL VALUES (18, 0, 27140)") cur.execute("INSERT INTO TPOL VALUES (19, 0, 27141)") cur.execute("INSERT INTO TPOL VALUES (20, 0, 27142)") cur.execute("INSERT INTO TPOL VALUES (21, 0, 27143)") cur.execute("INSERT INTO TPOL VALUES (22, 0, 27144)") cur.execute("INSERT INTO TPOL VALUES (23, 0, 27145)") cur.execute("INSERT INTO TPOL VALUES (24, 0, 27146)") cur.execute("INSERT INTO TPOL VALUES (25, 0, 27147)") cur.execute("INSERT INTO TPOL VALUES (26, 0, 27148)") cur.execute("INSERT INTO TPOL VALUES (27, 0, 27149)") cur.execute("INSERT INTO TPOL VALUES (28, 0, 27150)") cur.execute("INSERT INTO TPOL VALUES (29, 0, 27151)") cur.execute("INSERT INTO TPOL VALUES (30, 0, 27152)") cur.execute("INSERT INTO TPOL VALUES (31, 0, 27153)") cur.execute("INSERT INTO TPOL VALUES (32, 0, 27154)") #rocid 84, crateid 13 # Add modules for TPOL (moduleid|crateid|slot|type|SN) #others already exist cur.execute("INSERT INTO Module Values (1023, 13, 14, 'FADC250', '')") #rocps2 # Add channels for TPOL (chanid|moduleid|name|channel|system|col_name|enable) # sector cur.execute("INSERT INTO Channel Values (27123, 1022, 'TPOL-S1', 0, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27124, 1022, 'TPOL-S2', 1, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27125, 1022, 'TPOL-S3', 2, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27126, 1022, 'TPOL-S4', 3, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27127, 1022, 'TPOL-S5', 4, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27128, 1022, 'TPOL-S6', 5, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27129, 1022, 'TPOL-S7', 6, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27130, 1022, 'TPOL-S8', 7, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27131, 1022, 'TPOL-S9', 8, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27132, 1022, 'TPOL-S10', 9, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27133, 1022, 'TPOL-S11', 10, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27134, 1022, 'TPOL-S12', 11, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27135, 1022, 'TPOL-S13', 12, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27136, 1022, 'TPOL-S14', 13, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27137, 1022, 'TPOL-S15', 14, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27138, 1022, 'TPOL-S16', 15, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27139, 1023, 'TPOL-S17', 0, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27140, 1023, 'TPOL-S18', 1, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27141, 1023, 'TPOL-S19', 2, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27142, 1023, 'TPOL-S20', 3, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27143, 1023, 'TPOL-S21', 4, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27144, 1023, 'TPOL-S22', 5, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27145, 1023, 'TPOL-S23', 6, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27146, 1023, 'TPOL-S24', 7, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27147, 1023, 'TPOL-S25', 8, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27148, 1023, 'TPOL-S26', 9, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27149, 1023, 'TPOL-S27', 10, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27150, 1023, 'TPOL-S28', 11, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27151, 1023, 'TPOL-S29', 12, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27152, 1023, 'TPOL-S30', 13, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27153, 1023, 'TPOL-S31', 14, 'TPOL', 'adc_chanid', 1)") cur.execute("INSERT INTO Channel Values (27154, 1023, 'TPOL-S32', 15, 'TPOL', 'adc_chanid', 1)") #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'") print 'Done' # https://halldweb.jlab.org/wiki/index.php/HallD_Online_IP_Name_And_Address_Conventions