-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDecoder.cxx
53 lines (42 loc) · 1.01 KB
/
Decoder.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Interface for reading a data file for parallelization test
#include "Decoder.h"
#include <cstring> // for memset, memcpy
using namespace std;
Decoder::Decoder() = default;
void Decoder::Clear()
{
memset( event.module, 0, sizeof(event.module) );
}
int Decoder::Load( evbuf_t* evbuffer )
{
int status = Preload( evbuffer );
if( status )
return status;
Clear();
char* evtp = ((char*)evbuffer)+sizeof(event.header);
auto ndet = event.header.event_info & 0xFFFFU;
for( decltype(ndet) i = 0; i < ndet; ++i ) {
auto* m = (ModuleData*)evtp;
if( !m )
return 3;
int imod = m->header.module_number;
if( imod < 1 )
return 4;
event.module[imod-1] = m;
evtp += m->header.module_length;
}
return 0;
}
int Decoder::Preload( evbuf_t* evbuffer )
{
if( !evbuffer )
return 1;
if( evbuffer[0] < 8 )
return 2;
memcpy( &event.header, evbuffer, sizeof(event.header) );
return 0;
}
bool Decoder::IsSyncEvent() const
{
return ((event.header.event_info & 0x10000U) != 0);
}