1 | // Part of BNC, a utility for retrieving decoding and
|
---|
2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
3 | //
|
---|
4 | // Copyright (C) 2007
|
---|
5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
6 | // http://www.bkg.bund.de
|
---|
7 | // Czech Technical University Prague, Department of Geodesy
|
---|
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.
|
---|
24 |
|
---|
25 | /* -------------------------------------------------------------------------
|
---|
26 | * BKG NTRIP Client
|
---|
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 |
|
---|
41 | #include <unistd.h>
|
---|
42 | #include <signal.h>
|
---|
43 | #include <QApplication>
|
---|
44 | #include <QFile>
|
---|
45 | #include <iostream>
|
---|
46 |
|
---|
47 | #include "bncapp.h"
|
---|
48 | #include "bncwindow.h"
|
---|
49 |
|
---|
50 | using namespace std;
|
---|
51 |
|
---|
52 | void catch_signal(int) {
|
---|
53 | cout << "Program Interrupted by Ctrl-C" << endl;
|
---|
54 | ((bncApp*)qApp)->slotQuit();
|
---|
55 | }
|
---|
56 |
|
---|
57 | // Main Program
|
---|
58 | /////////////////////////////////////////////////////////////////////////////
|
---|
59 | int main(int argc, char *argv[]) {
|
---|
60 |
|
---|
61 | bool GUIenabled = true;
|
---|
62 | for (int ii = 1; ii < argc; ii++) {
|
---|
63 | if (QString(argv[ii]) == "-nw") {
|
---|
64 | GUIenabled = false;
|
---|
65 | break;
|
---|
66 | }
|
---|
67 | }
|
---|
68 |
|
---|
69 | QCoreApplication::setOrganizationName("BKG");
|
---|
70 | QCoreApplication::setOrganizationDomain("www.bkg.bund.de");
|
---|
71 | QCoreApplication::setApplicationName("BKG_NTRIP_Client");
|
---|
72 |
|
---|
73 | // Default Settings
|
---|
74 | // ----------------
|
---|
75 | QSettings settings;
|
---|
76 | if (settings.allKeys().size() == 0) {
|
---|
77 | settings.setValue("casterHost", "www.euref-ip.net");
|
---|
78 | settings.setValue("casterPort", 2101);
|
---|
79 | settings.setValue("rnxIntr", "15 min");
|
---|
80 | settings.setValue("ephIntr", "1 day");
|
---|
81 | settings.setValue("corrIntr", "1 day");
|
---|
82 | settings.setValue("rnxSkel", "SKL");
|
---|
83 | settings.setValue("waitTime", "5");
|
---|
84 | settings.setValue("makePause", 0);
|
---|
85 | settings.setValue("obsRate", "");
|
---|
86 | settings.setValue("adviseFail", "15");
|
---|
87 | settings.setValue("adviseReco", "5");
|
---|
88 | settings.setValue("perfIntr", "");
|
---|
89 | settings.setValue("corrTime", "5");
|
---|
90 | settings.setValue("messTypes", "");
|
---|
91 | settings.setValue("corrLate", 0);
|
---|
92 | }
|
---|
93 |
|
---|
94 | bncApp app(argc, argv, GUIenabled);
|
---|
95 |
|
---|
96 | // Interactive Mode - open the main window
|
---|
97 | // ---------------------------------------
|
---|
98 | if (GUIenabled) {
|
---|
99 |
|
---|
100 | QString fontString = settings.value("font").toString();
|
---|
101 | if ( !fontString.isEmpty() ) {
|
---|
102 | QFont newFont;
|
---|
103 | if (newFont.fromString(fontString)) {
|
---|
104 | QApplication::setFont(newFont);
|
---|
105 | }
|
---|
106 | }
|
---|
107 |
|
---|
108 | app.setWindowIcon(QPixmap(":ntrip-logo.png"));
|
---|
109 |
|
---|
110 | bncWindow* bncWin = new bncWindow();
|
---|
111 | bncWin->show();
|
---|
112 | }
|
---|
113 |
|
---|
114 | // Non-Interactive (Batch) Mode
|
---|
115 | // ----------------------------
|
---|
116 | else {
|
---|
117 |
|
---|
118 | bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
|
---|
119 | settings.value("outPort").toInt());
|
---|
120 |
|
---|
121 | app.setCaster(caster);
|
---|
122 |
|
---|
123 | // Ctrl-C Signal Handling
|
---|
124 | // ----------------------
|
---|
125 | signal(SIGINT, catch_signal);
|
---|
126 |
|
---|
127 | //// beg test
|
---|
128 | //// QTimer::singleShot(30000, &app, SLOT(slotQuit()));
|
---|
129 | //// end test
|
---|
130 |
|
---|
131 | app.setPort(settings.value("outEphPort").toInt());
|
---|
132 | app.setPortCorr(settings.value("corrPort").toInt());
|
---|
133 |
|
---|
134 | app.connect(caster, SIGNAL(getThreadErrors()), &app, SLOT(quit()));
|
---|
135 | app.connect(caster, SIGNAL(newMessage(QByteArray)),
|
---|
136 | &app, SLOT(slotMessage(QByteArray)));
|
---|
137 |
|
---|
138 | ((bncApp*)qApp)->slotMessage("============ Start BNC ============");
|
---|
139 |
|
---|
140 | int iMount = -1;
|
---|
141 | QListIterator<QString> it(settings.value("mountPoints").toStringList());
|
---|
142 | while (it.hasNext()) {
|
---|
143 | ++iMount;
|
---|
144 | QStringList hlp = it.next().split(" ");
|
---|
145 | if (hlp.size() <= 1) continue;
|
---|
146 | QUrl url(hlp[0]);
|
---|
147 | QByteArray format = hlp[1].toAscii();
|
---|
148 | QByteArray latitude = hlp[2].toAscii();
|
---|
149 | QByteArray longitude = hlp[3].toAscii();
|
---|
150 | QByteArray nmea = hlp[4].toAscii();
|
---|
151 | bncGetThread* getThread = new bncGetThread(url, format, latitude, longitude, nmea, iMount);
|
---|
152 | app.connect(getThread, SIGNAL(newMessage(QByteArray)),
|
---|
153 | &app, SLOT(slotMessage(const QByteArray)));
|
---|
154 |
|
---|
155 | caster->addGetThread(getThread);
|
---|
156 |
|
---|
157 | getThread->start();
|
---|
158 | }
|
---|
159 | if (caster->numStations() == 0) {
|
---|
160 | return 0;
|
---|
161 | }
|
---|
162 | }
|
---|
163 |
|
---|
164 | // Start the application
|
---|
165 | // ---------------------
|
---|
166 | return app.exec();
|
---|
167 | }
|
---|