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

Last change on this file since 1538 was 1538, checked in by mervart, 15 years ago

* empty log message *

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