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 
6 #include "interface/shared/fed_header.h"
7 
8 #define FED_HCTRLID_INSERT ( ( (FED_SLINK_START_MARKER) & FED_HCTRLID_WIDTH )<< FED_HCTRLID_SHIFT)
9 #define FED_EVTY_INSERT(a) ( ( (a) & FED_EVTY_WIDTH ) << FED_EVTY_SHIFT )
10 #define FED_LVL1_INSERT(a) ( ( (a) & FED_LVL1_WIDTH ) << FED_LVL1_SHIFT )
11 #define FED_BXID_INSERT(a) ( ( (a) & FED_BXID_WIDTH ) << FED_BXID_SHIFT )
12 #define FED_SOID_INSERT(a) ( ( (a) & FED_SOID_WIDTH ) << FED_SOID_SHIFT )
13 #define FED_VERSION_INSERT(a) ( ( (a) & FED_VERSION_WIDTH ) << FED_VERSION_SHIFT )
14 #define FED_MORE_HEADERS_INSERT(a) ( ( (a) & FED_MORE_HEADERS_WIDTH ) << FED_MORE_HEADERS_SHIFT )
15 
16 #include "interface/shared/fed_trailer.h"
17 #define FED_TCTRLID_INSERT ( ( (FED_SLINK_END_MARKER) & FED_TCTRLID_WIDTH ) << FED_TCTRLID_SHIFT )
18 #define FED_EVSZ_INSERT(a) ( ( (a) & FED_EVSZ_WIDTH ) << FED_EVSZ_SHIFT )
19 #define FED_CRCS_INSERT(a) ( ( (a) & FED_CRCS_WIDTH ) << FED_CRCS_SHIFT )
20 #define FED_STAT_INSERT(a) ( ( (a) & FED_STAT_WIDTH ) << FED_STAT_SHIFT )
21 #define FED_TTSI_INSERT(a) ( ( (a) & FED_TTSI_WIDTH ) << FED_TTSI_SHIFT )
22 #define FED_MORE_TRAILERS_INSERT(a) ( ( (a) & FED_MORE_TRAILERS_WIDTH ) << FED_MORE_TRAILERS_SHIFT )
23 
26 
27 namespace evf {
28 
30 
31 public:
33  for (unsigned int i = 0; i < fedinterface::EVFFED_LENGTH; i++) {
34  *(payload_.asWords + i) = 0;
35  }
36  char hostname[32];
37  int retval = gethostname(hostname, 32);
38  if (retval != 0) {
39  hostid_ = 0xdead;
40  } else {
41  if (strtok(hostname, "-") == 0)
42  hostid_ = 0xdead;
43  char *p = strtok(0, "-"); // rack id
44  long hostid = 0xdead;
45  if (p != 0)
46  hostid = strtol(p, 0, 16) << 8;
47  p = strtok(0, "-"); // node id
48  if (p == 0)
49  hostid += 0xdead;
50  else
51  hostid += strtol(p, 0, 16);
52  hostid_ = hostid;
53  }
57  + ((rb->instanceNumber()
60  }
61  unsigned char * const getPayload() {
62  return payload_.asBytes;
63  }
64  uint32_t getSize() {
66  }
67 
68  void putHeader(unsigned int l1id, unsigned int bxid) {
71  *(payload_.asHWords + (evtn::SLINK_HALFWORD_SIZE/sizeof(uint32_t)))
73  + FED_LVL1_INSERT(l1id) + FED_BXID_INSERT(bxid);
74 
75  }
76  // this function MUST be called again after filling is complete (hence again in EP!!!)
77  void putTrailer() {
78  uint32_t *fedtr_p = payload_.asHWords
80  *(fedtr_p + (evtn::SLINK_HALFWORD_SIZE/sizeof(uint32_t))) = FED_TCTRLID_INSERT
83  }
86  = ts;
87  }
88  void setRBEventCount(uint32_t evtcnt) {
90  = evtcnt;
91  }
92 
93  void setEPProcessId(pid_t pid) {
97  }
98  unsigned int fedId() const {
100  }
101  unsigned int size() const {
103  }
104 private:
105  union Payload {
107  uint32_t asHWords[fedinterface::EVFFED_TOTALSIZE / sizeof(uint32_t)];
109  };
111  unsigned int hostid_;
112 };
113 }
114 
115 #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)
const unsigned int EVFFED_RBINSTA_SHIFT
Definition: FED1023.h:38
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_RBINSTA_MASK
Definition: FED1023.h:37
unsigned int instanceNumber() const
const unsigned int EVFFED_RBPCIDE_SHIFT
Definition: FED1023.h:36
const unsigned int SLINK_HALFWORD_SIZE
Definition: FEDConstants.h:7
EvffedFillerRB(FUResourceBroker *rb)
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_
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)
Definition: EvffedFillerRB.h:9
#define FED_CRCS_INSERT(a)
#define FED_HCTRLID_INSERT
Definition: EvffedFillerRB.h:8
void putHeader(unsigned int l1id, unsigned int bxid)