[280] | 1 | // Part of BNC, a utility for retrieving decoding and
|
---|
[464] | 2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
[280] | 3 | //
|
---|
[464] | 4 | // Copyright (C) 2007
|
---|
[280] | 5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 6 | // http://www.bkg.bund.de
|
---|
[464] | 7 | // Czech Technical University Prague, Department of Geodesy
|
---|
[280] | 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.
|
---|
[35] | 24 |
|
---|
| 25 | /* -------------------------------------------------------------------------
|
---|
[93] | 26 | * BKG NTRIP Client
|
---|
[35] | 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 |
|
---|
[274] | 41 | #include <unistd.h>
|
---|
[603] | 42 | #include <signal.h>
|
---|
[35] | 43 | #include <QApplication>
|
---|
| 44 | #include <QFile>
|
---|
| 45 | #include <iostream>
|
---|
| 46 |
|
---|
[82] | 47 | #include "bncapp.h"
|
---|
[35] | 48 | #include "bncwindow.h"
|
---|
[1535] | 49 | #include "bncsettings.h"
|
---|
[2012] | 50 | #include "bncversion.h"
|
---|
[3251] | 51 | #include "upload/bncephuploadcaster.h"
|
---|
[3972] | 52 | #ifdef USE_POSTPROCESSING
|
---|
| 53 | # include "rinex/bncpostprocess.h"
|
---|
| 54 | # include "rinex/reqcedit.h"
|
---|
| 55 | # include "rinex/reqcanalyze.h"
|
---|
| 56 | #endif
|
---|
[35] | 57 |
|
---|
| 58 | using namespace std;
|
---|
| 59 |
|
---|
[603] | 60 | void catch_signal(int) {
|
---|
| 61 | cout << "Program Interrupted by Ctrl-C" << endl;
|
---|
[3005] | 62 | exit(0);
|
---|
[603] | 63 | }
|
---|
| 64 |
|
---|
[82] | 65 | // Main Program
|
---|
| 66 | /////////////////////////////////////////////////////////////////////////////
|
---|
[35] | 67 | int main(int argc, char *argv[]) {
|
---|
| 68 |
|
---|
[1146] | 69 | bool GUIenabled = true;
|
---|
[1552] | 70 | QByteArray rawFileName;
|
---|
[1501] | 71 | QString confFileName;
|
---|
[1146] | 72 |
|
---|
[3977] | 73 | QByteArray printHelp = "Usage: bnc --nw \n"
|
---|
| 74 | " --conf <confFileName> \n"
|
---|
| 75 | " --file <rawFileName> \n"
|
---|
| 76 | " --key <keyName> <keyValue>\n";
|
---|
| 77 |
|
---|
[100] | 78 | for (int ii = 1; ii < argc; ii++) {
|
---|
[3977] | 79 | if (QRegExp("--?help").exactMatch(argv[ii])) {
|
---|
| 80 | cout << printHelp.data();
|
---|
| 81 | exit(0);
|
---|
| 82 | }
|
---|
| 83 | if (QRegExp("--?nw").exactMatch(argv[ii])) {
|
---|
[100] | 84 | GUIenabled = false;
|
---|
| 85 | }
|
---|
[1552] | 86 | if (ii + 1 < argc) {
|
---|
[3977] | 87 | if (QRegExp("--?conf").exactMatch(argv[ii])) {
|
---|
[1552] | 88 | confFileName = QString(argv[ii+1]);
|
---|
[1146] | 89 | }
|
---|
[3977] | 90 | if (QRegExp("--?file").exactMatch(argv[ii])) {
|
---|
[1552] | 91 | GUIenabled = false;
|
---|
[1553] | 92 | rawFileName = QByteArray(argv[ii+1]);
|
---|
[1552] | 93 | }
|
---|
[1156] | 94 | }
|
---|
[1146] | 95 | }
|
---|
| 96 |
|
---|
[4162] | 97 | #ifdef Q_OS_MAC
|
---|
| 98 | if (argc== 3 && GUIenabled) {
|
---|
| 99 | confFileName = QString(argv[2]);
|
---|
| 100 | }
|
---|
| 101 | #else
|
---|
[1585] | 102 | if (argc == 2 && GUIenabled) {
|
---|
| 103 | confFileName = QString(argv[1]);
|
---|
| 104 | }
|
---|
[4162] | 105 | #endif
|
---|
[1585] | 106 |
|
---|
[1536] | 107 | bncApp app(argc, argv, GUIenabled);
|
---|
[1516] | 108 |
|
---|
[1538] | 109 | app.setApplicationName("BNC");
|
---|
| 110 | app.setOrganizationName("BKG");
|
---|
| 111 | app.setOrganizationDomain("www.bkg.bund.de");
|
---|
| 112 | app.setConfFileName( confFileName );
|
---|
| 113 |
|
---|
[1535] | 114 | bncSettings settings;
|
---|
[1503] | 115 |
|
---|
[3976] | 116 | for (int ii = 1; ii < argc - 2; ii++) {
|
---|
[3978] | 117 | if (QRegExp("--?key").exactMatch(argv[ii])) {
|
---|
[3976] | 118 | QString key(argv[ii+1]);
|
---|
| 119 | QString val(argv[ii+2]);
|
---|
| 120 | settings.setValue(key, val);
|
---|
| 121 | }
|
---|
| 122 | }
|
---|
| 123 |
|
---|
[180] | 124 | // Interactive Mode - open the main window
|
---|
| 125 | // ---------------------------------------
|
---|
[35] | 126 | if (GUIenabled) {
|
---|
[113] | 127 |
|
---|
[3280] | 128 | app.setMode(bncApp::interactive);
|
---|
| 129 |
|
---|
[113] | 130 | QString fontString = settings.value("font").toString();
|
---|
| 131 | if ( !fontString.isEmpty() ) {
|
---|
| 132 | QFont newFont;
|
---|
| 133 | if (newFont.fromString(fontString)) {
|
---|
| 134 | QApplication::setFont(newFont);
|
---|
| 135 | }
|
---|
| 136 | }
|
---|
[142] | 137 |
|
---|
[173] | 138 | app.setWindowIcon(QPixmap(":ntrip-logo.png"));
|
---|
[113] | 139 |
|
---|
[82] | 140 | bncWindow* bncWin = new bncWindow();
|
---|
[4346] | 141 | app.setMainWindow(bncWin);
|
---|
[35] | 142 | bncWin->show();
|
---|
| 143 | }
|
---|
[180] | 144 |
|
---|
[3975] | 145 | #ifdef USE_POSTPROCESSING
|
---|
| 146 |
|
---|
| 147 | // Post-Processing PPP
|
---|
| 148 | // -------------------
|
---|
| 149 | else if (settings.value("pppSPP").toString() == "Post-Processing") {
|
---|
| 150 | app.setMode(bncApp::batchPostProcessing);
|
---|
| 151 | t_postProcessing* postProcessing = new t_postProcessing(0);
|
---|
| 152 | postProcessing->start();
|
---|
| 153 | }
|
---|
| 154 |
|
---|
[3974] | 155 | // Post-Processing reqc edit
|
---|
| 156 | // -------------------------
|
---|
| 157 | else if (settings.value("reqcAction").toString() == "Edit/Concatenate") {
|
---|
| 158 | app.setMode(bncApp::batchPostProcessing);
|
---|
| 159 | t_reqcEdit* reqcEdit = new t_reqcEdit(0);
|
---|
| 160 | reqcEdit->start();
|
---|
| 161 | }
|
---|
| 162 |
|
---|
[3975] | 163 | // Post-Processing reqc analyze
|
---|
| 164 | // ----------------------------
|
---|
| 165 | else if (settings.value("reqcAction").toString() == "Analyze") {
|
---|
| 166 | app.setMode(bncApp::batchPostProcessing);
|
---|
| 167 | t_reqcAnalyze* reqcAnalyze = new t_reqcAnalyze(0);
|
---|
| 168 | reqcAnalyze->start();
|
---|
| 169 | }
|
---|
| 170 |
|
---|
| 171 | #endif
|
---|
| 172 |
|
---|
[3974] | 173 | // Non-Interactive (data gathering)
|
---|
| 174 | // --------------------------------
|
---|
[35] | 175 | else {
|
---|
[621] | 176 |
|
---|
[1138] | 177 | signal(SIGINT, catch_signal);
|
---|
| 178 |
|
---|
[3251] | 179 | bncEphUploadCaster* casterEph = new bncEphUploadCaster(); (void) casterEph;
|
---|
[3974] | 180 |
|
---|
[621] | 181 | bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
|
---|
| 182 | settings.value("outPort").toInt());
|
---|
| 183 |
|
---|
| 184 | app.setCaster(caster);
|
---|
[592] | 185 | app.setPort(settings.value("outEphPort").toInt());
|
---|
[937] | 186 | app.setPortCorr(settings.value("corrPort").toInt());
|
---|
[2909] | 187 | app.initCombination();
|
---|
[3974] | 188 |
|
---|
[1556] | 189 | app.connect(caster, SIGNAL(getThreadsFinished()), &app, SLOT(quit()));
|
---|
[3974] | 190 |
|
---|
[2012] | 191 | ((bncApp*)qApp)->slotMessage("========== Start BNC v" BNCVERSION " =========", true);
|
---|
[3974] | 192 |
|
---|
[1170] | 193 | // Normal case - data from Internet
|
---|
| 194 | // --------------------------------
|
---|
[3974] | 195 | if ( rawFileName.isEmpty() ) {
|
---|
[3280] | 196 | app.setMode(bncApp::nonInteractive);
|
---|
[4250] | 197 | caster->readMountPoints();
|
---|
[1170] | 198 | if (caster->numStations() == 0) {
|
---|
[1552] | 199 | exit(0);
|
---|
[1170] | 200 | }
|
---|
| 201 | }
|
---|
[3974] | 202 |
|
---|
[1170] | 203 | // Special case - data from file
|
---|
| 204 | // -----------------------------
|
---|
| 205 | else {
|
---|
[3280] | 206 | app.setMode(bncApp::batchPostProcessing);
|
---|
[3548] | 207 | bncRawFile* rawFile = new bncRawFile(rawFileName, "",
|
---|
[3531] | 208 | bncRawFile::input);
|
---|
[2519] | 209 | bncGetThread* getThread = new bncGetThread(rawFile);
|
---|
[2528] | 210 | caster->addGetThread(getThread, true);
|
---|
[35] | 211 | }
|
---|
| 212 | }
|
---|
[180] | 213 |
|
---|
| 214 | // Start the application
|
---|
| 215 | // ---------------------
|
---|
[35] | 216 | return app.exec();
|
---|
| 217 | }
|
---|