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

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

* empty log message *

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