source: ntrip/trunk/BNC/src/bncmain.cpp@ 5899

Last change on this file since 5899 was 5899, checked in by mervart, 8 years ago
File size: 6.3 KB
Line 
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 "app.h"
48#include "bnccore.h"
49#include "bncwindow.h"
50#include "bncsettings.h"
51#include "bncversion.h"
52#include "upload/bncephuploadcaster.h"
53#include "rinex/reqcedit.h"
54#include "rinex/reqcanalyze.h"
55#include "PPP/pppMain.h"
56
57using namespace std;
58
59void catch_signal(int) {
60 cout << "Program Interrupted by Ctrl-C" << endl;
61 exit(0);
62}
63
64// Main Program
65/////////////////////////////////////////////////////////////////////////////
66int main(int argc, char* argv[]) {
67
68 bool interactive = true;
69#ifdef WIN32
70 bool displaySet = true;
71#else
72 bool displaySet = false;
73#endif
74 QByteArray rawFileName;
75 QString confFileName;
76
77 QByteArray printHelp = "Usage: bnc --nw \n"
78 " --display <XXX> \n"
79 " --conf <confFileName> \n"
80 " --file <rawFileName> \n"
81 " --key <keyName> <keyValue>\n";
82
83 for (int ii = 1; ii < argc; ii++) {
84 if (QRegExp("--?help").exactMatch(argv[ii])) {
85 cout << printHelp.data();
86 exit(0);
87 }
88 if (QRegExp("--?nw").exactMatch(argv[ii])) {
89 interactive = false;
90 }
91 if (QRegExp("--?display").exactMatch(argv[ii])) {
92 displaySet = true;
93 strcpy(argv[ii], "-display"); // make it "-display" not "--display"
94 }
95 if (ii + 1 < argc) {
96 if (QRegExp("--?conf").exactMatch(argv[ii])) {
97 confFileName = QString(argv[ii+1]);
98 }
99 if (QRegExp("--?file").exactMatch(argv[ii])) {
100 interactive = false;
101 rawFileName = QByteArray(argv[ii+1]);
102 }
103 }
104 }
105
106#ifdef Q_OS_MAC
107 if (argc== 3 && interactive) {
108 confFileName = QString(argv[2]);
109 }
110#else
111 if (argc == 2 && interactive) {
112 confFileName = QString(argv[1]);
113 }
114#endif
115
116 bool GUIenabled = interactive || displaySet;
117 t_app app(argc, argv, GUIenabled);
118
119 app.setApplicationName("BNC");
120 app.setOrganizationName("BKG");
121 app.setOrganizationDomain("www.bkg.bund.de");
122
123 BNC_CORE->setGUIenabled(GUIenabled);
124 BNC_CORE->setConfFileName( confFileName );
125
126 bncSettings settings;
127
128 for (int ii = 1; ii < argc - 2; ii++) {
129 if (QRegExp("--?key").exactMatch(argv[ii])) {
130 QString key(argv[ii+1]);
131 QString val(argv[ii+2]);
132 settings.setValue(key, val);
133 }
134 }
135
136 // Interactive Mode - open the main window
137 // ---------------------------------------
138 if (interactive) {
139
140 BNC_CORE->setMode(t_bncCore::interactive);
141
142 QString fontString = settings.value("font").toString();
143 if ( !fontString.isEmpty() ) {
144 QFont newFont;
145 if (newFont.fromString(fontString)) {
146 QApplication::setFont(newFont);
147 }
148 }
149
150 app.setWindowIcon(QPixmap(":ntrip-logo.png"));
151
152 bncWindow* bncWin = new bncWindow();
153 BNC_CORE->setMainWindow(bncWin);
154 bncWin->show();
155 }
156
157 // Post-Processing reqc edit
158 // -------------------------
159 else if (settings.value("reqcAction").toString() == "Edit/Concatenate") {
160 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
161 t_reqcEdit* reqcEdit = new t_reqcEdit(0);
162 reqcEdit->start();
163 }
164
165 // Post-Processing reqc analyze
166 // ----------------------------
167 else if (settings.value("reqcAction").toString() == "Analyze") {
168 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
169 t_reqcAnalyze* reqcAnalyze = new t_reqcAnalyze(0);
170 reqcAnalyze->start();
171 }
172
173 // Non-Interactive (data gathering)
174 // --------------------------------
175 else {
176
177 signal(SIGINT, catch_signal);
178
179 bncEphUploadCaster* casterEph = new bncEphUploadCaster(); (void) casterEph;
180
181 bncCaster* caster = new bncCaster();
182
183 BNC_CORE->setCaster(caster);
184 BNC_CORE->setPort(settings.value("outEphPort").toInt());
185 BNC_CORE->setPortCorr(settings.value("corrPort").toInt());
186 BNC_CORE->initCombination();
187
188 BNC_CORE->connect(caster, SIGNAL(getThreadsFinished()), &app, SLOT(quit()));
189
190 BNC_CORE->slotMessage("========== Start BNC v" BNCVERSION " =========", true);
191
192 // PPP Client(s) (in separate threads)
193 // -----------------------------------
194 BNC_CORE->pppMain()->start();
195
196 // Normal case - data from Internet
197 // --------------------------------
198 if ( rawFileName.isEmpty() ) {
199 BNC_CORE->setMode(t_bncCore::nonInteractive);
200 caster->readMountPoints();
201 if (caster->numStations() == 0) {
202 exit(0);
203 }
204 }
205
206 // Special case - data from file
207 // -----------------------------
208 else {
209 BNC_CORE->setMode(t_bncCore::batchPostProcessing);
210 bncRawFile* rawFile = new bncRawFile(rawFileName, "",
211 bncRawFile::input);
212 bncGetThread* getThread = new bncGetThread(rawFile);
213 caster->addGetThread(getThread, true);
214 }
215 }
216
217 // Start the application
218 // ---------------------
219 return app.exec();
220}
Note: See TracBrowser for help on using the repository browser.