46 #include "azim_to_rcvb.h"
48 using namespace OLDEVP;
56 int FTPV1P0_PADK_SR::initialize()
60 memset((
char *)packed_address, 0,
sizeof(packed_address));
65 classname(Bank_FTPPADK) *raw_bank = detector->getBankFTPPADK(sector);
74 for(
int i=0; i < FTP_MZPADS; i++)
76 int padrow = raw_bank->index[i].pad_row;
77 int pad = raw_bank->index[i].pad;
78 if((padrow == 0xFF) && (pad == 0xFF))
continue;
83 padrow = ((int)(padrow-1)/6)%2+1;
84 place(padrow, pad, &ent);
92 void FTPV1P0_PADK_SR::place(
short padrow,
short pad,
FTPPADK_entry *p)
95 packed_address[padrow][pad] = pack(p->offset);
98 void FTPV1P0_PADK_SR::get(
short padrow,
short pad,
FTPPADK_entry *p)
101 unpack(p,packed_address[padrow][pad]);
105 short FTPV1P0_PADK_SR::pack(
short offset)
111 void FTPV1P0_PADK_SR::unpack(
FTPPADK_entry *entry,
short paddress)
113 entry->offset = paddress & 0x03FF;
120 if(!zs->initialize())
128 ADCRawReader *FTPV1P0_Reader::getADCRawReader(
int sector)
131 if(!adc->initialize())
142 if(!ped->initialize())
154 if(!rms->initialize())
163 GainReader *FTPV1P0_Reader::getGainReader(
int sector)
168 CPPReader *FTPV1P0_Reader::getCPPReader(
int sector)
171 if(!cpp->initialize())
185 ConfigReader *FTPV1P0_Reader::getConfigReader(
int sector)
195 if ((sector <= 0) || (sector > 60))
208 cout <<
"Error Reading PADK banks, sector=" << sector
209 <<
": " << errstr().c_str() << endl;
219 FTPV1P0_Reader::FTPV1P0_Reader(
EventReader *er, classname(Bank_FTPP) *pftp)
224 if (!pBankFTPP->test_CRC()) ERROR(ERR_CRC);
225 if (pBankFTPP->swap() < 0) ERROR(ERR_SWAP);
226 pBankFTPP->header.CRC = 0;
229 for(
int i=0;i<FTP_SECTORS;i++)
235 FTPV1P0_Reader::~FTPV1P0_Reader()
241 for(
int i=0;i<FTP_SECTORS;i++)
243 if(padk[i] != NULL)
delete padk[i];
247 int FTPV1P0_Reader::MemUsed()
257 classname(Bank_FTPCHAP) *FTPV1P0_Reader::getBankFTPCHAP(
int sector)
259 if((sector <= 0) || (sector > 60))
266 int chamber = sector_map[sector-1][0];
267 if((chamber < 0) || (chamber >= 2))
274 if((!pBankFTPP->Chamber[chamber].offset) ||
275 (!pBankFTPP->Chamber[chamber].length))
281 classname(Bank_FTPCHAP) *ptr = (classname(Bank_FTPCHAP) *)
282 (((INT32 *)pBankFTPP) +
283 pBankFTPP->Chamber[chamber].offset);
285 if(!ptr->test_CRC()) { pERROR(ERR_CRC);
return NULL; }
286 if(ptr->swap() < 0) { pERROR(ERR_SWAP);
return NULL; }
294 classname(Bank_FTPRBP) *FTPV1P0_Reader::getBankFTPRBP(
int sector,
295 classname(Bank_FTPCHAP) *chap)
297 if ((sector <= 0) || (sector > 60))
304 int rcvb = sector_map[sector-1][1];
if(rcvb>9) rcvb-=10;
305 if ((rcvb < 0) || (rcvb >= 10))
316 if ((!chap->RcvBoard[rcvb].offset) ||
317 (!chap->RcvBoard[rcvb].length) )
323 classname(Bank_FTPRBP) *ptr = (classname(Bank_FTPRBP) *)
325 chap->RcvBoard[rcvb].offset);
327 if(!ptr->test_CRC()) { pERROR(ERR_CRC);
return NULL; }
328 if(ptr->swap() < 0) { pERROR(ERR_SWAP);
return NULL; }
335 classname(Bank_FTPAZIP) *FTPV1P0_Reader::getBankFTPAZIP(
int sector,
336 classname(Bank_FTPRBP) *rbp)
338 if((sector <= 0) || (sector > 60))
345 int intsec = sector_map[sector-1][2];
347 if((intsec < 0) || (intsec >= 3))
353 if((!rbp->Sector[intsec].offset) ||
354 (!rbp->Sector[intsec].length))
360 classname(Bank_FTPAZIP) *ptr = (classname(Bank_FTPAZIP) *)
362 rbp->Sector[intsec].offset);
364 if(!ptr->test_CRC()) { pERROR(ERR_CRC);
return NULL; }
365 if(ptr->swap() < 0) { pERROR(ERR_SWAP);
return NULL; }
372 classname(Bank_FTPMZP) *FTPV1P0_Reader::getBankFTPMZP(
int sector,
373 classname(Bank_FTPRBP) *azip)
377 if ((sector <= 0) || (sector > 60))
385 int mz = sector_map[sector-1][2];
386 if ((mz < 0) || (mz >= 3))
397 if ((!azip->Sector[mz].offset) || (!azip->Sector[mz].length))
403 classname(Bank_FTPMZP) *ptr = (classname(Bank_FTPMZP) *)
405 azip->Sector[mz].offset);
408 if(!ptr->test_CRC()) { pERROR(ERR_CRC);
return NULL; }
409 if(ptr->swap() < 0) { pERROR(ERR_SWAP);
return NULL; }
418 classname(Bank_FTPMZP) *FTPV1P0_Reader::getBankFTPMZP(
int sector)
420 if ((sector <= 0) || (sector > 60))
426 classname(Bank_FTPCHAP) *chap = getBankFTPCHAP(sector);
427 if(!chap)
return NULL;
429 classname(Bank_FTPRBP) *rbp = getBankFTPRBP(sector, chap);
430 if(!rbp)
return NULL;
432 classname(Bank_FTPAZIP) *azip = getBankFTPAZIP(sector, rbp);
433 if(!azip)
return NULL;
436 classname(Bank_FTPMZP) *mzp = getBankFTPMZP(sector,rbp);
443 classname(Bank_FTPADCD) *FTPV1P0_Reader::getBankFTPADCD(
int sector)
448 classname(Bank_FTPMZP) *mzp = getBankFTPMZP(sector);
449 if(!mzp)
return NULL;
451 if((!mzp->FTPADCD.offset) || (!mzp->FTPADCD.length))
457 classname(Bank_FTPADCD) *ptr = (classname(Bank_FTPADCD) *)
459 mzp->FTPADCD.offset);
461 if(!ptr->test_CRC()) { pERROR(ERR_CRC);
return NULL; }
462 if(ptr->swap() < 0) { pERROR(ERR_SWAP);
return NULL; }
468 classname(Bank_FTPSEQD) *FTPV1P0_Reader::getBankFTPSEQD(
int sector)
473 classname(Bank_FTPMZP) *mzp = getBankFTPMZP(sector);
474 if(!mzp)
return NULL;
476 if((!mzp->FTPSEQD.offset) || (!mzp->FTPSEQD.length))
482 classname(Bank_FTPSEQD) *ptr = (classname(Bank_FTPSEQD) *)
484 mzp->FTPSEQD.offset);
486 if(!ptr->test_CRC()) { pERROR(ERR_CRC);
return NULL; }
487 if(ptr->swap() < 0) { pERROR(ERR_SWAP);
return NULL; }
493 classname(Bank_FTPADCX) *FTPV1P0_Reader::getBankFTPADCX(
int sector)
498 classname(Bank_FTPMZP) *mzp = getBankFTPMZP(sector);
499 if(!mzp)
return NULL;
501 if((!mzp->FTPADCX.offset) || (!mzp->FTPADCX.length))
507 classname(Bank_FTPADCX) *ptr = (classname(Bank_FTPADCX) *)
509 mzp->FTPADCX.offset);
511 if(!ptr->test_CRC()) { pERROR(ERR_CRC);
return NULL; }
512 if(ptr->swap() < 0) { pERROR(ERR_SWAP);
return NULL; }
518 classname(Bank_FTPPADK) *FTPV1P0_Reader::getBankFTPPADK(
int sector)
523 classname(Bank_FTPMZP) *mzp = getBankFTPMZP(sector);
524 if(!mzp)
return NULL;
529 if((!mzp->FTPPADK.offset) || (!mzp->FTPPADK.length))
535 classname(Bank_FTPPADK) *ptr = (classname(Bank_FTPPADK) *)
537 mzp->FTPPADK.offset);
539 if(!ptr->test_CRC()) { pERROR(ERR_CRC);
return NULL; }
540 if(ptr->swap() < 0) { pERROR(ERR_SWAP);
return NULL; }
546 classname(Bank_FTPCPPR) *FTPV1P0_Reader::getBankFTPCPPR(
int sector)
551 classname(Bank_FTPMZP) *mzp = getBankFTPMZP(sector);
552 if(!mzp)
return NULL;
554 if((!mzp->FTPCPPR.offset) || (!mzp->FTPCPPR.length))
560 classname(Bank_FTPCPPR) *ptr = (classname(Bank_FTPCPPR) *)
562 mzp->FTPCPPR.offset);
564 if(!ptr->test_CRC()) { pERROR(ERR_CRC);
return NULL; }
565 if(ptr->swap() < 0) { pERROR(ERR_SWAP);
return NULL; }
571 classname(Bank_FTPADCR) *FTPV1P0_Reader::getBankFTPADCR(
int sector)
576 classname(Bank_FTPMZP) *mzp = getBankFTPMZP(sector);
577 if(!mzp)
return NULL;
579 if((!mzp->FTPADCR.offset) || (!mzp->FTPADCR.length))
585 classname(Bank_FTPADCR) *ptr = (classname(Bank_FTPADCR) *)
587 mzp->FTPADCR.offset);
589 if(!ptr->test_CRC()) { pERROR(ERR_CRC);
return NULL; }
590 if(ptr->swap() < 0) { pERROR(ERR_SWAP);
return NULL; }
596 classname(Bank_FTPCFGR) *FTPV1P0_Reader::getBankFTPCFGR(
int sector)
601 classname(Bank_FTPPEDR) *FTPV1P0_Reader::getBankFTPPEDR(
int sector)
606 classname(Bank_FTPMZP) *mzp = getBankFTPMZP(sector);
607 if(!mzp)
return NULL;
609 if((!mzp->FTPPEDR.offset) || (!mzp->FTPPEDR.length))
615 classname(Bank_FTPPEDR) *ptr = (classname(Bank_FTPPEDR) *)
617 mzp->FTPPEDR.offset);
619 if(!ptr->test_CRC()) { pERROR(ERR_CRC);
return NULL; }
620 if(ptr->swap() < 0) { pERROR(ERR_SWAP);
return NULL; }
627 classname(Bank_FTPRMSR) *FTPV1P0_Reader::getBankFTPRMSR(
int sector)
632 classname(Bank_FTPMZP) *mzp = getBankFTPMZP(sector);
633 if(!mzp)
return NULL;
635 if((!mzp->FTPRMSR.offset) || (!mzp->FTPRMSR.length))
641 classname(Bank_FTPRMSR) *ptr = (classname(Bank_FTPRMSR) *)
643 mzp->FTPRMSR.offset);
645 if(!ptr->test_CRC()) { pERROR(ERR_CRC);
return NULL; }
646 if(ptr->swap() < 0) { pERROR(ERR_SWAP);
return NULL; }
653 classname(Bank_FTPGAINR) *FTPV1P0_Reader::getBankFTPGAINR(
int sector)
655 cout <<
"warning: FTPV1P0_Reader::getBankFTPGAINR() not implemented!"<< endl;
659 classname(Bank_FTPBADR) *FTPV1P0_Reader::getBankFTPBADR(
int sector)
661 cout <<
"warning: FTPV1P0_Reader::getBankFTPBADR() not implemented!"<< endl;