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 
28 namespace evf{
29 
31 
32  public:
34  for(unsigned int i = 0; i < fedinterface::EVFFED_LENGTH; i++){
35  unsigned int offset = i * evtn::SLINK_WORD_SIZE;
36  *(uint64_t*)(payload_ + offset ) = 0;
37  }
38  char hostname[32];
39  int retval = gethostname(hostname, 32);
40  if(retval != 0){
41  hostid_ = 0xdead;
42  }
43  else{
44  if(strtok(hostname,"-") == 0) hostid_ = 0xdead;
45  char *p = strtok(0,"-"); // rack id
46  long hostid = 0xdead;
47  if(p!=0) hostid = strtol(p,0,16) << 8;
48  p = strtok(0,"-"); // node id
49  if(p==0) hostid += 0xdead;
50  else hostid += strtol(p,0,16);
51  hostid_ = hostid;
52  }
56  }
57  unsigned char * const getPayload(){return payload_;}
59 
60  void putHeader(unsigned int l1id, unsigned int bxid){
61  *(uint32_t*)(payload_ )
63  *(uint32_t*)(payload_+ evtn::SLINK_HALFWORD_SIZE)
65 
66  }
67  // this function MUST be called again after filling is complete (hence again in EP!!!)
68  void putTrailer(){
70  *(uint32_t*)(fedtr_p+evtn::SLINK_HALFWORD_SIZE)
72  *(uint32_t*)(fedtr_p)
74  }
77  }
78  void setRBEventCount(uint32_t evtcnt){
79  *(uint32_t*) (payload_ + fedinterface::EVFFED_RBEVCNT_OFFSET) = evtcnt;
80  }
81 
82  void setEPProcessId(pid_t pid){
85  }
86  unsigned int fedId() const { return fedinterface::EVFFED_ID;}
87  unsigned int size() const { return fedinterface::EVFFED_TOTALSIZE;}
88  private:
90  unsigned int hostid_;
91  };
92 }
93 
94 
95 #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
#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
unsigned int offset(bool)
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
const unsigned int SLINK_WORD_SIZE
Definition: FEDConstants.h:6
#define FED_VERSION_INSERT(a)
const unsigned int EVFFED_RBIDENT_OFFSET
Definition: FED1023.h:34
void setRBTimeStamp(uint64_t ts)
#define FED_BXID_INSERT(a)
unsigned char payload_[fedinterface::EVFFED_TOTALSIZE]
const unsigned int EVFFED_EPPCIDE_MASK
Definition: FED1023.h:42
#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)