Definition at line 33 of file BinData.h.
◆ BinData()
Definition at line 18 of file BinData.cc.
19{
20 if (buf != NULL) {
21 setBuffer(buf);
22 m_header->nword_in_header =
sizeof(
BinHeader) / 4;
24 m_header->nevent_nboard = 0;
25 m_header->exp_run = 0;
26 m_header->event_number = 0;
27 m_header->node_id = 0;
28 }
29}
◆ ~BinData()
◆ getBody() [1/2]
unsigned int * getBody |
( |
| ) |
|
|
inline |
◆ getBody() [2/2]
const unsigned int * getBody |
( |
| ) |
const |
|
inline |
◆ getBodyByteSize()
int getBodyByteSize |
( |
| ) |
const |
|
inline |
Definition at line 77 of file BinData.h.
78 {
79 return getByteSize() - sizeof(BinHeader) - sizeof(BinTrailer);
80 }
◆ getBodyWordSize()
int getBodyWordSize |
( |
| ) |
const |
|
inline |
Definition at line 87 of file BinData.h.
87{ return (getBodyByteSize() / 4); };
◆ getBuffer() [1/2]
◆ getBuffer() [2/2]
const int * getBuffer |
( |
| ) |
const |
|
inline |
◆ getByteSize()
int getByteSize |
( |
| ) |
const |
|
inline |
Definition at line 74 of file BinData.h.
74{ return m_header->nword * 4; };
◆ getEventNumber()
int getEventNumber |
( |
| ) |
const |
|
inline |
Definition at line 47 of file BinData.h.
47{ return m_header->event_number; };
◆ getExpNumber()
int getExpNumber |
( |
| ) |
const |
|
inline |
Definition at line 44 of file BinData.h.
44{ return (m_header->exp_run >> 22) & 0x3FF; };
◆ getHeader() [1/2]
◆ getHeader() [2/2]
◆ getHeaderByteSize()
int getHeaderByteSize |
( |
| ) |
const |
|
inline |
Definition at line 76 of file BinData.h.
76{ return m_header->nword_in_header * 4; };
◆ getHeaderWordSize()
int getHeaderWordSize |
( |
| ) |
const |
|
inline |
Definition at line 75 of file BinData.h.
75{ return m_header->nword_in_header; };
◆ getNBoard()
Definition at line 61 of file BinData.h.
61{ return (m_header->nevent_nboard & 0xFFFF); };
◆ getNEvent()
Definition at line 60 of file BinData.h.
60{ return (m_header->nevent_nboard >> 16); };
◆ getNodeId()
Definition at line 93 of file BinData.h.
93{ return m_header->node_id; };
◆ getRunNumber()
int getRunNumber |
( |
| ) |
const |
|
inline |
Definition at line 45 of file BinData.h.
45{ return (m_header->exp_run & 0x3FFFFF) >> 8; };
◆ getSubNumber()
int getSubNumber |
( |
| ) |
const |
|
inline |
Definition at line 46 of file BinData.h.
46{ return (m_header->exp_run & 0x3FFFFF) & 0xFF; };
◆ getTrailer() [1/2]
◆ getTrailer() [2/2]
◆ getTrailerMagic()
unsigned int getTrailerMagic |
( |
| ) |
|
|
inline |
Definition at line 88 of file BinData.h.
89 {
90 m_trailer = reinterpret_cast<BinTrailer*>(m_body + getBodyWordSize());
91 return m_trailer->magic;
92 }
◆ getWordSize()
int getWordSize |
( |
| ) |
const |
|
inline |
Definition at line 73 of file BinData.h.
73{ return m_header->nword; };
◆ print()
Definition at line 69 of file BinData.cc.
70{
71 printf("headerwords=%d, nwords=%d, nboard=%d, nevent=%d, evtno=%d, expno=%d, runno=%d, subno=%d, nodeid=%d, trailer=%04x\n",
72 getHeaderWordSize(),
73 getWordSize(),
74
75 getNBoard(),
76 getNEvent(),
77 getEventNumber(),
78 getExpNumber(),
79 getRunNumber(),
80 getSubNumber(),
81 getNodeId(),
82 getTrailerMagic());
83}
◆ recvEvent()
Definition at line 47 of file BinData.cc.
48{
49 unsigned int count = socket.read(m_header,
sizeof(
BinHeader));
50 if (m_header->nword_in_header * 4 !=
sizeof(
BinHeader)) {
51 throw (
IOException(
"unexpected header size %d words",
52 m_header->nword_in_header));
53 }
54 const int nbytes_remains = getByteSize() -
sizeof(
BinHeader);
55 count += socket.read(m_body, nbytes_remains);
57 if (m_trailer->magic != TRAILER_MAGIC) {
58 throw (
IOException(
"unexpected header trailer magic %08x",
59 m_trailer->magic));
60 }
61 return count;
62}
◆ sendEvent()
unsigned int sendEvent |
( |
TCPSocket & |
socket | ) |
const |
Definition at line 64 of file BinData.cc.
65{
66 return socket.write(m_buf, getByteSize());
67}
◆ setBodyWordSize()
void setBodyWordSize |
( |
int |
nword | ) |
|
|
inline |
Definition at line 81 of file BinData.h.
82 {
83 setWordSize(nword + (sizeof(BinHeader) + sizeof(BinTrailer)) / 4);
84 m_trailer = reinterpret_cast<BinTrailer*>(m_body + getBodyWordSize());
85 m_trailer->magic = TRAILER_MAGIC;
86 }
◆ setBuffer()
void setBuffer |
( |
void * |
buf | ) |
|
Definition at line 36 of file BinData.cc.
37{
38 if (buf != NULL) {
39 m_buf = (int*)buf;
41 m_body = (
unsigned int*)(((
char*)buf) +
sizeof(
BinHeader));
42 } else {
43 m_buf = NULL;
44 }
45}
◆ setEventNumber()
int setEventNumber |
( |
int |
number | ) |
|
|
inline |
Definition at line 48 of file BinData.h.
48{ return m_header->event_number = number; };
◆ setExpNumber()
int setExpNumber |
( |
int |
exp_no | ) |
|
|
inline |
Definition at line 49 of file BinData.h.
50 {
51 m_header->exp_run = ((exp_no & 0x3FF) << 22) | (m_header->exp_run & 0x3FFFFF);
52 return getExpNumber();
53 };
◆ setNBoard()
Definition at line 67 of file BinData.h.
68 {
69 m_header->nevent_nboard = (m_header->nevent_nboard & 0xFFFF0000) | (nb & 0xFFFF);
70 return getNBoard();
71 };
◆ setNEvent()
Definition at line 62 of file BinData.h.
63 {
64 m_header->nevent_nboard = ((nev & 0xFFFF) << 16) | (m_header->nevent_nboard & 0xFFFF);
65 return getNEvent();
66 };
◆ setNodeId()
Definition at line 94 of file BinData.h.
94{ m_header->node_id = id; };
◆ setRunNumber()
int setRunNumber |
( |
int |
run_no, |
|
|
int |
sub_no |
|
) |
| |
|
inline |
Definition at line 54 of file BinData.h.
55 {
56 m_header->exp_run = (m_header->exp_run & 0xFFC00000) |
57 (run_no & 0x3FFFFF) << 8 | (sub_no & 0xFF);
58 return getRunNumber();
59 };
◆ setWordSize()
void setWordSize |
( |
int |
nword | ) |
|
|
inline |
Definition at line 72 of file BinData.h.
72{ m_header->nword = nword; };
◆ m_body
◆ m_buf
◆ m_header
◆ m_trailer
◆ MAX_EVENT_WORDS
const unsigned int MAX_EVENT_WORDS = 2 * 1024 * 1024 |
|
static |
◆ TRAILER_MAGIC
const unsigned int TRAILER_MAGIC = 0x7FFF0007 |
|
static |
The documentation for this class was generated from the following files: