![]() |
![]() |
00001 #ifndef FURESOURCEBROKER_H 00002 #define FURESOURCEBROKER_H 1 00003 00004 00005 #include "EventFilter/ResourceBroker/interface/FUTypes.h" 00006 #include "EventFilter/ResourceBroker/interface/FUResourceTable.h" 00007 00008 #include "EventFilter/Utilities/interface/StateMachine.h" 00009 #include "EventFilter/Utilities/interface/WebGUI.h" 00010 00011 #include "xdaq/Application.h" 00012 #include "xdaq/NamespaceURI.h" 00013 00014 #include "xdata/InfoSpace.h" 00015 #include "xdata/String.h" 00016 #include "xdata/Boolean.h" 00017 #include "xdata/UnsignedInteger32.h" 00018 #include "xdata/Double.h" 00019 00020 #include "toolbox/mem/Reference.h" 00021 #include "toolbox/fsm/exception/Exception.h" 00022 #include "toolbox/BSem.h" 00023 00024 #include "interface/shared/frl_header.h" 00025 #include "interface/shared/fed_header.h" 00026 #include "interface/shared/fed_trailer.h" 00027 00028 #include <vector> 00029 #include <string> 00030 #include <semaphore.h> 00031 #include <sys/time.h> 00032 00033 00034 namespace evf { 00035 00036 class BUProxy; 00037 class SMProxy; 00038 class EvffedFillerRB; 00039 00040 class FUResourceBroker : public xdaq::Application, 00041 public xdata::ActionListener 00042 { 00043 public: 00044 // 00045 // xdaq instantiator macro 00046 // 00047 XDAQ_INSTANTIATOR(); 00048 00049 00050 // 00051 // construction/destruction 00052 // 00053 FUResourceBroker(xdaq::ApplicationStub *s); 00054 virtual ~FUResourceBroker(); 00055 00056 00057 // 00058 // public member functions 00059 // 00060 00061 // work loop functions to be executed during transitional states (async) 00062 bool configuring(toolbox::task::WorkLoop* wl); 00063 bool enabling(toolbox::task::WorkLoop* wl); 00064 bool stopping(toolbox::task::WorkLoop* wl); 00065 bool halting(toolbox::task::WorkLoop* wl); 00066 00067 // fsm soap command callback 00068 xoap::MessageReference fsmCallback(xoap::MessageReference msg) 00069 throw (xoap::exception::Exception); 00070 00071 // i20 callbacks 00072 void I2O_FU_TAKE_Callback(toolbox::mem::Reference *bufRef); 00073 void I2O_FU_DATA_DISCARD_Callback(toolbox::mem::Reference *bufRef); 00074 void I2O_FU_DQM_DISCARD_Callback(toolbox::mem::Reference *bufRef); 00075 void I2O_EVM_LUMISECTION_Callback(toolbox::mem::Reference *bufRef); 00076 00077 // connection to BuilderUnit bu_ and StorageManager sm_ 00078 void connectToBUandSM() throw (evf::Exception); 00079 00080 // Hyper DAQ web page(s) [see Utilities/WebGUI] 00081 void webPageRequest(xgi::Input *in,xgi::Output *out) 00082 throw (xgi::exception::Exception); 00083 void customWebPage(xgi::Input *in,xgi::Output *out) 00084 throw (xgi::exception::Exception); 00085 00086 // xdata::ActionListener callback(s) 00087 void actionPerformed(xdata::Event& e); 00088 00089 // calculate monitoring information in separate thread 00090 void startMonitoringWorkLoop() throw (evf::Exception); 00091 bool monitoring(toolbox::task::WorkLoop* wl); 00092 00093 // watch the state of the shm buffer in a separate thread 00094 void startWatchingWorkLoop() throw (evf::Exception); 00095 bool watching(toolbox::task::WorkLoop* wl); 00096 00097 unsigned int instanceNumber() const {return instance_.value_;} 00098 00099 public: 00100 static const int CRC_ERROR_SHIFT = 0x0; 00101 static const int DATA_ERROR_SHIFT = 0x1; 00102 static const int LOST_ERROR_SHIFT = 0x2; 00103 static const int TIMEOUT_NOEVENT_ERROR_SHIFT= 0x3; 00104 static const int TIMEOUT_EVENT_ERROR_SHIFT = 0x4; 00105 static const int SENT_ERREVENT_ERROR_SHIFT = 0x5; 00106 00107 private: 00108 // 00109 // private member functions 00110 // 00111 void exportParameters(); 00112 void reset(); 00113 double deltaT(const struct timeval *start,const struct timeval *end); 00114 void emergencyStop(); 00115 void configureResources(); 00116 00117 void lock() { lock_.take(); } 00118 void unlock() { lock_.give(); } 00119 00120 00121 private: 00122 // 00123 // member data 00124 // 00125 00126 // finite state machine 00127 evf::StateMachine fsm_; 00128 00129 // Hyper DAQ web GUI 00130 WebGUI* gui_; 00131 00132 // application logger 00133 Logger log_; 00134 00135 // BuilderUnit (BU) to receive raw event data from 00136 BUProxy *bu_; 00137 00138 // StorageManager (SM) to send selected events to 00139 SMProxy *sm_; 00140 00141 // memory pool for bu <-> fu comunication messages 00142 toolbox::mem::Pool* i2oPool_; 00143 00144 // managed resources 00145 FUResourceTable* resourceTable_; 00146 00147 // workloop / action signature for monitoring 00148 toolbox::task::WorkLoop *wlMonitoring_; 00149 toolbox::task::ActionSignature *asMonitoring_; 00150 00151 // workloop / action signature for watching 00152 toolbox::task::WorkLoop *wlWatching_; 00153 toolbox::task::ActionSignature *asWatching_; 00154 00155 // application identifier 00156 std::string sourceId_; 00157 00158 // monitored parameters 00159 xdata::String url_; 00160 xdata::String class_; 00161 xdata::UnsignedInteger32 instance_; 00162 xdata::UnsignedInteger32 runNumber_; 00163 00164 00165 xdata::Double deltaT_; 00166 xdata::UnsignedInteger32 deltaN_; 00167 xdata::Double deltaSumOfSquares_; 00168 xdata::UnsignedInteger32 deltaSumOfSizes_; 00169 00170 xdata::Double throughput_; 00171 xdata::Double rate_; 00172 xdata::Double average_; 00173 xdata::Double rms_; 00174 00175 // monitored counters 00176 xdata::UnsignedInteger32 nbAllocatedEvents_; 00177 xdata::UnsignedInteger32 nbPendingRequests_; 00178 xdata::UnsignedInteger32 nbReceivedEvents_; 00179 xdata::UnsignedInteger32 nbProcessedEvents_; 00180 xdata::UnsignedInteger32 nbSentEvents_; 00181 xdata::UnsignedInteger32 nbSentDqmEvents_; 00182 xdata::UnsignedInteger32 nbSentErrorEvents_; 00183 xdata::UnsignedInteger32 nbPendingSMDiscards_; 00184 xdata::UnsignedInteger32 nbPendingSMDqmDiscards_; 00185 xdata::UnsignedInteger32 nbDiscardedEvents_; 00186 xdata::UnsignedInteger32 nbReceivedEol_; 00187 xdata::UnsignedInteger32 highestEolReceived_; 00188 xdata::UnsignedInteger32 nbEolPosted_; 00189 xdata::UnsignedInteger32 nbEolDiscarded_; 00190 00191 00192 xdata::UnsignedInteger32 nbLostEvents_; 00193 xdata::UnsignedInteger32 nbDataErrors_; 00194 xdata::UnsignedInteger32 nbCrcErrors_; 00195 xdata::UnsignedInteger32 nbTimeoutsWithEvent_; 00196 xdata::UnsignedInteger32 nbTimeoutsWithoutEvent_; 00197 xdata::UnsignedInteger32 dataErrorFlag_; 00198 00199 // standard parameters 00200 xdata::Boolean segmentationMode_; 00201 xdata::UnsignedInteger32 nbClients_; 00202 xdata::String clientPrcIds_; 00203 xdata::UnsignedInteger32 nbRawCells_; 00204 xdata::UnsignedInteger32 nbRecoCells_; 00205 xdata::UnsignedInteger32 nbDqmCells_; 00206 xdata::UnsignedInteger32 rawCellSize_; 00207 xdata::UnsignedInteger32 recoCellSize_; 00208 xdata::UnsignedInteger32 dqmCellSize_; 00209 00210 xdata::Boolean doDropEvents_; 00211 xdata::Boolean doFedIdCheck_; 00212 xdata::UnsignedInteger32 doCrcCheck_; 00213 xdata::UnsignedInteger32 doDumpEvents_; 00214 00215 xdata::String buClassName_; 00216 xdata::UnsignedInteger32 buInstance_; 00217 xdata::String smClassName_; 00218 xdata::UnsignedInteger32 smInstance_; 00219 00220 xdata::UnsignedInteger32 shmResourceTableTimeout_; 00221 xdata::UnsignedInteger32 monSleepSec_; 00222 xdata::UnsignedInteger32 watchSleepSec_; 00223 xdata::UnsignedInteger32 timeOutSec_; 00224 xdata::Boolean processKillerEnabled_; 00225 xdata::Boolean useEvmBoard_; 00226 00227 xdata::String reasonForFailed_; 00228 00229 00230 // debug parameters 00231 xdata::UnsignedInteger32 nbAllocateSent_; 00232 xdata::UnsignedInteger32 nbTakeReceived_; 00233 xdata::UnsignedInteger32 nbDataDiscardReceived_; 00234 xdata::UnsignedInteger32 nbDqmDiscardReceived_; 00235 00236 00237 // helper variables for monitoring 00238 struct timeval monStartTime_; 00239 UInt_t nbSentLast_; 00240 uint64_t sumOfSquaresLast_; 00241 UInt_t sumOfSizesLast_; 00242 00243 // lock 00244 toolbox::BSem lock_; 00245 EvffedFillerRB *frb_; 00246 bool shmInconsistent_; 00247 00248 friend class evf::EvffedFillerRB; 00249 }; 00250 00251 } // namespace evf 00252 00253 00254 #endif