[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"
|
---|
[35] | 50 |
|
---|
| 51 | using namespace std;
|
---|
| 52 |
|
---|
[603] | 53 | void catch_signal(int) {
|
---|
| 54 | cout << "Program Interrupted by Ctrl-C" << endl;
|
---|
[621] | 55 | ((bncApp*)qApp)->slotQuit();
|
---|
[603] | 56 | }
|
---|
| 57 |
|
---|
[82] | 58 | // Main Program
|
---|
| 59 | /////////////////////////////////////////////////////////////////////////////
|
---|
[35] | 60 | int main(int argc, char *argv[]) {
|
---|
| 61 |
|
---|
[1146] | 62 | bool GUIenabled = true;
|
---|
| 63 | bool fileInput = false;
|
---|
[1501] | 64 | bool confFile = false;
|
---|
[1540] | 65 | bool dragAndDrop = true;
|
---|
[1146] | 66 | QByteArray fileName;
|
---|
| 67 | QByteArray format;
|
---|
[1156] | 68 | QString dateString;
|
---|
| 69 | QString timeString;
|
---|
[1501] | 70 | QString confFileName;
|
---|
[1146] | 71 |
|
---|
[100] | 72 | for (int ii = 1; ii < argc; ii++) {
|
---|
[1146] | 73 | if (QByteArray(argv[ii]) == "-nw") {
|
---|
[100] | 74 | GUIenabled = false;
|
---|
| 75 | break;
|
---|
| 76 | }
|
---|
[35] | 77 | }
|
---|
| 78 |
|
---|
[1146] | 79 | for (int ii = 1; ii < argc; ii++) {
|
---|
| 80 | if (QByteArray(argv[ii]) == "-file" || QByteArray(argv[ii]) == "--file") {
|
---|
| 81 | GUIenabled = false;
|
---|
| 82 | fileInput = true;
|
---|
| 83 | if (ii+1 < argc) {
|
---|
| 84 | fileName = QByteArray(argv[ii+1]);
|
---|
| 85 | }
|
---|
| 86 | }
|
---|
| 87 | if (QByteArray(argv[ii]) == "-format" || QByteArray(argv[ii]) == "--format") {
|
---|
| 88 | GUIenabled = false;
|
---|
| 89 | fileInput = true;
|
---|
[1540] | 90 | dragAndDrop = false;
|
---|
[1146] | 91 | if (ii+1 < argc) {
|
---|
| 92 | format = QByteArray(argv[ii+1]);
|
---|
| 93 | }
|
---|
| 94 | }
|
---|
[1156] | 95 | if (QByteArray(argv[ii]) == "-date" || QByteArray(argv[ii]) == "--date") {
|
---|
[1540] | 96 | dragAndDrop = false;
|
---|
[1156] | 97 | if (ii+1 < argc) {
|
---|
| 98 | dateString = QString(argv[ii+1]);
|
---|
| 99 | }
|
---|
| 100 | }
|
---|
| 101 | if (QByteArray(argv[ii]) == "-time" || QByteArray(argv[ii]) == "--time") {
|
---|
[1540] | 102 | dragAndDrop = false;
|
---|
[1156] | 103 | if (ii+1 < argc) {
|
---|
| 104 | timeString = QString(argv[ii+1]);
|
---|
| 105 | }
|
---|
| 106 | }
|
---|
[1501] | 107 | if (QByteArray(argv[ii]) == "-conf" || QByteArray(argv[ii]) == "--conf") {
|
---|
| 108 | confFile = true;
|
---|
[1540] | 109 | dragAndDrop = false;
|
---|
[1501] | 110 | if (ii+1 < argc) {
|
---|
| 111 | confFileName = QString(argv[ii+1]);
|
---|
| 112 | }
|
---|
| 113 | }
|
---|
[1540] | 114 | if (dragAndDrop && ii == 1) {
|
---|
| 115 | confFile = true;
|
---|
| 116 | if (ii < argc) {
|
---|
| 117 | confFileName = QString(argv[ii]);
|
---|
| 118 | }
|
---|
| 119 | }
|
---|
[1146] | 120 | }
|
---|
| 121 |
|
---|
[1503] | 122 | QString printHelp;
|
---|
| 123 | printHelp = "Usage: bnc --conf <confFileName>\n"
|
---|
| 124 | " --file <inputFileName>\n"
|
---|
| 125 | " --format <RTIGS | RTCM_2 | RTCM_3>\n"
|
---|
| 126 | " --date YYYY-MM-DD --time HH:MM:SS";
|
---|
| 127 |
|
---|
[1501] | 128 | if (confFile && confFileName.isEmpty() ) {
|
---|
[1503] | 129 | cout << printHelp.toAscii().data() << endl;
|
---|
[1501] | 130 | exit(0);
|
---|
| 131 | }
|
---|
| 132 |
|
---|
[1536] | 133 | bncApp app(argc, argv, GUIenabled);
|
---|
[1516] | 134 |
|
---|
[1538] | 135 | app.setApplicationName("BNC");
|
---|
| 136 | app.setOrganizationName("BKG");
|
---|
| 137 | app.setOrganizationDomain("www.bkg.bund.de");
|
---|
| 138 | app.setConfFileName( confFileName );
|
---|
| 139 |
|
---|
[1535] | 140 | bncSettings settings;
|
---|
[1503] | 141 |
|
---|
[180] | 142 | // Interactive Mode - open the main window
|
---|
| 143 | // ---------------------------------------
|
---|
[35] | 144 | if (GUIenabled) {
|
---|
[113] | 145 |
|
---|
| 146 | QString fontString = settings.value("font").toString();
|
---|
| 147 | if ( !fontString.isEmpty() ) {
|
---|
| 148 | QFont newFont;
|
---|
| 149 | if (newFont.fromString(fontString)) {
|
---|
| 150 | QApplication::setFont(newFont);
|
---|
| 151 | }
|
---|
| 152 | }
|
---|
[142] | 153 |
|
---|
[173] | 154 | app.setWindowIcon(QPixmap(":ntrip-logo.png"));
|
---|
[113] | 155 |
|
---|
[82] | 156 | bncWindow* bncWin = new bncWindow();
|
---|
[35] | 157 | bncWin->show();
|
---|
| 158 | }
|
---|
[180] | 159 |
|
---|
| 160 | // Non-Interactive (Batch) Mode
|
---|
| 161 | // ----------------------------
|
---|
[35] | 162 | else {
|
---|
[621] | 163 |
|
---|
[1138] | 164 | signal(SIGINT, catch_signal);
|
---|
| 165 |
|
---|
[621] | 166 | bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
|
---|
| 167 | settings.value("outPort").toInt());
|
---|
| 168 |
|
---|
| 169 | app.setCaster(caster);
|
---|
[592] | 170 | app.setPort(settings.value("outEphPort").toInt());
|
---|
[937] | 171 | app.setPortCorr(settings.value("corrPort").toInt());
|
---|
[592] | 172 |
|
---|
[621] | 173 | app.connect(caster, SIGNAL(getThreadErrors()), &app, SLOT(quit()));
|
---|
[295] | 174 |
|
---|
[1299] | 175 | ((bncApp*)qApp)->slotMessage("============ Start BNC ============", true);
|
---|
[35] | 176 |
|
---|
[1170] | 177 | // Normal case - data from Internet
|
---|
| 178 | // --------------------------------
|
---|
| 179 | if (!fileInput) {
|
---|
[1179] | 180 | caster->slotReadMountPoints();
|
---|
[1170] | 181 | if (caster->numStations() == 0) {
|
---|
[1501] | 182 | return 0;
|
---|
[1170] | 183 | }
|
---|
| 184 | }
|
---|
| 185 |
|
---|
| 186 | // Special case - data from file
|
---|
| 187 | // -----------------------------
|
---|
| 188 | else {
|
---|
[1156] | 189 | if ( fileName.isEmpty() || format.isEmpty() ||
|
---|
| 190 | dateString.isEmpty() || timeString.isEmpty() ) {
|
---|
[1503] | 191 | cout << printHelp.toAscii().data() << endl;
|
---|
[1146] | 192 | exit(0);
|
---|
| 193 | }
|
---|
| 194 |
|
---|
[1156] | 195 | app._currentDateAndTimeGPS =
|
---|
[1157] | 196 | new QDateTime(QDate::fromString(dateString, Qt::ISODate),
|
---|
| 197 | QTime::fromString(timeString, Qt::ISODate), Qt::UTC);
|
---|
[1156] | 198 |
|
---|
[1146] | 199 | bncGetThread* getThread = new bncGetThread(fileName, format);
|
---|
[621] | 200 | caster->addGetThread(getThread);
|
---|
[35] | 201 | }
|
---|
| 202 | }
|
---|
[180] | 203 |
|
---|
| 204 | // Start the application
|
---|
| 205 | // ---------------------
|
---|
[35] | 206 | return app.exec();
|
---|
| 207 | }
|
---|