| 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: main
|
|---|
| 30 | *
|
|---|
| 31 | * Purpose: Application starts here
|
|---|
| 32 | *
|
|---|
| 33 | * Author: L. Mervart
|
|---|
| 34 | *
|
|---|
| 35 | * Created: 24-Dec-2005
|
|---|
| 36 | *
|
|---|
| 37 | * Changes:
|
|---|
| 38 | *
|
|---|
| 39 | * -----------------------------------------------------------------------*/
|
|---|
| 40 |
|
|---|
| 41 | #include <unistd.h>
|
|---|
| 42 | #include <signal.h>
|
|---|
| 43 | #include <QApplication>
|
|---|
| 44 | #include <QFile>
|
|---|
| 45 | #include <iostream>
|
|---|
| 46 |
|
|---|
| 47 | #include "app.h"
|
|---|
| 48 | #include "bnccore.h"
|
|---|
| 49 | #include "bncwindow.h"
|
|---|
| 50 | #include "bncsettings.h"
|
|---|
| 51 | #include "bncversion.h"
|
|---|
| 52 | #include "upload/bncephuploadcaster.h"
|
|---|
| 53 | #ifdef USE_POSTPROCESSING
|
|---|
| 54 | # include "rinex/bncpostprocess.h"
|
|---|
| 55 | # include "rinex/reqcedit.h"
|
|---|
| 56 | # include "rinex/reqcanalyze.h"
|
|---|
| 57 | #endif
|
|---|
| 58 |
|
|---|
| 59 | using namespace std;
|
|---|
| 60 |
|
|---|
| 61 | void catch_signal(int) {
|
|---|
| 62 | cout << "Program Interrupted by Ctrl-C" << endl;
|
|---|
| 63 | exit(0);
|
|---|
| 64 | }
|
|---|
| 65 |
|
|---|
| 66 | // Main Program
|
|---|
| 67 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 68 | int main(int argc, char* argv[]) {
|
|---|
| 69 |
|
|---|
| 70 | bool interactive = true;
|
|---|
| 71 | #ifdef WIN32
|
|---|
| 72 | bool displaySet = true;
|
|---|
| 73 | #else
|
|---|
| 74 | bool displaySet = false;
|
|---|
| 75 | #endif
|
|---|
| 76 | QByteArray rawFileName;
|
|---|
| 77 | QString confFileName;
|
|---|
| 78 |
|
|---|
| 79 | QByteArray printHelp = "Usage: bnc --nw \n"
|
|---|
| 80 | " --display <XXX> \n"
|
|---|
| 81 | " --conf <confFileName> \n"
|
|---|
| 82 | " --file <rawFileName> \n"
|
|---|
| 83 | " --key <keyName> <keyValue>\n";
|
|---|
| 84 |
|
|---|
| 85 | for (int ii = 1; ii < argc; ii++) {
|
|---|
| 86 | if (QRegExp("--?help").exactMatch(argv[ii])) {
|
|---|
| 87 | cout << printHelp.data();
|
|---|
| 88 | exit(0);
|
|---|
| 89 | }
|
|---|
| 90 | if (QRegExp("--?nw").exactMatch(argv[ii])) {
|
|---|
| 91 | interactive = false;
|
|---|
| 92 | }
|
|---|
| 93 | if (QRegExp("--?display").exactMatch(argv[ii])) {
|
|---|
| 94 | displaySet = true;
|
|---|
| 95 | strcpy(argv[ii], "-display"); // make it "-display" not "--display"
|
|---|
| 96 | }
|
|---|
| 97 | if (ii + 1 < argc) {
|
|---|
| 98 | if (QRegExp("--?conf").exactMatch(argv[ii])) {
|
|---|
| 99 | confFileName = QString(argv[ii+1]);
|
|---|
| 100 | }
|
|---|
| 101 | if (QRegExp("--?file").exactMatch(argv[ii])) {
|
|---|
| 102 | interactive = false;
|
|---|
| 103 | rawFileName = QByteArray(argv[ii+1]);
|
|---|
| 104 | }
|
|---|
| 105 | }
|
|---|
| 106 | }
|
|---|
| 107 |
|
|---|
| 108 | #ifdef Q_OS_MAC
|
|---|
| 109 | if (argc== 3 && interactive) {
|
|---|
| 110 | confFileName = QString(argv[2]);
|
|---|
| 111 | }
|
|---|
| 112 | #else
|
|---|
| 113 | if (argc == 2 && interactive) {
|
|---|
| 114 | confFileName = QString(argv[1]);
|
|---|
| 115 | }
|
|---|
| 116 | #endif
|
|---|
| 117 |
|
|---|
| 118 | bool GUIenabled = interactive || displaySet;
|
|---|
| 119 | t_app app(argc, argv, GUIenabled);
|
|---|
| 120 |
|
|---|
| 121 | app.setApplicationName("BNC");
|
|---|
| 122 | app.setOrganizationName("BKG");
|
|---|
| 123 | app.setOrganizationDomain("www.bkg.bund.de");
|
|---|
| 124 |
|
|---|
| 125 | BNC_CORE->setGUIenabled(GUIenabled);
|
|---|
| 126 | BNC_CORE->setConfFileName( confFileName );
|
|---|
| 127 |
|
|---|
| 128 | bncSettings settings;
|
|---|
| 129 |
|
|---|
| 130 | for (int ii = 1; ii < argc - 2; ii++) {
|
|---|
| 131 | if (QRegExp("--?key").exactMatch(argv[ii])) {
|
|---|
| 132 | QString key(argv[ii+1]);
|
|---|
| 133 | QString val(argv[ii+2]);
|
|---|
| 134 | settings.setValue(key, val);
|
|---|
| 135 | }
|
|---|
| 136 | }
|
|---|
| 137 |
|
|---|
| 138 | // Interactive Mode - open the main window
|
|---|
| 139 | // ---------------------------------------
|
|---|
| 140 | if (interactive) {
|
|---|
| 141 |
|
|---|
| 142 | BNC_CORE->setMode(t_bncCore::interactive);
|
|---|
| 143 |
|
|---|
| 144 | QString fontString = settings.value("font").toString();
|
|---|
| 145 | if ( !fontString.isEmpty() ) {
|
|---|
| 146 | QFont newFont;
|
|---|
| 147 | if (newFont.fromString(fontString)) {
|
|---|
| 148 | QApplication::setFont(newFont);
|
|---|
| 149 | }
|
|---|
| 150 | }
|
|---|
| 151 |
|
|---|
| 152 | app.setWindowIcon(QPixmap(":ntrip-logo.png"));
|
|---|
| 153 |
|
|---|
| 154 | bncWindow* bncWin = new bncWindow();
|
|---|
| 155 | BNC_CORE->setMainWindow(bncWin);
|
|---|
| 156 | bncWin->show();
|
|---|
| 157 | }
|
|---|
| 158 |
|
|---|
| 159 | #ifdef USE_POSTPROCESSING
|
|---|
| 160 |
|
|---|
| 161 | // Post-Processing PPP
|
|---|
| 162 | // -------------------
|
|---|
| 163 | else if (settings.value("pppSPP").toString() == "Post-Processing") {
|
|---|
| 164 | BNC_CORE->setMode(t_bncCore::batchPostProcessing);
|
|---|
| 165 | t_postProcessing* postProcessing = new t_postProcessing(0, 0, 0);
|
|---|
| 166 | postProcessing->start();
|
|---|
| 167 | }
|
|---|
| 168 |
|
|---|
| 169 | // Post-Processing reqc edit
|
|---|
| 170 | // -------------------------
|
|---|
| 171 | else if (settings.value("reqcAction").toString() == "Edit/Concatenate") {
|
|---|
| 172 | BNC_CORE->setMode(t_bncCore::batchPostProcessing);
|
|---|
| 173 | t_reqcEdit* reqcEdit = new t_reqcEdit(0);
|
|---|
| 174 | reqcEdit->start();
|
|---|
| 175 | }
|
|---|
| 176 |
|
|---|
| 177 | // Post-Processing reqc analyze
|
|---|
| 178 | // ----------------------------
|
|---|
| 179 | else if (settings.value("reqcAction").toString() == "Analyze") {
|
|---|
| 180 | BNC_CORE->setMode(t_bncCore::batchPostProcessing);
|
|---|
| 181 | t_reqcAnalyze* reqcAnalyze = new t_reqcAnalyze(0);
|
|---|
| 182 | reqcAnalyze->start();
|
|---|
| 183 | }
|
|---|
| 184 |
|
|---|
| 185 | #endif
|
|---|
| 186 |
|
|---|
| 187 | // Non-Interactive (data gathering)
|
|---|
| 188 | // --------------------------------
|
|---|
| 189 | else {
|
|---|
| 190 |
|
|---|
| 191 | signal(SIGINT, catch_signal);
|
|---|
| 192 |
|
|---|
| 193 | bncEphUploadCaster* casterEph = new bncEphUploadCaster(); (void) casterEph;
|
|---|
| 194 |
|
|---|
| 195 | bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
|
|---|
| 196 | settings.value("outPort").toInt());
|
|---|
| 197 |
|
|---|
| 198 | BNC_CORE->setCaster(caster);
|
|---|
| 199 | BNC_CORE->setPort(settings.value("outEphPort").toInt());
|
|---|
| 200 | BNC_CORE->setPortCorr(settings.value("corrPort").toInt());
|
|---|
| 201 | BNC_CORE->initCombination();
|
|---|
| 202 |
|
|---|
| 203 | BNC_CORE->connect(caster, SIGNAL(getThreadsFinished()), &app, SLOT(quit()));
|
|---|
| 204 |
|
|---|
| 205 | BNC_CORE->slotMessage("========== Start BNC v" BNCVERSION " =========", true);
|
|---|
| 206 |
|
|---|
| 207 | // Normal case - data from Internet
|
|---|
| 208 | // --------------------------------
|
|---|
| 209 | if ( rawFileName.isEmpty() ) {
|
|---|
| 210 | BNC_CORE->setMode(t_bncCore::nonInteractive);
|
|---|
| 211 | caster->readMountPoints();
|
|---|
| 212 | if (caster->numStations() == 0) {
|
|---|
| 213 | exit(0);
|
|---|
| 214 | }
|
|---|
| 215 | }
|
|---|
| 216 |
|
|---|
| 217 | // Special case - data from file
|
|---|
| 218 | // -----------------------------
|
|---|
| 219 | else {
|
|---|
| 220 | BNC_CORE->setMode(t_bncCore::batchPostProcessing);
|
|---|
| 221 | bncRawFile* rawFile = new bncRawFile(rawFileName, "",
|
|---|
| 222 | bncRawFile::input);
|
|---|
| 223 | bncGetThread* getThread = new bncGetThread(rawFile);
|
|---|
| 224 | caster->addGetThread(getThread, true);
|
|---|
| 225 | }
|
|---|
| 226 | }
|
|---|
| 227 |
|
|---|
| 228 | // Start the application
|
|---|
| 229 | // ---------------------
|
|---|
| 230 | return app.exec();
|
|---|
| 231 | }
|
|---|