Project

General

Profile

Useful Commands and Files for DB Configuration

{{last_modified}}

Over the past few weeks I have worked quite extensively with the NOvA configuration management and I am trying to keep some notes for future reference here.

General Setup

This incantation sets up the database interface:

setup_online
source `which setupNovaDBEnvVars.sh`

Database Queries

Here are some helpful functions that are available in the environment:

showDBTables

showDBColumns FCCDAQ.datadriven_triggers

showGlobalCfg

ShowNamedConfigDetails DAQ InitialGlobalConfig DCS FCCDAQ
ShowNamedConfigDetails DAQ 3172

FlattenNamedConfiguration DAQ InitialGlobalConfig DCS FCCDAQ

The following command can be used to run general PSQL queries:

runDBQuery "PSQL Query" 

Here are some examples for the different detectors and tables that I have worked with:

FCCDAQ (on novatest01)

runDBQuery "select * from fccdaq.datadriven_triggers order by id desc" 
runDBQuery "insert into fccdaq.datadriven_triggers ("name","enableflag","prescale","subsyscfgid","inserttime","insertuser") values ('DDenergy',true,1,9520,now(),'mfrank')" 

runDBQuery "select * from fccdaq.ddt_manager_connect_parameters order by id desc" 
runDBQuery "select id,hostname,nprocesses,subsyscfgid,inserttime from fccdaq.ddt_manager_connect_parameters order by id desc" 
runDBQuery "insert into fccdaq.ddt_manager_connect_parameters ("hostname","nprocesses","configpath","subsyscfgid","inserttime","insertuser") values ('default',2,'/home/novadaq/ddt/current.fcl',9568,now(),'mfrank')" 

runDBQuery "select * from fccdaq.named_subsystem_configurations order by id desc" 

NDOS

runDBQuery "select * from ndos.datadriven_triggers order by id desc" 
runDBQuery "insert into ndos.datadriven_triggers ("name","enableflag","prescale","subsyscfgid","inserttime","insertuser") values ('DDenergy',true,1,9520,now(),'mfrank')" 

runDBQuery "select * from ndos.ddt_manager_connect_parameters order by id desc" 
runDBQuery "insert into ndos.ddt_manager_connect_parameters ("hostname","nprocesses","configpath","subsyscfgid","inserttime","insertuser") values ('default',2,'/home/novadaq/ddt/current.fcl',9568,now(),'mfrank')" 

runDBQuery "select * from ndos.named_subsystem_configurations order by id desc" 

FD

runDBQuery "select * from fardet.datadriven_triggers order by id desc" 
runDBQuery "insert into fardet.datadriven_triggers ("name","enableflag","prescale","subsyscfgid","inserttime","insertuser") values ('DDenergy',true,1,9520,now(),'mfrank')" 

runDBQuery "select * from fardet.ddt_manager_connect_parameters order by id desc" 
runDBQuery "insert into fardet.ddt_manager_connect_parameters ("hostname","nprocesses","configpath","subsyscfgid","inserttime","insertuser") values ('default',2,'/home/novadaq/ddt/current.fcl',9568,now(),'mfrank')" 

runDBQuery "select * from fardet.named_subsystem_configurations order by id desc" 

XML File Generation

There is a suite of helpful XML generation binaries that are available in the NovaDAQConfiguration test area:

GenerateSampleGTRunCfgXML

GenerateSampleDDTConnectCfgXML

DB Table Creation

Here is how you create a new table in the database:

createTableInDB -u mfrank -d FCCDAQ -f NovaDatabase/tables/DAQConfig/DataDrivenTriggers.xml

createTableInDB -u mfrank -d FCCDAQ -f NovaDatabase/tables/DAQConfig/DDTManagerConnectParameters.xml

Jon recently added the -u option, so you might have to check out the latest version of NovaDatabase if it is not available in the base release.

The table now exists in the database, so you can see it with runDBQuery.

To fill the table with it's first instance, try modifying this ad hoc script copied from several written by Kurt.

However, you will need to make sure to add its information to several files, so it can be picked up for things such as Flattening and in the DAQConfigEditor.

DB Column Creation

Here are the commands that I used to create a new column in the dcm_application_run_ parameters:

runDBQuery "alter table fccdaq.dcm_application_run_parameters add monitorfebstatustimeinterval integer" 
runDBQuery "alter table fccdaq.dcm_application_run_parameters add monitorfebstatuslimit integer" 
runDBQuery "alter table fccdaq.dcm_application_run_parameters alter monitorfebstatustimeinterval set not null" 
runDBQuery "alter table fccdaq.dcm_application_run_parameters alter monitorfebstatuslimit set not null" 
runDBQuery "update fccdaq.dcm_application_run_parameters set monitorfebstatustimeinterval=1, monitorfebstatuslimit=1" 

Important Files

In addition to the list below, please see the Summary of existing ConfigManagement code and DB tables.

Here are all the files that I had to create/edit to get the DDT Manager configuration properly implemented:

NovaDatabase/tables/DAQConfig/DDTManagerConnectParameters.xml

NovaDatabase/tables/DAQConfig/addDDTConnectParams.sh

DDTManager/config/DDTConfig.xsd
generates: 
     DDTManager/cxx/include/DDTConfig.h
     DDTManager/cxx/src/DDTConfig.cpp

DatabaseUtils/cxx/include/DAQConfig/DDTConnectConfig.h
DatabaseUtils/cxx/src/DAQConfig/DDTConnectConfig.cpp

DatabaseUtils/cxx/src/GUI/DAQConfigEditorDisplay.cpp

DatabaseUtils/cxx/src/DAQConfig/FlattenNamedConfiguration.cc

NovaDAQConfiguration/cxx/include/DDTConnectConfigWrapper.h
NovaDAQConfiguration/cxx/src/DDTConnectConfigWrapper.cpp

NovaDAQConfiguration/cxx/src/CfgMgrDBHandler.cpp

NovaDAQConfiguration/cxx/test/GenerateSampleDDTConnectCfgXML.cc

Summary of existing ConfigManagement code and DB tables shows the status of most of these files for all of the different tables.