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 #ifndef UBXDEVICE_H
00028 #define UBXDEVICE_H
00029
00030 #include <GpCoreTools.h>
00031 #include <WaranCore.h>
00032
00033 #include "NavigationTimer.h"
00034
00035 #define MONITOR_DRIFT_MODE
00036
00037 class GpsServer;
00038 class GpsBuffer;
00039
00040 class UbxDevice : public PThread
00041 {
00042 public:
00043 enum Mode {Off=0, Track=1, Stack=2};
00044
00045 UbxDevice(const std::string& stationName, const std::string& basePath,
00046 const std::string& devicePath, GpsServer * server);
00047 ~UbxDevice();
00048
00049 #ifdef MONITOR_DRIFT_MODE
00050 void setMonitorDriftMode(bool m) {_monitorDriftMode=m;}
00051 bool monitorDriftMode() const {return _monitorDriftMode;}
00052 #endif
00053
00054 void startBroadcast();
00055 void startRecording();
00056 void stopRecording();
00057 bool requestNavigation();
00058
00059 void sendState(GpsBuffer * client);
00060 unsigned long int recordingTime();
00061 void sendRaw(GpsBuffer * client);
00062
00063 enum TimeStatus {NoLock, GpsLock, PpsLock, LostPpsLock, LostGpsLock, RecoverLockAfterPpsLost, RecoverLockAfterGpsLost};
00064 void setTimeStatus(TimeStatus s);
00065 TimeStatus timeStatus();
00066
00067 void resetGpsDrift();
00068 bool isResetGpsDrift();
00069
00070 void resetPpsDrift();
00071 bool isResetPpsDrift();
00072
00073 void setSatelliteCount(int c) {_satelliteCount=c;}
00074 void setGpsDriftCount(int c) {_gpsDriftCount=c;}
00075 void setPpsDriftCount(int c) {_ppsDriftCount=c;}
00076
00077 FILE * lockFixStream() {pthread_mutex_lock(&_fixStreamMutex); return _fixStream;}
00078 void unlockFixStream() {pthread_mutex_unlock(&_fixStreamMutex);}
00079 FILE * lockRawStream() {pthread_mutex_lock(&_rawStreamMutex); return _rawStream;}
00080 void unlockRawStream() {pthread_mutex_unlock(&_rawStreamMutex);}
00081 private:
00082 const char * timeStamp(char * buffer32);
00083 bool openFixFile();
00084 void closeFixFile();
00085 bool openRawFile();
00086 void closeRawFile();
00087 virtual void run();
00088 void sendSeismic(const char * cmd);
00089
00090 std::string _basePath;
00091 std::string _stationName;
00092 pthread_mutex_t _fixStreamMutex;
00093 pthread_mutex_t _rawStreamMutex;
00094 std::string _fixFileName;
00095 std::string _rawFileName;
00096 FILE * _rawStream;
00097 FILE * _fixStream;
00098 time_t _startRecordingTime;
00099 Serial * _serial;
00100 GpsServer * _server;
00101 NavigationTimer _navigationTimer;
00102 pthread_mutex_t _timeStatusMutex;
00103 TimeStatus _timeStatus:3;
00104 int _satelliteCount, _gpsDriftCount, _ppsDriftCount;
00105 bool _resetGpsDrift:1;
00106 bool _resetPpsDrift:1;
00107 #ifdef MONITOR_DRIFT_MODE
00108 bool _monitorDriftMode;
00109 #endif
00110 };
00111
00112 #endif // UBXDEVICE_H