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

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

* empty log message *

File size: 5.0 KB
RevLine 
[280]1// Part of BNC, a utility for retrieving decoding and
[464]2// converting GNSS data streams from NTRIP broadcasters.
[280]3//
[464]4// Copyright (C) 2007
[280]5// German Federal Agency for Cartography and Geodesy (BKG)
6// http://www.bkg.bund.de
[464]7// Czech Technical University Prague, Department of Geodesy
[280]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.
[35]24
25/* -------------------------------------------------------------------------
[93]26 * BKG NTRIP Client
[35]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
[274]41#include <unistd.h>
[603]42#include <signal.h>
[35]43#include <QApplication>
44#include <QFile>
45#include <iostream>
46
[82]47#include "bncapp.h"
[35]48#include "bncwindow.h"
[1535]49#include "bncsettings.h"
[35]50
51using namespace std;
52
[603]53void catch_signal(int) {
54 cout << "Program Interrupted by Ctrl-C" << endl;
[621]55 ((bncApp*)qApp)->slotQuit();
[603]56}
57
[82]58// Main Program
59/////////////////////////////////////////////////////////////////////////////
[35]60int main(int argc, char *argv[]) {
61
[1146]62 bool GUIenabled = true;
[1552]63 QByteArray rawFileName;
[1146]64 QByteArray format;
[1156]65 QString dateString;
66 QString timeString;
[1501]67 QString confFileName;
[1146]68
[100]69 for (int ii = 1; ii < argc; ii++) {
[1146]70 if (QByteArray(argv[ii]) == "-nw") {
[100]71 GUIenabled = false;
72 }
[1552]73 if (ii + 1 < argc) {
74 if (QByteArray(argv[ii]).indexOf("-conf") != -1) {
75 confFileName = QString(argv[ii+1]);
[1146]76 }
[1552]77 if (QByteArray(argv[ii]).indexOf("-file") != -1) {
78 GUIenabled = false;
[1553]79 rawFileName = QByteArray(argv[ii+1]);
[1552]80 }
81 if (QByteArray(argv[ii]).indexOf("-format") != -1) {
[1146]82 format = QByteArray(argv[ii+1]);
83 }
[1552]84 if (QByteArray(argv[ii]).indexOf("-date") != -1) {
[1156]85 dateString = QString(argv[ii+1]);
86 }
[1552]87 if (QByteArray(argv[ii]).indexOf("-time") != -1) {
[1156]88 timeString = QString(argv[ii+1]);
89 }
90 }
[1146]91 }
92
[1552]93 QString printHelp = "Usage: bnc -nw\n"
94 " --conf <confFileName>\n"
95 " --file <rawFileName>\n"
96 " --format <RTIGS | RTCM_2 | RTCM_3>\n"
97 " --date YYYY-MM-DD --time HH:MM:SS";
[1503]98
[1536]99 bncApp app(argc, argv, GUIenabled);
[1516]100
[1538]101 app.setApplicationName("BNC");
102 app.setOrganizationName("BKG");
103 app.setOrganizationDomain("www.bkg.bund.de");
104 app.setConfFileName( confFileName );
105
[1535]106 bncSettings settings;
[1503]107
[180]108 // Interactive Mode - open the main window
109 // ---------------------------------------
[35]110 if (GUIenabled) {
[113]111
112 QString fontString = settings.value("font").toString();
113 if ( !fontString.isEmpty() ) {
114 QFont newFont;
115 if (newFont.fromString(fontString)) {
116 QApplication::setFont(newFont);
117 }
118 }
[142]119
[173]120 app.setWindowIcon(QPixmap(":ntrip-logo.png"));
[113]121
[82]122 bncWindow* bncWin = new bncWindow();
[35]123 bncWin->show();
124 }
[180]125
126 // Non-Interactive (Batch) Mode
127 // ----------------------------
[35]128 else {
[621]129
[1138]130 signal(SIGINT, catch_signal);
131
[621]132 bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
133 settings.value("outPort").toInt());
134
135 app.setCaster(caster);
[592]136 app.setPort(settings.value("outEphPort").toInt());
[937]137 app.setPortCorr(settings.value("corrPort").toInt());
[592]138
[621]139 app.connect(caster, SIGNAL(getThreadErrors()), &app, SLOT(quit()));
[295]140
[1299]141 ((bncApp*)qApp)->slotMessage("============ Start BNC ============", true);
[35]142
[1170]143 // Normal case - data from Internet
144 // --------------------------------
[1552]145 if ( rawFileName.isEmpty() ) {
[1179]146 caster->slotReadMountPoints();
[1170]147 if (caster->numStations() == 0) {
[1552]148 exit(0);
[1170]149 }
150 }
151
152 // Special case - data from file
153 // -----------------------------
154 else {
[1552]155 if ( format.isEmpty() || dateString.isEmpty() || timeString.isEmpty() ) {
156 cout << printHelp.toAscii().data() << endl;
[1146]157 exit(0);
158 }
159
[1156]160 app._currentDateAndTimeGPS =
[1157]161 new QDateTime(QDate::fromString(dateString, Qt::ISODate),
162 QTime::fromString(timeString, Qt::ISODate), Qt::UTC);
[1156]163
[1552]164 bncGetThread* getThread = new bncGetThread(rawFileName, format);
[621]165 caster->addGetThread(getThread);
[35]166 }
167 }
[180]168
169 // Start the application
170 // ---------------------
[35]171 return app.exec();
172}
Note: See TracBrowser for help on using the repository browser.