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