16 #include "TRG_Reader.hh"
18 #include "trgStructures2007.h"
19 #include "trgStructures2008.h"
22 using namespace OLDEVP;
26 #include "trgStructures.h"
34 #include "trgStructures2000.h"
47 #include "duplicated.code"
49 #define SWITCH(x) x ## 2000
50 #include "duplicated.code"
56 data+=
sizeof(
unsigned short)+
sizeof(
char);
58 if(*data==0x12)
return 2000;
59 if(*data==0x13)
return 2001;
60 if(*data==0x20)
return 2003;
61 if(*data==0x21)
return 2004;
62 if(*data==0x22)
return 2005;
65 if(*data==0x30)
return 2007;
67 if(*data==0x31)
return 2007;
69 if(*data==0x10 || *data==0x32)
return 2008;
71 (void) printf(
"TRG_Reader::YearOfData : value %d=0x%x not treated\n",*data,*data);
79 mErr(0),pBankUnp(0),sizeUnp(0),pTRGD(0)
88 if(!pBankTRGP->test_CRC()) {
89 (void) printf(
"TRG_Reader::TRG_Reader: CRC error: %s %d\n",__FILE__,__LINE__);
92 if(pBankTRGP->swap()<0) {
95 (void) printf(
"TRG_Reader::TRG_Reader: swap error: %s %d\n",__FILE__,__LINE__);
97 pBankTRGP->header.CRC=0;
98 pBankTRGD=(
Bank_TRGD*) ((
char *)pBankTRGP + 4*pBankTRGP->theData.offset);
101 if(!pBankTRGD->test_CRC()) {
103 (void) printf(
"TRG_Reader::TRG_Reader: CRC error: %s %d\n",__FILE__,__LINE__);
105 char *ptr=(
char*)pBankTRGD; ptr+=40;
110 (void) printf(
"TRG_Reader::TRG_Reader: YearOfData() returned a failure status\n");
118 if(pBankTRGD->HerbSwap2000() <0) {
120 (void) printf(
"TRG_Reader::TRG_Reader: Swap error %s %d.\n",__FILE__,__LINE__);
127 if(pBankTRGD->HerbSwap() <0) {
129 (void) printf(
"TRG_Reader::TRG_Reader: Swap error %s %d.\n",__FILE__,__LINE__);
136 if(pBankTRGD->HerbSwap2003(ptr)<0) {
138 (void) printf(
"TRG_Reader::TRG_Reader: Swap error %s %d.\n",__FILE__,__LINE__);
145 if(pBankTRGD->HerbSwap2004(ptr)<0) {
147 (void) printf(
"TRG_Reader::TRG_Reader: Swap error %s %d.\n",__FILE__,__LINE__);
154 if(pBankTRGD->HerbSwap2005(ptr)<0) {
156 (void) printf(
"TRG_Reader::TRG_Reader: Swap error %s %d.\n",__FILE__,__LINE__);
164 if(UnpackTrg2007(pBankTRGP) < 0){
166 (void) printf(
"TRG_Reader::TRG_Reader: Swap error %s %d.\n",__FILE__,__LINE__);
168 pBankTRGD=(
Bank_TRGD*) ((
char *)pBankTRGP + 4*pBankTRGP->theData.offset);
173 if(UnpackTrg2008(pBankTRGP) < 0){
175 (void) printf(
"TRG_Reader::TRG_Reader: Swap error %s %d.\n",__FILE__,__LINE__);
177 pBankTRGD=(
Bank_TRGD*) ((
char *)pBankTRGP + 4*pBankTRGP->theData.offset);
183 (void) printf(
"TRG_Reader::TRG_Reader: Trigger reader instantiated, distance to data = %d bytes.\n",
184 pBankTRGP->theData.offset);
187 void TRG_Reader::dumpWordsToScreenInHexAndExit(
int nwords) {
190 pp=(
unsigned int*)pBankTRGD;
191 if(
sizeof(
unsigned int)!=4) { PP
"Error 77b in %s.\n",__FILE__); assert(0); }
192 for(i=0;i<nwords;i++) {
193 PP
"word number %3d: 0x%08x\n",i+1,pp[i]);
195 PP
"Exiting from diagnostic function.\n");
200 sprintf(rv,
"%s[%3d]",msg,nn);
203 #define Funsigned_short "%32s 0x%04x %15d\n"
204 #define Fchar "%32s %c %15d\n"
205 #define Funsigned_int "%32s 0x%08x %15d\n"
206 #define Funsigned_char "%32s 0x%02x %15d\n"
207 #define Funsigned_long Funsigned_int
208 #define FF fprintf(ff,
413 int Bank_TRGD::swapHerb4bytes(
unsigned long *
data,
int number) {
414 return swapHerb4bytes((
unsigned int*)data,number);
416 int Bank_TRGD::swapHerb4bytes(
unsigned int *data,
int number) {
419 for(i=0;i<number;i++) {
420 hh=(
char*)(&(data[i]));
421 temp[0]=hh[3]; temp[1]=hh[2]; temp[2]=hh[1]; temp[3]=hh[0];
422 data[i]=*((INT32*)temp);
426 int Bank_TRGD::swapHerb2bytes(
short unsigned int *data,
int number) {
429 for(i=0;i<number;i++) {
430 hh=(
char*)(&(data[i]));
431 temp[0]=hh[1]; temp[1]=hh[0];
432 data[i]=*((INT16*)temp);
Bank_TRGD * pTRGD
Size of unpacked bank space.
char * PrintHelp(char *, int)
for 2007 and later see TRG_Reader::UnpackTrg below
int YearOfData(char *)
This routine also exists in St_trg_Maker.