source: ntrip/trunk/BNC/bncmain.cpp@ 4156

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