00001 #ifndef _DAQ_DTA_H_
00002 #define _DAQ_DTA_H_
00003
00004
00005
00006
00007 #include <rts.h>
00008 #include <sys/types.h>
00009
00010 #include "daq_dta_structs.h"
00011
00012
00013 struct daq_store {
00014 u_char sec ;
00015 u_char row ;
00016 u_char pad ;
00017 char type ;
00018 u_int nitems ;
00019 } ;
00020
00021
00022 struct daq_store_hdr {
00023
00024 int hdr_bytes ;
00025 int hdr_version ;
00026 u_int endianess ;
00027 int obj_bytes ;
00028 char obj_name[32] ;
00029 u_int bytes_used ;
00030 char describe[128] ;
00031
00032 } ;
00033
00034
00035
00036 #define DAQ_DTA_STRUCT(expr) __STRING(expr),sizeof(expr)
00037 #define DAQ_DTA_ENDIANESS 0x04030201
00038 #define DAQ_DTA_C_VERSION 0
00039 #define DAQ_DTA_H_VERSION 0
00040
00041
00042
00043 class daq_dta {
00044 private:
00045
00046 daq_store *store_cur ;
00047 daq_store_hdr *hdr ;
00048
00049 u_int bytes_alloced ;
00050 u_int nitems ;
00051
00052 int do_swap ;
00053 char type ;
00054
00055 inline void sw(u_int &x) {
00056 x = swap32(x) ;
00057 }
00058 inline void sw(int &x) {
00059 x = swap32(x) ;
00060 }
00061 inline void sw(u_short &x) {
00062 x = swap16(x) ;
00063 }
00064 inline void sw(short &x) {
00065 x = swap16(x) ;
00066 }
00067
00068
00069
00070 inline void psw(u_int &x) {
00071 if(do_swap) x = swap32(x) ;
00072 }
00073 inline void psw(int &x) {
00074 if(do_swap) x = swap32(x) ;
00075 }
00076 inline void psw(u_short &x) {
00077 if(do_swap) x = swap16(x) ;
00078 }
00079 inline void psw(short &x) {
00080 if(do_swap) x = swap16(x) ;
00081 }
00082
00083
00084
00085 inline u_int tsw(u_int x) {
00086 if(do_swap) return swap32(x) ;
00087 return x ;
00088 }
00089 inline int tsw(int x) {
00090 if(do_swap) return swap32(x) ;
00091 return x ;
00092 }
00093 inline u_short tsw(u_short x) {
00094 if(do_swap) return swap16(x) ;
00095 return x ;
00096 }
00097 inline short tsw(short x) {
00098 if(do_swap) return swap16(x) ;
00099 return x ;
00100 }
00101
00102
00103 inline short l2h(short x) { return l2h16(x) ; } ;
00104 inline u_short l2h(u_short x) { return l2h16(x) ; } ;
00105 inline int l2h(int x) { return l2h32(x) ; } ;
00106 inline u_int l2h(u_int x) { return l2h32(x) ; } ;
00107
00108 inline short b2h(short x) { return b2h16(x) ; } ;
00109 inline u_short b2h(u_short x) { return b2h16(x) ; } ;
00110 inline int b2h(int x) { return b2h32(x) ; } ;
00111 inline u_int b2h(u_int x) { return b2h32(x) ; } ;
00112
00113 daq_store *get(u_int obj_cou=0) ;
00114
00115 void clear() ;
00116
00117 void release() ;
00118
00119
00120
00121 void commit(u_int bytes=0) ;
00122
00123 daq_store *store ;
00124 public:
00125
00126
00127 daq_dta() ;
00128 virtual ~daq_dta() ;
00129
00130
00131 daq_store *create(u_int bytes, const char *name, int rts_id, const char *o_name, u_int obj_size) ;
00132
00133 void *request(u_int obj_cou) ;
00134 void finalize(u_int obj_cou, int s=0, int row=0, int pad=0) ;
00135 void rewind() ;
00136
00137
00138 int is_empty() ;
00139
00140 int iterate() ;
00141
00142 inline size_t get_size_t() {
00143 return hdr->obj_bytes ;
00144 }
00145
00146 virtual const char *GetCVS() const {
00147 static const char cvs[]="Tag $Name: $: $Id: daq_dta.h,v 1.6 2010/12/02 07:28:20 tonko Exp $: built "__DATE__" "__TIME__ ;
00148 return cvs;
00149 }
00150
00151
00152
00153
00154
00155 union {
00156
00157 void *Void ;
00158 unsigned char *Byte ;
00159 unsigned short *Short ;
00160 unsigned int *Int32 ;
00161 unsigned long long *Int64 ;
00162
00163
00164 daq_trg_word *trg_word ;
00165
00166
00167 daq_adc_tb *adc ;
00168
00169
00170 daq_cld *cld ;
00171
00172
00173 daq_sim_adc_tb *sim_adc ;
00174
00175 daq_sim_cld *sim_cld ;
00176
00177
00178 daq_det_gain *gain ;
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203 } ;
00204
00205
00206
00207
00208
00209
00210 int sec ;
00211 union {
00212 int row ;
00213 int rdo ;
00214 } ;
00215
00216 int pad ;
00217
00218 u_int ncontent ;
00219
00220 } ;
00221
00222
00223 #endif