#include "TPCCommandCoderReadback.h" #define CoCoVersion "TPCCommandCoderReadback" //=========================================================================== TPCCommandCoderReadback::TPCCommandCoderReadback() { // // Constructor: Setup and connect to DB // fError.clear(); fDataBlock = new RcuContainer(); fALTRO = new AltroCommandCoder(); fRCU = new RCUCommandCoder; fBC = new BoardControllerCommandCoder(); fRCUce = new RCUControlEngine(); fBranch = 0; fFec = 0; fAltro = 0; fVersion = CoCoVersion; } //=========================================================================== TPCCommandCoderReadback::~TPCCommandCoderReadback() { // // Destructor // delete fRCU; delete fALTRO; delete fBC; delete fRCUce; delete fDataBlock; } //=========================================================================== void TPCCommandCoderReadback::reset() { // // Reset container // fDataBlock->reset(); } //=========================================================================== uint32_t* TPCCommandCoderReadback::getDataBlock() { // // Send the data block // return fDataBlock->getDataBlock(); } //=========================================================================== int TPCCommandCoderReadback::createDataBlock(char* target, int tag){ // // Create the data block. Return length (in bytes!). // uint32_t data; reset(); fDataBlock->setHardwareAddress(0xa); // dummy fDataBlock->setExternalConfiguration(false); // DCS only for(int channel = 0; channel < 16; channel++){ data = (uint32_t)fRCU->sendReadInstruction(fALTRO->receiveK1(fBranch,fFec,fAltro,channel)); fDataBlock->fillAltro(fBranch,fFec,fAltro,data); data = (uint32_t)fRCU->sendReadInstruction(fALTRO->receiveK2(fBranch,fFec,fAltro,channel)); fDataBlock->fillAltro(fBranch,fFec,fAltro,data); data = (uint32_t)fRCU->sendReadInstruction(fALTRO->receiveK3(fBranch,fFec,fAltro,channel)); fDataBlock->fillAltro(fBranch,fFec,fAltro,data); data = (uint32_t)fRCU->sendReadInstruction(fALTRO->receiveL1(fBranch,fFec,fAltro,channel)); fDataBlock->fillAltro(fBranch,fFec,fAltro,data); data = (uint32_t)fRCU->sendReadInstruction(fALTRO->receiveL2(fBranch,fFec,fAltro,channel)); fDataBlock->fillAltro(fBranch,fFec,fAltro,data); data = (uint32_t)fRCU->sendReadInstruction(fALTRO->receiveL3(fBranch,fFec,fAltro,channel)); fDataBlock->fillAltro(fBranch,fFec,fAltro,data); data = (uint32_t)fRCU->sendReadInstruction(fALTRO->receiveVFPED(fBranch,fFec,fAltro,channel)); fDataBlock->fillAltro(fBranch,fFec,fAltro,data); } // end channel loop data = (uint32_t)fRCU->sendReadInstruction(fALTRO->receiveZSTHR(fBranch,fFec,fAltro)); fDataBlock->fillAltro(fBranch,fFec,fAltro,data); data = (uint32_t)fRCU->sendReadInstruction(fALTRO->receiveBCTHR(fBranch,fFec,fAltro)); fDataBlock->fillAltro(fBranch,fFec,fAltro,data); data = (uint32_t)fRCU->sendReadInstruction(fALTRO->receiveTRCFG(fBranch,fFec,fAltro)); fDataBlock->fillAltro(fBranch,fFec,fAltro,data); data = (uint32_t)fRCU->sendReadInstruction(fALTRO->receiveDPCFG(fBranch,fFec,fAltro)); fDataBlock->fillAltro(fBranch,fFec,fAltro,data); data = (uint32_t)fRCU->sendReadInstruction(fALTRO->receiveDPCF2(fBranch,fFec,fAltro)); fDataBlock->fillAltro(fBranch,fFec,fAltro,data); // ================= Send READ_RESULT instruction ================== // add read result command fDataBlock->setReadResult(2*(7*16+5)); fDataBlock->finalize(); // return the length of the data block (in bytes!) // If size is negative, InterComLayer will analyse Errors. return (int)(fDataBlock->size()*4); } //=========================================================================== int TPCCommandCoderReadback::strtonum(string number) { // // convert string to number // char * strolConversionCheck; int retval = strtol(number.c_str(),&strolConversionCheck,0); return retval; } //=========================================================================== CommandCoderBase* getCoCoInst(void){ // // Get Command Coder Instance. This is called by e.g. InterComLayer in order to // use the Command Coder from the shared object library. // static TPCCommandCoderReadback instance; return &instance; }