Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:22:59

0001 -- creates the tables for the ecal daq configuration 
0002 -- 12-1-2007
0003 -- by F. Cavallari and P. Musella
0004 -- updated by FC on 14/3/2008
0005 -- ********** ECAL_RUN 
0006 
0007 
0008 CREATE TABLE ECAL_RUN_MODE_DEF (
0009         DEF_ID  NUMBER NOT NULL
0010      , RUN_MODE_STRING VARCHAR2(20)
0011 );
0012 ALTER TABLE ECAL_RUN_MODE_DEF ADD CONSTRAINT ecal_run_mode_def_pk PRIMARY KEY (def_id);
0013 ALTER TABLE ECAL_RUN_MODE_DEF ADD CONSTRAINT ecal_run_mode_def_uk1 UNIQUE (run_mode_string);
0014 
0015 CREATE SEQUENCE ecal_run_mode_def_sq INCREMENT BY 1 START WITH 1;
0016 CREATE trigger ecal_run_mode_def_trg
0017 before insert on ECAL_RUN_MODE_DEF
0018 for each row
0019 begin
0020 select ecal_run_mode_def_sq.NextVal into :new.def_id from dual;
0021 end;
0022 /
0023 
0024 prompt FUNCTION get_run_mode_def_id;
0025 create or replace function get_run_mode_def_id( run_mode IN VARCHAR ) return NUMBER
0026 IS
0027         ret NUMBER;
0028 BEGIN
0029         SELECT DEF_ID 
0030                 INTO    ret 
0031                 FROM    ECAL_RUN_MODE_DEF 
0032                 WHERE   RUN_MODE_STRING=run_mode
0033         ;
0034         return (ret);
0035 END;
0036 /
0037 
0038 CREATE TABLE ECAL_RUN_CONFIGURATION_DAT (
0039        CONFIG_ID NUMBER NOT NULL
0040      , TAG VARCHAR2(64) NOT NULL
0041      , VERSION NUMBER(22) NOT NULL
0042      , RUN_TYPE_DEF_ID NUMBER NOT NULL
0043      , RUN_MODE_DEF_ID NUMBER NOT NULL
0044      , NUM_OF_SEQUENCES NUMBER(22) NULL
0045      , DESCRIPTION VARCHAR2(200) NULL
0046      , DEFAULTS NUMBER NULL
0047      , TRG_MODE VARCHAR2(64) NULL
0048      , NUM_OF_EVENTS NUMber NULL
0049      , db_timestamp  TIMESTAMP DEFAULT SYSTIMESTAMP NOT NULL     
0050      , usage_status varchar2(15) DEFAULT 'VALID'     
0051 );
0052 
0053 ALTER TABLE ECAL_RUN_CONFIGURATION_DAT ADD CONSTRAINT ecal_config_pk PRIMARY KEY (config_id);
0054 ALTER TABLE ECAL_RUN_CONFIGURATION_DAT ADD CONSTRAINT ecal_config_uk1 UNIQUE (tag, version);
0055 ALTER TABLE ECAL_RUN_CONFIGURATION_DAT ADD CONSTRAINT ecal_config_fk2 FOREIGN KEY (run_mode_def_id) REFERENCES ECAL_RUN_MODE_DEF (DEF_ID) ;
0056 
0057 CREATE SEQUENCE ecal_run_sq INCREMENT BY 1 START WITH 1;
0058 
0059 
0060 prompt FUNCTION get_run_conf_id;
0061 create or replace function get_run_conf_id( the_tag IN VARCHAR, the_version in NUMBER ) return NUMBER
0062 IS
0063         ret NUMBER;
0064 BEGIN
0065         SELECT CONFIG_ID 
0066                 INTO    ret 
0067                 FROM    ECAL_RUN_CONFIGURATION_DAT r 
0068                 WHERE   r.TAG=the_tag
0069                 AND     r.VERSION=the_version
0070         ;
0071         return (ret);
0072 END;
0073 /
0074 
0075 -- ********** ECAL_SEQUENCE
0076 
0077 CREATE TABLE ECAL_SEQUENCE_TYPE_DEF (
0078         DEF_ID  NUMBER NOT NULL
0079         , RUN_TYPE_DEF_ID NUMBER NOT NULL
0080         , SEQUENCE_TYPE_STRING VARCHAR2(20)
0081 );
0082 ALTER TABLE ECAL_SEQUENCE_TYPE_DEF ADD CONSTRAINT ecal_sequence_type_def_pk  PRIMARY KEY (def_id);
0083 ALTER TABLE ECAL_SEQUENCE_TYPE_DEF ADD CONSTRAINT ecal_sequence_type_def_uk1 UNIQUE (run_type_def_id,sequence_type_string);
0084 
0085 CREATE SEQUENCE ecal_sequence_type_def_sq INCREMENT BY 1 START WITH 1;
0086 CREATE trigger ecal_sequence_type_def_trg
0087 before insert on ECAL_SEQUENCE_TYPE_DEF
0088 for each row
0089 begin
0090 select ecal_sequence_type_def_sq.NextVal into :new.def_id from dual;
0091 end;
0092 /
0093 
0094 prompt FUNCTION get_sequence_type_def_id;
0095 CREATE OR REPLACE FUNCTION get_sequence_type_def_id( a_run_type IN VARCHAR, seq_type VARCHAR ) return NUMBER
0096 IS
0097         ret NUMBER;
0098 BEGIN
0099         SELECT s.DEF_ID 
0100                 INTO    ret 
0101                 FROM    ECAL_SEQUENCE_TYPE_DEF s
0102                         , RUN_TYPE_DEF r
0103                 WHERE   s.SEQUENCE_TYPE_STRING=seq_type
0104                         AND r.RUN_TYPE=a_run_type
0105                         AND s.RUN_TYPE_DEF_ID=r.DEF_ID
0106         ;
0107         return (ret);
0108 END;
0109 /
0110 
0111 CREATE TABLE ECAL_SEQUENCE_DAT (
0112        SEQUENCE_ID NUMBER NOT NULL
0113      , ECAL_CONFIG_ID NUMBER NOT NULL
0114      , SEQUENCE_NUM NUMBER(22) NOT NULL
0115      , NUM_OF_CYCLES NUMBER(22) NULL
0116      , SEQUENCE_TYPE_DEF_ID NUMBER NOT NULL
0117      , DESCRIPTION VARCHAR2(200) NULL     
0118 );
0119 
0120 ALTER TABLE ECAL_SEQUENCE_DAT ADD CONSTRAINT ecal_sequence_dat_pk PRIMARY KEY (sequence_id);
0121 ALTER TABLE ECAL_SEQUENCE_DAT ADD CONSTRAINT ecal_sequence_dat_fk1 FOREIGN KEY (ecal_config_id)       REFERENCES ECAL_RUN_CONFIGURATION_DAT (CONFIG_ID);
0122 ALTER TABLE ECAL_SEQUENCE_DAT ADD CONSTRAINT ecal_sequence_dat_fk2 FOREIGN KEY (sequence_type_def_id) REFERENCES ECAL_SEQUENCE_TYPE_DEF (DEF_ID);
0123 ALTER TABLE ECAL_SEQUENCE_DAT ADD CONSTRAINT ecal_sequence_dat_uk1 UNIQUE (ecal_config_id, SEQUENCE_NUM);
0124 
0125 CREATE SEQUENCE ecal_sequence_dat_sq INCREMENT BY 1 START WITH 1;
0126 CREATE trigger ecal_sequence_dat_trg
0127 before insert on ECAL_SEQUENCE_DAT
0128 for each row
0129 begin
0130 select ecal_sequence_dat_sq.NextVal into :new.sequence_id from dual;
0131 end;
0132 /
0133 
0134 prompt FUNCTION get_sequence_id;
0135 create or replace function get_sequence_id( the_run_tag IN VARCHAR, the_run_version in NUMBER, the_seq_num in NUMBER ) return NUMBER
0136 IS
0137         ret NUMBER;
0138 BEGIN
0139         SELECT s.SEQUENCE_ID 
0140                 INTO    ret 
0141                 FROM    ECAL_RUN_CONFIGURATION_DAT r
0142                         , ECAL_SEQUENCE_DAT s 
0143                 WHERE   r.TAG=the_run_tag
0144                 AND     r.VERSION=the_run_version
0145                 AND     r.CONFIG_ID=s.ECAL_CONFIG_ID
0146                 AND     s.sequence_num=the_seq_num
0147         ;
0148         return (ret);
0149 END;
0150 /
0151 show errors;
0152 
0153 -- TODO Add a trigger to check that sequence type and run_type are coherent
0154 
0155 
0156 -- ********** ECAL_CYCLE_DAT
0157 
0158 CREATE TABLE ECAL_CYCLE_DAT (
0159           CYCLE_ID NUMBER NOT NULL
0160         , SEQUENCE_ID NUMBER NOT NULL
0161         , CYCLE_NUM NUMBER(22)
0162         , TAG VARCHAR2(64) NULL
0163         , DESCRIPTION VARCHAR2(200) NULL
0164  );    
0165 
0166 ALTER TABLE ECAL_CYCLE_DAT ADD CONSTRAINT ecal_cycle_dat_pk PRIMARY KEY (cycle_id);
0167 ALTER TABLE ECAL_CYCLE_DAT ADD CONSTRAINT ecal_cycxle_uk1 UNIQUE (sequence_id, cycle_num);
0168 ALTER TABLE ECAL_CYCLE_DAT ADD CONSTRAINT ecal_cycle_dat_fk1 FOREIGN KEY (sequence_id) REFERENCES ECAL_SEQUENCE_DAT (SEQUENCE_ID) ;
0169 
0170 CREATE SEQUENCE ecal_cycle_dat_sq INCREMENT BY 1 START WITH 1;
0171 CREATE trigger ecal_cycle_dat_trg
0172 before insert on ECAL_CYCLE_DAT
0173 for each row
0174 begin
0175 select ecal_cycle_dat_sq.NextVal into :new.cycle_id from dual;
0176 end;
0177 /
0178 
0179 -- ********** ECAL_CCS
0180 
0181 CREATE TABLE ECAL_CCS_CONFIGURATION (
0182         ccs_configuration_id NUMBER NOT NULL
0183         , ccs_tag VARCHAR2(32) NOT NULL
0184         , DACCAL NUMBER
0185         , DELAY NUMBER
0186         , GAIN VARCHAR2(64)
0187         , MEMGAIN VARCHAR2(64)
0188         , OFFSET_HIGH NUMBER
0189         , OFFSET_LOW  NUMBER
0190         , OFFSET_MID  NUMBER
0191         , TRG_MODE VARCHAR2(64)
0192         , TRG_FILTER VARCHAR2(64)
0193         , CLOCK NUMBER
0194         , BGO_SOURCE VARCHAR2(64)
0195         , TTS_MASK NUMBER
0196         , DAQ_BCID_PRESET NUMBER
0197         , TRIG_BCID_PRESET NUMBER
0198         , BC0_COUNTER NUMBER
0199         , BC0_DELAY NUMBER
0200         , TE_DELAY NUMBER
0201 );
0202 ALTER TABLE ECAL_CCS_CONFIGURATION ADD CONSTRAINT ecal_ccs_config_pk PRIMARY KEY (ccs_configuration_id);
0203 
0204 CREATE SEQUENCE ecal_CCS_CONFIG_sq INCREMENT BY 1 START WITH 1;
0205 
0206 
0207 CREATE TABLE ECAL_CCS_CYCLE (
0208           CYCLE_ID NUMBER NOT NULL,
0209           CCS_CONFIGURATION_ID NUMBER NOT NULL
0210          );    
0211 
0212 ALTER TABLE ECAL_CCS_CYCLE ADD CONSTRAINT ecal_ccs_cycle_pk PRIMARY KEY (CYCLE_ID);
0213 ALTER TABLE ECAL_CCS_CYCLE ADD CONSTRAINT ecal_ccs_cycle_fk1 FOREIGN KEY (cycle_id) REFERENCES ECAL_CYCLE_DAT (cycle_id);
0214 ALTER TABLE ECAL_CCS_CYCLE ADD CONSTRAINT ecal_ccs_cycle_fk2 FOREIGN KEY (ccs_configuration_id) REFERENCES ECAL_CCS_CONFIGURATION (ccs_configuration_id);
0215 
0216 
0217 -- ********** ECAL_DCC
0218 
0219 CREATE TABLE ECAL_DCC_CONFIGURATION (
0220         DCC_CONFIGURATION_ID NUMBER NOT NULL
0221         , dcc_tag VARCHAR2(32) NOT NULL
0222         , DCC_CONFIGURATION_URL VARCHAR2(100)
0223         , TESTPATTERN_FILE_URL VARCHAR2(100)
0224         , N_TESTPATTERNS_TO_LOAD NUMBER
0225         , SM_HALF NUMBER
0226         , dcc_CONFIGURATION CLOB
0227         , weightsmode varchar2(10) default 'CLOB' NOT NULL
0228 );
0229 ALTER TABLE ECAL_DCC_CONFIGURATION ADD CONSTRAINT ecal_dcc_config_pk PRIMARY KEY (dcc_configuration_id);
0230 
0231 CREATE SEQUENCE ecal_DCC_CONFIG_sq INCREMENT BY 1 START WITH 1;
0232 
0233 
0234 CREATE TABLE ECAL_DCC_CYCLE (
0235           CYCLE_ID NUMBER NOT NULL
0236          , DCC_CONFIGURATION_ID NUMBER NOT NULL
0237          );    
0238 
0239 ALTER TABLE ECAL_DCC_CYCLE ADD CONSTRAINT ecal_dcc_cycle_pk PRIMARY KEY (cycle_id);
0240 ALTER TABLE ECAL_DCC_CYCLE ADD CONSTRAINT ecal_dcc_cycle_fk1 FOREIGN KEY (cycle_id) REFERENCES ECAL_CYCLE_DAT (cycle_id);
0241 ALTER TABLE ECAL_DCC_CYCLE ADD CONSTRAINT ecal_dcc_cycle_fk2 FOREIGN KEY (dcc_configuration_id) REFERENCES ECAL_DCC_CONFIGURATION (dcc_configuration_id);
0242 
0243 
0244 -- ********** ECAL_DCu
0245 
0246 CREATE TABLE ECAL_DCu_CONFIGURATION (
0247         DCu_CONFIGURATION_ID NUMBER NOT NULL
0248         , dcu_tag VARCHAR2(32) NOT NULL
0249 );
0250 ALTER TABLE ECAL_DCu_CONFIGURATION ADD CONSTRAINT ecal_dcu_config_pk PRIMARY KEY (dcu_configuration_id);
0251 
0252 CREATE SEQUENCE ecal_DCu_CONFIG_sq INCREMENT BY 1 START WITH 1;
0253 CREATE TABLE ECAL_DCU_CYCLE (
0254           CYCLE_ID NUMBER NOT NULL
0255          , DCU_CONFIGURATION_ID NUMBER NOT NULL
0256          );    
0257 ALTER TABLE ECAL_DCU_CYCLE ADD CONSTRAINT ecal_dcu_cycle_pk PRIMARY KEY (cycle_id);
0258 ALTER TABLE ECAL_DCU_CYCLE ADD CONSTRAINT ecal_dcu_cycle_fk1 FOREIGN KEY (cycle_id) REFERENCES ECAL_CYCLE_DAT (cycle_id);
0259 ALTER TABLE ECAL_DCU_CYCLE ADD CONSTRAINT ecal_dcu_cycle_fk2 FOREIGN KEY (dcu_configuration_id) REFERENCES ECAL_DCu_CONFIGURATION (dcu_configuration_id);
0260 
0261 
0262 
0263 -- ********** ECAL_ttcf
0264 
0265 CREATE TABLE ECAL_TTCF_CONFIGURATION (
0266         TTCF_CONFIGURATION_ID NUMBER NOT NULL
0267         , TTCF_tag VARCHAR2(32) NOT NULL
0268         , TTCF_CONFIGURATION_FILE VARCHAR2(100) 
0269         , TTCF_CONFIGURATION CLOB,
0270 RXBC0_DELAY NUMBER, REG_30 NUMBER
0271 );
0272 ALTER TABLE ECAL_TTCF_CONFIGURATION ADD CONSTRAINT ecal_ttcf_config_pk PRIMARY KEY (ttcf_configuration_id);
0273 
0274 CREATE SEQUENCE ecal_TTCF_CONFIG_sq INCREMENT BY 1 START WITH 1;
0275 
0276 CREATE TABLE ECAL_TTCF_CYCLE (
0277           CYCLE_ID NUMBER NOT NULL
0278          , TTCF_CONFIGURATION_ID NUMBER NOT NULL
0279          );    
0280 
0281 ALTER TABLE ECAL_TTCF_CYCLE ADD CONSTRAINT ecal_ttcf_cycle_pk PRIMARY KEY (cycle_id);
0282 ALTER TABLE ECAL_TTCF_CYCLE ADD CONSTRAINT ecal_ttcf_cycle_fk1 FOREIGN KEY (cycle_id) REFERENCES ECAL_CYCLE_DAT (cycle_id);
0283 ALTER TABLE ECAL_TTCF_CYCLE ADD CONSTRAINT ecal_ttcf_cycle_fk2 FOREIGN KEY (ttcf_configuration_id) REFERENCES ECAL_TTCF_CONFIGURATION (ttcf_configuration_id);
0284 
0285 
0286 -- ********** ECAL_srp
0287 
0288 CREATE TABLE ECAL_SRP_CONFIGURATION (
0289         SRP_CONFIGURATION_ID NUMBER NOT NULL
0290         , SRP_tag VARCHAR2(32) NOT NULL
0291         , DEBUGMODE NUMBER
0292         , DUMMYMODE NUMBER
0293         , PATTERN_DIRECTORY VARCHAR2(100)
0294         , AUTOMATIC_MASKS NUMBER
0295         , SRP0BUNCHADJUSTPOSITION NUMBER 
0296         , SRP_CONFIG_FILE VARCHAR2(100)
0297         , SRP_CONFIGURATION CLOB
0298 );
0299 ALTER TABLE ECAL_SRP_CONFIGURATION ADD CONSTRAINT ecal_SRP_config_pk PRIMARY KEY (SRP_configuration_id);
0300 
0301 CREATE SEQUENCE ecal_SRP_CONFIG_sq INCREMENT BY 1 START WITH 1;
0302 
0303 
0304 CREATE TABLE ECAL_SRP_CYCLE (
0305           CYCLE_ID NUMBER NOT NULL
0306          , srp_CONFIGURATION_ID NUMBER NOT NULL
0307          );    
0308 
0309 ALTER TABLE ECAL_srp_CYCLE ADD CONSTRAINT ecal_srp_cycle_pk PRIMARY KEY (cycle_id);
0310 ALTER TABLE ECAL_srp_CYCLE ADD CONSTRAINT ecal_srp_cycle_fk1 FOREIGN KEY (cycle_id) REFERENCES ECAL_CYCLE_DAT (cycle_id);
0311 ALTER TABLE ECAL_srp_CYCLE ADD CONSTRAINT ecal_srp_cycle_fk2 FOREIGN KEY (srp_configuration_id) REFERENCES ECAL_SRP_CONFIGURATION (srp_configuration_id);
0312 
0313 
0314 -- ********** ECAL_LASER
0315 
0316 CREATE TABLE ECAL_LASER_CONFIGURATION (
0317         LASER_configuration_id NUMBER NOT NULL
0318         , laser_tag VARCHAR2(32) NOT NULL
0319         , laser_DEBUG NUMBER
0320         , DUMMY NUMBER
0321 -- ********** ECAL_MATACQ
0322         , MATACQ_BASE_ADDRESS NUMBER
0323         , MATACQ_NONE NUMBER
0324         , matacq_mode VARCHAR2(64)
0325         , channel_Mask NUMBER
0326         , max_Samples_For_Daq VARCHAR2(64)
0327         , maTACQ_FED_ID NUMBER
0328         , pedestal_File VARCHAR2(128)
0329         , use_Buffer NUMBER
0330         , postTrig NUMBER
0331         , fp_Mode NUMBER
0332         , hal_Module_File VARCHAR2(64)
0333         , hal_Address_Table_File VARCHAR2(64)
0334         , hal_Static_Table_File VARCHAR2(64)
0335         , matacq_Serial_Number VARCHAR2(64)
0336         , pedestal_Run_Event_Count NUMBER
0337         , raw_Data_Mode NUMBER
0338         , ACQUISITION_MODE VARCHAR2(64)
0339         , LOCAL_OUTPUT_FILE VARCHAR2(100)
0340         , MATACQ_VERNIER_MIN NUMBER
0341         , MATACQ_VERNIER_MAX NUMBER
0342 -- *********** emtc
0343         , emtc_none NUMBER
0344         , wte2_laser_delay NUMBER
0345         , laser_phase NUMBER
0346         , emtc_ttc_in NUMBER
0347         , emtc_slot_id NUMBER
0348 -- *********** ecal laser
0349         , WAVELENGTH NUMBER
0350         , POWER_SETTING NUMBER
0351         , OPTICAL_SWITCH NUMBER
0352         , FILTER NUMBER
0353         , LASER_CONTROL_ON NUMBER
0354         , LASER_CONTROL_HOST VARCHAR2(32)
0355         , LASER_CONTROL_PORT NUMBER
0356         , laser_tag2 varchar2(32)
0357 , wte_2_led_delay NUMBER(4)
0358 , led1_on NUMBER(1)
0359 , led2_on NUMBER(1)
0360 , led3_on NUMBER(1)
0361 , led4_on NUMBER(1)
0362 , VINJ NUMBER
0363 , orange_led_mon_ampl number
0364 , blue_led_mon_ampl number
0365 , trig_log_file varchar2(512)
0366 , led_control_on NUMBER(1)
0367 , led_control_host varchar2(100)
0368 , led_control_port NUMBER(5)
0369 , ir_laser_power number(3)
0370 , green_laser_power number(3)
0371 , red_laser_power number(3)
0372 , blue_laser_log_attenuator number(3) 
0373 , IR_LASER_LOG_ATTENUATOR NUMBER(3)
0374 , GREEN_LASER_LOG_ATTENUATOR  NUMBER(3)
0375 , RED_LASER_LOG_ATTENUATOR NUMBER(3)
0376 , LASER_CONFIG_FILE VARCHAR2(512)
0377 , laser_configuration CLOB
0378 );
0379 
0380 ALTER TABLE ECAL_LASER_CONFIGURATION ADD CONSTRAINT ecal_LASER_config_pk PRIMARY KEY (LASER_configuration_id);
0381 
0382 CREATE SEQUENCE ecal_LASER_CONFIG_sq INCREMENT BY 1 START WITH 1;
0383 
0384 
0385 CREATE TABLE ECAL_LASER_CYCLE (
0386           CYCLE_ID NUMBER NOT NULL
0387          , LASER_CONFIGURATION_ID NUMBER NOT NULL
0388          );    
0389 
0390 ALTER TABLE ECAL_LASER_CYCLE ADD CONSTRAINT ecal_LASER_cycle_pk PRIMARY KEY (cycle_id);
0391 ALTER TABLE ECAL_LASER_CYCLE ADD CONSTRAINT ecal_LASER_cycle_fk1 FOREIGN KEY (cycle_id) REFERENCES ECAL_CYCLE_DAT (cycle_id);
0392 ALTER TABLE ECAL_LASER_CYCLE ADD CONSTRAINT ecal_LASER_cycle_fk2 FOREIGN KEY (laser_configuration_id) REFERENCES ECAL_LASER_CONFIGURATION (LASER_configuration_id);
0393 
0394 
0395 -- ********** ECAL_TCC
0396 
0397 CREATE TABLE ECAL_TCC_CONFIGURATION (
0398         TCC_configuration_id NUMBER NOT NULL
0399         , TCC_tag VARCHAR2(32) NOT NULL
0400         , Configuration_file varchar2(100) NULL
0401         , LUT_CONFIGURATION_FILE VARCHAR2(100) NULL
0402         , SLB_CONFIGURATION_FILE VARCHAR2(100) NULL
0403         , TESTPATTERNFILE_URL VARCHAR2(100) NULL
0404         , N_TESTPATTERNS_TO_LOAD number NULL
0405                , tcc_configuration CLOB 
0406                , lut_configuration CLOB 
0407                , slb_configuration CLOB 
0408 );
0409 ALTER TABLE ECAL_TCC_CONFIGURATION ADD CONSTRAINT ecal_TCC_config_pk PRIMARY KEY (TCC_configuration_id);
0410 
0411 CREATE SEQUENCE ecal_TCC_CONFIG_sq INCREMENT BY 1 START WITH 1;
0412 
0413 
0414 CREATE TABLE ECAL_TCC_CYCLE (
0415  CYCLE_ID NUMBER NOT NULL
0416          , TCC_CONFIGURATION_ID NUMBER NOT NULL
0417          );    
0418 
0419 ALTER TABLE ECAL_TCC_CYCLE ADD CONSTRAINT ecal_TCC_cycle_pk PRIMARY KEY (cycle_id);
0420 ALTER TABLE ECAL_TCC_CYCLE ADD CONSTRAINT ecal_TCC_cycle_fk1 FOREIGN KEY (cycle_id) REFERENCES ECAL_CYCLE_DAT (cycle_id);
0421 ALTER TABLE ECAL_TCC_CYCLE ADD CONSTRAINT ecal_TCC_cycle_fk2 FOREIGN KEY (tcc_configuration_id) REFERENCES ECAL_TCC_CONFIGURATION (TCC_configuration_id);
0422 
0423 
0424 -- ********** ECAL_TTCci
0425 
0426 CREATE TABLE ECAL_TTCCI_CONFIGURATION (
0427         TTCCI_configuration_id NUMBER NOT NULL
0428         , TTCCI_tag VARCHAR2(32) NOT NULL
0429         , TTCCI_configuration_file varchar2(130)
0430         ,TRG_MODE varchar2(32)
0431         ,TRG_SLEEP NUMBER
0432         , Configuration CLOB
0433        , CONFIGURATION_SCRIPT varchar2(100)
0434        , CONFIGURATION_SCRIPT_PARAMS varchar2(100)
0435 );
0436 ALTER TABLE ECAL_TTCCI_CONFIGURATION ADD CONSTRAINT ecal_TTCCI_config_pk PRIMARY KEY (TTCCI_configuration_id);
0437 
0438 CREATE SEQUENCE ecal_TTCCI_CONFIG_sq INCREMENT BY 1 START WITH 1;
0439 
0440 
0441 CREATE TABLE ECAL_TTCCI_CYCLE (
0442            CYCLE_ID NUMBER NOT NULL
0443          , TTCCI_CONFIGURATION_ID NUMBER NOT NULL
0444          );    
0445 
0446 ALTER TABLE ECAL_TTCCI_CYCLE ADD CONSTRAINT ecal_TTCCI_cycle_pk PRIMARY KEY (cycle_id);
0447 ALTER TABLE ECAL_TTCCI_CYCLE ADD CONSTRAINT ecal_TTCCI_cycle_fk1 FOREIGN KEY (cycle_id) REFERENCES ECAL_CYCLE_DAT (cycle_id);
0448 ALTER TABLE ECAL_TTCCI_CYCLE ADD CONSTRAINT ecal_TTCCI_cycle_fk2 FOREIGN KEY (ttcci_configuration_id) REFERENCES ECAL_TTCCI_CONFIGURATION (TTCCI_configuration_id);
0449 
0450 
0451 
0452 -- ********** ECAL_LTC
0453 
0454 CREATE TABLE ECAL_LTC_CONFIGURATION (
0455         LTC_configuration_id NUMBER NOT NULL
0456         , LTC_tag VARCHAR2(32) NOT NULL
0457         , ltc_Configuration_file varchar2(100)
0458         , Configuration CLOB
0459 );
0460 ALTER TABLE ECAL_LTC_CONFIGURATION ADD CONSTRAINT ecal_LTC_config_pk PRIMARY KEY (LTC_configuration_id);
0461 
0462 CREATE SEQUENCE ecal_LTC_CONFIG_sq INCREMENT BY 1 START WITH 1;
0463 
0464 
0465 CREATE TABLE ECAL_LTC_CYCLE (
0466           CYCLE_ID NUMBER NOT NULL
0467          , LTC_CONFIGURATION_ID NUMBER NOT NULL
0468          );    
0469 
0470 ALTER TABLE ECAL_LTC_CYCLE ADD CONSTRAINT ecal_LTC_cycle_pk PRIMARY KEY (cycle_id);
0471 ALTER TABLE ECAL_LTC_CYCLE ADD CONSTRAINT ecal_LTC_cycle_fk1 FOREIGN KEY (cycle_id) REFERENCES ECAL_CYCLE_DAT (cycle_id);
0472 ALTER TABLE ECAL_LTC_CYCLE ADD CONSTRAINT ecal_LTC_cycle_fk2 FOREIGN KEY (ltc_configuration_id) REFERENCES ECAL_LTC_CONFIGURATION (LTC_configuration_id);
0473 
0474 -- ********** ECAL_LTS
0475 
0476 CREATE TABLE ECAL_LTS_CONFIGURATION (
0477         LTS_configuration_id NUMBER NOT NULL
0478         , lts_tag VARCHAR2(32) NOT NULL
0479         , TRIGGER_TYPE VARCHAR2(32)
0480         , NUM_OF_EVENTS NUMBER
0481         , RATE NUMBER
0482         , TRIG_LOC_L1_DELAY NUMBER
0483 );
0484 ALTER TABLE ECAL_LTS_CONFIGURATION ADD CONSTRAINT ecal_LTS_config_pk PRIMARY KEY (LTS_configuration_id);
0485 
0486 CREATE SEQUENCE ecal_LTS_CONFIG_sq INCREMENT BY 1 START WITH 1;
0487 
0488 
0489 CREATE TABLE ECAL_LTS_CYCLE (
0490           CYCLE_ID NUMBER NOT NULL
0491          , LTS_CONFIGURATION_ID NUMBER NOT NULL
0492          );    
0493 
0494 ALTER TABLE ECAL_LTS_CYCLE ADD CONSTRAINT ecal_LTS_cycle_pk PRIMARY KEY (cycle_id);
0495 ALTER TABLE ECAL_LTS_CYCLE ADD CONSTRAINT ecal_LTS_cycle_fk1 FOREIGN KEY (cycle_id) REFERENCES ECAL_CYCLE_DAT (cycle_id);
0496 ALTER TABLE ECAL_LTS_CYCLE ADD CONSTRAINT ecal_LTS_cycle_fk2 FOREIGN KEY (lts_configuration_id) REFERENCES ECAL_LTS_CONFIGURATION (LTS_configuration_id);
0497 
0498 -- ********** ECAL_JBH4
0499 
0500 CREATE TABLE ECAL_JBH4_CONFIGURATION (
0501         JBH4_configuration_id NUMBER NOT NULL
0502         , JBH4_tag VARCHAR2(32) NOT NULL
0503         , useBuffer NUMBER
0504         , halModuleFile VARCHAR2(64)
0505         , halAddressTableFile VARCHAR2(64)
0506         , halStaticTableFile VARCHAR2(64)
0507         , halCbd8210SerialNumber VARCHAR2(64)
0508         , caenBridgeType VARCHAR2(64)
0509         , caenLinkNumber NUMBER
0510         , caenBoardNumber NUMBER
0511 );
0512 ALTER TABLE ECAL_JBH4_CONFIGURATION ADD CONSTRAINT ecal_JBH4_config_pk PRIMARY KEY (JBH4_configuration_id);
0513 
0514 CREATE SEQUENCE ecal_JBH4_CONFIG_sq INCREMENT BY 1 START WITH 1;
0515 
0516 
0517 CREATE TABLE ECAL_JBH4_CYCLE (
0518           CYCLE_ID NUMBER NOT NULL
0519          , JBH4_CONFIGURATION_ID NUMBER NOT NULL
0520          );    
0521 
0522 ALTER TABLE ECAL_JBH4_CYCLE ADD CONSTRAINT ecal_JBH4_cycle_pk PRIMARY KEY (cycle_id);
0523 ALTER TABLE ECAL_JBH4_CYCLE ADD CONSTRAINT ecal_JBH4_cycle_fk1 FOREIGN KEY (cycle_id) REFERENCES ECAL_CYCLE_DAT (cycle_id);
0524 ALTER TABLE ECAL_JBH4_CYCLE ADD CONSTRAINT ecal_JBH4_cycle_fk2 FOREIGN KEY (jbh4_configuration_id) REFERENCES ECAL_JBH4_CONFIGURATION (JBH4_configuration_id);
0525 
0526 
0527 -- ********** ECAL_SCAN
0528 
0529 CREATE TABLE ECAL_SCAN_DAT (
0530           SCAN_ID NUMBER        
0531         , SCAN_tag VARCHAR2(32) NOT NULL
0532         , type_id number
0533         , scan_type varchar2(32) 
0534         , FROM_VAL NUMBER
0535         , TO_VAL NUMBER
0536         , STEP NUMBER
0537 );
0538 
0539 ALTER TABLE ECAL_SCAN_DAT ADD CONSTRAINT ecal_scan_dat_pk  PRIMARY KEY (scan_id);
0540 CREATE SEQUENCE ecal_SCAN_CONFIG_sq INCREMENT BY 1 START WITH 1;
0541 
0542 
0543 
0544 
0545 
0546 CREATE TABLE ECAL_SCAN_CYCLE (
0547           CYCLE_ID NUMBER NOT NULL
0548          , SCAN_ID NUMBER NOT NULL
0549          );    
0550 
0551 ALTER TABLE ECAL_SCAN_CYCLE ADD CONSTRAINT ecal_SCAN_cycle_pk  PRIMARY KEY (cycle_id);
0552 ALTER TABLE ECAL_SCAN_CYCLE ADD CONSTRAINT ecal_SCAN_cycle_fk1 FOREIGN KEY (cycle_id) REFERENCES ECAL_CYCLE_DAT (cycle_id);
0553 ALTER TABLE ECAL_SCAN_CYCLE ADD CONSTRAINT ecal_SCAN_cycle_fk2 FOREIGN KEY (scan_id)  REFERENCES ECAL_SCAN_DAT  (SCAN_id);
0554 
0555 -- ********** VIEWS
0556 
0557 CREATE OR REPLACE VIEW ECAL_RUN_CONFIGURATION AS
0558 select r.CONFIG_ID
0559      , r.TAG
0560      , r.VERSION
0561      , rtd.RUN_TYPE RUN_TYPE
0562      , rmd.RUN_MODE_STRING RUN_MODE
0563      , r.NUM_OF_SEQUENCES
0564      , r.DESCRIPTION RUN_CONFIG_DESCRIPTION
0565      , r.DEFAULTS
0566      , r.TRG_MODE
0567      , r.usage_status   
0568 from
0569         ECAL_RUN_CONFIGURATION_DAT r
0570         , RUN_TYPE_DEF rtd
0571         , ECAL_RUN_MODE_DEF rmd
0572 where
0573         r.RUN_TYPE_DEF_ID=rtd.DEF_ID
0574         and r.RUN_MODE_DEF_ID=rmd.DEF_ID
0575 ;
0576 
0577 
0578 CREATE OR REPLACE VIEW ECAL_SEQUENCE AS
0579 select
0580        s.SEQUENCE_ID
0581      , r.TAG
0582      , r.VERSION
0583      , s.SEQUENCE_NUM
0584      , s.NUM_OF_CYCLES
0585      , std.SEQUENCE_TYPE_STRING sequence_type
0586      , s.DESCRIPTION
0587 from
0588         ECAL_SEQUENCE_DAT s
0589         , ECAL_SEQUENCE_TYPE_DEF std
0590         , ECAL_RUN_CONFIGURATION_DAT r
0591 where
0592         s.ECAL_CONFIG_ID=r.CONFIG_ID
0593         and s.SEQUENCE_TYPE_DEF_ID=std.DEF_ID
0594 ;
0595 
0596 CREATE OR REPLACE VIEW ECAL_CYCLE AS
0597 SELECT 
0598         e.cycle_id
0599         , r.tag tag
0600         , r.version version
0601         , s.sequence_num
0602         , s.sequence_id
0603         , e.cycle_num
0604         , e.tag cycle_tag
0605         , e.description
0606         , ccs.CCS_CONFIGURATION_ID
0607         , dcc.dcc_CONFIGURATION_ID
0608         , laser.laser_CONFIGURATION_ID
0609         , ltc.ltc_CONFIGURATION_ID
0610         , lts.lts_CONFIGURATION_ID
0611         , dcu.dcu_CONFIGURATION_ID
0612         , tcc.tcc_CONFIGURATION_ID
0613         , ttcf.ttcf_CONFIGURATION_ID
0614         , srp.srp_configuration_id
0615         , ttcci.ttcci_CONFIGURATION_ID "TTCci_CONFIGURATION_ID"
0616         , jbh4.jbh4_CONFIGURATION_ID
0617         , scan.scan_id
0618 FROM
0619         ECAL_RUN_CONFIGURATION_DAT r,
0620         ECAL_SEQUENCE_DAT s,
0621         ECAL_CYCLE_Dat e
0622         LEFT OUTER join
0623         ECAL_CCS_CYCLE ccs on  e.cycle_id=ccs.cycle_ID
0624         left outer join
0625         ECAL_DCC_CYCLE dcc on  e.cycle_id=dcc.cycle_ID
0626         left outer join
0627         ECAL_LASER_CYCLE laser on e.cycle_id=laser.cycle_ID
0628         left outer join
0629         ECAL_ltc_CYCLE ltc on  e.cycle_id=ltc.cycle_ID
0630         left outer join
0631         ECAL_lts_CYCLE lts on e.cycle_id=lts.cycle_ID
0632         left outer join
0633         ECAL_dcu_CYCLE dcu on e.cycle_id=dcu.cycle_ID
0634         left outer join
0635         ECAL_tcc_CYCLE tcc on e.cycle_id=tcc.cycle_ID
0636         left outer join
0637         ECAL_ttcci_CYCLE ttcci on  e.cycle_id=ttcci.cycle_ID
0638         left outer join
0639         ECAL_jbh4_CYCLE jbh4 on  e.cycle_id=jbh4.cycle_ID
0640         left outer join
0641         ECAL_SCAN_cycle scan on e.cycle_id=scan.cycle_id
0642         left outer join
0643         ECAL_srp_cycle srp on e.cycle_id=srp.cycle_id
0644         left outer join
0645         ECAL_ttcf_CYCLE ttcf on e.cycle_id=ttcf.cycle_ID
0646 where 
0647         r.config_id=s.ecal_config_id 
0648         and e.sequence_id=s.sequence_id
0649 ;
0650 
0651 
0652 CREATE OR REPLACE VIEW ECAL_SCAN_CONFIGURATION AS
0653 select r.SCAN_ID SCAN_ID
0654         , r.SCAN_tag tag
0655      , r.type_id type_id
0656      , r.scan_type scan_type
0657      , r.FROM_VAL from_val
0658      , r.to_val to_val
0659      , r.STEP  step
0660  from
0661         ECAL_scan_dat r
0662 ;
0663 
0664 
0665 
0666 
0667 
0668 @insert_run_mod_defs