forked from sPHENIX-Collaboration/rcdaq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdaqBuffer.h
100 lines (69 loc) · 1.86 KB
/
daqBuffer.h
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#ifndef __DAQBUFFER_H
#define __DAQBUFFER_H
#include <EvtStructures.h>
#include <daq_device.h>
#include <EventTypes.h>
#include <daqEvent.h>
#include <BufferConstants.h>
#include <arpa/inet.h>
#define DAQONCSFORMAT 0
#define DAQPRDFFORMAT 1
#define PRDFBUFFERHEADER 0xffffffc0;
#define ONCSBUFFERHEADER 0xffffc0c0;
#define CTRL_BEGINRUN 1
#define CTRL_ENDRUN 2
#define CTRL_DATA 3
#define CTRL_CLOSE 4
#define CTRL_SENDFILENAME 5
#define CTRL_REMOTESUCCESS 100
#define CTRL_REMOTEFAIL 101
class daqBuffer {
public:
//** Constructors
daqBuffer(const int irun = 1, const int length = 8*1024*1024+2*8192
, const int iseq = 1);
virtual ~daqBuffer();
// this creates a new event on the next address
int nextEvent(const int etype, const int evtseq, const int maxsize);
int prepare_next( const int iseq, const int irun =-1);
// subevent adding
int addSubevent( daq_device *);
// add end-of-buffer
int addEoB();
// now the write routine
unsigned int writeout ( int fd);
// now the "send buffer to a server" routine
unsigned int sendout ( int fd );
// now the "send monitor data" routine
unsigned int sendData ( int fd, const int max_length);
// now the re-sizing of buffer
int setMaxSize( const int size);
// and the query
int getMaxSize() const ;
// and the query
int getBufSeq () const { return bptr->Bufseq; } ;
int getLength () const { return bptr->Length; } ;
int setEventFormat(const int f);
int getEventFormat() const {return format;};
protected:
typedef struct
{
int Length;
int ID;
int Bufseq;
int Runnr;
int data[1];
} *buffer_ptr;
buffer_ptr bptr;
int *data_ptr;
int current_index;
int max_length;
int max_size;
int left;
daqEvent *current_event;
int current_etype;
int has_end;
int format;
int currentBufferID;
};
#endif