5 #include <rtsSystems.h>
7 #include <SFS/sfs_index.h>
8 #include <DAQ_READER/daqReader.h>
9 #include <DAQ_READER/daq_dta.h>
15 const char *daq_trg::help_string =
"TRG tst\n" ;
21 daq_det_factory::det_factories[TRG_ID] = this ;
32 extern int trg_reader(
char *m,
struct trg_t *trg, u_int driver, u_int daqbits) ;
33 extern char *trg_find_raw(
char *m,
int *bytes);
37 LOG(DBG,
"TRG: rts_id %d, name %s, caller %p",rts_id,name,caller) ;
41 name = rts2name(rts_id) ;
45 if(caller) caller->insert(
this, rts_id) ;
50 LOG(DBG,
"%s: constructor: caller %p",name,caller) ;
55 LOG(DBG,
"%s: destructor",name) ;
64 daq_dta *daq_trg::get(
const char *bank,
int c1,
int c2,
int c3,
void *p1,
void *p2)
67 if(!present)
return 0 ;
69 if(strcmp(bank,
"*")==0) bank =
"legacy" ;
71 if(strcasecmp(bank,
"legacy") == 0) {
72 return handle_legacy() ;
74 else if(strcasecmp(bank,
"raw") == 0) {
78 LOG(ERR,
"%s: unknown bank %s",name,bank) ;
86 daq_dta *daq_trg::handle_legacy()
89 if(!(present & DET_PRESENT_DATAP)) {
90 LOG(NOTE,
"%s: can't have legacy without DATAP (post FY08), yet...",name) ;
95 legacy->create(1,
"trg_t",rts_id,DAQ_DTA_STRUCT(
trg_t)) ;
101 trg_reader(caller->mem, trg_p, m_Debug,caller->daqbits) ;
104 trg_p->daqbits = caller->daqbits ;
106 legacy->finalize(1,0,0,0) ;
121 if(present & DET_PRESENT_DATAP) {
122 ptr = trg_find_raw(caller->mem, &bytes) ;
124 LOG(DBG,
"%s: raw from DATAP: %d bytes",name,bytes) ;
126 if((ptr == 0) || (bytes == 0)) {
132 raw->create(bytes,
"trg_raw",rts_id,DAQ_DTA_STRUCT(
char)) ;
134 char *where = (
char *) raw->request(bytes) ;
135 memcpy(where, ptr, bytes) ;
141 sprintf(str,
"%s",sfs_name) ;
142 full_name = caller->get_sfs_name(str) ;
149 bytes = caller->sfs->fileSize(full_name) ;
155 LOG(DBG,
"%s(%s): full_name %s, bytes %d",name,sfs_name,full_name,bytes) ;
157 raw->create(bytes,
"trg_raw",rts_id,DAQ_DTA_STRUCT(
char)) ;
159 ptr = (
char *) raw->request(bytes) ;
161 ret = caller->sfs->read(full_name, ptr, bytes) ;
170 raw->finalize(bytes,0,0,0) ;
176 LOG(ERR,
"%s: handle_raw: error %d",name,err) ;