
--   Add a configuration to the 10% test stand hardware
--   ***********************************************************************************
--
--   Oracle PL/SQL Script For Testing of D0 SMT Online Database
--
--   This Script Inserts Testing Values into D0 SMT Online Database
--
--   To Run This Script, Login Your Oracle Account. Assume This Script
--   (SMT_OnlineDB_Test.sql) Is Located Under D:\fanxl\oracle\, Type:
--
--          @D:\fanxl\oracle\SMT_OnlineDB_Test.sql
--
--   Author: Xiaoling Fan
--   Institution: Northwestern University
--
--   Creation Date: Jan 4, 2000
--
--   Modified: Harald Fox,  Mar 29, 2000
--   ************************************************************************************

declare

i               int := 0;
Max_Channel     int := 64000;
Max_Crate       int := 10;

begin


--   -----------------------------------------------------------------------------------
--
--   Part 3, SMT Detector Configuration Database Testing
--
--   -----------------------------------------------------------------------------------

-- table SMT_VRB_CRATE

insert into SMT_VRB_CRATE
       (CRATE_SERIAL_NO, CRATE_ID, DESCRIPTION, GS_SECTOR, EPICS_NAME, CONTROLLER_NAME, CONTROLLER_TYPE,
        HOST_NAME, STATUS)
       values
       ('VRBCR-01', 1, 'VRB_CRATE-NU-01', '0x6c', 'NUSIL001', 'nusil001', 'mv2300', 'iris.phys.nwu.edu', 'test');

-- table SMT_SEQ_CRATE

insert into SMT_SEQ_CRATE
       (CRATE_SERIAL_NO, CRATE_ID, DESCRIPTION, STATUS)
       values
       ('SEQCR-01', 1, 'SEQ_CRATE-NU-01', 'test');

-- table SMT_INT_CRATE

insert into SMT_INTERFACE_CRATE
       (CRATE_SERIAL_NO, CRATE_ID, DESCRIPTION, STATUS)
       values
       ('INTCR-01', 1, 'INT_CRATE-NU-01', 'test');





-- table SMT_SVX_CHIP

insert into SMT_SVX_CHIP (SVX_SERIAL_NO) values ('3322-42_00');
insert into SMT_SVX_CHIP (SVX_SERIAL_NO) values ('3322-42_01');
insert into SMT_SVX_CHIP (SVX_SERIAL_NO) values ('3322-42_02');

insert into SMT_SVX_CHIP (SVX_SERIAL_NO) values ('3322-32_00');
insert into SMT_SVX_CHIP (SVX_SERIAL_NO) values ('3322-32_01');
insert into SMT_SVX_CHIP (SVX_SERIAL_NO) values ('3322-32_02');


--   -----------------------------------------------------------------------------------
--
--   Part 3, SMT Detector Configuration Database Testing
--
--   -----------------------------------------------------------------------------------


insert into SMT_DAQ_VRBC
       (VRBC_SERIAL_NO, VRBC_ID, DESCRIPTION, CRATE_SERIAL_NO, LOCATOR, EPICS_NAME, STATUS)
       values
       ('VRBC-01', 1, 'VRBC-NU-01', 'VRBCR-01', 14, 'SMT_VRBC_0114', 'test');

-- -- table SMT_DAQ_SEQC
-- 
-- insert into SMT_DAQ_SEQC
-- 	     (SEQC_SERIAL_NO, SEQC_ID, DESCRIPTION, CRATE_SERIAL_NO, LOCATOR, EPICS_NAME, STATUS)
-- 	     values
-- 	     ('SEQC-01', 1, 'SEQC-NU-01', 'SEQCR-01', 0, 'SMT_SEQC_0100', 'test');
-- insert into SMT_DAQ_SEQC
-- 	     (SEQC_SERIAL_NO, UPPER, SEQC_ID, DESCRIPTION, CRATE_SERIAL_NO, LOCATOR, EPICS_NAME, STATUS)
-- 	     values
-- 	     ('SEQC-02', 0, 2, 'SEQC-NU-02', 'SEQCR-01', 0, 'SMT_SEQC_0101', 'test');


-- table SMT_DAQ_VBD

insert into SMT_DAQ_VBD
       (VBD_SERIAL_NO, VBD_ID, DESCRIPTION, CRATE_SERIAL_NO, LOCATOR, EPICS_NAME, STATUS)
       values
       ('VBD-01', 1, 'VBD-NU-01', 'VRBCR-01', 4, 'SMT_VBD_0104', 'test');



-- table SMT_DAQ_HDI

insert into SMT_DAQ_HDI
       (HDI_SERIAL_NO, LOCATOR, DESCRIPTION, CAL_ID, ENABLE,
        HDI_TYPE, BARREL$SECTOR, LAYER$DISK, LADDER$WEDGE, NUMBER_OF_SVX_CHIP, 
        HDI_VIEW, STATUS)
       values
       ('3322-42', 'B', 'HDI-NU-001', 4010, 1, 'R30', 1, 1, 1, 3, 'TOP', 'test');

insert into SMT_DAQ_HDI
       (HDI_SERIAL_NO, LOCATOR, DESCRIPTION, CAL_ID, ENABLE,
        HDI_TYPE, BARREL$SECTOR, LAYER$DISK, LADDER$WEDGE, NUMBER_OF_SVX_CHIP, 
        HDI_VIEW, STATUS)
       values
       ('3322-32', 'B', 'HDI-NU-002', 4011, 1, 'R30', 1, 1, 1, 3, 'TOP', 'test');



-- table SMT_DAQ_INTERFACE

insert into SMT_DAQ_INTERFACE
       (INTERFACE_SERIAL_NO, INTERFACE_ID, DESCRIPTION, ENABLE, CRATE_SERIAL_NO, LOCATOR, 
        EPICS_NAME, STATUS)
       values
       ('INT-001', 1, 'INTERFACE-NU-01', 1, 'INTCR-01', 1, 'SMT_INT_0101', 'test');


-- table SMT_DAQ_INTERFACE_CHANNEL

insert into SMT_DAQ_INTERFACE_CHANNEL
       (INTERFACE_SERIAL_NO, INTERFACE_CHANNEL_ID, HDI_SERIAL_NO_B)
       values
       ('INT-001', 1, '3322-42');

insert into SMT_DAQ_INTERFACE_CHANNEL
       (INTERFACE_SERIAL_NO, INTERFACE_CHANNEL_ID, HDI_SERIAL_NO_B)
       values
       ('INT-001', 2, '3322-42');

insert into SMT_DAQ_INTERFACE_CHANNEL
       (INTERFACE_SERIAL_NO, INTERFACE_CHANNEL_ID, HDI_SERIAL_NO_B)
       values
       ('INT-001', 3, '3322-32');

insert into SMT_DAQ_INTERFACE_CHANNEL
       (INTERFACE_SERIAL_NO, INTERFACE_CHANNEL_ID, HDI_SERIAL_NO_B)
       values
       ('INT-001', 4, '3322-42');


-- table SMT_DAQ_SEQ

insert into SMT_DAQ_SEQ
       (SEQ_SERIAL_NO, DESCRIPTION, ENABLE, CRATE_SERIAL_NO, LOCATOR,
	EPICS_NAME, CROSSING_WIDTH, SEQ_ID_1, SEQ_ID_2, STATUS)
        values
       ('SEQ-0103', 'SEQ-NU-0103', 1, 'SEQCR-01', 1, 'SMT_SEQ_0103', 40, 1, 1, 'test');



-- table SMT_DAQ_SEQ_CHANNEL

insert into SMT_DAQ_SEQ_CHANNEL
       (SEQ_SERIAL_NO, SEQ_CHANNEL_ID, INTERFACE_SERIAL_NO, INTERFACE_CHANNEL_ID)
       values
       ('SEQ-0103', 1, 'INT-001', 1);

insert into SMT_DAQ_SEQ_CHANNEL
       (SEQ_SERIAL_NO, SEQ_CHANNEL_ID, INTERFACE_SERIAL_NO, INTERFACE_CHANNEL_ID)
       values
       ('SEQ-0103', 2, 'INT-001', 3);

insert into SMT_DAQ_SEQ_CHANNEL
       (SEQ_SERIAL_NO, SEQ_CHANNEL_ID, INTERFACE_SERIAL_NO, INTERFACE_CHANNEL_ID)
       values
       ('SEQ-0103', 3, 'INT-001', 3);

insert into SMT_DAQ_SEQ_CHANNEL
       (SEQ_SERIAL_NO, SEQ_CHANNEL_ID, INTERFACE_SERIAL_NO, INTERFACE_CHANNEL_ID)
       values
       ('SEQ-0103', 4, 'INT-001', 4);



-- table SMT_DAQ_VRB
 
insert into SMT_DAQ_VRB
       (VRB_SERIAL_NO, VRB_ID, DESCRIPTION, ENABLE, CRATE_SERIAL_NO, LOCATOR, EPICS_NAME, CHAN_ENABLE, STATUS)
       values
       ('VRB-001', 1, 'VRB-NU-001', 1, 'VRBCR-01', 10, 'SMT_VRB_010A', 2, 'test');


insert into SMT_DAQ_VRB
       (VRB_SERIAL_NO, VRB_ID, DESCRIPTION, ENABLE, CRATE_SERIAL_NO, LOCATOR, EPICS_NAME, CHAN_ENABLE, STATUS)
       values
       ('VRB-002', 2, 'VRB-NU-002', 1, 'VRBCR-01', 13, 'SMT_VRB_010D', 128, 'test');


-- table SMT_DAQ_VRB_CHANNEL

insert into SMT_DAQ_VRB_CHANNEL
       (VRB_SERIAL_NO, VRB_CHANNEL_ID, SEQ_SERIAL_NO, SEQ_CHANNEL_ID)
        values
       ('VRB-001', 1, 'SEQ-0103', 1);

insert into SMT_DAQ_VRB_CHANNEL
       (VRB_SERIAL_NO, VRB_CHANNEL_ID, SEQ_SERIAL_NO, SEQ_CHANNEL_ID)
        values
       ('VRB-001', 2, 'SEQ-0103', 2);

insert into SMT_DAQ_VRB_CHANNEL
       (VRB_SERIAL_NO, VRB_CHANNEL_ID, SEQ_SERIAL_NO, SEQ_CHANNEL_ID)
        values
       ('VRB-001', 3, 'SEQ-0103', 3);

insert into SMT_DAQ_VRB_CHANNEL
       (VRB_SERIAL_NO, VRB_CHANNEL_ID, SEQ_SERIAL_NO, SEQ_CHANNEL_ID)
        values
       ('VRB-001', 4, 'SEQ-0103', 4);





insert into SMT_DAQ_VRB_CHANNEL
       (VRB_SERIAL_NO, VRB_CHANNEL_ID, SEQ_SERIAL_NO, SEQ_CHANNEL_ID)
        values
       ('VRB-002', 4, 'SEQ-0103', 2);


-- table SMT_DAQ_SVX

insert into SMT_DAQ_SVX
       (SVX_SERIAL_NO, HDI_SERIAL_NO, SVX_ID, ADC_MAX, RAMP_TRIM, LAST_CHIP, 
        READ_NEIGHBOR, READ_ALL, POLARITY, PIPELINE, PREAMP_BAND, THRESHOLD, AVDD, 
	AVDD2, DVDD, V_DEPLETION, STATUS)
        values
        ('3322-42_00', '3322-42', 128, 129, 512,
         1, 1, 0, 1, 2, 16, 4, 5.00, 3.50, 4.95, 40.00, 'test');

insert into SMT_DAQ_SVX
       (SVX_SERIAL_NO, HDI_SERIAL_NO, SVX_ID, ADC_MAX, RAMP_TRIM, LAST_CHIP, 
        READ_NEIGHBOR, READ_ALL, POLARITY, PIPELINE, PREAMP_BAND, THRESHOLD, AVDD, 
	AVDD2, DVDD, V_DEPLETION, STATUS)
        values
        ('3322-42_01', '3322-42', 129, 129, 512,
         1, 1, 0, 1, 2, 16, 4, 5.00, 3.50, 4.95, 40.00, 'test');

insert into SMT_DAQ_SVX
       (SVX_SERIAL_NO, HDI_SERIAL_NO, SVX_ID, ADC_MAX, RAMP_TRIM, LAST_CHIP, 
        READ_NEIGHBOR, READ_ALL, POLARITY, PIPELINE, PREAMP_BAND, THRESHOLD, AVDD, 
	AVDD2, DVDD, V_DEPLETION, STATUS)
        values
        ('3322-42_02', '3322-42', 130, 129, 512,
         0, 1, 0, 1, 2, 16, 4, 5.00, 3.50, 4.95, 40.00, 'test');



insert into SMT_DAQ_SVX
       (SVX_SERIAL_NO, HDI_SERIAL_NO, SVX_ID, ADC_MAX, RAMP_TRIM, LAST_CHIP, 
        READ_NEIGHBOR, READ_ALL, POLARITY, PIPELINE, PREAMP_BAND, THRESHOLD, AVDD, 
	AVDD2, DVDD, V_DEPLETION, STATUS)
        values
        ('3322-32_00', '3322-32', 128, 129, 512,
         1, 1, 0, 1, 2, 16, 4, 5.00, 3.50, 4.95, 40.00, 'test');

insert into SMT_DAQ_SVX
       (SVX_SERIAL_NO, HDI_SERIAL_NO, SVX_ID, ADC_MAX, RAMP_TRIM, LAST_CHIP, 
        READ_NEIGHBOR, READ_ALL, POLARITY, PIPELINE, PREAMP_BAND, THRESHOLD, AVDD, 
	AVDD2, DVDD, V_DEPLETION, STATUS)
        values
        ('3322-32_01', '3322-32', 129, 129, 512,
         1, 1, 0, 1, 2, 16, 4, 5.00, 3.50, 4.95, 40.00, 'test');

insert into SMT_DAQ_SVX
       (SVX_SERIAL_NO, HDI_SERIAL_NO, SVX_ID, ADC_MAX, RAMP_TRIM, LAST_CHIP, 
        READ_NEIGHBOR, READ_ALL, POLARITY, PIPELINE, PREAMP_BAND, THRESHOLD, AVDD, 
	AVDD2, DVDD, V_DEPLETION, STATUS)
        values
        ('3322-32_02', '3322-32', 130, 129, 512,
         0, 1, 0, 1, 2, 16, 4, 5.00, 3.50, 4.95, 40.00, 'test');



end;                  
/                     
                      
--   End of the Script

