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

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

* empty log message *

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