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

Last change on this file since 2386 was 2386, checked in by mervart, 14 years ago

* empty log message *

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