[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"
|
---|
[35] | 52 |
|
---|
| 53 | using namespace std;
|
---|
| 54 |
|
---|
[603] | 55 | void catch_signal(int) {
|
---|
| 56 | cout << "Program Interrupted by Ctrl-C" << endl;
|
---|
[3005] | 57 | exit(0);
|
---|
[603] | 58 | }
|
---|
| 59 |
|
---|
[82] | 60 | // Main Program
|
---|
| 61 | /////////////////////////////////////////////////////////////////////////////
|
---|
[35] | 62 | int main(int argc, char *argv[]) {
|
---|
| 63 |
|
---|
[1146] | 64 | bool GUIenabled = true;
|
---|
[1552] | 65 | QByteArray rawFileName;
|
---|
[1146] | 66 | QByteArray format;
|
---|
[3004] | 67 | QByteArray staID;
|
---|
[1501] | 68 | QString confFileName;
|
---|
[1146] | 69 |
|
---|
[100] | 70 | for (int ii = 1; ii < argc; ii++) {
|
---|
[2832] | 71 | if (QByteArray(argv[ii]) == "-nw" || QByteArray(argv[ii]) == "--nw") {
|
---|
[100] | 72 | GUIenabled = false;
|
---|
| 73 | }
|
---|
[1552] | 74 | if (ii + 1 < argc) {
|
---|
| 75 | if (QByteArray(argv[ii]).indexOf("-conf") != -1) {
|
---|
| 76 | confFileName = QString(argv[ii+1]);
|
---|
[1146] | 77 | }
|
---|
[1552] | 78 | if (QByteArray(argv[ii]).indexOf("-file") != -1) {
|
---|
| 79 | GUIenabled = false;
|
---|
[1553] | 80 | rawFileName = QByteArray(argv[ii+1]);
|
---|
[1552] | 81 | }
|
---|
| 82 | if (QByteArray(argv[ii]).indexOf("-format") != -1) {
|
---|
[1146] | 83 | format = QByteArray(argv[ii+1]);
|
---|
| 84 | }
|
---|
[3076] | 85 | if (QByteArray(argv[ii]).indexOf("-mountpoint") != -1) {
|
---|
[3004] | 86 | staID = QByteArray(argv[ii+1]);
|
---|
| 87 | }
|
---|
[1156] | 88 | }
|
---|
[1146] | 89 | }
|
---|
| 90 |
|
---|
[1585] | 91 | if (argc == 2 && GUIenabled) {
|
---|
| 92 | confFileName = QString(argv[1]);
|
---|
| 93 | }
|
---|
| 94 |
|
---|
[3076] | 95 | QString printHelp = "Usage: bnc --nw\n"
|
---|
| 96 | " --conf <confFileName>\n"
|
---|
| 97 | " --file <rawFileName>\n"
|
---|
| 98 | " --mountpoint <station>\n"
|
---|
| 99 | " --format <RTIGS | RTCM_2 | RTCM_3>\n";
|
---|
[1503] | 100 |
|
---|
[1536] | 101 | bncApp app(argc, argv, GUIenabled);
|
---|
[1516] | 102 |
|
---|
[1538] | 103 | app.setApplicationName("BNC");
|
---|
| 104 | app.setOrganizationName("BKG");
|
---|
| 105 | app.setOrganizationDomain("www.bkg.bund.de");
|
---|
| 106 | app.setConfFileName( confFileName );
|
---|
| 107 |
|
---|
[1535] | 108 | bncSettings settings;
|
---|
[1503] | 109 |
|
---|
[180] | 110 | // Interactive Mode - open the main window
|
---|
| 111 | // ---------------------------------------
|
---|
[35] | 112 | if (GUIenabled) {
|
---|
[113] | 113 |
|
---|
[3280] | 114 | app.setMode(bncApp::interactive);
|
---|
| 115 |
|
---|
[113] | 116 | QString fontString = settings.value("font").toString();
|
---|
| 117 | if ( !fontString.isEmpty() ) {
|
---|
| 118 | QFont newFont;
|
---|
| 119 | if (newFont.fromString(fontString)) {
|
---|
| 120 | QApplication::setFont(newFont);
|
---|
| 121 | }
|
---|
| 122 | }
|
---|
[142] | 123 |
|
---|
[173] | 124 | app.setWindowIcon(QPixmap(":ntrip-logo.png"));
|
---|
[113] | 125 |
|
---|
[82] | 126 | bncWindow* bncWin = new bncWindow();
|
---|
[35] | 127 | bncWin->show();
|
---|
| 128 | }
|
---|
[180] | 129 |
|
---|
| 130 | // Non-Interactive (Batch) Mode
|
---|
| 131 | // ----------------------------
|
---|
[35] | 132 | else {
|
---|
[621] | 133 |
|
---|
[1138] | 134 | signal(SIGINT, catch_signal);
|
---|
| 135 |
|
---|
[3251] | 136 | bncEphUploadCaster* casterEph = new bncEphUploadCaster(); (void) casterEph;
|
---|
| 137 |
|
---|
[621] | 138 | bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
|
---|
| 139 | settings.value("outPort").toInt());
|
---|
| 140 |
|
---|
| 141 | app.setCaster(caster);
|
---|
[592] | 142 | app.setPort(settings.value("outEphPort").toInt());
|
---|
[937] | 143 | app.setPortCorr(settings.value("corrPort").toInt());
|
---|
[2909] | 144 | app.initCombination();
|
---|
[592] | 145 |
|
---|
[1556] | 146 | app.connect(caster, SIGNAL(getThreadsFinished()), &app, SLOT(quit()));
|
---|
[295] | 147 |
|
---|
[2012] | 148 | ((bncApp*)qApp)->slotMessage("========== Start BNC v" BNCVERSION " =========", true);
|
---|
[35] | 149 |
|
---|
[1170] | 150 | // Normal case - data from Internet
|
---|
| 151 | // --------------------------------
|
---|
[1552] | 152 | if ( rawFileName.isEmpty() ) {
|
---|
[3280] | 153 | app.setMode(bncApp::nonInteractive);
|
---|
[1179] | 154 | caster->slotReadMountPoints();
|
---|
[1170] | 155 | if (caster->numStations() == 0) {
|
---|
[1552] | 156 | exit(0);
|
---|
[1170] | 157 | }
|
---|
| 158 | }
|
---|
| 159 |
|
---|
| 160 | // Special case - data from file
|
---|
| 161 | // -----------------------------
|
---|
| 162 | else {
|
---|
[3280] | 163 | app.setMode(bncApp::batchPostProcessing);
|
---|
| 164 |
|
---|
[3004] | 165 | if ( format.isEmpty() || staID.isEmpty() ) {
|
---|
[1552] | 166 | cout << printHelp.toAscii().data() << endl;
|
---|
[1146] | 167 | exit(0);
|
---|
| 168 | }
|
---|
| 169 |
|
---|
[3004] | 170 | bncRawFile* rawFile = new bncRawFile(rawFileName, staID, format,
|
---|
[2519] | 171 | bncRawFile::input);
|
---|
[1156] | 172 |
|
---|
[2519] | 173 | bncGetThread* getThread = new bncGetThread(rawFile);
|
---|
[2528] | 174 | caster->addGetThread(getThread, true);
|
---|
[35] | 175 | }
|
---|
[2909] | 176 |
|
---|
[35] | 177 | }
|
---|
[180] | 178 |
|
---|
| 179 | // Start the application
|
---|
| 180 | // ---------------------
|
---|
[35] | 181 | return app.exec();
|
---|
| 182 | }
|
---|