source: ntrip/trunk/BNC/bncgetthread.cpp@ 710

Last change on this file since 710 was 710, checked in by weber, 16 years ago

* empty log message *

File size: 22.1 KB
Line 
1// Part of BNC, a utility for retrieving decoding and
2// converting GNSS data streams from NTRIP broadcasters.
3//
4// Copyright (C) 2007
5// German Federal Agency for Cartography and Geodesy (BKG)
6// http://www.bkg.bund.de
7// Czech Technical University Prague, Department of Geodesy
8// http://www.fsv.cvut.cz
9//
10// Email: euref-ip@bkg.bund.de
11//
12// This program is free software; you can redistribute it and/or
13// modify it under the terms of the GNU General Public License
14// as published by the Free Software Foundation, version 2.
15//
16// This program is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU General Public License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with this program; if not, write to the Free Software
23// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
25/* -------------------------------------------------------------------------
26 * BKG NTRIP Client
27 * -------------------------------------------------------------------------
28 *
29 * Class: bncGetThread
30 *
31 * Purpose: Thread that retrieves data from NTRIP caster
32 *
33 * Author: L. Mervart
34 *
35 * Created: 24-Dec-2005
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
41#include <stdlib.h>
42
43#include <QFile>
44#include <QTextStream>
45#include <QtNetwork>
46#include <QTime>
47
48#include "bncgetthread.h"
49#include "bnctabledlg.h"
50#include "bncapp.h"
51#include "bncutils.h"
52#include "bncrinex.h"
53#include "bnczerodecoder.h"
54
55#include "RTCM/RTCM2Decoder.h"
56#include "RTCM3/RTCM3Decoder.h"
57#include "RTIGS/RTIGSDecoder.h"
58
59using namespace std;
60
61// Constructor
62////////////////////////////////////////////////////////////////////////////
63bncGetThread::bncGetThread(const QUrl& mountPoint,
64 const QByteArray& format,
65 const QByteArray& latitude,
66 const QByteArray& longitude,
67 const QByteArray& nmea, int iMount) {
68
69 setTerminationEnabled(true);
70
71 _decoder = 0;
72 _mountPoint = mountPoint;
73 _staID = mountPoint.path().mid(1).toAscii();
74 _staID_orig = _staID;
75 _format = format;
76 _latitude = latitude;
77 _longitude = longitude;
78 _nmea = nmea;
79 _socket = 0;
80 _timeOut = 20*1000; // 20 seconds
81 _nextSleep = 1; // 1 second
82 _iMount = iMount; // index in mountpoints array
83
84 // Check name conflict
85 // -------------------
86 QSettings settings;
87 QListIterator<QString> it(settings.value("mountPoints").toStringList());
88 int num = 0;
89 int ind = -1;
90 while (it.hasNext()) {
91 ++ind;
92 QStringList hlp = it.next().split(" ");
93 if (hlp.size() <= 1) continue;
94 QUrl url(hlp[0]);
95 if (_mountPoint.path() == url.path()) {
96 if (_iMount > ind) {
97 ++num;
98 }
99 }
100 }
101
102 if (num > 0) {
103 _staID = _staID.left(_staID.length()-1) + QString("%1").arg(num).toAscii();
104 }
105
106 // Notice threshold
107 // ----------------
108 _inspSegm = 50;
109 if ( settings.value("obsRate").toString().isEmpty() ) { _inspSegm = 0; }
110 if ( settings.value("obsRate").toString().indexOf("5 Hz") != -1 ) { _inspSegm = 2; }
111 if ( settings.value("obsRate").toString().indexOf("1 Hz") != -1 ) { _inspSegm = 10; }
112 if ( settings.value("obsRate").toString().indexOf("0.5 Hz") != -1 ) { _inspSegm = 20; }
113 if ( settings.value("obsRate").toString().indexOf("0.2 Hz") != -1 ) { _inspSegm = 40; }
114 if ( settings.value("obsRate").toString().indexOf("0.1 Hz") != -1 ) { _inspSegm = 50; }
115 _adviseFail = settings.value("adviseFail").toInt();
116 _adviseReco = settings.value("adviseReco").toInt();
117 _adviseScript = settings.value("adviseScript").toString();
118 expandEnvVar(_adviseScript);
119
120 // Latency interval/average
121 // ------------------------
122 _latIntr = 86400;
123 if ( settings.value("latIntr").toString().isEmpty() ) { _latIntr = 0; }
124 if ( settings.value("latIntr").toString().indexOf("1 min") != -1 ) { _latIntr = 60; }
125 if ( settings.value("latIntr").toString().indexOf("5 min") != -1 ) { _latIntr = 300; }
126 if ( settings.value("latIntr").toString().indexOf("15 min") != -1 ) { _latIntr = 900; }
127 if ( settings.value("latIntr").toString().indexOf("1 hour") != -1 ) { _latIntr = 3600; }
128 if ( settings.value("latIntr").toString().indexOf("6 hours") != -1 ) { _latIntr = 21600; }
129 if ( settings.value("latIntr").toString().indexOf("1 day") != -1 ) { _latIntr = 86400; }
130
131 // RINEX writer
132 // ------------
133 _samplingRate = settings.value("rnxSampl").toInt();
134 if ( settings.value("rnxPath").toString().isEmpty() ) {
135 _rnx = 0;
136 }
137 else {
138 _rnx = new bncRinex(_staID, mountPoint, format, latitude, longitude, nmea);
139 }
140
141 msleep(100); //sleep 0.1 sec
142}
143
144// Destructor
145////////////////////////////////////////////////////////////////////////////
146bncGetThread::~bncGetThread() {
147 if (_socket) {
148 _socket->close();
149#if QT_VERSION == 0x040203
150 delete _socket;
151#else
152 _socket->deleteLater();
153#endif
154 }
155 delete _decoder;
156 delete _rnx;
157}
158
159#define AGENTVERSION "1.5"
160// Connect to Caster, send the Request (static)
161////////////////////////////////////////////////////////////////////////////
162QTcpSocket* bncGetThread::request(const QUrl& mountPoint,
163 QByteArray& latitude, QByteArray& longitude,
164 QByteArray& nmea, int timeOut,
165 QString& msg) {
166
167 // Connect the Socket
168 // ------------------
169 QSettings settings;
170 QString proxyHost = settings.value("proxyHost").toString();
171 int proxyPort = settings.value("proxyPort").toInt();
172
173 QTcpSocket* socket = new QTcpSocket();
174 if ( proxyHost.isEmpty() ) {
175 socket->connectToHost(mountPoint.host(), mountPoint.port());
176 }
177 else {
178 socket->connectToHost(proxyHost, proxyPort);
179 }
180 if (!socket->waitForConnected(timeOut)) {
181 msg += "Connect timeout\n";
182 delete socket;
183 return 0;
184 }
185
186 // Send Request
187 // ------------
188 QString uName = QUrl::fromPercentEncoding(mountPoint.userName().toAscii());
189 QString passW = QUrl::fromPercentEncoding(mountPoint.password().toAscii());
190 QByteArray userAndPwd;
191
192 if(!uName.isEmpty() || !passW.isEmpty())
193 {
194 userAndPwd = "Authorization: Basic " + (uName.toAscii() + ":" +
195 passW.toAscii()).toBase64() + "\r\n";
196 }
197
198 QUrl hlp;
199 hlp.setScheme("http");
200 hlp.setHost(mountPoint.host());
201 hlp.setPort(mountPoint.port());
202 hlp.setPath(mountPoint.path());
203
204 QByteArray reqStr;
205 if ( proxyHost.isEmpty() ) {
206 if (hlp.path().indexOf("/") != 0) hlp.setPath("/");
207 reqStr = "GET " + hlp.path().toAscii() + " HTTP/1.0\r\n";
208 } else {
209 reqStr = "GET " + hlp.toEncoded() + " HTTP/1.0\r\n";
210 }
211 reqStr += "User-Agent: NTRIP BNC/" AGENTVERSION "\r\n"
212 "Host: " + hlp.host().toAscii() + "\r\n"
213 + userAndPwd + "\r\n";
214
215// NMEA string to handle VRS stream
216// --------------------------------
217
218 double lat, lon;
219
220 lat = strtod(latitude,NULL);
221 lon = strtod(longitude,NULL);
222
223 if ((nmea == "yes") && (hlp.path().length() > 2) && (hlp.path().indexOf(".skl") < 0)) {
224 const char* flagN="N";
225 const char* flagE="E";
226 if (lon >180.) {lon=(lon-360.)*(-1.); flagE="W";}
227 if ((lon < 0.) && (lon >= -180.)) {lon=lon*(-1.); flagE="W";}
228 if (lon < -180.) {lon=(lon+360.); flagE="E";}
229 if (lat < 0.) {lat=lat*(-1.); flagN="S";}
230 QTime ttime(QDateTime::currentDateTime().toUTC().time());
231 int lat_deg = (int)lat;
232 double lat_min=(lat-lat_deg)*60.;
233 int lon_deg = (int)lon;
234 double lon_min=(lon-lon_deg)*60.;
235 int hh = 0 , mm = 0;
236 double ss = 0.0;
237 hh=ttime.hour();
238 mm=ttime.minute();
239 ss=(double)ttime.second()+0.001*ttime.msec();
240 QString gga;
241 gga += "GPGGA,";
242 gga += QString("%1%2%3,").arg((int)hh, 2, 10, QLatin1Char('0')).arg((int)mm, 2, 10, QLatin1Char('0')).arg((int)ss, 2, 10, QLatin1Char('0'));
243 gga += QString("%1%2,").arg((int)lat_deg,2, 10, QLatin1Char('0')).arg(lat_min, 7, 'f', 4, QLatin1Char('0'));
244 gga += flagN;
245 gga += QString(",%1%2,").arg((int)lon_deg,3, 10, QLatin1Char('0')).arg(lon_min, 7, 'f', 4, QLatin1Char('0'));
246 gga += flagE + QString(",1,05,1.00,+00100,M,10.000,M,,");
247 int xori;
248 char XOR = 0;
249 char *Buff =gga.toAscii().data();
250 int iLen = strlen(Buff);
251 for (xori = 0; xori < iLen; xori++) {
252 XOR ^= (char)Buff[xori];
253 }
254 gga += QString("*%1").arg(XOR, 2, 16, QLatin1Char('0'));
255 reqStr += "$";
256 reqStr += gga;
257 reqStr += "\r\n";
258 }
259
260 msg += reqStr;
261
262 socket->write(reqStr, reqStr.length());
263
264 if (!socket->waitForBytesWritten(timeOut)) {
265 msg += "Write timeout\n";
266 delete socket;
267 return 0;
268 }
269
270 return socket;
271}
272
273// Init Run
274////////////////////////////////////////////////////////////////////////////
275t_irc bncGetThread::initRun() {
276
277 // Initialize Socket
278 // -----------------
279 QString msg;
280 _socket = this->request(_mountPoint, _latitude, _longitude,
281 _nmea, _timeOut, msg);
282 if (!_socket) {
283 return failure;
284 }
285
286 // Read Caster Response
287 // --------------------
288 _socket->waitForReadyRead(_timeOut);
289 if (_socket->canReadLine()) {
290 QString line = _socket->readLine();
291
292 // Skip messages from proxy server
293 // -------------------------------
294 if (line.indexOf("ICY 200 OK") == -1 &&
295 line.indexOf("200 OK") != -1 ) {
296 bool proxyRespond = true;
297 while (true) {
298 if (_socket->canReadLine()) {
299 line = _socket->readLine();
300 if (!proxyRespond) {
301 break;
302 }
303 if (line.trimmed().isEmpty()) {
304 proxyRespond = false;
305 }
306 }
307 else {
308 _socket->waitForReadyRead(_timeOut);
309 if (_socket->bytesAvailable() <= 0) {
310 break;
311 }
312 }
313 }
314 }
315
316 if (line.indexOf("Unauthorized") != -1) {
317 QStringList table;
318 bncTableDlg::getFullTable(_mountPoint.host(), _mountPoint.port(), table);
319 QString net;
320 QStringListIterator it(table);
321 while (it.hasNext()) {
322 QString line = it.next();
323 if (line.indexOf("STR") == 0) {
324 QStringList tags = line.split(";");
325 if (tags.at(1) == _staID_orig) {
326 net = tags.at(7);
327 break;
328 }
329 }
330 }
331
332 QString reg;
333 it.toFront();
334 while (it.hasNext()) {
335 QString line = it.next();
336 if (line.indexOf("NET") == 0) {
337 QStringList tags = line.split(";");
338 if (tags.at(1) == net) {
339 reg = tags.at(7);
340 break;
341 }
342 }
343 }
344 emit(newMessage((_staID + ": Caster Response: " + line +
345 " Adjust User-ID and Password Register, see"
346 "\n " + reg).toAscii()));
347 return fatal;
348 }
349 if (line.indexOf("ICY 200 OK") != 0) {
350 emit(newMessage((_staID + ": Wrong Caster Response:\n" + line).toAscii()));
351 return failure;
352 }
353 }
354 else {
355 emit(newMessage(_staID + ": Response Timeout"));
356 return failure;
357 }
358
359 // Instantiate the filter
360 // ----------------------
361 if (!_decoder) {
362 if (_format.indexOf("RTCM_2") != -1) {
363 emit(newMessage("Get Data: " + _staID + " in RTCM 2.x format"));
364 _decoder = new RTCM2Decoder();
365 }
366 else if (_format.indexOf("RTCM_3") != -1) {
367 emit(newMessage("Get Data: " + _staID + " in RTCM 3.x format"));
368 _decoder = new RTCM3Decoder();
369 }
370 else if (_format.indexOf("RTIGS") != -1) {
371 emit(newMessage("Get Data: " + _staID + " in RTIGS format"));
372 _decoder = new RTIGSDecoder();
373 }
374 else if (_format.indexOf("SP3") != -1 || _format.indexOf("ZERO") != -1) {
375 emit(newMessage("Get Data: " + _staID + " in original format"));
376 _decoder = new bncZeroDecoder(_staID);
377 }
378 else {
379 emit(newMessage(_staID + ": Unknown data format " + _format));
380 return fatal;
381 }
382 }
383 return success;
384}
385
386// Run
387////////////////////////////////////////////////////////////////////////////
388void bncGetThread::run() {
389
390 const double maxDt = 600.0; // Check observation epoch
391 bool wrongEpoch = false;
392 bool decode = true;
393 int numSucc = 0;
394 int secSucc = 0;
395 int secFail = 0;
396 int initPause = 30; // Initial pause for corrupted streams
397 int currPause = 0;
398 bool begCorrupt = false;
399 bool endCorrupt = false;
400 int oldSec= 0;
401 int newSec = 0;
402 int numLat = 0;
403 double sumLat = 0.;
404 double minLat = maxDt;
405 double maxLat = -maxDt;
406 double curLat = 0.;
407 double leapsec = 14.; // Leap second for latency estimation
408 int week;
409 double sec;
410
411 _decodeTime = QDateTime::currentDateTime();
412 _decodeSucc = QDateTime::currentDateTime();
413 t_irc irc = initRun();
414
415 if (irc == fatal) {
416 QThread::exit(1);
417 return;
418 }
419 else if (irc != success) {
420 emit(newMessage(_staID + ": initRun failed, reconnecting"));
421 tryReconnect();
422 }
423
424 if (initPause < _inspSegm) {
425 initPause = _inspSegm;
426 }
427 currPause = initPause;
428
429 // Read Incoming Data
430 // ------------------
431 while (true) {
432 try {
433 if (_socket->state() != QAbstractSocket::ConnectedState) {
434 emit(newMessage(_staID + ": Socket not connected, reconnecting"));
435 tryReconnect();
436 }
437
438 QListIterator<p_obs> it(_decoder->_obsList);
439 while (it.hasNext()) {
440 delete it.next();
441 }
442 _decoder->_obsList.clear();
443
444 _socket->waitForReadyRead(_timeOut);
445 qint64 nBytes = _socket->bytesAvailable();
446 if (nBytes > 0) {
447 emit newBytes(_staID, nBytes);
448
449 char* data = new char[nBytes];
450 _socket->read(data, nBytes);
451 currentGPSWeeks(week, sec);
452
453 if (_inspSegm<1) {
454 _decoder->Decode(data, nBytes);
455 }
456 else {
457
458 // Decode data
459 // -----------
460 if (!_decodePause.isValid() ||
461 _decodePause.secsTo(QDateTime::currentDateTime()) >= currPause ) {
462
463 if (decode) {
464 if ( _decoder->Decode(data, nBytes) == success ) {
465 numSucc += 1;
466 }
467 if ( _decodeTime.secsTo(QDateTime::currentDateTime()) > _inspSegm ) {
468 decode = false;
469 }
470 }
471
472 // Check - once per inspect segment
473 // --------------------------------
474 if (!decode) {
475 _decodeTime = QDateTime::currentDateTime();
476 if (numSucc>0) {
477 secSucc += _inspSegm;
478 _decodeSucc = QDateTime::currentDateTime();
479 if (secSucc > _adviseReco * 60) {
480 secSucc = _adviseReco * 60 + 1;
481 }
482 numSucc = 0;
483 currPause = initPause;
484 _decodePause.setDate(QDate());
485 _decodePause.setTime(QTime());
486 }
487 else {
488 secFail += _inspSegm;
489 secSucc = 0;
490 if (secFail > _adviseFail * 60) {
491 secFail = _adviseFail * 60 + 1;
492 }
493 if (!_decodePause.isValid()) {
494 _decodePause = QDateTime::currentDateTime();
495 }
496 else {
497 _decodePause.setDate(QDate());
498 _decodePause.setTime(QTime());
499 secFail = secFail + currPause - _inspSegm;
500 currPause = currPause * 2;
501 if (currPause > 960) {
502 currPause = 960;
503 }
504 }
505 }
506
507 // End corrupt threshold
508 // ---------------------
509 if ( begCorrupt && !endCorrupt && secSucc > _adviseReco * 60 ) {
510 _endDateCor = QDateTime::currentDateTime().addSecs(- _adviseReco * 60).toUTC().date().toString("yy-MM-dd");
511 _endTimeCor = QDateTime::currentDateTime().addSecs(- _adviseReco * 60).toUTC().time().toString("hh:mm:ss");
512 emit(newMessage((_staID + ": Recovery threshold exceeded, corruption ended " + _endDateCor + " " + _endTimeCor).toAscii()));
513 callScript(("End_Corrupted " + _endDateCor + " " + _endTimeCor + " Begin was " + _begDateCor + " " + _begTimeCor).toAscii());
514 endCorrupt = true;
515 begCorrupt = false;
516 secFail = 0;
517 }
518 else {
519
520 // Begin corrupt threshold
521 // -----------------------
522 if ( !begCorrupt && secFail > _adviseFail * 60 ) {
523 _begDateCor = _decodeSucc.toUTC().date().toString("yy-MM-dd");
524 _begTimeCor = _decodeSucc.toUTC().time().toString("hh:mm:ss");
525 emit(newMessage((_staID + ": Failure threshold exceeded, corrupted since " + _begDateCor + " " + _begTimeCor).toAscii()));
526 callScript(("Begin_Corrupted " + _begDateCor + " " + _begTimeCor).toAscii());
527 begCorrupt = true;
528 endCorrupt = false;
529 secSucc = 0;
530 numSucc = 0;
531 }
532 }
533 decode = true;
534 }
535 }
536 }
537
538 // End outage threshold
539 // --------------------
540 if ( _decodeStart.isValid() && _decodeStart.secsTo(QDateTime::currentDateTime()) > _adviseReco * 60 ) {
541 _decodeStart.setDate(QDate());
542 _decodeStart.setTime(QTime());
543 if (_inspSegm>0) {
544 _endDateOut = QDateTime::currentDateTime().addSecs(- _adviseReco * 60).toUTC().date().toString("yy-MM-dd");
545 _endTimeOut = QDateTime::currentDateTime().addSecs(- _adviseReco * 60).toUTC().time().toString("hh:mm:ss");
546 emit(newMessage((_staID + ": Recovery threshold exceeded, outage ended " + _endDateOut + " " + _endTimeOut).toAscii()));
547 callScript(("End_Outage " + _endDateOut + " " + _endTimeOut + " Begin was " + _begDateOut + " " + _begTimeOut).toAscii());
548 }
549 }
550
551 delete [] data;
552
553 QListIterator<p_obs> it(_decoder->_obsList);
554 while (it.hasNext()) {
555 p_obs obs = it.next();
556
557 // Check observation epoch
558 // -----------------------
559 const double secPerWeek = 7.0 * 24.0 * 3600.0;
560
561 if (week < obs->_o.GPSWeek) {
562 week += 1;
563 sec -= secPerWeek;
564 }
565 if (week > obs->_o.GPSWeek) {
566 week -= 1;
567 sec += secPerWeek;
568 }
569 double dt = fabs(sec - obs->_o.GPSWeeks);
570 if (week != obs->_o.GPSWeek || dt > maxDt) {
571 if (!wrongEpoch) {
572 emit( newMessage(_staID + ": Wrong observation epoch") );
573 wrongEpoch = true;
574 }
575 delete obs;
576 continue;
577 }
578 else {
579 wrongEpoch = false;
580
581 // Latency
582 // -------
583 if (_latIntr>0) {
584 newSec = static_cast<int>(sec);
585 if (newSec != oldSec) {
586 if (newSec % _latIntr < oldSec % _latIntr) {
587 if (numLat>0) {
588 emit( newMessage(QString("%1: %2 sec mean latency, min %3, max %4")
589 .arg(_staID.data())
590 .arg(int(sumLat/numLat*100)/100.)
591 .arg(int(minLat*100)/100.)
592 .arg(int(maxLat*100)/100.)
593 .toAscii()) );
594 }
595 sumLat = 0.;
596 numLat = 0;
597 minLat = maxDt;
598 maxLat = -maxDt;
599 }
600 curLat = sec - obs->_o.GPSWeeks + leapsec;
601 printf("curLat %f\n",curLat);
602 sumLat += curLat;
603 if (curLat < minLat) minLat = curLat;
604 if (curLat >= maxLat) maxLat = curLat;
605 numLat += 1;
606 oldSec = newSec;
607 }
608 }
609 }
610
611 // RINEX Output
612 // ------------
613 if (_rnx) {
614 long iSec = long(floor(obs->_o.GPSWeeks+0.5));
615 long newTime = obs->_o.GPSWeek * 7*24*3600 + iSec;
616 if (_samplingRate == 0 || iSec % _samplingRate == 0) {
617 _rnx->deepCopy(obs);
618 }
619 _rnx->dumpEpoch(newTime);
620 }
621
622 bool firstObs = (obs == _decoder->_obsList.first());
623 obs->_status = t_obs::posted;
624 emit newObs(_staID, firstObs, obs);
625 }
626 _decoder->_obsList.clear();
627 }
628 else {
629 emit(newMessage(_staID + ": Data Timeout, reconnecting"));
630 tryReconnect();
631 }
632 }
633 catch (const char* msg) {
634 emit(newMessage(_staID + msg));
635 tryReconnect();
636 }
637 }
638}
639
640// Exit
641////////////////////////////////////////////////////////////////////////////
642void bncGetThread::exit(int exitCode) {
643 if (exitCode!= 0) {
644 emit error(_staID);
645 }
646 QThread::exit(exitCode);
647 terminate();
648}
649
650// Try Re-Connect
651////////////////////////////////////////////////////////////////////////////
652void bncGetThread::tryReconnect() {
653 if (_rnx) {
654 _rnx->setReconnectFlag(true);
655 }
656 if ( !_decodeStart.isValid()) {
657 _decodeStop = QDateTime::currentDateTime();
658 }
659 while (1) {
660 delete _socket; _socket = 0;
661 sleep(_nextSleep);
662 if ( initRun() == success ) {
663 if ( !_decodeStop.isValid()) {
664 _decodeStart = QDateTime::currentDateTime();
665 }
666 break;
667 }
668 else {
669
670 // Begin outage threshold
671 // ----------------------
672 if ( _decodeStop.isValid() && _decodeStop.secsTo(QDateTime::currentDateTime()) > _adviseFail * 60 ) {
673 _decodeStop.setDate(QDate());
674 _decodeStop.setTime(QTime());
675 if (_inspSegm>0) {
676 _begDateOut = _decodeTime.toUTC().date().toString("yy-MM-dd");
677 _begTimeOut = _decodeTime.toUTC().time().toString("hh:mm:ss");
678 emit(newMessage((_staID + ": Failure threshold exceeded, outage since " + _begDateOut + " " + _begTimeOut).toAscii()));
679 callScript(("Begin_Outage " + _begDateOut + " " + _begTimeOut).toAscii());
680 }
681 }
682 _nextSleep *= 2;
683 if (_nextSleep > 256) {
684 _nextSleep = 256;
685 }
686 _nextSleep += rand() % 6;
687 }
688 }
689 _nextSleep = 1;
690}
691
692// Call advisory notice script
693////////////////////////////////////////////////////////////////////////////
694void bncGetThread::callScript(const char* _comment) {
695 QMutexLocker locker(&_mutex);
696 if (!_adviseScript.isEmpty()) {
697 msleep(1);
698#ifdef WIN32
699 QProcess::startDetached(_adviseScript, QStringList() << _staID << _comment) ;
700#else
701 QProcess::startDetached("nohup", QStringList() << _adviseScript << _staID << _comment) ;
702#endif
703 }
704}
Note: See TracBrowser for help on using the repository browser.