[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"
|
---|
| 49 |
|
---|
| 50 | using namespace std;
|
---|
| 51 |
|
---|
[603] | 52 | void catch_signal(int) {
|
---|
| 53 | cout << "Program Interrupted by Ctrl-C" << endl;
|
---|
[621] | 54 | ((bncApp*)qApp)->slotQuit();
|
---|
[603] | 55 | }
|
---|
| 56 |
|
---|
[82] | 57 | // Main Program
|
---|
| 58 | /////////////////////////////////////////////////////////////////////////////
|
---|
[35] | 59 | int main(int argc, char *argv[]) {
|
---|
| 60 |
|
---|
[1146] | 61 | bool GUIenabled = true;
|
---|
| 62 | bool fileInput = false;
|
---|
| 63 | QByteArray fileName;
|
---|
| 64 | QByteArray format;
|
---|
| 65 |
|
---|
[100] | 66 | for (int ii = 1; ii < argc; ii++) {
|
---|
[1146] | 67 | if (QByteArray(argv[ii]) == "-nw") {
|
---|
[100] | 68 | GUIenabled = false;
|
---|
| 69 | break;
|
---|
| 70 | }
|
---|
[35] | 71 | }
|
---|
| 72 |
|
---|
[1146] | 73 | for (int ii = 1; ii < argc; ii++) {
|
---|
| 74 | if (QByteArray(argv[ii]) == "-file" || QByteArray(argv[ii]) == "--file") {
|
---|
| 75 | GUIenabled = false;
|
---|
| 76 | fileInput = true;
|
---|
| 77 | if (ii+1 < argc) {
|
---|
| 78 | fileName = QByteArray(argv[ii+1]);
|
---|
| 79 | }
|
---|
| 80 | }
|
---|
| 81 | if (QByteArray(argv[ii]) == "-format" || QByteArray(argv[ii]) == "--format") {
|
---|
| 82 | GUIenabled = false;
|
---|
| 83 | fileInput = true;
|
---|
| 84 | if (ii+1 < argc) {
|
---|
| 85 | format = QByteArray(argv[ii+1]);
|
---|
| 86 | }
|
---|
| 87 | }
|
---|
| 88 | }
|
---|
| 89 |
|
---|
[93] | 90 | QCoreApplication::setOrganizationName("BKG");
|
---|
[684] | 91 | QCoreApplication::setOrganizationDomain("www.bkg.bund.de");
|
---|
[93] | 92 | QCoreApplication::setApplicationName("BKG_NTRIP_Client");
|
---|
[35] | 93 |
|
---|
[180] | 94 | // Default Settings
|
---|
| 95 | // ----------------
|
---|
[113] | 96 | QSettings settings;
|
---|
[180] | 97 | if (settings.allKeys().size() == 0) {
|
---|
| 98 | settings.setValue("casterHost", "www.euref-ip.net");
|
---|
[684] | 99 | settings.setValue("casterPort", 2101);
|
---|
[180] | 100 | settings.setValue("rnxIntr", "15 min");
|
---|
[565] | 101 | settings.setValue("ephIntr", "1 day");
|
---|
[951] | 102 | settings.setValue("corrIntr", "1 day");
|
---|
[180] | 103 | settings.setValue("rnxSkel", "SKL");
|
---|
[1035] | 104 | settings.setValue("waitTime", "5");
|
---|
[722] | 105 | settings.setValue("makePause", 0);
|
---|
[686] | 106 | settings.setValue("obsRate", "");
|
---|
[668] | 107 | settings.setValue("adviseFail", "15");
|
---|
| 108 | settings.setValue("adviseReco", "5");
|
---|
[728] | 109 | settings.setValue("perfIntr", "");
|
---|
[1035] | 110 | settings.setValue("corrTime", "5");
|
---|
| 111 | settings.setValue("messTypes", "");
|
---|
[180] | 112 | }
|
---|
[114] | 113 |
|
---|
[533] | 114 | bncApp app(argc, argv, GUIenabled);
|
---|
| 115 |
|
---|
[180] | 116 | // Interactive Mode - open the main window
|
---|
| 117 | // ---------------------------------------
|
---|
[35] | 118 | if (GUIenabled) {
|
---|
[113] | 119 |
|
---|
| 120 | QString fontString = settings.value("font").toString();
|
---|
| 121 | if ( !fontString.isEmpty() ) {
|
---|
| 122 | QFont newFont;
|
---|
| 123 | if (newFont.fromString(fontString)) {
|
---|
| 124 | QApplication::setFont(newFont);
|
---|
| 125 | }
|
---|
| 126 | }
|
---|
[142] | 127 |
|
---|
[173] | 128 | app.setWindowIcon(QPixmap(":ntrip-logo.png"));
|
---|
[113] | 129 |
|
---|
[82] | 130 | bncWindow* bncWin = new bncWindow();
|
---|
[35] | 131 | bncWin->show();
|
---|
| 132 | }
|
---|
[180] | 133 |
|
---|
| 134 | // Non-Interactive (Batch) Mode
|
---|
| 135 | // ----------------------------
|
---|
[35] | 136 | else {
|
---|
[621] | 137 |
|
---|
[1138] | 138 | signal(SIGINT, catch_signal);
|
---|
| 139 |
|
---|
[621] | 140 | bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
|
---|
| 141 | settings.value("outPort").toInt());
|
---|
| 142 |
|
---|
| 143 | app.setCaster(caster);
|
---|
[592] | 144 | app.setPort(settings.value("outEphPort").toInt());
|
---|
[937] | 145 | app.setPortCorr(settings.value("corrPort").toInt());
|
---|
[592] | 146 |
|
---|
[621] | 147 | app.connect(caster, SIGNAL(getThreadErrors()), &app, SLOT(quit()));
|
---|
[628] | 148 | app.connect(caster, SIGNAL(newMessage(QByteArray)),
|
---|
| 149 | &app, SLOT(slotMessage(QByteArray)));
|
---|
[295] | 150 |
|
---|
| 151 | ((bncApp*)qApp)->slotMessage("============ Start BNC ============");
|
---|
[35] | 152 |
|
---|
[1146] | 153 | if (fileInput) {
|
---|
| 154 | if (fileName.isEmpty() || format.isEmpty()) {
|
---|
| 155 | cout << "Usage: bnc --file <fileName> --format <RTIGS | RTCM_2 | RTCM_3>" << endl;
|
---|
| 156 | exit(0);
|
---|
| 157 | }
|
---|
| 158 |
|
---|
| 159 | bncGetThread* getThread = new bncGetThread(fileName, format);
|
---|
[628] | 160 | app.connect(getThread, SIGNAL(newMessage(QByteArray)),
|
---|
| 161 | &app, SLOT(slotMessage(const QByteArray)));
|
---|
[1138] | 162 |
|
---|
[621] | 163 | caster->addGetThread(getThread);
|
---|
[1138] | 164 |
|
---|
[35] | 165 | getThread->start();
|
---|
| 166 | }
|
---|
[1138] | 167 | else {
|
---|
| 168 | int iMount = -1;
|
---|
| 169 | QListIterator<QString> it(settings.value("mountPoints").toStringList());
|
---|
| 170 | while (it.hasNext()) {
|
---|
| 171 | ++iMount;
|
---|
| 172 | QStringList hlp = it.next().split(" ");
|
---|
| 173 | if (hlp.size() <= 1) continue;
|
---|
| 174 | QUrl url(hlp[0]);
|
---|
| 175 | QByteArray format = hlp[1].toAscii();
|
---|
| 176 | QByteArray latitude = hlp[2].toAscii();
|
---|
| 177 | QByteArray longitude = hlp[3].toAscii();
|
---|
| 178 | QByteArray nmea = hlp[4].toAscii();
|
---|
| 179 |
|
---|
| 180 | bncGetThread* getThread = new bncGetThread(url, format, latitude, longitude, nmea, iMount);
|
---|
| 181 |
|
---|
| 182 | app.connect(getThread, SIGNAL(newMessage(QByteArray)),
|
---|
| 183 | &app, SLOT(slotMessage(const QByteArray)));
|
---|
| 184 |
|
---|
| 185 | caster->addGetThread(getThread);
|
---|
| 186 |
|
---|
| 187 | getThread->start();
|
---|
| 188 | }
|
---|
| 189 | if (caster->numStations() == 0) {
|
---|
| 190 | return 0;
|
---|
| 191 | }
|
---|
[82] | 192 | }
|
---|
[35] | 193 | }
|
---|
[180] | 194 |
|
---|
| 195 | // Start the application
|
---|
| 196 | // ---------------------
|
---|
[35] | 197 | return app.exec();
|
---|
| 198 | }
|
---|