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

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