Mapping the SMT in the EPICS database


by Freya Blekman, NIKHEF, Amsterdam, the Netherlands.

Contents:

  1. The Excel files
  2. how to get the information to SQL commands
  3. General structure
  4. The python script setupSMT.py
  5. the SQL macro setupWholeSMT.sql
  6. changing the format of the Excel sheet and still getting correct SQL commands
  7. changing the location of the .sql files created by Visual Basic

  1. the Excel files
  2. The mapping of all components of the SMT is done and maintained by Breeze Quinn. The most recent version can usually be found in d0server4/users/quinn/excel/ These excel sheets contain much more information than is necessary for our purposes. This is why I added an extra worksheet which gathers all the info necessary and creates the appropriate SQL commands. The most recent modified version of the spreadsheet can be found in the following dir on d0server4: d0server4/users/fblekman/ExceltoSQL/.
    This directory also contains a MS Visual Basic Module which can be used to collect and save the SQL commands. This VB module is also present in CVS, in onl_smtcalib/oracle/VBmodule/VBmodule.bas.

  3. How to get the information to SQL commands
  4. When looking at the file excel file in d0server4/user/fblekman/exceltoSQL/ one can see that it contains several worksheets.
    These are direct copies from the Sector_1/2/3/4/5/6VRB files in the excel documents created by Breeze. The collect_columns sheet contains the macros to extract the information from all different cells. There are four buttons on there, one extracts all info, two create the SQL commands, pressing the fourth button will save the commands in files (and ask you to confirm this)

  5. General structure
  6. The SMT Epics database is installed in the following way:

    After declaration of all different types of tables, the HDIs and SVX tables are inserted. Then the Interface boards, Sequencers and VRBs (and their channels, etc) are added. At this time a 1 to 1 mapping is still used in the database.

    The Interface channels are connected to dummy HDIs which are deleted after the proper HDI is associated with the interface channel which belongs to it. Eventually, the interface channels are associated with the right Sequencer channels, which in their place are then assigned to certain VRB channels.

    All these different steps consist of large amounts of SQL commands. The SQL commands belonging to each different step or part of the DAQ chain are saved in different files, to make it easier to modify single parts of it.

    When extracting onl_smtcalib from CVS, the /onl_smtcalib/oracle/ directory will have the following file structure:

    drwxr-xr-x    2 fblekman D0            57 Feb  7 18:32 CVS

    -rw-r--r--    1 fblekman D0         25980 Feb  7 19:00 createDb.sql

    drwxr-xr-x    3 fblekman D0          4096 Feb  7 19:00 VBmodule

                                                            -> contains the Visual Basic Module

    drwxr-xr-x    7 fblekman D0          4096 Feb  7 19:00 filesFromExcel

                                                            -> files created in excel

    -rw-r--r--    1 fblekman D0           537 Feb  7 19:00 setupWholeSMT.sql

    drwxr-xr-x    3 fblekman D0            51 Feb  7 19:00 setupSMT

     -> setupSMT.py

    The files and directories used by setupWholeSMT.sql are underlined.

  7. The python script setupSMT/setupSMT.py
  8. Run this script to create all SQL files needed for the setup of the database with the oracle account of your choice. One can also set the script to connect to the fblekman@d0on ORACLE account itself (by setting one of the variables at the top of the script), but at the moment it is more convenient to write to separate files first. If this script is not ran first, the setupWholeSMT.sql macro won't have all the files it needs. After running setupSMT.py python script, the setupSMT directory will contain a collection of SQL files.

  9. The SQL macrosetupWholeSMT.sql
  10. This macro runs all different sql macros in the right order.

    Look what's in there to get an idea of how it works. Essentially it first runs SetupDb.sql and then installs the HDIs, SVX chips, Crates, VRB and SEQ Controllers, Interface Boards, Sequencers and VRBs and their respective channels.

    After setting up the basic framework, the connections between the different components are set, using the files created by the visual basic macro in excel. Eventually, this leads to the same connection between the components as in the real SMT.

  11. Changing the Excel sheet and still getting correct SQL commands
  12. The Visual Basic code for the Excel sheet is set up to ensure that the ingoing exceed worksheet can be changed fairly easily without having to completely re-write the VB code. To modify the VB code, open excel, select the SQL_Commands worksheet and right-click on the desired macro button. Then Choose "Assign Macro" to open a window and view the VB code. One of the choices there is "Edit", this opens the Microsoft Visual Basic Editor. (which can also be opened via the task bar.) The variables that can be modified easily are situated at the top of the VB script:

    After changing any of these values the VB code should be recompiled. This can be done in the "debug" menu in the taskbar. Forgetting to recompile the code can leave you with no visual basic module at all belonging to the excel sheet. It is essential to compile the module before saving the excel file.

    The visual basic module can also be imported (if you're getting a fresh module from CVS) or exported (if you want to save your module and then ftp it to one of the unix machines to update the version in CVS). These options can be found in the "file" menu in the taskbar.

  13. Changing the location of the .sql files created by Visual Basic
  14. Open the macro that saves the SQL commands in Excel. (see 6.)  The filenames are defined at the top of the subroutine. Don’t forget to recompile and save the macro before closing excel.


    last modified: Thursday February 7, 2001, by Freya Blekman, fblekman@fnal.gov, NIKHEF Amsterdam, the Netherlands.