7 #include <rtsSystems.h>
11 #include <SFS/sfs_index.h>
12 #include <DAQ_READER/daqReader.h>
13 #include <DAQ_READER/daq_dta.h>
19 const char *daq_pxl::help_string =
"PXL\n\
20 raw returns raw data\n" ;
27 daq_det_factory::det_factories[PXL_ID] = this ;
41 name = rts2name(rts_id) ;
45 if(caller) caller->insert(
this, rts_id) ;
49 LOG(DBG,
"%s: constructor: caller %p",name,rts_caller) ;
55 LOG(DBG,
"%s: DEstructor",name) ;
63 daq_dta *daq_pxl::get(
const char *bank,
int sec,
int rdo,
int pad,
void *p1,
void *p2)
67 if(present == 0)
return 0 ;
70 if(strcasecmp(bank,
"raw")==0) {
71 return handle_raw(sec,rdo) ;
74 LOG(ERR,
"%s: unknown bank type \"%s\"",name,bank) ;
80 daq_dta *daq_pxl::handle_raw(
int sec,
int rdo)
93 LOG(DBG,
"%s: present %d",name,present) ;
105 s_start = s_stop = sec ;
113 r_start = r_stop = rdo ;
117 raw->create(8*1024,
"pxl_raw",rts_id,DAQ_DTA_STRUCT(
char)) ;
119 for(
int s=s_start;s<=s_stop;s++) {
120 for(
int r=r_start;r<=r_stop;r++) {
121 sprintf(str,
"%s/sec%02d/rb%02d/raw",sfs_name, s, r) ;
122 full_name = caller->get_sfs_name(str) ;
124 if(!full_name) continue ;
125 bytes = caller->sfs->fileSize(full_name) ;
128 st = (
char *) raw->request(bytes) ;
130 int ret = caller->sfs->read(str, st, bytes) ;
132 LOG(ERR,
"ret is %d") ;
136 raw->finalize(bytes,s,r,0) ;
152 int daq_pxl::get_l2(
char *buff,
int words,
struct daq_trg_word *trg,
int rdo)
155 u_int *d32 = (u_int *)buff ;
157 int last_ix = words - 1 ;
158 int token, daq_cmd, trg_cmd ;
161 if(d32[0] != 0xAAAAAAAA) err |= 1 ;
162 if(d32[last_ix] != 0xBBBBBBBB) err |= 2 ;
164 if((d32[1] & 0xFFF00000) != 0xC0000000) err |= 8 ;
168 if(d32[1] == 0xC000FFFF) {
169 LOG(NOTE,
"RDO %d: trigger-only event...",rdo) ;
176 token = d32[1] & 0xFFF ;
177 daq_cmd = (d32[1] & 0xF000) >> 12 ;
178 trg_cmd = (d32[1] & 0xF0000) >> 16 ;
182 if(err || (token == 0)) {
187 if(trg_cmd != 4) err |= 8 ;
189 trg[t_cou].t = token ;
190 trg[t_cou].daq = daq_cmd ;
191 trg[t_cou].trg = trg_cmd ;
192 trg[t_cou].rhic = d32[7] ;
193 trg[t_cou].rhic_delta = 0 ;
198 int last_p = last_ix - 1 ;
206 for(
int i=last_p;i>=0;i--) {
207 if(d32[i] == 0xCCCCCCCC) {
214 for(
int i=first_trg;i<=last_p;i++) {
215 trg[t_cou].t = d32[i] & 0xFFF ;
216 trg[t_cou].daq = (d32[i] & 0xF000) >> 12 ;
217 trg[t_cou].trg = (d32[i] & 0xF0000) >> 16 ;
218 trg[t_cou].rhic = trg[0].rhic + 1 ;
219 trg[t_cou].rhic_delta = 0 ;
221 switch(trg[t_cou].trg) {
241 LOG(ERR,
"RDO %d: error 0x%X, t_cou %d",rdo,err,t_cou) ;
243 for(
int i=0;i<16;i++) {
244 LOG(ERR,
" RDO %d: %2d/%2d: 0x%08X",rdo,i,words,d32[i]) ;
247 int s = last_ix - 10 ;
250 for(
int i=s;i<=last_ix;i++) {
251 LOG(ERR,
" RDO %d: %2d/%2d: 0x%08X",rdo,i,words,d32[i]) ;