[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;
|
---|
[1501] | 63 | bool confFile = false;
|
---|
[1146] | 64 | QByteArray fileName;
|
---|
| 65 | QByteArray format;
|
---|
[1156] | 66 | QString dateString;
|
---|
| 67 | QString timeString;
|
---|
[1501] | 68 | QString confFileName;
|
---|
| 69 | QString confFileIs;
|
---|
[1146] | 70 |
|
---|
[100] | 71 | for (int ii = 1; ii < argc; ii++) {
|
---|
[1146] | 72 | if (QByteArray(argv[ii]) == "-nw") {
|
---|
[100] | 73 | GUIenabled = false;
|
---|
| 74 | break;
|
---|
| 75 | }
|
---|
[35] | 76 | }
|
---|
| 77 |
|
---|
[1146] | 78 | for (int ii = 1; ii < argc; ii++) {
|
---|
| 79 | if (QByteArray(argv[ii]) == "-file" || QByteArray(argv[ii]) == "--file") {
|
---|
| 80 | GUIenabled = false;
|
---|
| 81 | fileInput = true;
|
---|
| 82 | if (ii+1 < argc) {
|
---|
| 83 | fileName = QByteArray(argv[ii+1]);
|
---|
| 84 | }
|
---|
| 85 | }
|
---|
| 86 | if (QByteArray(argv[ii]) == "-format" || QByteArray(argv[ii]) == "--format") {
|
---|
| 87 | GUIenabled = false;
|
---|
| 88 | fileInput = true;
|
---|
| 89 | if (ii+1 < argc) {
|
---|
| 90 | format = QByteArray(argv[ii+1]);
|
---|
| 91 | }
|
---|
| 92 | }
|
---|
[1156] | 93 | if (QByteArray(argv[ii]) == "-date" || QByteArray(argv[ii]) == "--date") {
|
---|
| 94 | if (ii+1 < argc) {
|
---|
| 95 | dateString = QString(argv[ii+1]);
|
---|
| 96 | }
|
---|
| 97 | }
|
---|
| 98 | if (QByteArray(argv[ii]) == "-time" || QByteArray(argv[ii]) == "--time") {
|
---|
| 99 | if (ii+1 < argc) {
|
---|
| 100 | timeString = QString(argv[ii+1]);
|
---|
| 101 | }
|
---|
| 102 | }
|
---|
[1501] | 103 | if (QByteArray(argv[ii]) == "-conf" || QByteArray(argv[ii]) == "--conf") {
|
---|
| 104 | confFile = true;
|
---|
| 105 | if (ii+1 < argc) {
|
---|
| 106 | confFileName = QString(argv[ii+1]);
|
---|
| 107 | }
|
---|
| 108 | }
|
---|
[1146] | 109 | }
|
---|
| 110 |
|
---|
[1501] | 111 | if (confFile && confFileName.isEmpty() ) {
|
---|
| 112 | cout << "Usage: bnc --conf <confFileName>\n"
|
---|
| 113 | " --file <inputFileName>\n"
|
---|
| 114 | " --format <RTIGS | RTCM_2 | RTCM_3>\n"
|
---|
| 115 | " --date YYYY-MM-DD --time HH:MM:SS" << endl;
|
---|
| 116 | exit(0);
|
---|
| 117 | }
|
---|
| 118 |
|
---|
[93] | 119 | QCoreApplication::setOrganizationName("BKG");
|
---|
[684] | 120 | QCoreApplication::setOrganizationDomain("www.bkg.bund.de");
|
---|
[1501] | 121 | if (!confFileName.isEmpty()) {
|
---|
| 122 | confFileIs = confFileName;
|
---|
| 123 | } else {
|
---|
| 124 | confFileIs = "BKG_NTRIP_Client";
|
---|
| 125 | }
|
---|
| 126 | QCoreApplication::setApplicationName(confFileIs);
|
---|
[35] | 127 |
|
---|
[180] | 128 | // Default Settings
|
---|
| 129 | // ----------------
|
---|
[113] | 130 | QSettings settings;
|
---|
[180] | 131 | if (settings.allKeys().size() == 0) {
|
---|
| 132 | settings.setValue("casterHost", "www.euref-ip.net");
|
---|
[1273] | 133 | settings.setValue("casterHostList", QStringList());
|
---|
[684] | 134 | settings.setValue("casterPort", 2101);
|
---|
[180] | 135 | settings.setValue("rnxIntr", "15 min");
|
---|
[565] | 136 | settings.setValue("ephIntr", "1 day");
|
---|
[951] | 137 | settings.setValue("corrIntr", "1 day");
|
---|
[180] | 138 | settings.setValue("rnxSkel", "SKL");
|
---|
[1035] | 139 | settings.setValue("waitTime", "5");
|
---|
[722] | 140 | settings.setValue("makePause", 0);
|
---|
[686] | 141 | settings.setValue("obsRate", "");
|
---|
[668] | 142 | settings.setValue("adviseFail", "15");
|
---|
| 143 | settings.setValue("adviseReco", "5");
|
---|
[728] | 144 | settings.setValue("perfIntr", "");
|
---|
[1035] | 145 | settings.setValue("corrTime", "5");
|
---|
[1307] | 146 | settings.setValue("miscMount", "");
|
---|
[180] | 147 | }
|
---|
[114] | 148 |
|
---|
[1282] | 149 | // Truncate list of casters
|
---|
| 150 | // ------------------------
|
---|
| 151 | int maxListSize = 5;
|
---|
| 152 | QStringList casterHostList = settings.value("casterHostList").toStringList();
|
---|
| 153 | if ( casterHostList.count() > maxListSize ) {
|
---|
| 154 | QStringList listCopy;
|
---|
| 155 | for (int ii = 0; ii < maxListSize; ii++) {
|
---|
| 156 | listCopy.push_back(casterHostList[ii]);
|
---|
| 157 | }
|
---|
| 158 | settings.setValue("casterHostList", listCopy);
|
---|
| 159 | }
|
---|
| 160 |
|
---|
| 161 |
|
---|
[533] | 162 | bncApp app(argc, argv, GUIenabled);
|
---|
| 163 |
|
---|
[1166] | 164 | int waitCoTime = settings.value("corrTime").toInt();
|
---|
| 165 | if (waitCoTime < 1) {
|
---|
| 166 | waitCoTime = 1;
|
---|
| 167 | }
|
---|
| 168 | app.setWaitCoTime(waitCoTime);
|
---|
| 169 |
|
---|
[180] | 170 | // Interactive Mode - open the main window
|
---|
| 171 | // ---------------------------------------
|
---|
[35] | 172 | if (GUIenabled) {
|
---|
[113] | 173 |
|
---|
| 174 | QString fontString = settings.value("font").toString();
|
---|
| 175 | if ( !fontString.isEmpty() ) {
|
---|
| 176 | QFont newFont;
|
---|
| 177 | if (newFont.fromString(fontString)) {
|
---|
| 178 | QApplication::setFont(newFont);
|
---|
| 179 | }
|
---|
| 180 | }
|
---|
[142] | 181 |
|
---|
[173] | 182 | app.setWindowIcon(QPixmap(":ntrip-logo.png"));
|
---|
[113] | 183 |
|
---|
[82] | 184 | bncWindow* bncWin = new bncWindow();
|
---|
[35] | 185 | bncWin->show();
|
---|
| 186 | }
|
---|
[180] | 187 |
|
---|
| 188 | // Non-Interactive (Batch) Mode
|
---|
| 189 | // ----------------------------
|
---|
[35] | 190 | else {
|
---|
[621] | 191 |
|
---|
[1138] | 192 | signal(SIGINT, catch_signal);
|
---|
| 193 |
|
---|
[621] | 194 | bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
|
---|
| 195 | settings.value("outPort").toInt());
|
---|
| 196 |
|
---|
| 197 | app.setCaster(caster);
|
---|
[592] | 198 | app.setPort(settings.value("outEphPort").toInt());
|
---|
[937] | 199 | app.setPortCorr(settings.value("corrPort").toInt());
|
---|
[592] | 200 |
|
---|
[621] | 201 | app.connect(caster, SIGNAL(getThreadErrors()), &app, SLOT(quit()));
|
---|
[295] | 202 |
|
---|
[1299] | 203 | ((bncApp*)qApp)->slotMessage("============ Start BNC ============", true);
|
---|
[35] | 204 |
|
---|
[1170] | 205 | // Normal case - data from Internet
|
---|
| 206 | // --------------------------------
|
---|
| 207 | if (!fileInput) {
|
---|
[1179] | 208 | caster->slotReadMountPoints();
|
---|
[1170] | 209 | if (caster->numStations() == 0) {
|
---|
[1501] | 210 | return 0;
|
---|
[1170] | 211 | }
|
---|
| 212 | }
|
---|
| 213 |
|
---|
| 214 | // Special case - data from file
|
---|
| 215 | // -----------------------------
|
---|
| 216 | else {
|
---|
[1156] | 217 | if ( fileName.isEmpty() || format.isEmpty() ||
|
---|
| 218 | dateString.isEmpty() || timeString.isEmpty() ) {
|
---|
[1501] | 219 | cout << "Usage: bnc --conf <confFileName>\n"
|
---|
| 220 | " --file <inputFileName>\n"
|
---|
[1156] | 221 | " --format <RTIGS | RTCM_2 | RTCM_3>\n"
|
---|
| 222 | " --date YYYY-MM-DD --time HH:MM:SS" << endl;
|
---|
[1146] | 223 | exit(0);
|
---|
| 224 | }
|
---|
| 225 |
|
---|
[1156] | 226 | app._currentDateAndTimeGPS =
|
---|
[1157] | 227 | new QDateTime(QDate::fromString(dateString, Qt::ISODate),
|
---|
| 228 | QTime::fromString(timeString, Qt::ISODate), Qt::UTC);
|
---|
[1156] | 229 |
|
---|
[1146] | 230 | bncGetThread* getThread = new bncGetThread(fileName, format);
|
---|
[621] | 231 | caster->addGetThread(getThread);
|
---|
[35] | 232 | }
|
---|
| 233 | }
|
---|
[180] | 234 |
|
---|
| 235 | // Start the application
|
---|
| 236 | // ---------------------
|
---|
[35] | 237 | return app.exec();
|
---|
| 238 | }
|
---|