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

Last change on this file since 1551 was 1548, checked in by weber, 15 years ago

* empty log message *

File size: 5.8 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
51using namespace std;
52
53void catch_signal(int) {
54 cout << "Program Interrupted by Ctrl-C" << endl;
55 ((bncApp*)qApp)->slotQuit();
56}
57
58// Main Program
59/////////////////////////////////////////////////////////////////////////////
60int main(int argc, char *argv[]) {
61
62 bool GUIenabled = true;
63 bool fileInput = false;
64 bool confFile = false;
65 bool dragAndDrop = true;
66 QByteArray fileName;
67 QByteArray format;
68 QString dateString;
69 QString timeString;
70 QString confFileName;
71
72 for (int ii = 1; ii < argc; ii++) {
73 if (QByteArray(argv[ii]) == "-nw") {
74 GUIenabled = false;
75 dragAndDrop = false;
76 break;
77 }
78 }
79
80 for (int ii = 1; ii < argc; ii++) {
81 if (QByteArray(argv[ii]) == "-file" || QByteArray(argv[ii]) == "--file") {
82 GUIenabled = false;
83 fileInput = true;
84 dragAndDrop = false;
85 if (ii+1 < argc) {
86 fileName = QByteArray(argv[ii+1]);
87 }
88 }
89 if (QByteArray(argv[ii]) == "-format" || QByteArray(argv[ii]) == "--format") {
90 GUIenabled = false;
91 fileInput = true;
92 dragAndDrop = false;
93 if (ii+1 < argc) {
94 format = QByteArray(argv[ii+1]);
95 }
96 }
97 if (QByteArray(argv[ii]) == "-date" || QByteArray(argv[ii]) == "--date") {
98 dragAndDrop = false;
99 if (ii+1 < argc) {
100 dateString = QString(argv[ii+1]);
101 }
102 }
103 if (QByteArray(argv[ii]) == "-time" || QByteArray(argv[ii]) == "--time") {
104 dragAndDrop = false;
105 if (ii+1 < argc) {
106 timeString = QString(argv[ii+1]);
107 }
108 }
109 if (QByteArray(argv[ii]) == "-conf" || QByteArray(argv[ii]) == "--conf") {
110 confFile = true;
111 dragAndDrop = false;
112 if (ii+1 < argc) {
113 confFileName = QString(argv[ii+1]);
114 }
115 }
116 if (dragAndDrop && ii == 1) {
117 confFile = true;
118 if (ii < argc) {
119 confFileName = QString(argv[ii]);
120 }
121 }
122 }
123
124 QString printHelp;
125 printHelp = "Usage: bnc -nw\n"
126 " --conf <confFileName>\n"
127 " --file <inputFileName>\n"
128 " --format <RTIGS | RTCM_2 | RTCM_3>\n"
129 " --date YYYY-MM-DD --time HH:MM:SS";
130
131 if (confFile && confFileName.isEmpty() ) {
132 cout << printHelp.toAscii().data() << endl;
133 exit(0);
134 }
135
136 bncApp app(argc, argv, GUIenabled);
137
138 app.setApplicationName("BNC");
139 app.setOrganizationName("BKG");
140 app.setOrganizationDomain("www.bkg.bund.de");
141 app.setConfFileName( confFileName );
142
143 bncSettings settings;
144
145 // Interactive Mode - open the main window
146 // ---------------------------------------
147 if (GUIenabled) {
148
149 QString fontString = settings.value("font").toString();
150 if ( !fontString.isEmpty() ) {
151 QFont newFont;
152 if (newFont.fromString(fontString)) {
153 QApplication::setFont(newFont);
154 }
155 }
156
157 app.setWindowIcon(QPixmap(":ntrip-logo.png"));
158
159 bncWindow* bncWin = new bncWindow();
160 bncWin->show();
161 }
162
163 // Non-Interactive (Batch) Mode
164 // ----------------------------
165 else {
166
167 signal(SIGINT, catch_signal);
168
169 bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
170 settings.value("outPort").toInt());
171
172 app.setCaster(caster);
173 app.setPort(settings.value("outEphPort").toInt());
174 app.setPortCorr(settings.value("corrPort").toInt());
175
176 app.connect(caster, SIGNAL(getThreadErrors()), &app, SLOT(quit()));
177
178 ((bncApp*)qApp)->slotMessage("============ Start BNC ============", true);
179
180 // Normal case - data from Internet
181 // --------------------------------
182 if (!fileInput) {
183 caster->slotReadMountPoints();
184 if (caster->numStations() == 0) {
185 return 0;
186 }
187 }
188
189 // Special case - data from file
190 // -----------------------------
191 else {
192 if ( fileName.isEmpty() || format.isEmpty() ||
193 dateString.isEmpty() || timeString.isEmpty() ) {
194 cout << printHelp.toAscii().data() << endl;
195 exit(0);
196 }
197
198 app._currentDateAndTimeGPS =
199 new QDateTime(QDate::fromString(dateString, Qt::ISODate),
200 QTime::fromString(timeString, Qt::ISODate), Qt::UTC);
201
202 bncGetThread* getThread = new bncGetThread(fileName, format);
203 caster->addGetThread(getThread);
204 }
205 }
206
207 // Start the application
208 // ---------------------
209 return app.exec();
210}
Note: See TracBrowser for help on using the repository browser.