CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Block.cc
Go to the documentation of this file.
2 
4 
5 #define EDM_ML_DEBUG 1
6 
7 namespace l1t {
8  uint32_t
10  {
11  if (type_ == MP7) {
12  LogTrace("L1T") << "Writing MP7 link header";
13  return ((id_ & ID_mask) << ID_shift) | ((size_ & size_mask) << size_shift);
14  }
15  LogTrace("L1T") << "Writing CTP7 link header";
16  return ((id_ & CTP7_mask) << CTP7_shift);
17  }
18 
19  std::auto_ptr<Block>
21  {
22  if (end_ - data_ < getHeaderSize())
23  return std::auto_ptr<Block>();
24  auto header = getHeader();
25 
26  if (end_ - data_ < header.getSize()) {
27  edm::LogError("L1T")
28  << "Expecting a block size of " << header.getSize()
29  << " but only " << (end_ - data_) << " words remaining";
30  return std::auto_ptr<Block>();
31  }
32 
33  LogTrace("L1T") << "Creating block with size " << header.getSize();
34 
35  auto res = std::auto_ptr<Block>(new Block(header, data_, data_ + header.getSize()));
36  data_ += header.getSize();
37  return res;
38  }
39 
40  MP7Payload::MP7Payload(const uint32_t * data, const uint32_t * end) : Payload(data, end)
41  {
42  // FIXME extract firmware version here
43  // skip header for now
44  LogTrace("L1T") << "Skipping " << std::hex << *data_;
45  ++data_;
46  }
47 
50  {
51  LogTrace("L1T") << "Getting header from " << std::hex << *data_;
52  return BlockHeader(data_++);
53  }
54 
55  CTP7Payload::CTP7Payload(const uint32_t * data, const uint32_t * end) : Payload(data, end)
56  {
57  ++data_;
58  size_ = (*data >> size_shift) & size_mask;
59  ++data_;
60  }
61 
64  {
65  return BlockHeader(data_++, size_);
66  }
67 }
uint32_t raw(block_t type=MP7) const
Definition: Block.cc:9
type
Definition: HCALResponse.h:21
static const unsigned int size_shift
Definition: Block.h:99
virtual BlockHeader getHeader() override
Definition: Block.cc:63
static const unsigned int CTP7_mask
Definition: Block.h:30
std::auto_ptr< Block > getBlock()
Definition: Block.cc:20
Definition: Block.h:10
static const unsigned int ID_shift
Definition: Block.h:31
block_t type_
Definition: Block.h:38
const uint32_t * end_
Definition: Block.h:79
static const unsigned int ID_mask
Definition: Block.h:32
unsigned size_
Definition: Block.h:101
virtual BlockHeader getHeader()=0
block_t
Definition: Block.h:10
CTP7Payload(const uint32_t *data, const uint32_t *end)
Definition: Block.cc:55
virtual unsigned getHeaderSize() const =0
static const unsigned int size_mask
Definition: Block.h:34
#define end
Definition: vmac.h:37
unsigned int size_
Definition: Block.h:37
#define LogTrace(id)
const uint32_t * data_
Definition: Block.h:78
virtual BlockHeader getHeader() override
Definition: Block.cc:49
static const unsigned int size_mask
Definition: Block.h:98
static const unsigned int CTP7_shift
Definition: Block.h:29
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
unsigned int id_
Definition: Block.h:36
static const unsigned int size_shift
Definition: Block.h:33
MP7Payload(const uint32_t *data, const uint32_t *end)
Definition: Block.cc:40