[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;
|
---|
[1552] | 63 | QByteArray rawFileName;
|
---|
[1146] | 64 | QByteArray format;
|
---|
[1156] | 65 | QString dateString;
|
---|
| 66 | QString timeString;
|
---|
[1501] | 67 | QString confFileName;
|
---|
[1146] | 68 |
|
---|
[100] | 69 | for (int ii = 1; ii < argc; ii++) {
|
---|
[1146] | 70 | if (QByteArray(argv[ii]) == "-nw") {
|
---|
[100] | 71 | GUIenabled = false;
|
---|
| 72 | }
|
---|
[1552] | 73 | if (ii + 1 < argc) {
|
---|
| 74 | if (QByteArray(argv[ii]).indexOf("-conf") != -1) {
|
---|
| 75 | confFileName = QString(argv[ii+1]);
|
---|
[1146] | 76 | }
|
---|
[1552] | 77 | if (QByteArray(argv[ii]).indexOf("-file") != -1) {
|
---|
| 78 | GUIenabled = false;
|
---|
[1553] | 79 | rawFileName = QByteArray(argv[ii+1]);
|
---|
[1552] | 80 | }
|
---|
| 81 | if (QByteArray(argv[ii]).indexOf("-format") != -1) {
|
---|
[1146] | 82 | format = QByteArray(argv[ii+1]);
|
---|
| 83 | }
|
---|
[1552] | 84 | if (QByteArray(argv[ii]).indexOf("-date") != -1) {
|
---|
[1156] | 85 | dateString = QString(argv[ii+1]);
|
---|
| 86 | }
|
---|
[1552] | 87 | if (QByteArray(argv[ii]).indexOf("-time") != -1) {
|
---|
[1156] | 88 | timeString = QString(argv[ii+1]);
|
---|
| 89 | }
|
---|
| 90 | }
|
---|
[1146] | 91 | }
|
---|
| 92 |
|
---|
[1585] | 93 | if (argc == 2 && GUIenabled) {
|
---|
| 94 | confFileName = QString(argv[1]);
|
---|
| 95 | }
|
---|
| 96 |
|
---|
[1552] | 97 | QString printHelp = "Usage: bnc -nw\n"
|
---|
| 98 | " --conf <confFileName>\n"
|
---|
| 99 | " --file <rawFileName>\n"
|
---|
| 100 | " --format <RTIGS | RTCM_2 | RTCM_3>\n"
|
---|
| 101 | " --date YYYY-MM-DD --time HH:MM:SS";
|
---|
[1503] | 102 |
|
---|
[1536] | 103 | bncApp app(argc, argv, GUIenabled);
|
---|
[1516] | 104 |
|
---|
[1538] | 105 | app.setApplicationName("BNC");
|
---|
| 106 | app.setOrganizationName("BKG");
|
---|
| 107 | app.setOrganizationDomain("www.bkg.bund.de");
|
---|
| 108 | app.setConfFileName( confFileName );
|
---|
| 109 |
|
---|
[1535] | 110 | bncSettings settings;
|
---|
[1503] | 111 |
|
---|
[180] | 112 | // Interactive Mode - open the main window
|
---|
| 113 | // ---------------------------------------
|
---|
[35] | 114 | if (GUIenabled) {
|
---|
[113] | 115 |
|
---|
| 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 |
|
---|
[621] | 136 | bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
|
---|
| 137 | settings.value("outPort").toInt());
|
---|
| 138 |
|
---|
| 139 | app.setCaster(caster);
|
---|
[592] | 140 | app.setPort(settings.value("outEphPort").toInt());
|
---|
[937] | 141 | app.setPortCorr(settings.value("corrPort").toInt());
|
---|
[592] | 142 |
|
---|
[1556] | 143 | app.connect(caster, SIGNAL(getThreadsFinished()), &app, SLOT(quit()));
|
---|
[295] | 144 |
|
---|
[1299] | 145 | ((bncApp*)qApp)->slotMessage("============ Start BNC ============", true);
|
---|
[35] | 146 |
|
---|
[1170] | 147 | // Normal case - data from Internet
|
---|
| 148 | // --------------------------------
|
---|
[1552] | 149 | if ( rawFileName.isEmpty() ) {
|
---|
[1179] | 150 | caster->slotReadMountPoints();
|
---|
[1170] | 151 | if (caster->numStations() == 0) {
|
---|
[1552] | 152 | exit(0);
|
---|
[1170] | 153 | }
|
---|
| 154 | }
|
---|
| 155 |
|
---|
| 156 | // Special case - data from file
|
---|
| 157 | // -----------------------------
|
---|
| 158 | else {
|
---|
[1552] | 159 | if ( format.isEmpty() || dateString.isEmpty() || timeString.isEmpty() ) {
|
---|
| 160 | cout << printHelp.toAscii().data() << endl;
|
---|
[1146] | 161 | exit(0);
|
---|
| 162 | }
|
---|
| 163 |
|
---|
[1156] | 164 | app._currentDateAndTimeGPS =
|
---|
[1157] | 165 | new QDateTime(QDate::fromString(dateString, Qt::ISODate),
|
---|
| 166 | QTime::fromString(timeString, Qt::ISODate), Qt::UTC);
|
---|
[1156] | 167 |
|
---|
[1552] | 168 | bncGetThread* getThread = new bncGetThread(rawFileName, format);
|
---|
[621] | 169 | caster->addGetThread(getThread);
|
---|
[35] | 170 | }
|
---|
| 171 | }
|
---|
[180] | 172 |
|
---|
| 173 | // Start the application
|
---|
| 174 | // ---------------------
|
---|
[35] | 175 | return app.exec();
|
---|
| 176 | }
|
---|