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 CITYSIGNAL_H
00029 #define CITYSIGNAL_H
00030
00031 #include <QGpCoreTools.h>
00032 #include "GeopsyCoreDLLExport.h"
00033
00034 namespace GeopsyCore {
00035
00036 #define BLOCK_SIZE 9
00037
00038 class GEOPSYCORE_EXPORT CitySignal
00039 {
00040 TRANSLATIONS("CitySignal");
00041 public:
00042 CitySignal();
00043 ~CitySignal();
00044
00045 bool readHeader(QFile * stream, int version);
00046 bool loadSignals(QFile * stream) const;
00047 bool erase(QFile * stream);
00048
00049 enum RecorderType {Unknown, CityShark1, CityShark2};
00050
00051 const DateTime& startTime() const {return _startTime;}
00052 const DateTime& endTime() const {return _endTime;}
00053 const char * fileIndex() const {return _fileIndex;}
00054 int channelNum() const {return _channelNum;}
00055 int duration() const {return _duration;}
00056 int gain() const {return _gain;}
00057 int maxAllowedAmpl() const {return _maxAllowedAmpl;}
00058 int maxReachedAmpl() const {return _maxReachedAmpl;}
00059 int frequency() const {return _frequency;}
00060 int nSamples() const {return _nSamples;}
00061 double saturation() const {return _saturation;}
00062 bool erased() const {return _erased;}
00063 QString fileName() const {return _startTime.toString("yyMMdd_hhmm")+"."+_fileIndex;}
00064 private:
00065 void readBlock(QFile * f) {f->read (_currentBlock, BLOCK_SIZE);}
00066 inline void setRecorder(char *ptr);
00067 inline int getSample(char * ptr) const;
00068 inline char * getCouple(char * startPtr);
00069 void setCurrentYear(DateTime& dt);
00070 private:
00071 char _currentBlock [BLOCK_SIZE+1];
00072
00073 RecorderType _recorder;
00074 bool _erased;
00075 qint64 _dataOffset;
00076
00077 int _channelNum;
00078 int _softwareVersion;
00079 int _serialNum;
00080 DateTime _startTime;
00081 DateTime _endTime;
00082 char _fileIndex[4];
00083 int _frequency;
00084 int _duration;
00085 int _nSamples;
00086 int _gain;
00087 double _saturation;
00088 int _maxAllowedAmpl;
00089 int _maxReachedAmpl;
00090
00091 int _latitudeDeg;
00092 int _longitudeDeg;
00093 double _latitudeMin;
00094 double _longitudeMin;
00095 int _satNum;
00096 double _altitude;
00097 };
00098
00099 inline void CitySignal::setRecorder(char * ptr)
00100 {
00101 TRACE;
00102 if(*ptr=='\0') _recorder=CityShark1;
00103 else if(*ptr=='2' && *(ptr+1)=='\0') _recorder=CityShark2;
00104 else _recorder=Unknown;
00105 }
00106
00107 inline char * CitySignal::getCouple(char * startPtr)
00108 {
00109 TRACE;
00110 char * ptr=startPtr;
00111 while(*ptr!='\0' && *ptr!=',') ptr++;
00112 *ptr='\0';
00113 return ptr+1;
00114 }
00115
00116 inline int CitySignal::getSample(char * ptr) const
00117 {
00118 TRACE;
00119 union {
00120 struct {unsigned char b1, b2, b3, b4;} b;
00121 int dw;
00122 } val;
00123 #if Q_BYTE_ORDER==Q_BIG_ENDIAN
00124 val.b.b2=ptr[0];
00125 val.b.b3=ptr[1];
00126 val.b.b4=ptr[2];
00127 if(val.b.b2>=0x80) val.b.b1=0xFF; else val.b.b1=0x00;
00128 #else // LITTLE ENDIAN
00129 val.b.b3=ptr[0];
00130 val.b.b2=ptr[1];
00131 val.b.b1=ptr[2];
00132 if(val.b.b3>=0x80) val.b.b4=0xFF; else val.b.b4=0x00;
00133 #endif
00134 return val.dw;
00135 }
00136
00137 }
00138
00139 #endif // CITYSIGNAL_H