CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FUResourceBroker.h
Go to the documentation of this file.
1 #ifndef FURESOURCEBROKER_H
2 #define FURESOURCEBROKER_H 1
3 
4 
7 
10 
11 #include "xdaq/Application.h"
12 #include "xdaq/NamespaceURI.h"
13 
14 #include "xdata/InfoSpace.h"
15 #include "xdata/String.h"
16 #include "xdata/Boolean.h"
17 #include "xdata/UnsignedInteger32.h"
18 #include "xdata/Double.h"
19 
20 #include "toolbox/mem/Reference.h"
21 #include "toolbox/fsm/exception/Exception.h"
22 #include "toolbox/BSem.h"
23 
24 #include "interface/shared/frl_header.h"
25 #include "interface/shared/fed_header.h"
26 #include "interface/shared/fed_trailer.h"
27 
28 #include <vector>
29 #include <string>
30 #include <semaphore.h>
31 #include <sys/time.h>
32 
33 
34 namespace evf {
35 
36  class BUProxy;
37  class SMProxy;
38  class EvffedFillerRB;
39 
40  class FUResourceBroker : public xdaq::Application,
41  public xdata::ActionListener
42  {
43  public:
44  //
45  // xdaq instantiator macro
46  //
48 
49 
50  //
51  // construction/destruction
52  //
53  FUResourceBroker(xdaq::ApplicationStub *s);
54  virtual ~FUResourceBroker();
55 
56 
57  //
58  // public member functions
59  //
60 
61  // work loop functions to be executed during transitional states (async)
62  bool configuring(toolbox::task::WorkLoop* wl);
63  bool enabling(toolbox::task::WorkLoop* wl);
64  bool stopping(toolbox::task::WorkLoop* wl);
65  bool halting(toolbox::task::WorkLoop* wl);
66 
67  // fsm soap command callback
68  xoap::MessageReference fsmCallback(xoap::MessageReference msg)
70 
71  // i20 callbacks
72  void I2O_FU_TAKE_Callback(toolbox::mem::Reference *bufRef);
73  void I2O_FU_DATA_DISCARD_Callback(toolbox::mem::Reference *bufRef);
74  void I2O_FU_DQM_DISCARD_Callback(toolbox::mem::Reference *bufRef);
75  void I2O_EVM_LUMISECTION_Callback(toolbox::mem::Reference *bufRef);
76 
77  // connection to BuilderUnit bu_ and StorageManager sm_
78  void connectToBUandSM() throw (evf::Exception);
79 
80  // Hyper DAQ web page(s) [see Utilities/WebGUI]
83  void customWebPage(xgi::Input *in,xgi::Output *out)
85 
86  // xdata::ActionListener callback(s)
87  void actionPerformed(xdata::Event& e);
88 
89  // calculate monitoring information in separate thread
91  bool monitoring(toolbox::task::WorkLoop* wl);
92 
93  // watch the state of the shm buffer in a separate thread
95  bool watching(toolbox::task::WorkLoop* wl);
96 
97  unsigned int instanceNumber() const {return instance_.value_;}
98 
99  public:
100  static const int CRC_ERROR_SHIFT = 0x0;
101  static const int DATA_ERROR_SHIFT = 0x1;
102  static const int LOST_ERROR_SHIFT = 0x2;
103  static const int TIMEOUT_NOEVENT_ERROR_SHIFT= 0x3;
104  static const int TIMEOUT_EVENT_ERROR_SHIFT = 0x4;
105  static const int SENT_ERREVENT_ERROR_SHIFT = 0x5;
106 
107  private:
108  //
109  // private member functions
110  //
111  void exportParameters();
112  void reset();
113  double deltaT(const struct timeval *start,const struct timeval *end);
114  void emergencyStop();
115  void configureResources();
116 
117  void lock() { lock_.take(); }
118  void unlock() { lock_.give(); }
119 
120 
121  private:
122  //
123  // member data
124  //
125 
126  // finite state machine
128 
129  // Hyper DAQ web GUI
131 
132  // application logger
133  Logger log_;
134 
135  // BuilderUnit (BU) to receive raw event data from
137 
138  // StorageManager (SM) to send selected events to
140 
141  // memory pool for bu <-> fu comunication messages
142  toolbox::mem::Pool* i2oPool_;
143 
144  // managed resources
146 
147  // workloop / action signature for monitoring
148  toolbox::task::WorkLoop *wlMonitoring_;
149  toolbox::task::ActionSignature *asMonitoring_;
150 
151  // workloop / action signature for watching
152  toolbox::task::WorkLoop *wlWatching_;
153  toolbox::task::ActionSignature *asWatching_;
154 
155  // application identifier
156  std::string sourceId_;
157 
158  // monitored parameters
159  xdata::String url_;
160  xdata::String class_;
161  xdata::UnsignedInteger32 instance_;
162  xdata::UnsignedInteger32 runNumber_;
163 
164 
165  xdata::Double deltaT_;
166  xdata::UnsignedInteger32 deltaN_;
167  xdata::Double deltaSumOfSquares_;
168  xdata::UnsignedInteger32 deltaSumOfSizes_;
169 
170  xdata::Double throughput_;
171  xdata::Double rate_;
172  xdata::Double average_;
173  xdata::Double rms_;
174 
175  // monitored counters
176  xdata::UnsignedInteger32 nbAllocatedEvents_;
177  xdata::UnsignedInteger32 nbPendingRequests_;
178  xdata::UnsignedInteger32 nbReceivedEvents_;
179  xdata::UnsignedInteger32 nbProcessedEvents_;
180  xdata::UnsignedInteger32 nbSentEvents_;
181  xdata::UnsignedInteger32 nbSentDqmEvents_;
182  xdata::UnsignedInteger32 nbSentErrorEvents_;
183  xdata::UnsignedInteger32 nbPendingSMDiscards_;
184  xdata::UnsignedInteger32 nbPendingSMDqmDiscards_;
185  xdata::UnsignedInteger32 nbDiscardedEvents_;
186 
187  xdata::UnsignedInteger32 nbLostEvents_;
188  xdata::UnsignedInteger32 nbDataErrors_;
189  xdata::UnsignedInteger32 nbCrcErrors_;
190  xdata::UnsignedInteger32 nbTimeoutsWithEvent_;
191  xdata::UnsignedInteger32 nbTimeoutsWithoutEvent_;
192  xdata::UnsignedInteger32 dataErrorFlag_;
193 
194  // standard parameters
195  xdata::Boolean segmentationMode_;
196  xdata::UnsignedInteger32 nbClients_;
197  xdata::String clientPrcIds_;
198  xdata::UnsignedInteger32 nbRawCells_;
199  xdata::UnsignedInteger32 nbRecoCells_;
200  xdata::UnsignedInteger32 nbDqmCells_;
201  xdata::UnsignedInteger32 rawCellSize_;
202  xdata::UnsignedInteger32 recoCellSize_;
203  xdata::UnsignedInteger32 dqmCellSize_;
204 
205  xdata::Boolean doDropEvents_;
206  xdata::Boolean doFedIdCheck_;
207  xdata::UnsignedInteger32 doCrcCheck_;
208  xdata::UnsignedInteger32 doDumpEvents_;
209 
210  xdata::String buClassName_;
211  xdata::UnsignedInteger32 buInstance_;
212  xdata::String smClassName_;
213  xdata::UnsignedInteger32 smInstance_;
214 
215  xdata::UnsignedInteger32 shmResourceTableTimeout_;
216  xdata::UnsignedInteger32 monSleepSec_;
217  xdata::UnsignedInteger32 watchSleepSec_;
218  xdata::UnsignedInteger32 timeOutSec_;
219  xdata::Boolean processKillerEnabled_;
220  xdata::Boolean useEvmBoard_;
221 
222  xdata::String reasonForFailed_;
223 
224 
225  // debug parameters
226  xdata::UnsignedInteger32 nbAllocateSent_;
227  xdata::UnsignedInteger32 nbTakeReceived_;
228  xdata::UnsignedInteger32 nbDataDiscardReceived_;
229  xdata::UnsignedInteger32 nbDqmDiscardReceived_;
230 
231 
232  // helper variables for monitoring
233  struct timeval monStartTime_;
237 
238  // lock
239  toolbox::BSem lock_;
242 
243  friend class evf::EvffedFillerRB;
244  };
245 
246 } // namespace evf
247 
248 
249 #endif
xdata::String clientPrcIds_
xdata::UnsignedInteger32 nbLostEvents_
static const int SENT_ERREVENT_ERROR_SHIFT
#define Input(cl)
Definition: vmac.h:189
FUResourceBroker(xdaq::ApplicationStub *s)
xdata::UnsignedInteger32 monSleepSec_
xdata::UnsignedInteger32 nbDiscardedEvents_
xdata::UnsignedInteger32 nbReceivedEvents_
xdata::UnsignedInteger32 nbPendingSMDqmDiscards_
xdata::UnsignedInteger32 nbPendingRequests_
xdata::UnsignedInteger32 nbSentDqmEvents_
xdata::UnsignedInteger32 nbRawCells_
void I2O_FU_TAKE_Callback(toolbox::mem::Reference *bufRef)
xdata::UnsignedInteger32 nbTimeoutsWithoutEvent_
void customWebPage(xgi::Input *in, xgi::Output *out)
xdata::UnsignedInteger32 nbSentEvents_
xdata::UnsignedInteger32 nbSentErrorEvents_
xdata::UnsignedInteger32 buInstance_
xdata::UnsignedInteger32 nbDataDiscardReceived_
bool watching(toolbox::task::WorkLoop *wl)
xdata::String reasonForFailed_
static const int LOST_ERROR_SHIFT
void I2O_FU_DATA_DISCARD_Callback(toolbox::mem::Reference *bufRef)
double deltaT(const struct timeval *start, const struct timeval *end)
unsigned int instanceNumber() const
xdata::Boolean segmentationMode_
void I2O_FU_DQM_DISCARD_Callback(toolbox::mem::Reference *bufRef)
xdata::UnsignedInteger32 nbDqmDiscardReceived_
xdata::UnsignedInteger32 nbDataErrors_
xdata::UnsignedInteger32 doDumpEvents_
xdata::UnsignedInteger32 nbClients_
xdata::UnsignedInteger32 nbProcessedEvents_
bool halting(toolbox::task::WorkLoop *wl)
xdata::UnsignedInteger32 runNumber_
bool configuring(toolbox::task::WorkLoop *wl)
xdata::UnsignedInteger32 smInstance_
toolbox::task::WorkLoop * wlMonitoring_
EvffedFillerRB * frb_
bool stopping(toolbox::task::WorkLoop *wl)
xdata::Boolean doFedIdCheck_
xdata::UnsignedInteger32 nbTakeReceived_
xdata::UnsignedInteger32 timeOutSec_
xdata::UnsignedInteger32 rawCellSize_
xdata::UnsignedInteger32 nbRecoCells_
#define end
Definition: vmac.h:38
xdata::UnsignedInteger32 nbDqmCells_
bool enabling(toolbox::task::WorkLoop *wl)
static const int TIMEOUT_EVENT_ERROR_SHIFT
tuple out
Definition: dbtoconf.py:99
xdata::UnsignedInteger32 nbAllocatedEvents_
void actionPerformed(xdata::Event &e)
unsigned int UInt_t
Definition: FUTypes.h:12
xdata::UnsignedInteger32 nbTimeoutsWithEvent_
xdata::Boolean processKillerEnabled_
xdata::UnsignedInteger32 nbPendingSMDiscards_
FUResourceTable * resourceTable_
xdata::UnsignedInteger32 deltaSumOfSizes_
xdata::Boolean useEvmBoard_
xdata::UnsignedInteger32 dqmCellSize_
unsigned long long uint64_t
Definition: Time.h:15
xdata::Double deltaSumOfSquares_
static const int CRC_ERROR_SHIFT
xoap::MessageReference fsmCallback(xoap::MessageReference msg)
static const int TIMEOUT_NOEVENT_ERROR_SHIFT
xdata::String smClassName_
xdata::UnsignedInteger32 deltaN_
#define Output(cl)
Definition: vmac.h:193
xdata::UnsignedInteger32 recoCellSize_
xdata::String buClassName_
xdata::UnsignedInteger32 watchSleepSec_
xdata::UnsignedInteger32 shmResourceTableTimeout_
void I2O_EVM_LUMISECTION_Callback(toolbox::mem::Reference *bufRef)
bool monitoring(toolbox::task::WorkLoop *wl)
string s
Definition: asciidump.py:422
toolbox::mem::Pool * i2oPool_
toolbox::task::WorkLoop * wlWatching_
xdata::Boolean doDropEvents_
xdata::UnsignedInteger32 doCrcCheck_
static const int DATA_ERROR_SHIFT
xdata::UnsignedInteger32 instance_
toolbox::task::ActionSignature * asMonitoring_
xdata::UnsignedInteger32 nbCrcErrors_
void webPageRequest(xgi::Input *in, xgi::Output *out)
toolbox::task::ActionSignature * asWatching_
xdata::UnsignedInteger32 nbAllocateSent_
struct timeval monStartTime_
xdata::UnsignedInteger32 dataErrorFlag_
evf::StateMachine fsm_