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

Last change on this file since 716 was 716, 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
409 _decodeTime = QDateTime::currentDateTime();
410 _decodeSucc = QDateTime::currentDateTime();
411 t_irc irc = initRun();
412
413 if (irc == fatal) {
414 QThread::exit(1);
415 return;
416 }
417 else if (irc != success) {
418 emit(newMessage(_staID + ": initRun failed, reconnecting"));
419 tryReconnect();
420 }
421
422 if (initPause < _inspSegm) {
423 initPause = _inspSegm;
424 }
425 currPause = initPause;
426
427 // Read Incoming Data
428 // ------------------
429 while (true) {
430 try {
431 if (_socket->state() != QAbstractSocket::ConnectedState) {
432 emit(newMessage(_staID + ": Socket not connected, reconnecting"));
433 tryReconnect();
434 }
435
436 QListIterator<p_obs> it(_decoder->_obsList);
437 while (it.hasNext()) {
438 delete it.next();
439 }
440 _decoder->_obsList.clear();
441
442 _socket->waitForReadyRead(_timeOut);
443 qint64 nBytes = _socket->bytesAvailable();
444 if (nBytes > 0) {
445 emit newBytes(_staID, nBytes);
446
447 char* data = new char[nBytes];
448 _socket->read(data, nBytes);
449
450 if (_inspSegm<1) {
451 _decoder->Decode(data, nBytes);
452 }
453 else {
454
455 // Decode data
456 // -----------
457 if (!_decodePause.isValid() ||
458 _decodePause.secsTo(QDateTime::currentDateTime()) >= currPause ) {
459
460 if (decode) {
461 if ( _decoder->Decode(data, nBytes) == success ) {
462 numSucc += 1;
463 }
464 if ( _decodeTime.secsTo(QDateTime::currentDateTime()) > _inspSegm ) {
465 decode = false;
466 }
467 }
468
469 // Check - once per inspect segment
470 // --------------------------------
471 if (!decode) {
472 _decodeTime = QDateTime::currentDateTime();
473 if (numSucc>0) {
474 secSucc += _inspSegm;
475 _decodeSucc = QDateTime::currentDateTime();
476 if (secSucc > _adviseReco * 60) {
477 secSucc = _adviseReco * 60 + 1;
478 }
479 numSucc = 0;
480 currPause = initPause;
481 _decodePause.setDate(QDate());
482 _decodePause.setTime(QTime());
483 }
484 else {
485 secFail += _inspSegm;
486 secSucc = 0;
487 if (secFail > _adviseFail * 60) {
488 secFail = _adviseFail * 60 + 1;
489 }
490 if (!_decodePause.isValid()) {
491 _decodePause = QDateTime::currentDateTime();
492 }
493 else {
494 _decodePause.setDate(QDate());
495 _decodePause.setTime(QTime());
496 secFail = secFail + currPause - _inspSegm;
497 currPause = currPause * 2;
498 if (currPause > 960) {
499 currPause = 960;
500 }
501 }
502 }
503
504 // End corrupt threshold
505 // ---------------------
506 if ( begCorrupt && !endCorrupt && secSucc > _adviseReco * 60 ) {
507 _endDateCor = QDateTime::currentDateTime().addSecs(- _adviseReco * 60).toUTC().date().toString("yy-MM-dd");
508 _endTimeCor = QDateTime::currentDateTime().addSecs(- _adviseReco * 60).toUTC().time().toString("hh:mm:ss");
509 emit(newMessage((_staID + ": Recovery threshold exceeded, corruption ended " + _endDateCor + " " + _endTimeCor).toAscii()));
510 callScript(("End_Corrupted " + _endDateCor + " " + _endTimeCor + " Begin was " + _begDateCor + " " + _begTimeCor).toAscii());
511 endCorrupt = true;
512 begCorrupt = false;
513 secFail = 0;
514 }
515 else {
516
517 // Begin corrupt threshold
518 // -----------------------
519 if ( !begCorrupt && secFail > _adviseFail * 60 ) {
520 _begDateCor = _decodeSucc.toUTC().date().toString("yy-MM-dd");
521 _begTimeCor = _decodeSucc.toUTC().time().toString("hh:mm:ss");
522 emit(newMessage((_staID + ": Failure threshold exceeded, corrupted since " + _begDateCor + " " + _begTimeCor).toAscii()));
523 callScript(("Begin_Corrupted " + _begDateCor + " " + _begTimeCor).toAscii());
524 begCorrupt = true;
525 endCorrupt = false;
526 secSucc = 0;
527 numSucc = 0;
528 }
529 }
530 decode = true;
531 }
532 }
533 }
534
535 // End outage threshold
536 // --------------------
537 if ( _decodeStart.isValid() && _decodeStart.secsTo(QDateTime::currentDateTime()) > _adviseReco * 60 ) {
538 _decodeStart.setDate(QDate());
539 _decodeStart.setTime(QTime());
540 if (_inspSegm>0) {
541 _endDateOut = QDateTime::currentDateTime().addSecs(- _adviseReco * 60).toUTC().date().toString("yy-MM-dd");
542 _endTimeOut = QDateTime::currentDateTime().addSecs(- _adviseReco * 60).toUTC().time().toString("hh:mm:ss");
543 emit(newMessage((_staID + ": Recovery threshold exceeded, outage ended " + _endDateOut + " " + _endTimeOut).toAscii()));
544 callScript(("End_Outage " + _endDateOut + " " + _endTimeOut + " Begin was " + _begDateOut + " " + _begTimeOut).toAscii());
545 }
546 }
547
548 delete [] data;
549
550 QListIterator<p_obs> it(_decoder->_obsList);
551 while (it.hasNext()) {
552 p_obs obs = it.next();
553
554 // Check observation epoch
555 // -----------------------
556 int week;
557 double sec;
558 currentGPSWeeks(week, sec);
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>(obs->_o.GPSWeeks);
585 if (newSec != oldSec) {
586 if (newSec % _latIntr < oldSec % _latIntr) {
587 if (numLat>0) {
588 emit( newMessage(QString("%1: Mean latency %2 sec, 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 sumLat += curLat;
602 if (curLat < minLat) minLat = curLat;
603 if (curLat >= maxLat) maxLat = curLat;
604 numLat += 1;
605 oldSec = newSec;
606 }
607 }
608 }
609
610 // RINEX Output
611 // ------------
612 if (_rnx) {
613 long iSec = long(floor(obs->_o.GPSWeeks+0.5));
614 long newTime = obs->_o.GPSWeek * 7*24*3600 + iSec;
615 if (_samplingRate == 0 || iSec % _samplingRate == 0) {
616 _rnx->deepCopy(obs);
617 }
618 _rnx->dumpEpoch(newTime);
619 }
620
621 bool firstObs = (obs == _decoder->_obsList.first());
622 obs->_status = t_obs::posted;
623 emit newObs(_staID, firstObs, obs);
624 }
625 _decoder->_obsList.clear();
626 }
627 else {
628 emit(newMessage(_staID + ": Data Timeout, reconnecting"));
629 tryReconnect();
630 }
631 }
632 catch (const char* msg) {
633 emit(newMessage(_staID + msg));
634 tryReconnect();
635 }
636 }
637}
638
639// Exit
640////////////////////////////////////////////////////////////////////////////
641void bncGetThread::exit(int exitCode) {
642 if (exitCode!= 0) {
643 emit error(_staID);
644 }
645 QThread::exit(exitCode);
646 terminate();
647}
648
649// Try Re-Connect
650////////////////////////////////////////////////////////////////////////////
651void bncGetThread::tryReconnect() {
652 if (_rnx) {
653 _rnx->setReconnectFlag(true);
654 }
655 if ( !_decodeStart.isValid()) {
656 _decodeStop = QDateTime::currentDateTime();
657 }
658 while (1) {
659 delete _socket; _socket = 0;
660 sleep(_nextSleep);
661 if ( initRun() == success ) {
662 if ( !_decodeStop.isValid()) {
663 _decodeStart = QDateTime::currentDateTime();
664 }
665 break;
666 }
667 else {
668
669 // Begin outage threshold
670 // ----------------------
671 if ( _decodeStop.isValid() && _decodeStop.secsTo(QDateTime::currentDateTime()) > _adviseFail * 60 ) {
672 _decodeStop.setDate(QDate());
673 _decodeStop.setTime(QTime());
674 if (_inspSegm>0) {
675 _begDateOut = _decodeTime.toUTC().date().toString("yy-MM-dd");
676 _begTimeOut = _decodeTime.toUTC().time().toString("hh:mm:ss");
677 emit(newMessage((_staID + ": Failure threshold exceeded, outage since " + _begDateOut + " " + _begTimeOut).toAscii()));
678 callScript(("Begin_Outage " + _begDateOut + " " + _begTimeOut).toAscii());
679 }
680 }
681 _nextSleep *= 2;
682 if (_nextSleep > 256) {
683 _nextSleep = 256;
684 }
685 _nextSleep += rand() % 6;
686 }
687 }
688 _nextSleep = 1;
689}
690
691// Call advisory notice script
692////////////////////////////////////////////////////////////////////////////
693void bncGetThread::callScript(const char* _comment) {
694 QMutexLocker locker(&_mutex);
695 if (!_adviseScript.isEmpty()) {
696 msleep(1);
697#ifdef WIN32
698 QProcess::startDetached(_adviseScript, QStringList() << _staID << _comment) ;
699#else
700 QProcess::startDetached("nohup", QStringList() << _adviseScript << _staID << _comment) ;
701#endif
702 }
703}
Note: See TracBrowser for help on using the repository browser.