00001 #include <sys/types.h>
00002
00003 #include <rtsLog.h>
00004 #include <rtsSystems.h>
00005 #include <daqFormats.h>
00006 #include <rts.h>
00007
00008 #include <DAQ_READER/daq_det.h>
00009
00010 const struct hdrs {
00011 char *emcp ;
00012 char *secp ;
00013 char *rbp ;
00014 char *adc ;
00015 } hdrs[2] = {
00016 { CHAR_EMCP, CHAR_EMCSECP, CHAR_EMCRBP, CHAR_EMCADCR },
00017 { CHAR_EECP, CHAR_EECSECP, CHAR_EECRBP, CHAR_EECADCR }
00018 } ;
00019
00020
00021
00022
00023
00024
00025 char *emc_single_reader(char *e, int *bytes, int rts_id)
00026 {
00027 struct EMCP *emcp = (struct EMCP *)e ;
00028 u_int off, len ;
00029 int hdr_ix, sec_ix ;
00030
00031 *bytes = 0 ;
00032
00033 if(!emcp) return 0 ;
00034
00035 switch(rts_id) {
00036 case BTOW_ID :
00037 hdr_ix = 0 ;
00038 sec_ix = 0 ;
00039 break ;
00040 case ETOW_ID :
00041 hdr_ix = 1 ;
00042 sec_ix = 0 ;
00043 break ;
00044 case ESMD_ID :
00045 hdr_ix = 1 ;
00046 sec_ix = 1 ;
00047 break ;
00048 default :
00049 return 0 ;
00050 }
00051
00052 if(checkBank(emcp->bh.bank_type, hdrs[hdr_ix].emcp)<0) return 0 ;
00053
00054 off = b2h32(emcp->sec[sec_ix].off) ;
00055 len = b2h32(emcp->sec[sec_ix].len) ;
00056
00057 if((len==0) || (off==0)) return 0 ;
00058
00059 struct EMCSECP *emcsecp = (struct EMCSECP *)((u_int *)emcp + off) ;
00060
00061 if(checkBank(emcsecp->bh.bank_type, hdrs[hdr_ix].secp)<0) return 0 ;
00062
00063
00064 len = b2h32(emcsecp->fiber[0].len) ;
00065 off = b2h32(emcsecp->fiber[0].off) ;
00066
00067 if((len==0) || (off==0)) return 0 ;
00068
00069 struct EMCRBP *emcrbp = (struct EMCRBP *)((u_int *)emcsecp + off) ;
00070
00071 if(checkBank(emcrbp->bh.bank_type, hdrs[hdr_ix].rbp)< 0) return 0 ;
00072
00073
00074 len = b2h32(emcrbp->banks[0].len) ;
00075 off = b2h32(emcrbp->banks[0].off) ;
00076
00077 if((len==0) || (off==0)) return 0 ;
00078
00079 struct DUMMYDATA *emcadc = (DUMMYDATA *) ((u_int *)emcrbp + off) ;
00080
00081 if(checkBank(emcadc->bh.bank_type, hdrs[hdr_ix].adc)<0) return 0 ;
00082
00083
00084 *bytes = l2h32(emcadc->bh.length)*4 - 40 ;
00085 return ((char *)emcadc + 40) ;
00086 }
00087
00088
00089