source: ntrip/trunk/BNC/bncapp.cpp@ 1612

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

* empty log message *

File size: 20.7 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: bncApp
30 *
31 * Purpose: This class implements the main application
32 *
33 * Author: L. Mervart
34 *
35 * Created: 29-Aug-2006
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
41#include <iostream>
42#include <QMessageBox>
43#include <cmath>
44#include <unistd.h>
45
46#include "bncapp.h"
47#include "bncutils.h"
48#include "bncrinex.h"
49#include "bncsettings.h"
50
51using namespace std;
52
53struct converttimeinfo {
54 int second; /* seconds of GPS time [0..59] */
55 int minute; /* minutes of GPS time [0..59] */
56 int hour; /* hour of GPS time [0..24] */
57 int day; /* day of GPS time [1..28..30(31)*/
58 int month; /* month of GPS time [1..12]*/
59 int year; /* year of GPS time [1980..] */
60};
61
62extern "C" {
63 void converttime(struct converttimeinfo *c, int week, int tow);
64 void updatetime(int *week, int *tow, int tk, int fixnumleap);
65}
66
67// Constructor
68////////////////////////////////////////////////////////////////////////////
69bncApp::bncApp(int& argc, char* argv[], bool GUIenabled) :
70 QApplication(argc, argv, GUIenabled) {
71
72 _bncVersion = "BNC 1.7";
73
74 _logFileFlag = 0;
75 _logFile = 0;
76 _logStream = 0;
77 _caster = 0;
78
79 // Lists of Ephemeris
80 // ------------------
81 for (int ii = PRN_GPS_START; ii <= PRN_GPS_END; ii++) {
82 _gpsEph[ii-PRN_GPS_START] = 0;
83 }
84 for (int ii = PRN_GLONASS_START; ii <= PRN_GLONASS_END; ii++) {
85 _glonassEph[ii-PRN_GLONASS_START] = 0;
86 }
87
88 // Eph file(s)
89 // -----------
90 _rinexVers = 0;
91 _ephFileGPS = 0;
92 _ephStreamGPS = 0;
93 _ephFileGlonass = 0;
94 _ephStreamGlonass = 0;
95
96 _port = 0;
97 _server = 0;
98 _sockets = 0;
99
100 _portCorr = 0;
101 _serverCorr = 0;
102 _socketsCorr = 0;
103
104 _pgmName = _bncVersion.leftJustified(20, ' ', true);
105#ifdef WIN32
106 _userName = QString("${USERNAME}");
107#else
108 _userName = QString("${USER}");
109#endif
110 expandEnvVar(_userName);
111 _userName = _userName.leftJustified(20, ' ', true);
112
113 _lastDumpCoSec = 0;
114
115 _corrs = new QMultiMap<long, QString>;
116
117 _currentDateAndTimeGPS = 0;
118}
119
120// Destructor
121////////////////////////////////////////////////////////////////////////////
122bncApp::~bncApp() {
123 delete _logStream;
124 delete _logFile;
125 delete _ephStreamGPS;
126 delete _ephFileGPS;
127 delete _server;
128 delete _sockets;
129 delete _serverCorr;
130 delete _socketsCorr;
131 if (_rinexVers == 2) {
132 delete _ephStreamGlonass;
133 delete _ephFileGlonass;
134 }
135 for (int ii = PRN_GPS_START; ii <= PRN_GPS_END; ii++) {
136 delete _gpsEph[ii-PRN_GPS_START];
137 }
138 for (int ii = PRN_GLONASS_START; ii <= PRN_GLONASS_END; ii++) {
139 delete _glonassEph[ii-PRN_GLONASS_START];
140 }
141
142 delete _corrs;
143
144 delete _currentDateAndTimeGPS;
145}
146
147// Write a Program Message
148////////////////////////////////////////////////////////////////////////////
149void bncApp::slotMessage(QByteArray msg, bool showOnScreen) {
150
151 QMutexLocker locker(&_mutexMessage);
152
153 messagePrivate(msg);
154 emit newMessage(msg, showOnScreen);
155}
156
157// Write a Program Message (private, no lock)
158////////////////////////////////////////////////////////////////////////////
159void bncApp::messagePrivate(const QByteArray& msg) {
160
161 // First time resolve the log file name
162 // ------------------------------------
163 QDate currDate = currentDateAndTimeGPS().date();
164 if (_logFileFlag == 0 || _fileDate != currDate) {
165 delete _logFile;
166 _logFileFlag = 1;
167 bncSettings settings;
168 QString logFileName = settings.value("logFile").toString();
169 if ( !logFileName.isEmpty() ) {
170 expandEnvVar(logFileName);
171 _logFile = new QFile(logFileName + "_" +
172 currDate.toString("yyMMdd").toAscii().data());
173 _fileDate = currDate;
174 if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
175 _logFile->open(QIODevice::WriteOnly | QIODevice::Append);
176 }
177 else {
178 _logFile->open(QIODevice::WriteOnly);
179 }
180 _logStream = new QTextStream();
181 _logStream->setDevice(_logFile);
182 }
183 }
184
185 if (_logStream) {
186 *_logStream << currentDateAndTimeGPS().toString("yy-MM-dd hh:mm:ss ").toAscii().data();
187 *_logStream << msg.data() << endl;
188 _logStream->flush();
189 }
190}
191
192// New GPS Ephemeris
193////////////////////////////////////////////////////////////////////////////
194void bncApp::slotNewGPSEph(gpsephemeris* gpseph) {
195
196 QMutexLocker locker(&_mutex);
197
198 gpsephemeris copy_gpseph = *gpseph;
199 emit newEphGPS(copy_gpseph);
200
201 printEphHeader();
202
203 gpsephemeris** ee = &_gpsEph[gpseph->satellite-1];
204
205 if ( *ee == 0 ||
206 gpseph->GPSweek > (*ee)->GPSweek ||
207 (gpseph->GPSweek == (*ee)->GPSweek && gpseph->TOC > (*ee)->TOC) ) {
208 delete *ee;
209 *ee = gpseph;
210 printGPSEph(gpseph, true);
211 }
212 else {
213 printGPSEph(gpseph, false);
214 delete gpseph;
215 }
216}
217
218// New Glonass Ephemeris
219////////////////////////////////////////////////////////////////////////////
220void bncApp::slotNewGlonassEph(glonassephemeris* glonasseph) {
221
222 QMutexLocker locker(&_mutex);
223
224 glonassephemeris copy_glonasseph = *glonasseph;
225 emit newEphGlonass(copy_glonasseph);
226
227 printEphHeader();
228
229 glonassephemeris** ee = &_glonassEph[glonasseph->almanac_number-1];
230
231 int wwOld, towOld, wwNew, towNew;
232 if (*ee != 0) {
233 wwOld = (*ee)->GPSWeek;
234 towOld = (*ee)->GPSTOW;
235 updatetime(&wwOld, &towOld, (*ee)->tb*1000, 0);
236
237 wwNew = glonasseph->GPSWeek;
238 towNew = glonasseph->GPSTOW;
239 updatetime(&wwNew, &towNew, glonasseph->tb*1000, 0);
240 }
241
242 if ( *ee == 0 ||
243 wwNew > wwOld ||
244 (wwNew == wwOld && towNew > towOld) ) {
245 delete *ee;
246 *ee = glonasseph;
247 printGlonassEph(glonasseph, true);
248 }
249 else {
250 printGlonassEph(glonasseph, false);
251 delete glonasseph;
252 }
253}
254
255// Print Header of the output File(s)
256////////////////////////////////////////////////////////////////////////////
257void bncApp::printEphHeader() {
258
259 bncSettings settings;
260
261 // Initialization
262 // --------------
263 if (_rinexVers == 0) {
264
265 if ( Qt::CheckState(settings.value("ephV3").toInt()) == Qt::Checked) {
266 _rinexVers = 3;
267 }
268 else {
269 _rinexVers = 2;
270 }
271
272 _ephPath = settings.value("ephPath").toString();
273
274 if ( !_ephPath.isEmpty() ) {
275 if ( _ephPath[_ephPath.length()-1] != QDir::separator() ) {
276 _ephPath += QDir::separator();
277 }
278 expandEnvVar(_ephPath);
279 }
280 }
281
282 // (Re-)Open output File(s)
283 // ------------------------
284 if (!_ephPath.isEmpty()) {
285
286 QDateTime datTim = currentDateAndTimeGPS();
287
288 QString ephFileNameGPS = _ephPath + "BRDC" +
289 QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0'));
290
291 QString hlpStr = bncRinex::nextEpochStr(datTim,
292 settings.value("ephIntr").toString());
293
294 if (_rinexVers == 3) {
295 ephFileNameGPS += hlpStr + datTim.toString(".yyP");
296 }
297 else {
298 ephFileNameGPS += hlpStr + datTim.toString(".yyN");
299 }
300
301 if (_ephFileNameGPS == ephFileNameGPS) {
302 return;
303 }
304 else {
305 _ephFileNameGPS = ephFileNameGPS;
306 }
307
308 for (int ii = PRN_GPS_START; ii <= PRN_GPS_END; ii++) {
309 delete _gpsEph[ii-PRN_GPS_START];
310 _gpsEph[ii-PRN_GPS_START] = 0;
311 }
312 for (int ii = PRN_GLONASS_START; ii <= PRN_GLONASS_END; ii++) {
313 delete _glonassEph[ii-PRN_GLONASS_START];
314 _glonassEph[ii-PRN_GLONASS_START] = 0;
315 }
316
317 delete _ephStreamGPS;
318 delete _ephFileGPS;
319
320 QFlags<QIODevice::OpenModeFlag> appendFlagGPS;
321 QFlags<QIODevice::OpenModeFlag> appendFlagGlonass;
322
323 if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked &&
324 QFile::exists(ephFileNameGPS) ) {
325 appendFlagGPS = QIODevice::Append;
326 }
327
328 _ephFileGPS = new QFile(ephFileNameGPS);
329 _ephFileGPS->open(QIODevice::WriteOnly | appendFlagGPS);
330 _ephStreamGPS = new QTextStream();
331 _ephStreamGPS->setDevice(_ephFileGPS);
332
333 if (_rinexVers == 3) {
334 _ephFileGlonass = _ephFileGPS;
335 _ephStreamGlonass = _ephStreamGPS;
336 }
337 else if (_rinexVers == 2) {
338 QString ephFileNameGlonass = _ephPath + "BRDC" +
339 QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0')) +
340 hlpStr + datTim.toString(".yyG");
341
342 delete _ephStreamGlonass;
343 delete _ephFileGlonass;
344
345 if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked &&
346 QFile::exists(ephFileNameGlonass) ) {
347 appendFlagGlonass = QIODevice::Append;
348 }
349
350 _ephFileGlonass = new QFile(ephFileNameGlonass);
351 _ephFileGlonass->open(QIODevice::WriteOnly | appendFlagGlonass);
352 _ephStreamGlonass = new QTextStream();
353 _ephStreamGlonass->setDevice(_ephFileGlonass);
354 }
355
356 // Header - RINEX Version 3
357 // ------------------------
358 if (_rinexVers == 3) {
359 if ( ! (appendFlagGPS & QIODevice::Append)) {
360 QString line;
361 line.sprintf(
362 "%9.2f%11sN: GNSS NAV DATA M: Mixed%12sRINEX VERSION / TYPE\n",
363 3.0, "", "");
364 *_ephStreamGPS << line;
365
366 QString hlp = currentDateAndTimeGPS().toString("yyyyMMdd hhmmss UTC").leftJustified(20, ' ', true);
367 *_ephStreamGPS << _pgmName.toAscii().data()
368 << _userName.toAscii().data()
369 << hlp.toAscii().data()
370 << "PGM / RUN BY / DATE" << endl;
371
372 line.sprintf("%60sEND OF HEADER\n", "");
373 *_ephStreamGPS << line;
374
375 _ephStreamGPS->flush();
376 }
377 }
378
379 // Headers - RINEX Version 2
380 // -------------------------
381 else if (_rinexVers == 2) {
382 if (! (appendFlagGPS & QIODevice::Append)) {
383 QString line;
384 line.sprintf(
385 "%9.2f%11sN: GPS NAV DATA%25sRINEX VERSION / TYPE\n", 2.11, "", "");
386 *_ephStreamGPS << line;
387
388 QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
389 *_ephStreamGPS << _pgmName.toAscii().data()
390 << _userName.toAscii().data()
391 << hlp.toAscii().data()
392 << "PGM / RUN BY / DATE" << endl;
393
394 line.sprintf("%60sEND OF HEADER\n", "");
395 *_ephStreamGPS << line;
396
397 _ephStreamGPS->flush();
398 }
399 if (! (appendFlagGlonass & QIODevice::Append)) {
400 QString line;
401 line.sprintf(
402 "%9.2f%11sG: GLONASS NAV DATA%21sRINEX VERSION / TYPE\n",2.11,"","");
403 *_ephStreamGlonass << line;
404
405 QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
406 *_ephStreamGlonass << _pgmName.toAscii().data()
407 << _userName.toAscii().data()
408 << hlp.toAscii().data()
409 << "PGM / RUN BY / DATE" << endl;
410
411 line.sprintf("%60sEND OF HEADER\n", "");
412 *_ephStreamGlonass << line;
413
414 _ephStreamGlonass->flush();
415 }
416 }
417 }
418}
419
420// Print One GPS Ephemeris
421////////////////////////////////////////////////////////////////////////////
422void bncApp::printGPSEph(gpsephemeris* ep, bool printFile) {
423
424 QString lineV2;
425 QString lineV3;
426
427 struct converttimeinfo cti;
428 converttime(&cti, ep->GPSweek, ep->TOC);
429
430 lineV3.sprintf("G%02d %04d %02d %02d %02d %02d %02d %18.11e %18.11e %18.11e\n",
431 ep->satellite, cti.year, cti.month, cti.day, cti.hour,
432 cti.minute, cti.second, ep->clock_bias, ep->clock_drift,
433 ep->clock_driftrate);
434
435 lineV2.sprintf("%02d %02d %02d %02d %02d %02d%5.1f %18.11e %18.11e %18.11e\n",
436 ep->satellite, cti.year%100, cti.month, cti.day, cti.hour,
437 cti.minute, (double) cti.second, ep->clock_bias,
438 ep->clock_drift, ep->clock_driftrate);
439
440 QString line;
441 QByteArray allLines;
442
443 QByteArray fmt;
444 QByteArray fmt2;
445 if (_rinexVers == 2) {
446 fmt = " %18.11e %18.11e %18.11e %18.11e\n";
447 fmt2 = " %18.11e %18.11e\n";
448 }
449 else {
450 fmt = " %18.11e %18.11e %18.11e %18.11e\n";
451 fmt2 = " %18.11e %18.11e\n";
452 }
453
454 line.sprintf(fmt.data(), (double)ep->IODE, ep->Crs, ep->Delta_n, ep->M0);
455 allLines += line;
456
457 line.sprintf(fmt.data(), ep->Cuc, ep->e, ep->Cus, ep->sqrt_A);
458 allLines += line;
459
460 line.sprintf(fmt.data(), (double) ep->TOE, ep->Cic, ep->OMEGA0, ep->Cis);
461 allLines += line;
462
463 line.sprintf(fmt.data(), ep->i0, ep->Crc, ep->omega, ep->OMEGADOT);
464 allLines += line;
465
466 double dd = 0;
467 unsigned long ii = ep->flags;
468 if(ii & GPSEPHF_L2CACODE)
469 dd += 2.0;
470 if(ii & GPSEPHF_L2PCODE)
471 dd += 1.0;
472 line.sprintf(fmt.data(), ep->IDOT, dd, (double) ep->GPSweek,
473 ii & GPSEPHF_L2PCODEDATA ? 1.0 : 0.0);
474 allLines += line;
475
476 if(ep->URAindex <= 6) /* URA index */
477 dd = ceil(10.0*pow(2.0, 1.0+((double)ep->URAindex)/2.0))/10.0;
478 else
479 dd = ceil(10.0*pow(2.0, ((double)ep->URAindex)/2.0))/10.0;
480 line.sprintf(fmt.data(), dd, ((double) ep->SVhealth), ep->TGD,
481 ((double) ep->IODC));
482 allLines += line;
483
484 line.sprintf(fmt2.data(), ((double)ep->TOW), 0.0);
485 allLines += line;
486
487 printOutput(printFile, _ephStreamGPS, lineV2, lineV3, allLines);
488}
489
490// Print One Glonass Ephemeris
491////////////////////////////////////////////////////////////////////////////
492void bncApp::printGlonassEph(glonassephemeris* ep, bool printFile) {
493
494 int ww = ep->GPSWeek;
495 int tow = ep->GPSTOW;
496 struct converttimeinfo cti;
497
498 updatetime(&ww, &tow, ep->tb*1000, 0);
499 converttime(&cti, ww, tow);
500
501 int tk = ep->tk-3*60*60;
502 if (tk < 0) {
503 tk += 86400;
504 }
505
506 QString lineV2;
507 QString lineV3;
508
509 lineV3.sprintf("R%02d %04d %02d %02d %02d %02d %02d %18.11e %18.11e %18.11e\n",
510 ep->almanac_number, cti.year, cti.month, cti.day, cti.hour,
511 cti.minute, cti.second, -ep->tau, ep->gamma, (double) tk);
512
513 lineV2.sprintf("%02d %02d %02d %02d %02d %02d%5.1f %18.11e %18.11e %18.11e\n",
514 ep->almanac_number, cti.year%100, cti.month, cti.day,
515 cti.hour, cti.minute, (double) cti.second, -ep->tau,
516 ep->gamma, (double) tk);
517
518 QString line;
519 QByteArray allLines;
520
521 QByteArray fmt;
522 if (_rinexVers == 2) {
523 fmt = " %18.11e %18.11e %18.11e %18.11e\n";
524 }
525 else {
526 fmt = " %18.11e %18.11e %18.11e %18.11e\n";
527 }
528
529 line.sprintf(fmt.data(), ep->x_pos, ep->x_velocity, ep->x_acceleration,
530 (ep->flags & GLOEPHF_UNHEALTHY) ? 1.0 : 0.0);
531 allLines += line;
532
533 line.sprintf(fmt.data(), ep->y_pos, ep->y_velocity, ep->y_acceleration,
534 (double) ep->frequency_number);
535 allLines += line;
536
537 line.sprintf(fmt.data(), ep->z_pos, ep->z_velocity, ep->z_acceleration,
538 (double) ep->E);
539 allLines += line;
540
541 printOutput(printFile, _ephStreamGlonass, lineV2, lineV3, allLines);
542}
543
544// Output
545////////////////////////////////////////////////////////////////////////////
546void bncApp::printOutput(bool printFile, QTextStream* stream,
547 const QString& lineV2,
548 const QString& lineV3,
549 const QByteArray& allLines) {
550 // Output into file
551 // ----------------
552 if (printFile && stream) {
553 if (_rinexVers == 2) {
554 *stream << lineV2.toAscii();
555 }
556 else {
557 *stream << lineV3.toAscii();
558 }
559 *stream << allLines;
560 stream->flush();
561 }
562
563 // Output into the socket
564 // ----------------------
565 if (_sockets) {
566 QMutableListIterator<QTcpSocket*> is(*_sockets);
567 while (is.hasNext()) {
568 QTcpSocket* sock = is.next();
569 if (sock->state() == QAbstractSocket::ConnectedState) {
570 if (sock->write(lineV3.toAscii()) == -1 ||
571 sock->write(allLines) == -1) {
572 delete sock;
573 is.remove();
574 }
575 }
576 else if (sock->state() != QAbstractSocket::ConnectingState) {
577 delete sock;
578 is.remove();
579 }
580 }
581 }
582}
583
584// Set Port Number
585////////////////////////////////////////////////////////////////////////////
586void bncApp::setPort(int port) {
587 _port = port;
588 if (_port != 0) {
589 delete _server;
590 _server = new QTcpServer;
591 if ( !_server->listen(QHostAddress::Any, _port) ) {
592 slotMessage("bncApp: Cannot listen on ephemeris port", true);
593 }
594 connect(_server, SIGNAL(newConnection()), this, SLOT(slotNewConnection()));
595 delete _sockets;
596 _sockets = new QList<QTcpSocket*>;
597 }
598}
599
600// Set Port Number
601////////////////////////////////////////////////////////////////////////////
602void bncApp::setPortCorr(int port) {
603 _portCorr = port;
604 if (_portCorr != 0) {
605 delete _serverCorr;
606 _serverCorr = new QTcpServer;
607 if ( !_serverCorr->listen(QHostAddress::Any, _portCorr) ) {
608 slotMessage("bncApp: Cannot listen on correction port", true);
609 }
610 connect(_serverCorr, SIGNAL(newConnection()), this, SLOT(slotNewConnectionCorr()));
611 delete _socketsCorr;
612 _socketsCorr = new QList<QTcpSocket*>;
613 }
614}
615
616// New Connection
617////////////////////////////////////////////////////////////////////////////
618void bncApp::slotNewConnection() {
619 _sockets->push_back( _server->nextPendingConnection() );
620}
621
622// New Connection
623////////////////////////////////////////////////////////////////////////////
624void bncApp::slotNewConnectionCorr() {
625 _socketsCorr->push_back( _serverCorr->nextPendingConnection() );
626}
627
628//
629////////////////////////////////////////////////////////////////////////////
630void bncApp::slotQuit() {
631 cout << "bncApp::slotQuit" << endl;
632 delete _caster;
633 quit();
634}
635
636//
637////////////////////////////////////////////////////////////////////////////
638void bncApp::slotNewCorrLine(QString line, QString staID, long coTime) {
639
640 QMutexLocker locker(&_mutex);
641
642 if (!_socketsCorr) {
643 return;
644 }
645
646 bncSettings settings;
647 _waitCoTime = settings.value("corrTime").toInt();
648 if (_waitCoTime < 1) {
649 _waitCoTime = 1;
650 }
651
652 // First time, set the _lastDumpSec immediately
653 // --------------------------------------------
654 if (_lastDumpCoSec == 0) {
655 _lastDumpCoSec = coTime - 1;
656 }
657
658 // An old correction - throw it away
659 // ---------------------------------
660 if (coTime <= _lastDumpCoSec) {
661 QString line = staID + ": Correction for one sat neglected because overaged by " +
662 QString().sprintf(" %ld sec",
663 _lastDumpCoSec - coTime + _waitCoTime);
664 messagePrivate(line.toAscii());
665 emit( newMessage(line.toAscii(), true) );
666 return;
667 }
668
669 _corrs->insert(coTime, QString(line + " " + staID));
670
671 // Dump Corrections
672 // ----------------
673 if (coTime - _waitCoTime > _lastDumpCoSec) {
674 dumpCorrs(_lastDumpCoSec + 1, coTime - _waitCoTime);
675 _lastDumpCoSec = coTime - _waitCoTime;
676 }
677}
678
679// Dump Complete Correction Epochs
680////////////////////////////////////////////////////////////////////////////
681void bncApp::dumpCorrs(long minTime, long maxTime) {
682
683 for (long sec = minTime; sec <= maxTime; sec++) {
684 QList<QString> allCorrs = _corrs->values(sec);
685 QListIterator<QString> it(allCorrs);
686 while (it.hasNext()) {
687 QString corrLine = it.next() + "\n";
688
689 QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
690 while (is.hasNext()) {
691 QTcpSocket* sock = is.next();
692 if (sock->state() == QAbstractSocket::ConnectedState) {
693 if (sock->write(corrLine.toAscii()) == -1) {
694 delete sock;
695 is.remove();
696 }
697 }
698 else if (sock->state() != QAbstractSocket::ConnectingState) {
699 delete sock;
700 is.remove();
701 }
702 }
703 }
704 _corrs->remove(sec);
705 }
706}
707
708//
709////////////////////////////////////////////////////////////////////////////
710void bncApp::setConfFileName(const QString& confFileName) {
711 if (confFileName.isEmpty()) {
712 _confFileName = QDir::homePath() + QDir::separator()
713 + ".config" + QDir::separator()
714 + organizationName() + QDir::separator()
715 + applicationName() + ".ini";
716 }
717 else {
718 _confFileName = confFileName;
719 }
720}
Note: See TracBrowser for help on using the repository browser.