CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EvffedFillerRB.h
Go to the documentation of this file.
1 #ifndef EVENTFILTER_RESOURCEBROKER_EVFFEDFILLERRB
2 #define EVENTFILTER_RESOURCEBROKER_EVFFEDFILLERRB
3 
4 #include <unistd.h>
5 #include <stdlib.h>
6 #include <string.h>
7 
9 
10 #define FED_HCTRLID_INSERT ( ( (FED_SLINK_START_MARKER) & FED_HCTRLID_WIDTH )<< FED_HCTRLID_SHIFT)
11 #define FED_EVTY_INSERT(a) ( ( (a) & FED_EVTY_WIDTH ) << FED_EVTY_SHIFT )
12 #define FED_LVL1_INSERT(a) ( ( (a) & FED_LVL1_WIDTH ) << FED_LVL1_SHIFT )
13 #define FED_BXID_INSERT(a) ( ( (a) & FED_BXID_WIDTH ) << FED_BXID_SHIFT )
14 #define FED_SOID_INSERT(a) ( ( (a) & FED_SOID_WIDTH ) << FED_SOID_SHIFT )
15 #define FED_VERSION_INSERT(a) ( ( (a) & FED_VERSION_WIDTH ) << FED_VERSION_SHIFT )
16 #define FED_MORE_HEADERS_INSERT(a) ( ( (a) & FED_MORE_HEADERS_WIDTH ) << FED_MORE_HEADERS_SHIFT )
17 
19 #define FED_TCTRLID_INSERT ( ( (FED_SLINK_END_MARKER) & FED_TCTRLID_WIDTH ) << FED_TCTRLID_SHIFT )
20 #define FED_EVSZ_INSERT(a) ( ( (a) & FED_EVSZ_WIDTH ) << FED_EVSZ_SHIFT )
21 #define FED_CRCS_INSERT(a) ( ( (a) & FED_CRCS_WIDTH ) << FED_CRCS_SHIFT )
22 #define FED_STAT_INSERT(a) ( ( (a) & FED_STAT_WIDTH ) << FED_STAT_SHIFT )
23 #define FED_TTSI_INSERT(a) ( ( (a) & FED_TTSI_WIDTH ) << FED_TTSI_SHIFT )
24 #define FED_MORE_TRAILERS_INSERT(a) ( ( (a) & FED_MORE_TRAILERS_WIDTH ) << FED_MORE_TRAILERS_SHIFT )
25 
27 //#include "EventFilter/ResourceBroker/interface/FUResourceBroker.h"
29 
30 namespace evf {
31 
33 
34 public:
35  EvffedFillerRB(/*FUResourceBroker *rb*/) {
36  for (unsigned int i = 0; i < fedinterface::EVFFED_LENGTH; i++) {
37  *(payload_.asWords + i) = 0;
38  }
39  char hostname[32];
40  int retval = gethostname(hostname, 32);
41  if (retval != 0) {
42  hostid_ = 0xdead;
43  } else {
44  if (strtok(hostname, "-") == 0)
45  hostid_ = 0xdead;
46  char *p = strtok(0, "-"); // rack id
47  long hostid = 0xdead;
48  if (p != 0)
49  hostid = strtol(p, 0, 16) << 8;
50  p = strtok(0, "-"); // node id
51  if (p == 0)
52  hostid += 0xdead;
53  else
54  hostid += strtol(p, 0, 16);
55  hostid_ = hostid;
56  }
60 /* + ((rb->instanceNumber() */
61 /* & fedinterface::EVFFED_RBINSTA_MASK) */
62 /* << fedinterface::EVFFED_RBINSTA_SHIFT) */
63  ;
64  }
65  unsigned char * const getPayload() {
66  return payload_.asBytes;
67  }
68  uint32_t getSize() {
70  }
71 
72  void putHeader(unsigned int l1id, unsigned int bxid) {
75  *(payload_.asHWords + (evtn::SLINK_HALFWORD_SIZE/sizeof(uint32_t)))
77  + FED_LVL1_INSERT(l1id) + FED_BXID_INSERT(bxid);
78 
79  }
80  // this function MUST be called again after filling is complete (hence again in EP!!!)
81  void putTrailer() {
82  uint32_t *fedtr_p = payload_.asHWords
84  *(fedtr_p + (evtn::SLINK_HALFWORD_SIZE/sizeof(uint32_t))) = FED_TCTRLID_INSERT
87  }
90  = ts;
91  }
92  void setRBEventCount(uint32_t evtcnt) {
94  = evtcnt;
95  }
96  void setEPProcessId(pid_t pid) {
100  }
103  = word;
104  }
105 
106  unsigned int fedId() const {
108  }
109  unsigned int size() const {
111  }
112 private:
113  union Payload {
115  uint32_t asHWords[fedinterface::EVFFED_TOTALSIZE / sizeof(uint32_t)];
117  };
119  unsigned int hostid_;
120 };
121 }
122 
123 #endif
#define FED_TCTRLID_INSERT
int i
Definition: DBlmapReader.cc:9
unsigned int size() const
const unsigned int EVFFED_EPIDENT_OFFSET
Definition: FED1023.h:41
void setRBEventCount(uint32_t evtcnt)
unsigned char asBytes[fedinterface::EVFFED_TOTALSIZE]
#define FED_EVSZ_INSERT(a)
const unsigned int EVFFED_EPPCIDE_SHIFT
Definition: FED1023.h:43
const unsigned int EVFFED_ID
Definition: FED1023.h:28
unsigned int fedId() const
const unsigned int EVFFED_RBPCIDE_SHIFT
Definition: FED1023.h:36
const unsigned int SLINK_HALFWORD_SIZE
Definition: FEDConstants.h:7
const unsigned int EVFFED_DAQDIA1_OFFSET
Definition: FED1023.h:56
void setEPProcessId(pid_t pid)
#define FED_LVL1_INSERT(a)
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
Definition: CRC16.h:67
const unsigned int EVFFED_TOTALSIZE
Definition: FED1023.h:30
const unsigned int FED_TRAILER_SIZE
Definition: FEDConstants.h:9
const unsigned int EVFFED_RBPCIDE_MASK
Definition: FED1023.h:35
const unsigned int EVFFED_RBEVCNT_OFFSET
Definition: FED1023.h:33
#define FED_SOID_INSERT(a)
const unsigned int EVFFED_RBWCTIM_OFFSET
Definition: FED1023.h:39
unsigned char *const getPayload()
unsigned long long uint64_t
Definition: Time.h:15
unsigned int hostid_
tuple pid
Definition: sysUtil.py:22
const unsigned int EVFFED_LENGTH
Definition: FED1023.h:31
const unsigned int EVFFED_VERSION
Definition: FED1023.h:29
#define FED_VERSION_INSERT(a)
uint32_t asHWords[fedinterface::EVFFED_TOTALSIZE/sizeof(uint32_t)]
const unsigned int EVFFED_RBIDENT_OFFSET
Definition: FED1023.h:34
void setRBTimeStamp(uint64_t ts)
#define FED_BXID_INSERT(a)
const unsigned int EVFFED_EPPCIDE_MASK
Definition: FED1023.h:42
uint64_t asWords[fedinterface::EVFFED_TOTALSIZE/sizeof(uint64_t)]
#define FED_EVTY_INSERT(a)
void setDAQDiaWord1(uint64_t word)
#define FED_CRCS_INSERT(a)
#define FED_HCTRLID_INSERT
void putHeader(unsigned int l1id, unsigned int bxid)