[280] | 1 | // Part of BNC, a utility for retrieving decoding and
|
---|
| 2 | // converting GNSS data streams from NTRIP broadcasters,
|
---|
| 3 | // written by Leos Mervart.
|
---|
| 4 | //
|
---|
| 5 | // Copyright (C) 2006
|
---|
| 6 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 7 | // http://www.bkg.bund.de
|
---|
| 8 | // Czech Technical University Prague, Department of Advanced Geodesy
|
---|
| 9 | // http://www.fsv.cvut.cz
|
---|
| 10 | //
|
---|
| 11 | // Email: euref-ip@bkg.bund.de
|
---|
| 12 | //
|
---|
| 13 | // This program is free software; you can redistribute it and/or
|
---|
| 14 | // modify it under the terms of the GNU General Public License
|
---|
| 15 | // as published by the Free Software Foundation, version 2.
|
---|
| 16 | //
|
---|
| 17 | // This program is distributed in the hope that it will be useful,
|
---|
| 18 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 20 | // GNU General Public License for more details.
|
---|
| 21 | //
|
---|
| 22 | // You should have received a copy of the GNU General Public License
|
---|
| 23 | // along with this program; if not, write to the Free Software
|
---|
| 24 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
[82] | 25 |
|
---|
| 26 | /* -------------------------------------------------------------------------
|
---|
[93] | 27 | * BKG NTRIP Client
|
---|
[82] | 28 | * -------------------------------------------------------------------------
|
---|
| 29 | *
|
---|
| 30 | * Class: bncApp
|
---|
| 31 | *
|
---|
| 32 | * Purpose: This class implements the main application
|
---|
| 33 | *
|
---|
| 34 | * Author: L. Mervart
|
---|
| 35 | *
|
---|
| 36 | * Created: 29-Aug-2006
|
---|
| 37 | *
|
---|
| 38 | * Changes:
|
---|
| 39 | *
|
---|
| 40 | * -----------------------------------------------------------------------*/
|
---|
| 41 |
|
---|
| 42 | #include <iostream>
|
---|
[149] | 43 | #include <QSettings>
|
---|
[150] | 44 | #include <QMessageBox>
|
---|
[82] | 45 |
|
---|
| 46 | #include "bncapp.h"
|
---|
[151] | 47 | #include "bncutils.h"
|
---|
[82] | 48 |
|
---|
| 49 | using namespace std;
|
---|
| 50 |
|
---|
| 51 | // Constructor
|
---|
| 52 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 53 | bncApp::bncApp(int argc, char* argv[], bool GUIenabled) :
|
---|
| 54 | QApplication(argc, argv, GUIenabled) {
|
---|
[109] | 55 |
|
---|
[150] | 56 | _logFileFlag = 0;
|
---|
| 57 | _logFile = 0;
|
---|
| 58 | _logStream = 0;
|
---|
[152] | 59 |
|
---|
[261] | 60 | _bncVersion = "BNC 1.0b";
|
---|
[82] | 61 | }
|
---|
| 62 |
|
---|
| 63 | // Destructor
|
---|
| 64 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 65 | bncApp::~bncApp() {
|
---|
[109] | 66 | delete _logStream;
|
---|
| 67 | delete _logFile;
|
---|
[82] | 68 | }
|
---|
| 69 |
|
---|
| 70 | // Write a Program Message
|
---|
| 71 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 72 | void bncApp::slotMessage(const QByteArray msg) {
|
---|
[150] | 73 |
|
---|
[243] | 74 | QMutexLocker locker(&_mutex);
|
---|
| 75 |
|
---|
[150] | 76 | // First time resolve the log file name
|
---|
| 77 | // ------------------------------------
|
---|
| 78 | if (_logFileFlag == 0) {
|
---|
| 79 | _logFileFlag = 1;
|
---|
| 80 | QSettings settings;
|
---|
| 81 | QString logFileName = settings.value("logFile").toString();
|
---|
| 82 | if ( !logFileName.isEmpty() ) {
|
---|
[151] | 83 | expandEnvVar(logFileName);
|
---|
[150] | 84 | _logFile = new QFile(logFileName);
|
---|
[275] | 85 | if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
|
---|
| 86 | _logFile->open(QIODevice::WriteOnly | QIODevice::Append);
|
---|
| 87 | }
|
---|
| 88 | else {
|
---|
| 89 | _logFile->open(QIODevice::WriteOnly);
|
---|
| 90 | }
|
---|
[150] | 91 | _logStream = new QTextStream();
|
---|
| 92 | _logStream->setDevice(_logFile);
|
---|
| 93 | }
|
---|
| 94 | }
|
---|
| 95 |
|
---|
[109] | 96 | if (_logStream) {
|
---|
[335] | 97 | *_logStream << QDate::currentDate().toString("yy-MM-dd ").toAscii().data();
|
---|
[199] | 98 | *_logStream << QTime::currentTime().toString("hh:mm:ss ").toAscii().data();
|
---|
[109] | 99 | *_logStream << msg.data() << endl;
|
---|
| 100 | _logStream->flush();
|
---|
[82] | 101 | }
|
---|
| 102 | }
|
---|