CMS 3D CMS Logo

SMFUSenderEntry.h

Go to the documentation of this file.
00001 #ifndef _smfusenderentry_h_
00002 #define _smfusenderentry_h_
00003 
00004 #include <exception>
00005 #include <vector>
00006 
00007 #include "boost/shared_ptr.hpp"
00008 #include "boost/thread/thread.hpp"
00009 
00010 #include "EventFilter/Utilities/interface/i2oEvfMsgs.h"
00011 #include "IOPool/Streamer/interface/MsgTools.h"
00012 #include "toolbox/mem/Reference.h"
00013 #include "toolbox/Chrono.h"
00014 
00015 namespace stor {
00016 
00017 struct SMFUSenderRegCollection // used to stored collection of INIT messages
00018 {
00019   std::vector<std::string> outModName_;
00020   std::map<std::string, uint32> outModName2ModId_;
00021   std::map<uint32, std::string> outModId2ModName_;
00022   std::map<std::string, uint32> registrySizeMap_;    // size of registry in bytes once received AND copied
00023   std::map<std::string, uint32> totFramesMap_;  // number of frames in this fragment
00024   std::map<std::string, uint32> currFramesMap_; // current frames received for registry
00025 };
00026 
00027 struct SMFUSenderDatCollection // used to keep track of event messages
00028 {
00029   std::map<std::string, unsigned int> framesReceivedMap_;
00030   std::map<std::string, unsigned int> eventsReceivedMap_;
00031   std::map<std::string, unsigned int> lastEventIDMap_;
00032   std::map<std::string, unsigned int> lastFrameNumMap_;
00033   std::map<std::string, unsigned int> lastTotalFrameNumMap_;
00034   std::map<std::string, unsigned long long> totalSizeReceivedMap_;// For data only
00035 };
00036 
00037 struct SMFUSenderEntry  // used to store each FU sender
00038 {
00039   SMFUSenderEntry(const char* hltURL,
00040                  const char* hltClassName,
00041                  const unsigned int hltLocalId,
00042                  const unsigned int hltInstance,
00043                  const unsigned int hltTid,
00044                  const unsigned int frameCount,
00045                  const unsigned int numFramesToAllocate,
00046                  const std::string outModName,
00047                  const uint32 outModId,
00048                  const uint32 rbBufferID,
00049                  const uint32 regSize);
00050   private:
00051   
00052   char          hltURL_[MAX_I2O_SM_URLCHARS];       // FU+HLT identifiers
00053   char          hltClassName_[MAX_I2O_SM_URLCHARS];
00054   unsigned int  hltLocalId_;
00055   unsigned int  hltInstance_;
00056   unsigned int  hltTid_;
00057   const uint32  rbBufferID_;
00058   SMFUSenderRegCollection registryCollection_;
00059   unsigned int  connectStatus_;   // FU+HLT connection status
00060   double        lastLatency_;     // Latency of last frame in microseconds
00061   unsigned int  runNumber_;
00062   bool          isLocal_;         // If detected a locally sent frame chain
00063   // data members below are to track the data frames from this FU
00064   SMFUSenderDatCollection datCollection_;
00065   unsigned int  framesReceived_;
00066   unsigned int  eventsReceived_;
00067   unsigned int  lastEventID_;
00068   unsigned int  lastRunID_;
00069   unsigned int  totalOutOfOrder_;
00070   unsigned long long  totalSizeReceived_;// For data only
00071   unsigned int  totalBadEvents_;   // Update meaning: include original size check?
00072   toolbox::Chrono chrono_;         // Keep latency for connection check
00073   boost::mutex entry_lock_;
00074 
00075   bool sameURL(const char* hltURL);
00076   bool sameClassName(const char* hltClassName);
00077 
00078   public:
00079   
00081   void addReg2Entry(const unsigned int frameCount, const unsigned int numFramesToAllocate,
00082                  const std::string outModName, const uint32 outModId,
00083                  const uint32 regSize);
00084   bool addFrame(const unsigned int frameCount, const unsigned int numFrames,
00085                 const uint32 regSize, const std::string outModName);
00086   bool update4Data(const unsigned int runNumber, const unsigned int eventNumber,
00087                    const unsigned int frameNum, const unsigned int totalFrames,
00088                    const unsigned int origdatasize, const uint32 outModId);
00089   bool sameOutMod(const std::string outModName);
00090   bool sameOutMod(const uint32 outModId);
00091   void setDataStatus();
00092   void setrunNumber(const unsigned int run);
00093   void setisLocal(const bool local);
00094   bool regIsCopied(const std::string outModName);
00095 
00096   
00097   //double getStopWTime() const;  // more const below (nothings changes inside) didn't work due to mutex
00098   double getStopWTime();
00099   boost::shared_ptr<std::vector<char> > getvhltURL();
00100   boost::shared_ptr<std::vector<char> > getvhltClassName();
00101   unsigned int gethltLocalId() const {return hltLocalId_;}
00102   unsigned int gethltInstance() const {return hltInstance_;}
00103   unsigned int gethltTid() const {return hltTid_;}
00104   uint32       getrbBufferID() const {return rbBufferID_;}
00105   unsigned int getnumOutMod() const {return registryCollection_.outModName_.size();}
00106   SMFUSenderRegCollection getRegistryCollection() const {return registryCollection_;}
00107   SMFUSenderDatCollection getDatCollection() const {return datCollection_;}
00108   unsigned int getregistrySize(const std::string outModName);
00109   unsigned int gettotFrames(const std::string outModName);
00110   unsigned int getcurrFrames(const std::string outModName);
00111   unsigned int getconnectStatus() const {return connectStatus_;}
00112   double       getlastLatency() const {return lastLatency_;}
00113   unsigned int getrunNumber() const {return runNumber_;}
00114   bool         getisLocal() const {return isLocal_;}
00115   unsigned int getAllframesReceived() const {return framesReceived_;}
00116   unsigned int getframesReceived(const std::string outModName);
00117   unsigned int getAlleventsReceived() const {return eventsReceived_;}
00118   unsigned int geteventsReceived(const std::string outModName);
00119   unsigned int getlastEventID() const {return lastEventID_;}
00120   unsigned int getlastRunID() const {return lastRunID_;}
00121   unsigned int getlastFrameNum(const std::string outModName);
00122   unsigned int getlastTotalFrameNum(const std::string outModName);
00123   unsigned int gettotalOutOfOrder() const {return totalOutOfOrder_;}
00124   unsigned long long getAlltotalSizeReceived() const {return totalSizeReceived_;}
00125   unsigned long long gettotalSizeReceived(const std::string outModName);
00126   unsigned int gettotalBadEvents() const {return totalBadEvents_;}
00127 
00128   bool getDataStatus();  
00129   bool matchFirst(const char* hltURL, const char* hltClassName, 
00130                              const unsigned int hltLocalId,
00131                              const unsigned int hltInstance, 
00132                              const unsigned int hltTid);
00133   bool match(const char* hltURL, const char* hltClassName, 
00134                              const unsigned int hltLocalId,
00135                              const unsigned int hltInstance, 
00136                              const unsigned int hltTid,
00137                              const uint32 rbBufferID,
00138                              const std::string outModName);
00139   bool matchFirst(const char* hltURL, const char* hltClassName, 
00140                              const unsigned int hltLocalId,
00141                              const unsigned int hltInstance, 
00142                              const unsigned int hltTid,
00143                              const std::string outModName);
00144   bool matchFirst(const char* hltURL, const char* hltClassName, 
00145                              const unsigned int hltLocalId,
00146                              const unsigned int hltInstance, 
00147                              const unsigned int hltTid,
00148                              const uint32 outModId);
00149   
00150 };
00151 }
00152 #endif

Generated on Tue Jun 9 17:34:55 2009 for CMSSW by  doxygen 1.5.4