6 #include <rtsSystems.h>
7 #include <daqFormats.h>
9 #include <SFS/sfs_index.h>
11 #include <DAQ_READER/daqReader.h>
12 #include <DAQ_READER/daq_dta.h>
17 extern int etof_reader(
char *mem,
struct etof_t *etof, u_int driver) ;
22 const char *daq_etof::help_string =
"\
26 raw returns=ptr of start of DDL data; c1=sector[1..1]; c2=rdo[1..4]; \n\
35 daq_det_factory::det_factories[ETOF_ID] = this ;
50 name = rts2name(rts_id) ;
53 if(caller) caller->insert(
this, rts_id) ;
59 LOG(DBG,
"%s: constructor: caller %p",name,rts_caller) ;
65 LOG(DBG,
"%s: DEstructor",name) ;
75 daq_dta *daq_etof::get(
const char *bank,
int sec,
int row,
int pad,
void *p1,
void *p2)
79 if(present==0)
return 0 ;
81 LOG(DBG,
"%s: looking for bank %s",name,bank) ;
83 if(strcmp(bank,
"*")==0) bank =
"raw" ;
87 if(strcasecmp(bank,
"raw")==0) {
88 if((present & DET_PRESENT_SFS)==0)
return 0 ;
89 return handle_raw(sec,row) ;
92 LOG(ERR,
"%s: unknown bank type \"%s\"",name,bank) ;
98 daq_dta *daq_etof::handle_raw(
int sec,
int rdo)
106 sprintf(str,
"%s/sec01/rb01/raw",sfs_name) ;
107 char *full_name = caller->get_sfs_name(str) ;
109 LOG(DBG,
"%s: trying sfs on \"%s\"",name,str) ;
110 if(full_name == 0)
return 0 ;
112 int size = caller->sfs->fileSize(full_name) ;
114 LOG(DBG,
"Got size %d",size) ;
116 LOG(DBG,
"%s: %s: not found in this event",name,str) ;
120 char *ptr = (
char *) malloc(size) ;
121 LOG(DBG,
"Malloc at %p",ptr) ;
123 caller->sfs->read(full_name, ptr, size) ;
125 LOG(DBG,
"sfs read succeeded") ;
130 int ret = get_l2(ptr,size*4,&trg,1) ;
131 LOG(NOTE,
"get_l2 returns %d: %d %d %d",ret,trg.trg,trg.daq,trg.t) ;
134 LOG(TERR,
"ETOF size %d",size) ;
135 u_int *d32 = (u_int *)ptr ;
136 for(
int i=0;i<size/4;i++) {
137 LOG(TERR,
"%d = 0x%08X",i,d32[i]) ;
145 raw->create(size,
"etof_raw",rts_id,DAQ_DTA_STRUCT(u_char)) ;
147 char *st = (
char *) raw->request(size) ;
150 memcpy(st,ptr+40,size) ;
154 raw->finalize(size,1,1,0) ;
163 int daq_etof::get_token(
char *addr,
int words)
165 LOG(ERR,
"get_token") ;
170 cou = get_l2(addr,words,trg,1) ;
172 if(cou==0)
return -1000 ;
173 if(trg[0].t==0)
return -ENOSYS ;
193 int daq_etof::get_l2(
char *addr,
int words,
struct daq_trg_word *trg,
int rdo)
196 int in_words = words ;
205 LOG(NOTE,
"Token %d, CRC word 0x%08X, format number 0x%08X",bh->token,bh->crc,bh->format_number) ;
207 trg[0].t = bh->crc & 0xFFF ;
208 trg[0].trg = (bh->crc>>16)&0xF ;
209 trg[0].daq = (bh->crc>>12)&0xF ;
214 LOG(ERR,
"[%d] Bad Event: T %4d: words %d",
215 rdo,trg[0].t,in_words) ;