5 #include <rtsSystems.h>
6 #include <daqFormats.h>
8 #include <SFS/sfs_index.h>
9 #include <DAQ_READER/daqReader.h>
10 #include <DAQ_READER/daq_dta.h>
14 extern int sc_reader(
char *m,
struct sc_t *sc, u_int driver) ;
22 daq_det_factory::det_factories[SC_ID] = this ;
35 const char *daq_sc::help_string =
"SC tst\n" ;
41 LOG(DBG,
"SC: rts_id %d, name %s",rts_id,name) ;
45 name = rts2name(rts_id) ;
50 if(caller) caller->insert(
this, rts_id) ;
55 LOG(DBG,
"%s: constructor: caller %p",name,caller) ;
60 LOG(DBG,
"%s: destructor",name) ;
69 daq_dta *daq_sc::get(
const char *bank,
int c1,
int c2,
int c3,
void *p1,
void *p2)
72 if(!present)
return 0 ;
75 if(!bank || strcmp(bank,
"*")==0) bank =
"legacy" ;
77 if(strcasecmp(bank,
"legacy") == 0) {
78 return handle_legacy() ;
80 else if(strcasecmp(bank,
"raw") == 0) {
84 LOG(ERR,
"%s: unknown bank %s",name,bank) ;
94 char *local_store = 0 ;
100 if(!(present & DET_PRESENT_SFS))
return 0 ;
104 sprintf(str,
"%s",sfs_name) ;
105 full_name = caller->get_sfs_name(str) ;
112 bytes = caller->sfs->fileSize(full_name) ;
118 raw->create(bytes,
"sc_raw",rts_id,DAQ_DTA_STRUCT(
char)) ;
120 local_store = (
char *) raw->request(bytes) ;
122 ret = caller->sfs->read(str, local_store, bytes) ;
129 raw->finalize(bytes,0,0,0) ;
136 LOG(ERR,
"%s: handle_raw: error %d",name,err) ;
141 daq_dta *daq_sc::handle_legacy()
148 legacy->create(1,
"sc_t",rts_id,DAQ_DTA_STRUCT(
sc_t)) ;
151 sc_t *sc_p = (
sc_t *) legacy->request(1) ;
154 if(present & DET_PRESENT_DATAP) {
155 sc_reader(caller->mem, sc_p, m_Debug) ;
168 struct SCD *scd = (
struct SCD *) dd->Void ;
171 if(scd->bh.byte_order != DAQ_RAW_FORMAT_ORDER) {
175 LOG(DBG,
"Need to swap SCD(sfs) %d?",swapit) ;
177 sc_p->time = qswap32(swapit,scd->time) ;
179 u_int tmp_f = qswap32(swapit,scd->mag_field) ;
180 memcpy(&(sc_p->mag_field),&tmp_f,4) ;
186 for(u_int i=0;i<(
sizeof(sc_p->rich_scalers)/4);i++) {
187 sc_p->rich_scalers[i] = qswap32(swapit, scd->rich_scalers[i]) ;
192 legacy->finalize(1,0,0,0) ;
199 LOG(ERR,
"%s: handle_legacy: error %d",name,err) ;