00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef _LIGO_FRAMETYPE_H
00040 #define _LIGO_FRAMETYPE_H
00041
00042
00043 #include <iosfwd>
00044 #include "framefast/fftype.hh"
00045
00046
00047 namespace framefast {
00048
00049
00061
00062
00064 const int maxName = 64;
00066 const int maxDictElements = 100;
00067
00069 struct ptr_struct {
00071 int_2u_t fDataClass;
00073 int_4u_t fDataInstance;
00074
00076 ptr_struct();
00078 int read (int version, const char* p, bool swapit);
00080 int write (int version, char* p, bool swapit) const;
00082 bool set (int version, const char* name);
00084 void operator++ (int) {
00085 fDataInstance++; }
00086 };
00087
00089 const int typeID_int_1s_t = 0;
00091 const int typeID_int_2s_t = 1;
00093 const int typeID_real_8_t = 2;
00095 const int typeID_real_4_t = 3;
00097 const int typeID_int_4s_t = 4;
00099 const int typeID_int_8s_t = 5;
00101 const int typeID_complex_8_t = 6;
00103 const int typeID_complex_16_t = 7;
00105 const int typeID_string = 8;
00107 const int typeID_int_2u_t = 9;
00109 const int typeID_int_4u_t = 10;
00111 const int typeID_int_8u_t = 11;
00113 const int typeID_int_1u_t = 12;
00114
00116 const char* const kFrameH = "FrameH";
00118 const char* const kFrDetector = "FrDetector";
00120 const char* const kFrHistory = "FrHistory";
00122 const char* const kFrRawData = "FrRawData";
00124 const char* const kFrAdcData = "FrAdcData";
00126 const char* const kFrVect = "FrVect";
00128 const char* const kFrEndOfFrame = "FrEndOfFrame";
00130 const char* const kFrTOC = "FrTOC";
00132 const char* const kFrEndOfFile = "FrEndOfFile";
00133
00134
00136 struct fileheader_t {
00138 int_1s_t fIGWD[5];
00140 int_1u_t fVersion;
00142 int_1u_t fMinorVersion;
00144 int_1u_t fSize_int2;
00146 int_1u_t fSize_int4;
00148 int_1u_t fSize_int8;
00150 int_1u_t fSize_real4;
00152 int_1u_t fSize_real8;
00154 int_2u_t fByteOrder2;
00156 int_4u_t fByteOrder4;
00158 int_8u_t fByteOrder8;
00160 real_4_t fPi4;
00162 real_8_t fPi8;
00164 int_1s_t fAlpha[2];
00165
00167 fileheader_t();
00169 void init (int version);
00171 int read (const char* p);
00173 int write (char* p, bool swap = false) const;
00174 };
00175
00176
00178 struct generic_t {
00180 int_8u_t fLen;
00182 int_2u_t fClass;
00184 int_4u_t fInstance;
00185
00187 generic_t();
00189 int read (int version, const char* p, bool swap = false, bool skipSH = false);
00191 int write (int version, char* p, bool swap = false) const;
00193 void fixlength (int version, char* p, int_8u_t len,
00194 bool swapit = false) const;
00195 };
00196
00197
00199 struct dict_element_t : public generic_t {
00201 char fName[maxName];
00203 char fType[maxName];
00205 char fComment[maxName];
00206
00208 dict_element_t();
00210 int read (int version, const char* p, bool swap = false);
00212 int write (int version, char* p, bool swap = false) const;
00213 };
00214
00215
00217 struct dict_header_t : public generic_t {
00219 char fName[maxName];
00221 int_2u_t fClassNum;
00223 char fComment[maxName];
00225 dict_element_t* fElements;
00227 int_2u_t fElementNum;
00228
00230 dict_header_t();
00232 dict_header_t (const dict_header_t& dicth);
00234 ~dict_header_t();
00236 dict_header_t& operator= (const dict_header_t& dicth);
00238 int read (int version, const char* p, bool swap = false);
00240 int write (int version, char* p, bool swap = false) const;
00241 };
00242
00243
00245 struct dict_t {
00247 dict_header_t fDict[maxDictElements];
00249 int_2u_t fDictNum;
00250
00252 dict_t() : fDictNum (0) {
00253 }
00255 void standard (int version);
00257 int write (int version, char* p, bool swap = false) const;
00258 };
00259
00260
00262 struct frameheader_t : public generic_t {
00264 char fName[maxName];
00266 int_4s_t fRun;
00268 int_4u_t fFrame;
00270 int_4u_t fDataQual;
00272 int_4u_t fGTimeS;
00274 int_4u_t fGTimeN;
00276 int_2u_t fULeapS;
00278 int_4s_t fLocalTime;
00280 real_8_t fFrameLen;
00285 ptr_struct fDir[14];
00286
00288 frameheader_t();
00290 int read (int version, const char* p, bool swap = false);
00292 int write (int version, char* p, bool swap = false) const;
00293 };
00294
00295
00297 struct detector_t : public generic_t {
00299 char fName[maxName];
00301 char fPrefix[4];
00303 int_2s_t fLongitudeD;
00305 int_2s_t fLongitudeM;
00307 real_4_t fLongitudeS;
00309 int_2s_t fLatitudeD;
00311 int_2s_t fLatitudeM;
00313 real_4_t fLatitudeS;
00315 real_4_t fElevation;
00317 real_4_t fArmXAzimuth;
00319 real_4_t fArmYAzimuth;
00321 real_4_t fArmXAltitude;
00323 real_4_t fArmYAltitude;
00325 real_4_t fArmXMidpoint;
00327 real_4_t fArmYMidpoint;
00329 int_4s_t fLocalTime;
00331 int_4u_t fDataQuality;
00333 char fQaBitList[maxName];
00334
00336 ptr_struct fMore[3];
00337
00339 detector_t();
00341 int read (int version, const char* p, bool swap = false);
00343 int write (int version, char* p, bool swap = false) const;
00345 real_8_t get_longitude() const;
00347 void set_longitude (real_8_t lon);
00349 real_8_t get_latitude() const;
00351 void set_latitude (real_8_t lat);
00352 };
00353
00354
00356 struct hist_t : public generic_t {
00358 char fName[maxName];
00360 int_4u_t fTime;
00362 char fComment[maxName];
00364 ptr_struct fNext;
00365
00367 hist_t();
00369 int read (int version, const char* p, bool swap = false);
00371 int write (int version, char* p, bool swap = false) const;
00372 };
00373
00374
00376 struct rawdata_t : public generic_t {
00378 char fName[maxName];
00380 ptr_struct fData[5];
00381
00383 rawdata_t();
00385 int read (int version, const char* p, bool swap = false);
00387 int write (int version, char* p, bool swap = false) const;
00388 };
00389
00391 enum datatype_t {
00393 kAdcData = 0,
00395 kProcData = 1,
00397 kSimData = 2,
00399 kSerData = 3
00400 };
00401
00403 struct adcdata_t : public generic_t {
00405 datatype_t fDatatype;
00407 char fName[maxName];
00409 char fComment[maxName];
00411 int_4u_t fChannelGroup;
00413 int_4u_t fChannelNumber;
00415 int_4u_t fNBits;
00417 real_4_t fBias;
00419 real_4_t fSlope;
00421 char fUnit[maxName];
00423 real_8_t fSampleRate;
00425 int_4s_t fTimeOffsetS;
00427 int_4u_t fTimeOffsetN;
00429 real_8_t fFShift;
00431 real_4_t fPhase;
00433 int_2u_t fDataValid;
00435 ptr_struct fData[4];
00436
00438 adcdata_t();
00440 int read (int version, datatype_t dtype, const char* p, bool swap = false);
00442 int write (int version, char* p, bool swap = false) const;
00443 };
00444
00445
00447 struct frvect_t : public generic_t {
00449 enum datacopy {
00451 fv_nocopy = 0,
00453 fv_copy = 1,
00455 fv_original = 2
00456 };
00457
00459 char fName[maxName];
00461 int_2u_t fCompress;
00463 int_2u_t fType;
00465 int_8u_t fNData;
00467 int_8u_t fNBytes;
00469 int_8u_t fNCompBytes;
00471 int_4u_t fNDim;
00473 int_8u_t fNx[4];
00475 real_8_t fDx[4];
00477 real_8_t fStartX[4];
00479 char fUnitX[4][maxName];
00481 char fUnitY[maxName];
00483 ptr_struct fNext;
00484
00486 frvect_t();
00488 frvect_t (const frvect_t& vect);
00490 ~frvect_t();
00492 frvect_t& operator= (const frvect_t& vect);
00493
00495 bool allocate (int_2u_t type, int size);
00497 void deallocate ();
00499 void clone (const frvect_t& templ);
00501 void image (const frvect_t& templ);
00503 int read (int version, const char* p, bool swap = false, datacopy cpy = fv_copy);
00505 int write (int version, char* p, bool swap = false) const;
00507 int get (real_4_t* dat, int max) const;
00509 int get (real_8_t* dat, int max) const;
00511 int get (complex_8_t* dat, int max) const;
00513 int get (complex_16_t* dat, int max) const;
00515 int get (int_2s_t* dat, int max) const;
00517 int get (int_4s_t* dat, int max) const;
00519 bool fill (int_4u_t pos, int_4u_t num, const frvect_t& src,
00520 int_4u_t ofs = 0, real_8_t mul = 1);
00521
00523 bool fill (int_4u_t pos, int_4u_t num, const char* values,
00524 bool swapit = false);
00526 const char* data (int offset = 0) const {
00527 return fData ? ((const char*) fData + offset) : 0; }
00528
00529 private:
00531 void* fData;
00533 mutable bool fOwn;
00534 };
00535
00536
00538 struct data_t {
00540 adcdata_t fADC;
00542 frvect_t fVect;
00543
00544
00545 data_t();
00547 ~data_t();
00549 bool allocate (int_2u_t type, int size);
00551 void deallocate ();
00553 void clone (const data_t& templ);
00562 bool fill (int_4u_t pos, int_4u_t num, const data_t& src,
00563 int_4u_t ofs = 0, real_8_t mul = 1);
00564 };
00565
00566
00568 struct endof_frame_t : public generic_t {
00570 int_4s_t fRun;
00572 int_4u_t fFrame;
00574 int_4u_t fChkType;
00576 int_4u_t fChkSum;
00577
00579 endof_frame_t();
00581 int read (int version, const char* p, bool swap = false);
00583 int write (int version, char* p, bool swap = false) const;
00584 };
00585
00586
00588 struct endof_file_t : public generic_t {
00590 int_4u_t fNFrames;
00592 int_8u_t fNBytes;
00594 int_4u_t fChkType;
00596 int_4u_t fChkSum;
00598 int_8u_t fSeekTOC;
00599
00601 endof_file_t ();
00603 int read (int version, const char* p, bool swap = false);
00605 int read (int version, const char* framestart, int_8u_t framelen,
00606 bool swap = false);
00608 int write (int version, char* p, bool swap = false) const;
00610 static int size (int version);
00611 };
00612
00613
00615 struct toc_frame_t {
00617 int_4u_t fDataQual;
00619 int_4u_t fGTimeS;
00621 int_4u_t fGTimeN;
00623 real_8_t fDt;
00625 int_4s_t fRun;
00627 int_4u_t fFrame;
00629 int_8u_t fPositionH;
00631 int_8u_t fNFirstADC;
00633 int_8u_t fNFirstSer;
00635 int_8u_t fNFirstTable;
00637 int_8u_t fNFirstMsg;
00638
00640 toc_frame_t ();
00641 };
00642
00644 struct toc_SH_t {
00646 int_2u_t fSHid;
00648 char fSHName[maxName];
00650 toc_SH_t ();
00651 };
00652
00654 struct toc_detector_t {
00656 char fDetector[maxName];
00658 int_8u_t fPos;
00659
00661 toc_detector_t ();
00662 };
00663
00665 struct toc_stat_t {
00667 char fName[maxName];
00669 char fDetector[maxName];
00671 int_4u_t fStatInstance;
00672
00673
00675 toc_stat_t ();
00676 };
00677
00679 struct toc_data_t {
00681 char fName[maxName];
00683 int_4u_t fChannelID;
00685 int_4u_t fGroupID;
00687 int_8u_t* fPosition;
00688
00690 toc_data_t ();
00692 bool operator== (const toc_data_t& d2) const;
00694 bool operator< (const toc_data_t& d2) const;
00695 };
00696
00698 struct toc_Event_t {
00700 char fName[maxName];
00702 int_4u_t fGTimeS;
00704 int_4u_t fGTimeN;
00706 int_8u_t fPosition;
00707
00709 toc_Event_t ();
00710 };
00711
00713 struct toc_t : public generic_t {
00715 int_2s_t fULeapS;
00717 int_4s_t fLocalTime;
00719 int_4u_t fNFrame;
00721 toc_frame_t* fFrames;
00723 int_4u_t fNSH;
00725 toc_SH_t* fSH;
00727 int_4u_t fNDetector;
00729 toc_detector_t* fDetInfo;
00731 int_4u_t fNStatType;
00733 toc_stat_t* fStat;
00735 int_4u_t fNData[5];
00737 toc_data_t* fData[5];
00739 int_4u_t fNEvt[2];
00741 toc_Event_t* fEvt[2];
00742
00744 toc_t();
00746 toc_t (const toc_t& toc);
00748 ~toc_t();
00750 toc_t& operator= (const toc_t& toc);
00752 bool allocate (int newsize, int datablck = 0);
00754 bool init (int version);
00756 int read (int version, const char* p, bool swap = false);
00758 bool scan (const char* p, int len, bool swap = false);
00760 int write (int version, char* p, bool swap = false) const;
00762 int size (int version) const;
00763
00765 toc_data_t* find (const char* chnname) const;
00767 toc_data_t* find (const char* chnname, int datablck) const;
00769 toc_data_t* add (const char* chnname, int datablck = 0);
00770
00772 toc_detector_t* findDetector (const char* name) const;
00774 toc_detector_t* addDetector (const char* name);
00775
00776 private:
00778 int_8u_t* fDataPosBuf[5];
00780 int_4s_t fChannelMax[5];
00781 };
00782
00783
00784
00792 std::ostream& dumpframe (std::ostream& os, const char* p, int len);
00793
00800 std::ostream& operator<< (std::ostream& os, const fileheader_t& h);
00801 std::ostream& dump (std::ostream& os, const fileheader_t& h);
00802
00809 std::ostream& operator<< (std::ostream& os, const dict_element_t& el);
00810 std::ostream& dump (std::ostream& os, const dict_element_t& el,
00811 int version = 4);
00812
00819 std::ostream& operator<< (std::ostream& os, const dict_header_t& h);
00820 std::ostream& dump (std::ostream& os, const dict_header_t& h,
00821 int version = 4, bool elements = true);
00822
00829 std::ostream& operator<< (std::ostream& os, const dict_t& dict);
00830 std::ostream& dump (std::ostream& os, const dict_t& dict,
00831 int version = 4);
00832
00839 std::ostream& operator<< (std::ostream& os, const frameheader_t& h);
00840 std::ostream& dump (std::ostream& os, const frameheader_t& h,
00841 int version = 4);
00842
00849 std::ostream& operator<< (std::ostream& os, const detector_t& d);
00850 std::ostream& dump (std::ostream& os, const detector_t& d,
00851 int version = 4);
00852
00859 std::ostream& operator<< (std::ostream& os, const hist_t& hist);
00860 std::ostream& dump (std::ostream& os, const hist_t& hist,
00861 int version = 4);
00862
00869 std::ostream& operator<< (std::ostream& os, const rawdata_t& d);
00870 std::ostream& dump (std::ostream& os, const rawdata_t& d,
00871 int version = 4);
00872
00879 std::ostream& operator<< (std::ostream& os, const adcdata_t& adc);
00880 std::ostream& dump (std::ostream& os, const adcdata_t& adc,
00881 int version = 4);
00882
00889 std::ostream& operator<< (std::ostream& os, const frvect_t& vec);
00890 std::ostream& dump (std::ostream& os, const frvect_t& vec,
00891 int version = 4);
00892
00899 std::ostream& operator<< (std::ostream& os, const endof_frame_t& eof);
00900 std::ostream& dump (std::ostream& os, const endof_frame_t& eof,
00901 int version = 4);
00902
00909 std::ostream& operator<< (std::ostream& os, const endof_file_t& eof);
00910 std::ostream& dump (std::ostream& os, const endof_file_t& eof,
00911 int version = 4);
00912
00919 std::ostream& operator<< (std::ostream& os, const toc_t& toc);
00920 std::ostream& dump (std::ostream& os, const toc_t& toc,
00921 int version = 4);
00922
00923
00925 class framereader;
00927 class framewriter;
00928
00930
00931
00932 }
00933
00934 #endif