#include <FUResource.h>
Public Member Functions | |
void | allocate (FUShmRawCell *shmCell) |
void | appendBlockToSuperFrag (MemRef_t *bufRef) |
UInt_t | buResourceId () const |
bool | crcBeingChecked () |
void | doCrcCheck (bool doCrcCheck) |
UInt_t | evtNumber () const |
bool | fatalError () const |
void | fillSuperFragPayload () throw (evf::Exception) |
FUResource (UInt_t fuResourceId, log4cplus::Logger, EvffedFillerRB *, xdaq::Application *) | |
UInt_t | fuResourceId () const |
void | incNbSent () |
bool | isAllocated () const |
bool | isComplete () const |
UInt_t | nbBytes (bool reset=true) |
UInt_t | nbCrcErrors (bool reset=true) |
UInt_t | nbErrors (bool reset=true) |
UInt_t | nbSent () const |
void | process (MemRef_t *bufRef) |
void | release (bool detachResource) |
void | releaseSuperFrag () |
void | removeLastAppendedBlockFromSuperFrag () |
void | scheduleCRCError () |
evf::FUShmRawCell * | shmCell () |
void | superFragSize () throw (evf::Exception) |
virtual | ~FUResource () |
Static Public Member Functions | |
static void | doFedIdCheck (bool doFedIdCheck) |
static void | useEvmBoard (bool useEvmBoard) |
Private Attributes | |
xdaq::Application * | app_ |
UInt_t | buResourceId_ |
bool | doCrcCheck_ |
UInt_t | eventPayloadSize_ |
UInt_t | eventSize_ |
UInt_t | evtNumber_ |
bool | fatalError_ |
UInt_t | fedSize_ [1024] |
EvffedFillerRB * | frb_ |
UInt_t | fuResourceId_ |
UInt_t | iBlock_ |
UInt_t | iSuperFrag_ |
log4cplus::Logger | log_ |
UInt_t | nbBytes_ |
UInt_t | nbCrcErrors_ |
UInt_t | nbErrors_ |
UInt_t | nBlock_ |
UInt_t | nbSent_ |
bool | nextEventWillHaveCRCError_ |
UInt_t | nFedMax_ |
UInt_t | nSuperFrag_ |
UInt_t | nSuperFragMax_ |
evf::FUShmRawCell * | shmCell_ |
MemRef_t * | superFragHead_ |
UInt_t | superFragSize_ |
MemRef_t * | superFragTail_ |
Static Private Attributes | |
static bool | doFedIdCheck_ = true |
static unsigned int | gtpDaqId_ = FEDNumbering::MAXTriggerGTPFEDID |
static unsigned int | gtpeId_ = FEDNumbering::MINTriggerEGTPFEDID |
static unsigned int | gtpEvmId_ = FEDNumbering::MINTriggerGTPFEDID |
static bool | useEvmBoard_ = true |
Friends | |
class | ResourceChecker |
FUResource::FUResource | ( | UInt_t | fuResourceId, |
log4cplus::Logger | logger, | ||
EvffedFillerRB * | frb, | ||
xdaq::Application * | app | ||
) |
Definition at line 45 of file FUResource.cc.
: log_(logger), fuResourceId_(fuResourceId), superFragHead_(0), superFragTail_(0), nbBytes_(0), superFragSize_(0), shmCell_(0), frb_(frb), app_(app), nextEventWillHaveCRCError_(false) { //release(); }
FUResource::~FUResource | ( | ) | [virtual] |
Definition at line 54 of file FUResource.cc.
{ }
void FUResource::allocate | ( | FUShmRawCell * | shmCell | ) |
Associate a ShmRawCell to the resource
Definition at line 63 of file FUResource.cc.
References evf::FUShmRawCell::clear(), eventPayloadSize_, fuResourceId_, evf::FUShmRawCell::nFed(), nFedMax_, evf::FUShmRawCell::nSuperFrag(), nSuperFragMax_, evf::FUShmRawCell::payloadSize(), evf::FUShmRawCell::setEventTypeData(), evf::FUShmRawCell::setFuResourceId(), shmCell(), and shmCell_.
Referenced by evf::FUResourceQueue::buildResource(), and evf::FUResourceTable::buildResource().
{ //release(); shmCell_ = shmCell; shmCell_->clear(); shmCell_->setFuResourceId(fuResourceId_); //UPDATED shmCell_->setEventTypeData(); eventPayloadSize_ = shmCell_->payloadSize(); nFedMax_ = shmCell_->nFed(); nSuperFragMax_ = shmCell_->nSuperFrag(); /* cout << "shmCell = " << shmCell_ << " shm cell furesourceId = " << fuResourceId_ << " payload size = " << shmCell_->payloadSize() << " nFed max = " << shmCell_->nFed() << " nSuperFragMax_ = " << shmCell_->nSuperFrag() << endl; */ }
void FUResource::appendBlockToSuperFrag | ( | MemRef_t * | bufRef | ) |
Append I2O block to super fragment
Definition at line 184 of file FUResource.cc.
References superFragHead_, and superFragTail_.
{ if (0 == superFragHead_) { superFragHead_ = bufRef; superFragTail_ = bufRef; } else { superFragTail_->setNextReference(bufRef); superFragTail_ = bufRef; } return; }
UInt_t evf::FUResource::buResourceId | ( | ) | const [inline] |
bool evf::FUResource::crcBeingChecked | ( | ) | [inline] |
void evf::FUResource::doCrcCheck | ( | bool | doCrcCheck | ) | [inline] |
Definition at line 104 of file FUResource.h.
References doCrcCheck_.
Referenced by evf::FUResourceQueue::buildResource(), and evf::FUResourceTable::buildResource().
{ doCrcCheck_ = doCrcCheck; }
static void evf::FUResource::doFedIdCheck | ( | bool | doFedIdCheck | ) | [inline, static] |
Definition at line 97 of file FUResource.h.
References doFedIdCheck_.
Referenced by evf::FUResourceBroker::actionPerformed(), and evf::rb_statemachine::SharedResources::configureResources().
{ doFedIdCheck_ = doFedIdCheck; }
UInt_t evf::FUResource::evtNumber | ( | ) | const [inline] |
bool evf::FUResource::fatalError | ( | ) | const [inline] |
Definition at line 110 of file FUResource.h.
References fatalError_.
Referenced by evf::FUResourceQueue::buildResource(), evf::FUResourceTable::buildResource(), and process().
{ return fatalError_; }
void FUResource::fillSuperFragPayload | ( | ) | throw (evf::Exception) |
Fills super fragment payload with I2O blocks
Definition at line 248 of file FUResource.cc.
References evtNumber_, fuResourceId_, iSuperFrag_, evf::FUShmRawCell::markSuperFrag(), nbBytes(), nbBytes_, nbErrors_, shmCell_, superFragHead_, superFragSize_, and evf::FUShmRawCell::writeData().
{ UChar_t *blockAddr = 0; UChar_t *frlHeaderAddr = 0; UChar_t *fedAddr = 0; UInt_t nbBytes = 0; UInt_t nbBytesTot = 0; frlh_t *frlHeader = 0; UChar_t *bufferPos = 0; UChar_t *startPos = 0; MemRef_t* bufRef = superFragHead_; while (bufRef != 0) { blockAddr = (UChar_t*) bufRef->getDataLocation(); frlHeaderAddr = blockAddr + sizeof(I2O_EVENT_DATA_BLOCK_MESSAGE_FRAME); fedAddr = frlHeaderAddr + sizeof(frlh_t); frlHeader = (frlh_t*) frlHeaderAddr; nbBytes = frlHeader->segsize & FRL_SEGSIZE_MASK; nbBytesTot += nbBytes; // check if still within limits if (nbBytesTot > superFragSize_) { nbErrors_++; stringstream oss; oss << "Reached end of buffer." << " fuResourceId:" << fuResourceId_ << " evtNumber:" << evtNumber_ << " iSuperFrag:" << iSuperFrag_; XCEPT_RAISE(evf::Exception, oss.str()); } bufferPos = shmCell_->writeData(fedAddr, nbBytes); if (0 == startPos) startPos = bufferPos; nbBytes_ += nbBytes; bufRef = bufRef->getNextReference(); } if (!shmCell_->markSuperFrag(iSuperFrag_, superFragSize_, startPos)) { nbErrors_++; stringstream oss; oss << "Failed to mark super fragment in shared mem buffer." << " fuResourceId:" << fuResourceId_ << " evtNumber:" << evtNumber_ << " iSuperFrag:" << iSuperFrag_; XCEPT_RAISE(evf::Exception, oss.str()); } return; }
UInt_t evf::FUResource::fuResourceId | ( | ) | const [inline] |
void evf::FUResource::incNbSent | ( | ) | [inline] |
Increment the number of sent resources
Definition at line 134 of file FUResource.h.
References nbSent_.
{ nbSent_++; }
bool evf::FUResource::isAllocated | ( | ) | const [inline] |
Definition at line 113 of file FUResource.h.
References shmCell_.
Referenced by evf::FUResourceQueue::buildResource(), and evf::FUResourceTable::buildResource().
{ return 0 != shmCell_; }
bool evf::FUResource::isComplete | ( | ) | const [inline] |
Checks if all I2O blocks have been received for this resource
Definition at line 221 of file FUResource.h.
References gather_cfg::cout, iBlock_, iSuperFrag_, nBlock_, and nSuperFrag_.
Referenced by evf::FUResourceQueue::buildResource(), evf::FUResourceTable::buildResource(), and process().
{ #ifdef DEBUG_FURESOURCE_H cout << "------------------------------------------------------"<< endl; cout << "nBlock " << nBlock_ << " iBlock " << iBlock_ << " nSuperFrag " << nSuperFrag_ << " iSuperFrag " << iSuperFrag_ << endl; #endif return (nBlock_ && nSuperFrag_ && (iSuperFrag_ == nSuperFrag_) && (iBlock_ == nBlock_)); }
UInt_t FUResource::nbBytes | ( | bool | reset = true | ) |
Definition at line 324 of file FUResource.cc.
References nbBytes_, and query::result.
Referenced by fillSuperFragPayload().
UInt_t FUResource::nbCrcErrors | ( | bool | reset = true | ) |
Definition at line 316 of file FUResource.cc.
References nbCrcErrors_, and query::result.
Referenced by evf::FUResourceQueue::buildResource(), and evf::FUResourceTable::buildResource().
{ UInt_t result = nbCrcErrors_; if (reset) nbCrcErrors_ = 0; return result; }
UInt_t FUResource::nbErrors | ( | bool | reset = true | ) |
Definition at line 308 of file FUResource.cc.
References nbErrors_, and query::result.
Referenced by evf::FUResourceQueue::buildResource(), and evf::FUResourceTable::buildResource().
UInt_t evf::FUResource::nbSent | ( | ) | const [inline] |
void FUResource::process | ( | MemRef_t * | bufRef | ) |
Process resource
Definition at line 126 of file FUResource.cc.
References gather_cfg::cout, alignCSCRings::e, evtNumber_, Exception, fatalError(), fatalError_, evf::EvffedFillerRB::fedId(), fedSize_, frb_, fuResourceId_, evf::EvffedFillerRB::getPayload(), isComplete(), iSuperFrag_, log_, evf::FUShmRawCell::markFed(), evf::FUShmRawCell::markSuperFrag(), nbErrors_, evf::ResourceChecker::processDataBlock(), evf::EvffedFillerRB::putHeader(), evf::EvffedFillerRB::putTrailer(), shmCell_, evf::EvffedFillerRB::size(), superFragSize_, and evf::FUShmRawCell::writeData().
Referenced by evf::FUResourceQueue::buildResource(), and evf::FUResourceTable::buildResource().
{ if (fatalError()) { LOG4CPLUS_ERROR(log_, "THIS SHOULD *NEVER* HAPPEN!."); // DEBUG bufRef->release(); return; } #ifdef DEBUG_FU_RES std::cout << "Started process() for bufRef: " << bufRef<< std::endl; #endif MemRef_t* itBufRef = bufRef; while (0 != itBufRef && !fatalError()) { MemRef_t* next = itBufRef->getNextReference(); itBufRef->setNextReference(0); try { ResourceChecker resCheck(this); resCheck.processDataBlock(itBufRef); } catch (xcept::Exception& e) { LOG4CPLUS_ERROR(log_, "EVENT LOST:" << xcept::stdformat_exception_history(e)); fatalError_ = true; itBufRef->setNextReference(next); } itBufRef = next; } if (isComplete()) { frb_->putHeader(evtNumber_, 0); frb_->putTrailer(); fedSize_[frb_->fedId()] = frb_->size(); UChar_t *startPos = shmCell_->writeData(frb_->getPayload(), frb_->size()); superFragSize_ = frb_->size(); if (!shmCell_->markSuperFrag(iSuperFrag_, superFragSize_, startPos)) { nbErrors_++; stringstream oss; oss << "Failed to mark super fragment in shared mem buffer." << " fuResourceId:" << fuResourceId_ << " evtNumber:" << evtNumber_ << " iSuperFrag:" << iSuperFrag_; XCEPT_RAISE(evf::Exception, oss.str()); } if (!shmCell_->markFed(frb_->fedId(), frb_->size(), startPos)) { nbErrors_++; stringstream oss; oss << "Failed to mark fed in buffer." << " evtNumber:" << evtNumber_ << " fedId:" << frb_->fedId() << " fedSize:" << frb_->size() << " fedAddr:0x" << hex << (unsigned long) frb_->getPayload() << dec; XCEPT_RAISE(evf::Exception, oss.str()); } } return; }
void FUResource::release | ( | bool | detachResource | ) |
Release resource
Definition at line 82 of file FUResource.cc.
References buResourceId_, doCrcCheck_, alignCSCRings::e, eventSize_, evtNumber_, Exception, fatalError_, fedSize_, i, iBlock_, iSuperFrag_, log_, nbCrcErrors_, nbErrors_, nBlock_, nbSent_, nSuperFrag_, shmCell_, superFragHead_, and superFragTail_.
Referenced by evf::FUResourceQueue::buildResource(), evf::FUResourceTable::buildResource(), evf::FUResourceQueue::initialize(), and evf::FUResourceTable::initialize().
{ doCrcCheck_ = false; fatalError_ = false; buResourceId_ = 0xffffffff; evtNumber_ = 0xffffffff; if (0 != superFragHead_) { try { superFragHead_->release(); } catch (xcept::Exception& e) { LOG4CPLUS_ERROR( log_, "Failed to release superFragHead: " << xcept::stdformat_exception_history(e)); } } superFragHead_ = 0; superFragTail_ = 0; iBlock_ = 0; nBlock_ = 0xffffffff; iSuperFrag_ = 0; nSuperFrag_ = 0xffffffff; nbSent_ = 0; nbErrors_ = 0; nbCrcErrors_ = 0; for (UInt_t i = 0; i < 1024; i++) fedSize_[i] = 0; eventSize_ = 0; if (0 != shmCell_) { shmCell_ = 0; if (detachResource) shmdt(shmCell_); } }
void FUResource::releaseSuperFrag | ( | ) |
Releases the current super fragment and memory used by it
Definition at line 298 of file FUResource.cc.
References superFragHead_, and superFragTail_.
{ if (0 == superFragHead_) return; superFragHead_->release(); // throws xcept::Exception superFragHead_ = 0; superFragTail_ = 0; return; }
void FUResource::removeLastAppendedBlockFromSuperFrag | ( | ) |
Remove last appended I2O block from super fragment
Definition at line 196 of file FUResource.cc.
References cond::rpcobimon::current, superFragHead_, and superFragTail_.
{ if (0 == superFragHead_) { //nothing to do... why did we get here then ??? } else if (superFragHead_ == superFragTail_) { superFragHead_ = 0; superFragTail_ = 0; } else { MemRef_t *next = 0; MemRef_t *current = superFragHead_; while ((next = current->getNextReference()) != superFragTail_) { current = next; //get to the next-to-last block } superFragTail_ = current; current->setNextReference(0); } return; }
void evf::FUResource::scheduleCRCError | ( | ) | [inline] |
Definition at line 148 of file FUResource.h.
References nextEventWillHaveCRCError_.
{ nextEventWillHaveCRCError_ = true; }
evf::FUShmRawCell* evf::FUResource::shmCell | ( | ) | [inline] |
Returns a pointer to the Shm Raw cell associated to this resource
Definition at line 145 of file FUResource.h.
References shmCell_.
Referenced by allocate(), and evf::FUResourceTable::buildResource().
{ return shmCell_; }
void FUResource::superFragSize | ( | ) | throw (evf::Exception) |
Returns the size of the current super fragment
Definition at line 216 of file FUResource.cc.
References eventPayloadSize_, eventSize_, evtNumber_, fuResourceId_, iSuperFrag_, nbErrors_, superFragHead_, and superFragSize_.
{ UChar_t *blockAddr = 0; UChar_t *frlHeaderAddr = 0; frlh_t *frlHeader = 0; superFragSize_ = 0; UInt_t frameSize = sizeof(I2O_EVENT_DATA_BLOCK_MESSAGE_FRAME); MemRef_t* bufRef = superFragHead_; while (0 != bufRef) { blockAddr = (UChar_t*) bufRef->getDataLocation(); frlHeaderAddr = blockAddr + frameSize; frlHeader = (frlh_t*) frlHeaderAddr; superFragSize_ += frlHeader->segsize & FRL_SEGSIZE_MASK; bufRef = bufRef->getNextReference(); } eventSize_ += superFragSize_; if (eventSize_ > eventPayloadSize_) { nbErrors_++; stringstream oss; oss << "Event size exceeds maximum size." << " fuResourceId:" << fuResourceId_ << " evtNumber:" << evtNumber_ << " iSuperFrag:" << iSuperFrag_ << " eventSize:" << eventSize_ << " eventPayloadSize:" << eventPayloadSize_; XCEPT_RAISE(evf::Exception, oss.str()); } }
static void evf::FUResource::useEvmBoard | ( | bool | useEvmBoard | ) | [inline, static] |
Definition at line 101 of file FUResource.h.
References useEvmBoard_.
Referenced by evf::FUResourceBroker::actionPerformed(), and evf::rb_statemachine::SharedResources::configureResources().
{ useEvmBoard_ = useEvmBoard; }
friend class ResourceChecker [friend] |
Definition at line 202 of file FUResource.h.
xdaq::Application* evf::FUResource::app_ [private] |
Definition at line 194 of file FUResource.h.
Referenced by evf::ResourceChecker::findFEDs().
UInt_t evf::FUResource::buResourceId_ [private] |
Definition at line 166 of file FUResource.h.
Referenced by buResourceId(), and release().
bool evf::FUResource::doCrcCheck_ [private] |
Definition at line 162 of file FUResource.h.
Referenced by crcBeingChecked(), doCrcCheck(), evf::ResourceChecker::findFEDs(), and release().
bool FUResource::doFedIdCheck_ = true [static, private] |
Definition at line 159 of file FUResource.h.
Referenced by doFedIdCheck(), and evf::ResourceChecker::findFEDs().
UInt_t evf::FUResource::eventPayloadSize_ [private] |
Definition at line 172 of file FUResource.h.
Referenced by allocate(), and superFragSize().
UInt_t evf::FUResource::eventSize_ [private] |
Definition at line 189 of file FUResource.h.
Referenced by release(), and superFragSize().
UInt_t evf::FUResource::evtNumber_ [private] |
Definition at line 167 of file FUResource.h.
Referenced by evtNumber(), fillSuperFragPayload(), evf::ResourceChecker::findFEDs(), process(), release(), and superFragSize().
bool evf::FUResource::fatalError_ [private] |
Definition at line 163 of file FUResource.h.
Referenced by fatalError(), process(), and release().
UInt_t evf::FUResource::fedSize_[1024] [private] |
Definition at line 187 of file FUResource.h.
Referenced by evf::ResourceChecker::findFEDs(), process(), and release().
EvffedFillerRB* evf::FUResource::frb_ [private] |
Definition at line 192 of file FUResource.h.
Referenced by process().
UInt_t evf::FUResource::fuResourceId_ [private] |
Definition at line 165 of file FUResource.h.
Referenced by allocate(), fillSuperFragPayload(), fuResourceId(), process(), and superFragSize().
unsigned int FUResource::gtpDaqId_ = FEDNumbering::MAXTriggerGTPFEDID [static, private] |
Definition at line 198 of file FUResource.h.
Referenced by evf::ResourceChecker::findFEDs().
unsigned int FUResource::gtpeId_ = FEDNumbering::MINTriggerEGTPFEDID [static, private] |
Definition at line 200 of file FUResource.h.
Referenced by evf::ResourceChecker::findFEDs().
unsigned int FUResource::gtpEvmId_ = FEDNumbering::MINTriggerGTPFEDID [static, private] |
Definition at line 199 of file FUResource.h.
Referenced by evf::ResourceChecker::findFEDs().
UInt_t evf::FUResource::iBlock_ [private] |
Definition at line 176 of file FUResource.h.
Referenced by isComplete(), and release().
UInt_t evf::FUResource::iSuperFrag_ [private] |
Definition at line 178 of file FUResource.h.
Referenced by fillSuperFragPayload(), evf::ResourceChecker::findFEDs(), isComplete(), process(), release(), and superFragSize().
log4cplus::Logger evf::FUResource::log_ [private] |
Definition at line 156 of file FUResource.h.
Referenced by evf::ResourceChecker::findFEDs(), process(), and release().
UInt_t evf::FUResource::nbBytes_ [private] |
Definition at line 185 of file FUResource.h.
Referenced by fillSuperFragPayload(), and nbBytes().
UInt_t evf::FUResource::nbCrcErrors_ [private] |
Definition at line 184 of file FUResource.h.
Referenced by evf::ResourceChecker::findFEDs(), nbCrcErrors(), and release().
UInt_t evf::FUResource::nbErrors_ [private] |
Definition at line 183 of file FUResource.h.
Referenced by fillSuperFragPayload(), evf::ResourceChecker::findFEDs(), nbErrors(), process(), release(), and superFragSize().
UInt_t evf::FUResource::nBlock_ [private] |
Definition at line 177 of file FUResource.h.
Referenced by isComplete(), and release().
UInt_t evf::FUResource::nbSent_ [private] |
Definition at line 181 of file FUResource.h.
Referenced by incNbSent(), nbSent(), and release().
bool evf::FUResource::nextEventWillHaveCRCError_ [private] |
Definition at line 196 of file FUResource.h.
Referenced by evf::ResourceChecker::findFEDs(), and scheduleCRCError().
UInt_t evf::FUResource::nFedMax_ [private] |
Definition at line 173 of file FUResource.h.
Referenced by allocate().
UInt_t evf::FUResource::nSuperFrag_ [private] |
Definition at line 179 of file FUResource.h.
Referenced by isComplete(), and release().
UInt_t evf::FUResource::nSuperFragMax_ [private] |
Definition at line 174 of file FUResource.h.
Referenced by allocate().
evf::FUShmRawCell* evf::FUResource::shmCell_ [private] |
Definition at line 191 of file FUResource.h.
Referenced by allocate(), fillSuperFragPayload(), evf::ResourceChecker::findFEDs(), isAllocated(), process(), release(), and shmCell().
MemRef_t* evf::FUResource::superFragHead_ [private] |
Definition at line 169 of file FUResource.h.
Referenced by appendBlockToSuperFrag(), fillSuperFragPayload(), release(), releaseSuperFrag(), removeLastAppendedBlockFromSuperFrag(), and superFragSize().
UInt_t evf::FUResource::superFragSize_ [private] |
Definition at line 188 of file FUResource.h.
Referenced by fillSuperFragPayload(), process(), and superFragSize().
MemRef_t* evf::FUResource::superFragTail_ [private] |
Definition at line 170 of file FUResource.h.
Referenced by appendBlockToSuperFrag(), release(), releaseSuperFrag(), and removeLastAppendedBlockFromSuperFrag().
bool FUResource::useEvmBoard_ = true [static, private] |
Definition at line 161 of file FUResource.h.
Referenced by evf::ResourceChecker::findFEDs(), and useEvmBoard().