CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/EventFilter/ResourceBroker/interface/FUResource.h

Go to the documentation of this file.
00001 
00002 //
00003 // FUResource
00004 // ----------
00005 //
00006 //            12/10/2006 Philipp Schieferdecker <philipp.schieferdecker@cern.ch>
00007 //            20/01/2012 Andrei Spataru <aspataru@cern.ch>
00009 
00010 #ifndef FURESOURCE_H
00011 #define FURESOURCE_H 1
00012 
00013 #include "EventFilter/ShmBuffer/interface/FUShmRawCell.h"
00014 #include "EventFilter/ResourceBroker/interface/FUTypes.h"
00015 #include "EventFilter/Utilities/interface/Exception.h"
00016 
00017 #include "log4cplus/logger.h"
00018 
00019 #include <vector>
00020 
00021 #define FED_HCTRLID    0x50000000
00022 #define FED_TCTRLID    0xa0000000
00023 #define REAL_SOID_MASK 0x0003FF00
00024 #define FED_RBIT_MASK  0x0000C004
00025 
00026 //#define DEBUG_FURESOURCE_H
00027 
00028 namespace xdaq {
00029 class Application;
00030 }
00031 
00032 namespace evf {
00033 
00034 class EvffedFillerRB;
00035 
00043 class FUResource {
00044 public:
00045         //
00046         // construction/destruction
00047         //
00048         FUResource(UInt_t fuResourceId, log4cplus::Logger, EvffedFillerRB *,
00049                         xdaq::Application *);
00050         virtual ~FUResource();
00051 
00052         //
00053         // member functions
00054         //
00055 
00060         void allocate(FUShmRawCell* shmCell);
00064         void process(MemRef_t* bufRef);
00065 
00069         void release(bool detachResource);
00070 
00074         void appendBlockToSuperFrag(MemRef_t* bufRef);
00075 
00079         void removeLastAppendedBlockFromSuperFrag();
00080 
00084         void superFragSize() throw (evf::Exception);
00085 
00089         void fillSuperFragPayload() throw (evf::Exception);
00090 
00094         void releaseSuperFrag();
00095 
00096         static
00097         void doFedIdCheck(bool doFedIdCheck) {
00098                 doFedIdCheck_ = doFedIdCheck;
00099         }
00100         static
00101         void useEvmBoard(bool useEvmBoard) {
00102                 useEvmBoard_ = useEvmBoard;
00103         }
00104         void doCrcCheck(bool doCrcCheck) {
00105                 doCrcCheck_ = doCrcCheck;
00106         }
00107         bool crcBeingChecked() {
00108                 return doCrcCheck_;
00109         }
00110         bool fatalError() const {
00111                 return fatalError_;
00112         }
00113         bool isAllocated() const {
00114                 return 0 != shmCell_;
00115         }
00116         bool isComplete() const;
00117 
00118         UInt_t fuResourceId() const {
00119                 return fuResourceId_;
00120         }
00121         UInt_t buResourceId() const {
00122                 return buResourceId_;
00123         }
00124         UInt_t evtNumber() const {
00125                 return evtNumber_;
00126         }
00127         UInt_t nbSent() const {
00128                 return nbSent_;
00129         }
00130 
00134         void incNbSent() {
00135                 nbSent_++;
00136         }
00137 
00138         UInt_t nbErrors(bool reset = true);
00139         UInt_t nbCrcErrors(bool reset = true);
00140         UInt_t nbBytes(bool reset = true);
00141 
00145         evf::FUShmRawCell* shmCell() {
00146                 return shmCell_;
00147         }
00148         void scheduleCRCError() {
00149                 nextEventWillHaveCRCError_ = true;
00150         }
00151 
00152 private:
00153         //
00154         // member data
00155         //
00156         log4cplus::Logger log_;
00157 
00158         static
00159         bool doFedIdCheck_;
00160         static
00161         bool useEvmBoard_;
00162         bool doCrcCheck_;
00163         bool fatalError_;
00164 
00165         UInt_t fuResourceId_;
00166         UInt_t buResourceId_;
00167         UInt_t evtNumber_;
00168 
00169         MemRef_t* superFragHead_;
00170         MemRef_t* superFragTail_;
00171 
00172         UInt_t eventPayloadSize_;
00173         UInt_t nFedMax_;
00174         UInt_t nSuperFragMax_;
00175 
00176         UInt_t iBlock_;
00177         UInt_t nBlock_;
00178         UInt_t iSuperFrag_;
00179         UInt_t nSuperFrag_;
00180 
00181         UInt_t nbSent_;
00182 
00183         UInt_t nbErrors_;
00184         UInt_t nbCrcErrors_;
00185         UInt_t nbBytes_;
00186 
00187         UInt_t fedSize_[1024];
00188         UInt_t superFragSize_;
00189         UInt_t eventSize_;
00190 
00191         evf::FUShmRawCell* shmCell_;
00192         EvffedFillerRB *frb_;
00193 
00194         xdaq::Application *app_;
00195 
00196         bool nextEventWillHaveCRCError_;
00197 
00198         static unsigned int gtpDaqId_;
00199         static unsigned int gtpEvmId_;
00200         static unsigned int gtpeId_;
00201 
00202         friend class ResourceChecker;
00203 
00204 };
00205 
00206 //
00207 // typedefs
00208 //
00209 typedef std::vector<FUResource*> FUResourceVec_t;
00210 
00211 } // namespace evf
00212 
00213 //
00214 // implementation of inline functions
00215 //
00216 
00220 inline
00221 bool evf::FUResource::isComplete() const {
00222 
00223 #ifdef DEBUG_FURESOURCE_H
00224         cout << "------------------------------------------------------"<< endl;
00225         cout << "nBlock " << nBlock_
00226         << " iBlock " << iBlock_
00227         << " nSuperFrag " << nSuperFrag_
00228         << " iSuperFrag " << iSuperFrag_
00229         << endl;
00230 #endif
00231         return (nBlock_ && nSuperFrag_ && (iSuperFrag_ == nSuperFrag_) && (iBlock_
00232                         == nBlock_));
00233 }
00234 
00235 #endif