Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
daqBuffer.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file daqBuffer.h
1 #ifndef __DAQBUFFER_H
2 #define __DAQBUFFER_H
3 
4 
5 #include <lzo/lzoutil.h>
6 
7 #include <EvtStructures.h>
8 #include <daq_device.h>
9 #include <EventTypes.h>
10 #include <daqEvent.h>
11 #include <BufferConstants.h>
12 #include "md5.h"
13 
14 #include <arpa/inet.h>
15 
16 
17 #define CTRL_BEGINRUN 1
18 #define CTRL_ENDRUN 2
19 #define CTRL_DATA 3
20 #define CTRL_CLOSE 4
21 #define CTRL_SENDFILENAME 5
22 #define CTRL_ROLLOVER 6
23 
24 #define CTRL_REMOTESUCCESS 100
25 #define CTRL_REMOTEFAIL 101
26 
27 
28 
29 class daqBuffer {
30 
31 public:
32 
33  //** Constructors
34 
35  daqBuffer(const int irun = 1, const int length = 8*1024*1024+2*8192
36  , const int iseq = 1, md5_state_t *md5state = 0);
37 
38  virtual ~daqBuffer();
39 
40  // this creates a new event on the next address
41  int nextEvent(const int etype, const int evtseq, const int maxsize);
42 
43  int prepare_next( const int iseq, const int irun =-1);
44 
45  // subevent adding
46  unsigned int addSubevent( daq_device *);
47 
48  // add end-of-buffer
49  unsigned int addEoB();
50 
51  int setCompression(const int flag);
52  int getCompression() const {return wants_compression;} ;
53 
54  // now the write routine
55  unsigned int writeout ( int fd);
56 
57  // now the "send buffer to a server" routine
58  unsigned int sendout ( int fd );
59 
60  // now the "send monitor data" routine
61  unsigned int sendData ( int fd, const int max_length);
62 
63  // now the re-sizing of buffer
64  int setMaxSize( const int size);
65 
66  // and the query
67  int getMaxSize() const ;
68 
69  // and the query
70  int getBufSeq () const { return bptr->Bufseq; } ;
71  unsigned int getLength () const { return bptr->Length; } ;
72 
73  int setEventFormat(const int f);
74  int getEventFormat() const {return format;};
75 
76  // MD5 checksum business
78  md5_state_t * getMD5State() const {return _md5state;};
79 
80 protected:
81 
82  // now the compress routine
83  int compress ();
84 
85  typedef struct
86  {
87  unsigned int Length;
88  int ID;
89  int Bufseq;
90  int Runnr;
91  int data[1];
92  } *buffer_ptr;
93 
94  int _broken;
96  int *data_ptr;
99  int max_size;
100  int left;
103  int has_end;
104 
105  int format;
107 
109 
111 
112  static int lzo_initialized;
113  lzo_byte *wrkmem;
115  unsigned int *outputarray;
116 
117 };
118 
119 #endif
120