[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 |
|
---|
| 61 | bool GUIenabled = true;
|
---|
[100] | 62 | for (int ii = 1; ii < argc; ii++) {
|
---|
| 63 | if (QString(argv[ii]) == "-nw") {
|
---|
| 64 | GUIenabled = false;
|
---|
| 65 | break;
|
---|
| 66 | }
|
---|
[35] | 67 | }
|
---|
| 68 |
|
---|
[93] | 69 | QCoreApplication::setOrganizationName("BKG");
|
---|
| 70 | QCoreApplication::setOrganizationDomain("www.ifag.de");
|
---|
| 71 | QCoreApplication::setApplicationName("BKG_NTRIP_Client");
|
---|
[35] | 72 |
|
---|
[180] | 73 | // Default Settings
|
---|
| 74 | // ----------------
|
---|
[113] | 75 | QSettings settings;
|
---|
[180] | 76 | if (settings.allKeys().size() == 0) {
|
---|
| 77 | settings.setValue("casterHost", "www.euref-ip.net");
|
---|
| 78 | settings.setValue("casterPort", 80);
|
---|
| 79 | settings.setValue("rnxIntr", "15 min");
|
---|
[565] | 80 | settings.setValue("ephIntr", "1 day");
|
---|
[180] | 81 | settings.setValue("rnxSkel", "SKL");
|
---|
[572] | 82 | settings.setValue("waitTime", 5);
|
---|
[180] | 83 | }
|
---|
[114] | 84 |
|
---|
[533] | 85 | bncApp app(argc, argv, GUIenabled);
|
---|
| 86 |
|
---|
[180] | 87 | // Interactive Mode - open the main window
|
---|
| 88 | // ---------------------------------------
|
---|
[35] | 89 | if (GUIenabled) {
|
---|
[113] | 90 |
|
---|
| 91 | QString fontString = settings.value("font").toString();
|
---|
| 92 | if ( !fontString.isEmpty() ) {
|
---|
| 93 | QFont newFont;
|
---|
| 94 | if (newFont.fromString(fontString)) {
|
---|
| 95 | QApplication::setFont(newFont);
|
---|
| 96 | }
|
---|
| 97 | }
|
---|
[142] | 98 |
|
---|
[173] | 99 | app.setWindowIcon(QPixmap(":ntrip-logo.png"));
|
---|
[113] | 100 |
|
---|
[82] | 101 | bncWindow* bncWin = new bncWindow();
|
---|
[35] | 102 | bncWin->show();
|
---|
| 103 | }
|
---|
[180] | 104 |
|
---|
| 105 | // Non-Interactive (Batch) Mode
|
---|
| 106 | // ----------------------------
|
---|
[35] | 107 | else {
|
---|
[621] | 108 |
|
---|
| 109 | bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
|
---|
| 110 | settings.value("outPort").toInt());
|
---|
| 111 |
|
---|
| 112 | app.setCaster(caster);
|
---|
| 113 |
|
---|
[603] | 114 | // Ctrl-C Signal Handling
|
---|
| 115 | // ----------------------
|
---|
| 116 | signal(SIGINT, catch_signal);
|
---|
[35] | 117 |
|
---|
[621] | 118 | //// beg test
|
---|
[624] | 119 | //// QTimer::singleShot(30000, &app, SLOT(slotQuit()));
|
---|
[621] | 120 | //// end test
|
---|
| 121 |
|
---|
[592] | 122 | app.setPort(settings.value("outEphPort").toInt());
|
---|
| 123 |
|
---|
[621] | 124 | app.connect(caster, SIGNAL(getThreadErrors()), &app, SLOT(quit()));
|
---|
[628] | 125 | app.connect(caster, SIGNAL(newMessage(QByteArray)),
|
---|
| 126 | &app, SLOT(slotMessage(QByteArray)));
|
---|
[295] | 127 |
|
---|
| 128 | ((bncApp*)qApp)->slotMessage("============ Start BNC ============");
|
---|
[35] | 129 |
|
---|
[278] | 130 | int iMount = -1;
|
---|
[35] | 131 | QListIterator<QString> it(settings.value("mountPoints").toStringList());
|
---|
| 132 | while (it.hasNext()) {
|
---|
[278] | 133 | ++iMount;
|
---|
[59] | 134 | QStringList hlp = it.next().split(" ");
|
---|
[82] | 135 | if (hlp.size() <= 1) continue;
|
---|
[59] | 136 | QUrl url(hlp[0]);
|
---|
[88] | 137 | QByteArray format = hlp[1].toAscii();
|
---|
[366] | 138 | QByteArray latitude = hlp[2].toAscii();
|
---|
| 139 | QByteArray longitude = hlp[3].toAscii();
|
---|
| 140 | QByteArray nmea = hlp[4].toAscii();
|
---|
| 141 | bncGetThread* getThread = new bncGetThread(url, format, latitude, longitude, nmea, iMount);
|
---|
[628] | 142 | app.connect(getThread, SIGNAL(newMessage(QByteArray)),
|
---|
| 143 | &app, SLOT(slotMessage(const QByteArray)));
|
---|
[82] | 144 |
|
---|
[621] | 145 | caster->addGetThread(getThread);
|
---|
[35] | 146 |
|
---|
| 147 | getThread->start();
|
---|
| 148 | }
|
---|
[621] | 149 | if (caster->numStations() == 0) {
|
---|
[82] | 150 | return 0;
|
---|
| 151 | }
|
---|
[35] | 152 | }
|
---|
[180] | 153 |
|
---|
| 154 | // Start the application
|
---|
| 155 | // ---------------------
|
---|
[35] | 156 | return app.exec();
|
---|
| 157 | }
|
---|