Go to the documentation of this file.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 #ifndef GURALPCOMPRESSEDBLOCK_H
00029 #define GURALPCOMPRESSEDBLOCK_H
00030
00031 #include <QGpCoreTools.h>
00032
00033 #include "GeopsyCoreDLLExport.h"
00034 #include "TimeRange.h"
00035 #include "Signal.h"
00036
00037 namespace GeopsyCore {
00038
00039 class GEOPSYCORE_EXPORT GuralpCompressedBlock
00040 {
00041 TRANSLATIONS("GuralpCompressedBlock")
00042 public:
00043 GuralpCompressedBlock();
00044 GuralpCompressedBlock(const GuralpCompressedBlock& o);
00045 ~GuralpCompressedBlock();
00046
00047 void operator=(const GuralpCompressedBlock& o);
00048 bool operator==(const GuralpCompressedBlock& o) const;
00049
00050 enum StreamType {Data, MuxChannel, Status, ChannelData, BytePipe, Information, Unknown};
00051
00052 inline bool readHeader(QFile& f);
00053 inline bool readBody(QFile& f);
00054 inline void skipBody(QFile& f);
00055
00056 bool parseHeader(const char * gcfHeader);
00057 bool parseBody(const char * gcfBody);
00058
00059 StreamType streamType() const;
00060 const char * streamTypeString() const;
00061 int nSamples() const {return _nSamples;}
00062 double samplingFrequency() const {return _samplingFrequency;}
00063 QString name() const {return _device;}
00064 QDateTime startTime() const {return _startTime;}
00065 TimeRange timeRange(const QDateTime& refTime) const;
00066 Signal::Components component() const;
00067 bool isData() const {return _component!='0' && _component!='I';}
00068 int compressionCode() {return _compressionCode;}
00069 int sample(int index) const {return _samples[index];}
00070 uint hash() const {return _hash;}
00071
00072 void debugPrint() const;
00073 private:
00074 inline static void base36ToAscii(qint32 b, char * str);
00075 uint _hash;
00076 char _systemID[7];
00077 char _device[5];
00078 char _component;
00079 char _channel;
00080 QDateTime _startTime;
00081 double _samplingFrequency;
00082 int _compressionCode;
00083 int _nSamples;
00084 int * _samples;
00085 };
00086
00087 inline uint qHash(const GuralpCompressedBlock& b) {
00088 return b.hash();
00089 }
00090
00091 inline bool GuralpCompressedBlock::readHeader(QFile& f)
00092 {
00093
00094 char header[16];
00095 qint64 n=f.read(header, 16);
00096 if(n!=16) return false;
00097 return parseHeader(header);
00098 }
00099
00100 inline bool GuralpCompressedBlock::readBody(QFile& f)
00101 {
00102 char body[1008];
00103 qint64 n=f.read(body,1008);
00104 if(n!=1008) return false;
00105 return parseBody(body);
00106 }
00107
00108 inline void GuralpCompressedBlock::skipBody(QFile& f)
00109 {
00110 f.seek(f.pos()+1008);
00111 }
00112
00113 }
00114
00115 #endif // GURALPCOMPRESSEDBLOCK_H