# Presentation: 219037

## EPICS DB in RDB

- K.Vijayan
- June 2006

## DLS Schema contains

**EPICS**
- Domain, Sub domain, Technical Area, Component, Subsystem, Record Specifier
- Crate
- Device
- IOC
- DBD
- DBGroups
- DB File
- Archiver group files
- DB file Templates
- IOC, Carrier & IP Cards

**Notes:**
DLS RDB contains Epics, Cables, Eqp Tracking, eLog and Detectors Specification database

EPICS
We are capturing the device names, crate type, crate,
IOC information and the Expanded db (after substitution) files to RDB. 
Rack location and the devices in the rack are also in rdb.

## Device Naming

**Domain, Subdomain, Technical Area & Component**
**Device - DD[SSS]-TT-CCCCC-NN**
**Examples:**
**	****LI-VA-PIRG-01**
**	****BR01C-MA-VSTR-01**
**	****BS-MA-QUAD-01**
**	****SR01A-MA-QUAD-10**
**Subsystem **
**Record Specifier**
**PV Name = Device:[Subsystem]:Record Specifier**
**Example:**
**     ****BL06I-MO-MONO-01:AX1:HOMEF**

**Notes:**
DD – Domain identifies a major area of the accelerator complex.

SSS – Optional - 
	Sub-domain is used to further subdivide complex domains such 
	as SR (Storage Ring).  Each domain has its own separately defined 
	list of sub-domains. 

TA – Technical area defines the technical sub-system to which the device 
     belongs.  It can also be used to help identify the group or person 
     responsible for the device.

CCCCC - defines the particular type of device.

NN - A two digit number identifying a particular instance of a device.

PV Name :
EPICS record reference names are constructed from device names by appending a
record specifier (and optionally, a sub-system name)  as follows

Device ID[:Subsystem]:Record Specifier

Sub system – sub system is intended to allow the use of hierarchy within 
the EPICS IOC database (i.e. Visual DCT hierarchy) 
The total length of sub system and record specifier may be up to 
9 characters.  However, if the sub system component is not used then record 
specifier may be up to 10 characters in length.  (This accommodates the : 
delimiter between sub system and the record.) 
Separate tables for each of device, subsystem and record specifier.

## Device 

**Notes:**
This is the list of devices in RDB.
Most of them are created when uploading the expanded db file.
You can always keep track, when the device is last modified and the modified user.

## Expanded DB File in RDB

- RDB

- Perl Scripts
- Expanded
- DB Files

- Perl Scripts
- Expanded
- DB Files &
- Template
- DB Files

- Front end
- screens (web browser)
- using Apache/PHP

- Epics Record
- Template File

- Substitution
- File

- dbLoadTemplate

- Perl Scripts
- DBD File

- Perl Scripts
- Template
- DB Files

**Notes:**
Initially all the DBD files are uploaded to the RDB.
User will manually run the Perl script to upload the expanded db file to RDB.
Using web browser, user can view the uploaded db file.

## Upload DB file to RDB

- Perl script is used to upload the expanded db file to RDB. Whenever new release of DB file, user will run this Perl script to upload to RDB
- During the upload process of expanded DB file, the device names (id) are inserted in to Device  table from the PV name (device_id:[subsystem]:record specifier).
- We can view the user name and the date time of device/record creation.
- [kv73@pc0026 ~]$ read_db.pl -h
- USAGE: /home/tools/bin/read_db.pl [options]
- 	    -h               : help
- 	    -v               : verbose
- 	    -f DB-file       : EPICS DB file to read
- 	    -g dbgroup_id    : logic to put records under
- 	    -i Database Instance : D-Development, P-Production
- 	    -r Remove RDB Internal Values: <Default value is N-No> Y
- 	    -d Delete extra PV's from RDB: <Default value is N-No> Y
- 	    -a Adds dbgroup in RDB: <Input IOC NAME> e.g.LI-VA-IOC-01
- 	    -E Input Epics Version in RDB: <R3.13.9> e.g.R3.14.6
- 	Reads an EPICS DB file into the relational database.
- 	Does remove existing RDB entries, if you select option -d to Y, else just adds the DB file
- 	information. For a from-scratch import, first run
- 	'dbgroups.pl -D'.

**Notes:**
This upload process in done using Perl scripts (thanks to Kay- Uwe Kasemir)

I modified the same Perl scripts according to our requirements. Most of our 
tables will have two columns updated_by and updated_date. While uploading 
the expanded db file to rdb User id and the date time is captured in the 
oracle tables. So later we can view which user is using this expanded db file 
and the date time of last modification. 

After uploading the expanded db file to rdb,  user can modify or delete any  
PV’s in the RDB using the web browser.

## DB File

**Notes:**
This is the ER diagram involved in uploading the scripts

## DB Records

**Notes:**
After uploading an expanded DB file to RDB, users can view the db file as 
records and fields using this record maintenance and field maintenance screen.

Next to record id column there is “D” button, after clicking this “D” 
button user will able to see all the fields of the record type of the particular
record id (PV). And they can add any field or modify using this program.

## DB Fields

## Archiver Configuration

- Archiver configuration file
- View and Modify Archiver Configuration
- Import/Export Archiver Configuration

**Notes:**
All the archiver configuration files are uploaded to RDB. 
So that all the pv’s are validated against the naming convention.
User can view and modify the configuration parameters.
User can export the existing archive configuration from RDB.

## Archiver Configuration

## Import/Export Archiver Configuration

## Crate Details

- Using Equipment Tracking
- Equipment details
- IOC
- IP Carrier
- IP Module

**Notes:**
Equipment Tracking will have all the information of the equipment like Manufacturers, model numbers, type of the equipment, location (in house or in subcontract) and responsible user for that equipment.
All the crate, IOC, IP carrier and IP modules are added in equipment Tracking and each equipment are uniquely identified by equipment ID.

## View Child Equipments

**Notes:**
If we select a crate and you can view all the child equipments with in that.
e.g. Crate 
       ..IOC
       ..IP carrier
       ....IP Module
       ....IP Module
       ..Transition card
      etc.

## IOC – Equipment Detail

**Notes:**
If we click the V button, then we can view the Epics IOC information and the Equipment details of the IOC also.

## View 

## What we are using

-  Oracle 9i on Red Hat Linux AS v2.1 - Dell Server
-  Apache Web Server
-  PHP
- User interface screens / forms for data input & reading  using web browser
-  Perl
-  for uploading of flat files to the RDB & vice versa
-  ER Studio
-  Logical and Physical design of the EPICS database
- Plan to move Oracle 10g on Red Hat Linux AS 4.0 – Dell Server

## THE END