6 #include <rtsSystems.h>
10 #include <SFS/sfs_index.h>
11 #include <DAQ_READER/daqReader.h>
12 #include <DAQ_READER/daq_dta.h>
18 const char *daq_l4::help_string =
"L4\n\
19 tpx returns TPX SL3;\n\
20 trg returns TRG SL3;\n" ;
26 daq_det_factory::det_factories[L4_ID] = this ;
46 caller->insert(
this, rts_id) ;
54 LOG(DBG,
"%s: constructor: caller %p",name,rts_caller) ;
60 LOG(DBG,
"%s: DEstructor",name) ;
72 daq_dta *daq_l4::get(
const char *bank,
int sec,
int rdo,
int pad,
void *p1,
void *p2)
75 if(present == 0)
return 0 ;
78 if(strcasecmp(bank,
"tpx")==0) {
79 return handle_tpx(sec) ;
81 else if(strcasecmp(bank,
"trg")==0) {
84 else if(strcasecmp(bank,
"tof")==0) {
87 else if(strncasecmp(bank,
"gl3",3)==0) {
88 return handle_gl3(sec, bank) ;
92 LOG(ERR,
"%s: unknown bank type \"%s\"",name,bank) ;
98 daq_dta *daq_l4::handle_tpx(
int sec)
101 int s_start, s_stop ;
107 LOG(ERR,
"%s: not present?",name) ;
111 LOG(DBG,
"%s: present %d",name,present) ;
119 s_start = s_stop = sec ;
123 for(
int s=s_start;s<=s_stop;s++) {
127 sprintf(str,
"%s/tpx/sec%02d/sl3",sfs_name, sec) ;
128 full_name = caller->get_sfs_name(str) ;
130 if(!full_name)
return 0 ;
131 bytes = caller->sfs->fileSize(full_name) ;
133 tpx->create(bytes,
"hlt_tpx",rts_id,DAQ_DTA_STRUCT(
char)) ;
134 st = (
char *) tpx->request(bytes) ;
136 int ret = caller->sfs->read(str, st, bytes) ;
138 LOG(ERR,
"ret is %d") ;
141 tpx->finalize(bytes,s,1,0) ;
159 LOG(ERR,
"%s: not present?",name) ;
163 LOG(DBG,
"%s: present %d",name,present) ;
169 sprintf(str,
"%s/trg/sec%02d/sl3",sfs_name, 1) ;
170 full_name = caller->get_sfs_name(str) ;
172 if(!full_name)
return 0 ;
173 bytes = caller->sfs->fileSize(full_name) ;
175 trg->create(bytes,
"hlt_trg",rts_id,DAQ_DTA_STRUCT(
char)) ;
176 st = (
char *) trg->request(bytes) ;
178 int ret = caller->sfs->read(str, st, bytes) ;
180 LOG(ERR,
"ret is %d") ;
183 trg->finalize(bytes,1,1,0) ;
199 LOG(ERR,
"%s: not present?",name) ;
203 LOG(DBG,
"%s: present %d",name,present) ;
209 sprintf(str,
"%s/tof/sec%02d/sl3",sfs_name, 1) ;
210 full_name = caller->get_sfs_name(str) ;
212 if(!full_name)
return 0 ;
213 bytes = caller->sfs->fileSize(full_name) ;
215 tof->create(bytes,
"hlt_tof",rts_id,DAQ_DTA_STRUCT(
char)) ;
216 st = (
char *)
tof->request(bytes) ;
218 int ret = caller->sfs->read(str, st, bytes) ;
220 LOG(ERR,
"ret is %d") ;
223 tof->finalize(bytes,1,1,0) ;
231 daq_dta *daq_l4::handle_gl3(
int sec,
const char *bank)
240 LOG(ERR,
"%s: not present?",name) ;
244 LOG(DBG,
"%s: sec %d, bank %s: present %d",name,sec,bank,present) ;
250 sprintf(str,
"%s/gl3",sfs_name) ;
251 full_name = caller->get_sfs_name(str) ;
253 LOG(DBG,
"Trying 1: %s: got %s",str,full_name) ;
256 sprintf(str,
"%s/gl3/sec%02d",sfs_name, 1) ;
257 full_name = caller->get_sfs_name(str) ;
259 LOG(DBG,
"Trying 2: %s: got %s",str,full_name) ;
260 if(!full_name)
return 0 ;
264 bytes = caller->sfs->fileSize(full_name) ;
266 gl3->create(1024,
"hlt_gl3",rts_id,DAQ_DTA_STRUCT(
char)) ;
268 fs_dir *dir = caller->sfs->opendir(full_name) ;
269 if(dir==0)
return 0 ;
272 while((entry = caller->sfs->readdir(dir))) {
274 bytes = caller->sfs->fileSize(entry->full_name) ;
276 LOG(WARN,
"%s: 0 bytes?",entry->full_name) ;
282 LOG(DBG,
"%d: %s %s %d",cou,entry->full_name,entry->d_name,bytes) ;
284 st = (
char *) gl3->request(bytes+
sizeof(
l4_gl3_t)) ;
288 char *yada = ((
l4_gl3_t *)st)->name ;
289 strncpy(yada,entry->d_name,32) ;
292 int ret = caller->sfs->read(entry->full_name, st+
sizeof(
l4_gl3_t), bytes) ;
294 LOG(ERR,
"ret is %d") ;
297 gl3->finalize(bytes+
sizeof(
l4_gl3_t),cou,1,0) ;