- Timestamp:
- Sep 8, 2006, 10:09:25 AM (18 years ago)
- Location:
- trunk/BNC
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bncconst.h
r126 r138 1 1 #ifndef BNCCONST_H 2 2 #define BNCCONST_H 3 4 enum t_irc {failure = -1, success}; // return code 3 5 4 6 class t_CST { -
trunk/BNC/bncgetthread.cpp
r136 r138 37 37 _socket = 0; 38 38 _timeOut = 10*1000; // 10 seconds 39 _nextSleep = 1; // 1 second 39 40 } 40 41 … … 102 103 // Init Run 103 104 //////////////////////////////////////////////////////////////////////////// 104 voidbncGetThread::initRun() {105 t_irc bncGetThread::initRun() { 105 106 106 107 // Send the Request … … 113 114 114 115 if (!_socket) { 115 return exit(1);116 return failure; 116 117 } 117 118 … … 123 124 if (line.indexOf("ICY 200 OK") != 0) { 124 125 emit(newMessage(("Wrong Caster Response:\n" + line).toAscii())); 125 returnexit(1);126 exit(1); 126 127 } 127 128 } 128 129 else { 129 130 emit(newMessage("Response Timeout")); 130 return exit(1);131 return failure; 131 132 } 132 133 … … 148 149 else { 149 150 emit(newMessage(_staID + " Unknown data format " + _format)); 150 return exit(1); 151 } 152 } 151 exit(1); 152 } 153 } 154 return success; 153 155 } 154 156 … … 157 159 void bncGetThread::run() { 158 160 159 initRun(); 161 if ( initRun() != success ) { 162 emit(newMessage("initRun failed, reconnecting")); 163 tryReconnect(); 164 } 160 165 161 166 // Read Incoming Data … … 194 199 //////////////////////////////////////////////////////////////////////////// 195 200 void bncGetThread::tryReconnect() { 196 197 } 201 while (1) { 202 delete _socket; _socket = 0; 203 sleep(_nextSleep); 204 if ( initRun() == success ) { 205 break; 206 } 207 else { 208 _nextSleep *= 2; 209 } 210 } 211 _nextSleep = 1; 212 } -
trunk/BNC/bncgetthread.h
r136 r138 7 7 8 8 #include "RTCM/GPSDecoder.h" 9 #include "bncconst.h" 9 10 10 11 class bncGetThread : public QThread { … … 27 28 protected: 28 29 virtual void run(); 30 29 31 private: 30 voidinitRun();31 void tryReconnect();32 void message(const QString&);33 void exit(int exitCode = 0);32 t_irc initRun(); 33 void message(const QString&); 34 void exit(int exitCode = 0); 35 void tryReconnect(); 34 36 GPSDecoder* _decoder; 35 37 QTcpSocket* _socket; … … 38 40 QByteArray _format; 39 41 int _timeOut; 42 int _nextSleep; 40 43 }; 41 44
Note:
See TracChangeset
for help on using the changeset viewer.