00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef TARTEVENTSTORE_H
00012 #define TARTEVENTSTORE_H
00013
00014 #include <sys/ipc.h>
00015 #include <sys/shm.h>
00016 #include <sys/sem.h>
00017 #include <fstream>
00018 #include "TArtSharedMemory.h"
00019 #include "TArtSemaphore.h"
00020 #include "TArtDataSource.h"
00021 using namespace std;
00022
00023 #define MAXFILENAME 1024
00024 #define MB 1048576 // Unit of MByte (1024*1024)
00025 #define MAXBLOCKSIZE 131072 // maximum block size 128kByte
00026 #define WORDSIZE 2 // Byte
00027
00028
00029
00030
00031 #ifdef __cplusplus
00032 extern "C" {
00033 #endif
00034 void init_getdata__();
00035 void open_rawdat__(char name[132], int* fnamelen, int* flag);
00036 void get_block__(short ret[MAXBLOCKSIZE], int *flag);
00037 void get_evt__(unsigned short* blkbuf, unsigned short* evtbuf,
00038 unsigned short* blkflg, unsigned short* runbuff,
00039 unsigned short* rnum, int* nw);
00040 void close_rawdat__();
00041 void findsegment_(unsigned short* evtdata,
00042 int *evtsize,
00043 int *addr,
00044 int *nw,
00045 int *maxsegid);
00046
00047 #ifdef __cplusplus
00048 }
00049 #endif
00050
00051
00052
00053 typedef union {
00054 unsigned long int BYTE;
00055 struct {
00056 unsigned long int fSize:22;
00057 unsigned long int fClassID:6;
00058 unsigned long int fLayer:2;
00059 unsigned long int fReserved:2;
00060 unsigned long int fAddress:32;
00061 } BIT;
00062 } ArtHeader_t;
00063
00064 typedef enum {
00065 kOFFLINE = 1, kONLINE
00066 } ArtLineMode_t;
00067
00068
00073 class TArtEventStore {
00074 public:
00075
00076 typedef enum {
00077 kRDF, kRIDF
00078 } ArtFileType_t;
00079
00080 ~TArtEventStore();
00081 static TArtEventStore *Instance();
00082 void SetLineMode(ArtLineMode_t mode) {fLineMode = mode;}
00083 ArtFileStat_t Open(char *filename = 0);
00084 void Close();
00085 ArtBlockStat_t GetNextBlock(void);
00086 ArtEventStat_t GetNextEvent(unsigned short *evtbuf,
00087 unsigned short *runbuf,
00088 unsigned short *rnum,
00089 int &nWord);
00090 TArtDataSource* GetDataSource() { return fDataSource; }
00091 private:
00092 TArtDataSource *fDataSource;
00093 ArtFileStat_t fFileStatus;
00094 ArtBlockStat_t fBlockStatus;
00095 ArtEventStat_t fEventStatus;
00096 int fBlockSize;
00097 int fEventSize;
00098 int fEventPointer;
00099 ArtLineMode_t fLineMode;
00100 char fFilename[MAXFILENAME];
00101 ArtFileType_t fFileType;
00102 TArtSharedMemory *fSharedMemory;
00103 TArtSemaphore *fSemaphore;
00104 ifstream fFile;
00105 static TArtEventStore *fgEventStore;
00106 private:
00107 TArtEventStore();
00108 TArtEventStore(const TArtEventStore&) {;}
00109 TArtEventStore& operator=(const TArtEventStore&) {;}
00110
00111 };
00112 #endif // end of #ifdef TARTEVENTSTORE_H