Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-02 08:21:01

0001 #ifndef __DAQBUFFER_H
0002 #define __DAQBUFFER_H
0003 
0004 
0005 #include <lzo/lzoutil.h>
0006 
0007 #include <EvtStructures.h>
0008 #include <daq_device.h>
0009 #include <EventTypes.h>
0010 #include <daqEvent.h>
0011 #include <BufferConstants.h>
0012 #include "md5.h"
0013 
0014 #include <arpa/inet.h>
0015 
0016 
0017 #define CTRL_BEGINRUN        1
0018 #define CTRL_ENDRUN          2
0019 #define CTRL_DATA            3
0020 #define CTRL_CLOSE           4
0021 #define CTRL_SENDFILENAME    5
0022 #define CTRL_ROLLOVER        6
0023 
0024 #define CTRL_REMOTESUCCESS 100
0025 #define CTRL_REMOTEFAIL    101
0026 
0027 
0028 
0029 class daqBuffer {
0030 
0031 public:
0032 
0033   //** Constructors
0034 
0035   daqBuffer(const int irun = 1, const int length = 8*1024*1024+2*8192
0036         , const int iseq = 1,   md5_state_t *md5state = 0);
0037 
0038   virtual ~daqBuffer();
0039 
0040   //  this creates a new event on the next address
0041   int nextEvent(const int etype, const int evtseq, const int maxsize);
0042 
0043   int prepare_next( const int iseq, const int irun =-1);
0044 
0045   // subevent adding
0046   unsigned int addSubevent( daq_device *);
0047 
0048   //  add end-of-buffer
0049   unsigned int addEoB();
0050 
0051   int setCompression(const int flag);
0052   int getCompression() const {return wants_compression;} ;
0053   
0054   // now the write routine
0055   unsigned int writeout ( int fd);
0056 
0057   // now the "send buffer to a server" routine
0058   unsigned int sendout ( int fd );
0059   
0060   // now the "send monitor data" routine
0061   unsigned int sendData ( int fd, const int max_length);
0062 
0063   // now the re-sizing of buffer
0064   int setMaxSize( const int size);
0065 
0066   // and the query
0067   int getMaxSize() const ;
0068 
0069   // and the query
0070   int getBufSeq () const { return bptr->Bufseq; } ;
0071   unsigned int getLength () const { return bptr->Length; } ;
0072 
0073   int setEventFormat(const int f);
0074   int getEventFormat() const {return format;};
0075 
0076   // MD5 checksum business
0077   void setMD5State( md5_state_t *md5state) {_md5state = md5state;};
0078   md5_state_t * getMD5State() const {return _md5state;};
0079   void setMD5Enabled(const int x) { if(x) md5_enabled =1; else md5_enabled =0; }
0080   int  getMD5Enabled() const { return md5_enabled; };
0081 
0082 protected:
0083 
0084   // now the compress routine
0085   int compress ();
0086   
0087   typedef struct 
0088   { 
0089     unsigned int Length;
0090     int ID;
0091     int Bufseq;
0092     int Runnr;
0093     int data[1];
0094   } *buffer_ptr;
0095 
0096   int _broken;
0097   buffer_ptr bptr;
0098   int *data_ptr;
0099   int current_index;
0100   int max_length;
0101   int max_size;
0102   int left;
0103   daqEvent *current_event;
0104   int current_etype;
0105   int has_end;
0106   
0107   int format;
0108   int wants_compression;
0109   
0110   int currentBufferID;
0111 
0112   int md5_enabled;
0113   md5_state_t *_md5state;
0114 
0115   static int lzo_initialized;
0116   lzo_byte *wrkmem;
0117   lzo_uint  outputarraylength;
0118   unsigned int *outputarray;
0119 
0120 };
0121 
0122 #endif
0123