8 #include <daqFormats.h>
9 #include <rtsSystems.h>
14 int sc_reader(
char *m,
struct sc_t *sc, u_int driver)
19 if(m == NULL)
return 0 ;
27 datap = (
struct DATAP *) m ;
28 if(datap->bh.byte_order != DAQ_RAW_FORMAT_ORDER)
32 len = qswap32(swapdatap, datap->det[EXT_ID].len);
33 if(len == 0)
return 0;
35 off = qswap32(swapdatap, datap->det[EXT_ID].off);
36 if(off == 0)
return 0;
40 if(checkBank(datapx->bh.bank_type,
"DATAPX") < 0) {
46 if(datapx->bh.byte_order != DAQ_RAW_FORMAT_ORDER)
49 len = qswap32(swapdatapx, datapx->det[SC_ID-10].len);
50 if(len == 0)
return 0 ;
53 off = qswap32(swapdatapx, datapx->det[SC_ID-10].off);
54 if(off == 0)
return 0;
56 LOG(DBG,
"SC raw len %d (0x%x), off %d(0x%x)",len,len,off,off,0) ;
58 SCD *scd = (
struct SCD *)(((u_int *)datapx)+off) ;
59 if(checkBank(scd->bh.bank_type,
"SCD") < 0) {
63 if(scd->bh.byte_order != DAQ_RAW_FORMAT_ORDER)
67 int sz = qswap32(swapscd, scd->bh.length);
71 ((u_int)len >
sizeof(
SCD))) {
72 LOG(ERR,
"SCD Sizes not consistent: datap=%d, bh=%d SCD=%d",
73 len, sz,
sizeof(scd),0,0);
78 LOG(DBG,
"Need to swap SCD? %d",swapscd) ;
81 sc->time = qswap32(swapscd, scd->time);
82 int mag = qswap32(swapscd, scd->mag_field);
83 memcpy(&sc->mag_field, &mag, 4);
84 for(
int i=0;i<16;i++) {
85 sc->rich_scalers[i] = qswap32(swapscd, scd->rich_scalers[i]);
88 sc->timelag = qswap32(swapdatap, datap->time) - sc->time;
90 int alag = sc->timelag > 0 ? sc->timelag : -sc->timelag;
92 if(alag > 5) sc->valid = 0;