source: ntrip/trunk/BNS/bnswindow.cpp@ 1668

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

* empty log message *

File size: 38.7 KB
Line 
1
2/* -------------------------------------------------------------------------
3 * BKG NTRIP Server
4 * -------------------------------------------------------------------------
5 *
6 * Class: bnsWindow
7 *
8 * Purpose: This class implements the main application window.
9 *
10 * Author: L. Mervart
11 *
12 * Created: 29-Mar-2008
13 *
14 * Changes:
15 *
16 * -----------------------------------------------------------------------*/
17
18#include <iostream>
19
20#include "bnswindow.h"
21#include "bnshlpdlg.h"
22#include "bnssettings.h"
23
24using namespace std;
25
26// About Dialog - Constructor
27////////////////////////////////////////////////////////////////////////////
28bnsAboutDlg::bnsAboutDlg(QWidget* parent) :
29 QDialog(parent) {
30
31 QTextBrowser* tb = new QTextBrowser;
32 QUrl url; url.setPath(":bnsabout.html");
33 tb->setSource(url);
34 tb->setReadOnly(true);
35
36 int ww = QFontMetrics(font()).width('w');
37 QPushButton* _closeButton = new QPushButton("Close");
38 _closeButton->setMaximumWidth(10*ww);
39 connect(_closeButton, SIGNAL(clicked()), this, SLOT(close()));
40
41 QGridLayout* dlgLayout = new QGridLayout();
42 QLabel* img = new QLabel();
43 img->setPixmap(QPixmap(":ntrip-logo.png"));
44 dlgLayout->addWidget(img, 0,0);
45 dlgLayout->addWidget(new QLabel("BKG Ntrip State Space Server (BNS) Version 1.1"), 0,1);
46 dlgLayout->addWidget(tb,1,0,1,2);
47 dlgLayout->addWidget(_closeButton,2,1,Qt::AlignRight);
48
49 setLayout(dlgLayout);
50 resize(60*ww, 60*ww);
51 show();
52}
53
54// About Dialog - Destructor
55////////////////////////////////////////////////////////////////////////////
56bnsAboutDlg::~bnsAboutDlg() {
57};
58
59// Flowchart Dialog - Constructor
60////////////////////////////////////////////////////////////////////////////
61bnsFlowchartDlg::bnsFlowchartDlg(QWidget* parent) :
62 QDialog(parent) {
63
64 int ww = QFontMetrics(font()).width('w');
65 QPushButton* _closeButton = new QPushButton("Close");
66 _closeButton->setMaximumWidth(10*ww);
67 connect(_closeButton, SIGNAL(clicked()), this, SLOT(close()));
68
69 QGridLayout* dlgLayout = new QGridLayout();
70 QLabel* img = new QLabel();
71 img->setPixmap(QPixmap(":bnsflowchart.png"));
72 dlgLayout->addWidget(img, 0,0);
73 dlgLayout->addWidget(_closeButton,1,0,Qt::AlignLeft);
74
75 setLayout(dlgLayout);
76 show();
77}
78
79// Flowchart Dialog - Destructor
80////////////////////////////////////////////////////////////////////////////
81bnsFlowchartDlg::~bnsFlowchartDlg() {
82};
83
84// Constructor
85////////////////////////////////////////////////////////////////////////////
86bnsWindow::bnsWindow() {
87
88 _bns = 0;
89
90 bnsSettings settings;
91
92 QString fontString = settings.value("font").toString();
93 if ( !fontString.isEmpty() ) {
94 QFont newFont;
95 if (newFont.fromString(fontString)) {
96 QApplication::setFont(newFont);
97 }
98 }
99
100 int ww = QFontMetrics(this->font()).width('w');
101 setMinimumSize(77*ww, 65*ww);
102 setWindowTitle(tr("BKG Ntrip State Space Server (BNS) Version 1.1"));
103 setWindowIcon(QPixmap(":ntrip-logo.png"));
104
105 // Create Actions
106 // --------------
107 _actHelp = new QAction(tr("&Help Contents"),this);
108 connect(_actHelp, SIGNAL(triggered()), SLOT(slotHelp()));
109
110 _actAbout = new QAction(tr("&About BNS"),this);
111 connect(_actAbout, SIGNAL(triggered()), SLOT(slotAbout()));
112
113 _actFlowchart = new QAction(tr("&Flow Chart"),this);
114 connect(_actFlowchart, SIGNAL(triggered()), SLOT(slotFlowchart()));
115
116 _actFontSel = new QAction(tr("Select &Font"),this);
117 connect(_actFontSel, SIGNAL(triggered()), SLOT(slotFontSel()));
118
119 _actSaveOpt = new QAction(tr("&Save Options"),this);
120 connect(_actSaveOpt, SIGNAL(triggered()), SLOT(slotSaveOptions()));
121
122 _actQuit = new QAction(tr("&Quit"),this);
123 connect(_actQuit, SIGNAL(triggered()), SLOT(close()));
124
125 _actWhatsThis= new QAction(tr("Help=Shift+F1"),this);
126 connect(_actWhatsThis, SIGNAL(triggered()), SLOT(slotWhatsThis()));
127
128 _actStart = new QAction(tr("Sta&rt"),this);
129 connect(_actStart, SIGNAL(triggered()), SLOT(slotStart()));
130
131 _actStop = new QAction(tr("Sto&p"),this);
132 connect(_actStop, SIGNAL(triggered()), SLOT(slotStop()));
133 _actStop->setEnabled(false);
134
135 CreateMenu();
136 AddToolbar();
137
138 // Canvas with Editable Fields
139 // ---------------------------
140 _canvas = new QWidget;
141 setCentralWidget(_canvas);
142
143 // Proxy Options
144 // -------------
145 _proxyHostLineEdit = new QLineEdit(settings.value("proxyHost").toString());
146 _proxyPortLineEdit = new QLineEdit(settings.value("proxyPort").toString());
147
148 // General Options
149 // ---------------
150 _logFileLineEdit = new QLineEdit(settings.value("logFile").toString());
151 _fileAppendCheckBox = new QCheckBox();
152 _fileAppendCheckBox->setCheckState(Qt::CheckState(settings.value("fileAppend").toInt()));
153 _autoStartCheckBox = new QCheckBox();
154 _autoStartCheckBox->setCheckState(Qt::CheckState(
155 settings.value("autoStart").toInt()));
156
157 // RINEX Ephemeris Options
158 // -----------------------
159 _ephHostLineEdit = new QLineEdit(settings.value("ephHost").toString());
160 _ephPortLineEdit = new QLineEdit(settings.value("ephPort").toString());
161 _ephEchoLineEdit = new QLineEdit(settings.value("ephEcho").toString());
162
163 // Clocks & Orbits Options
164 // -----------------------
165 _clkPortLineEdit = new QLineEdit(settings.value("clkPort").toString());
166 _inpEchoLineEdit = new QLineEdit(settings.value("inpEcho").toString());
167
168
169 // Ephemeris Corrections I Options
170 // -------------------------------
171 _outHost_1_LineEdit = new QLineEdit(settings.value("outHost1").toString());
172 _outPort_1_LineEdit = new QLineEdit(settings.value("outPort1").toString());
173 _password_1_LineEdit = new QLineEdit(settings.value("password1").toString());
174 _password_1_LineEdit->setEchoMode(QLineEdit::Password);
175 _mountpoint_1_LineEdit = new QLineEdit(settings.value("mountpoint_1").toString());
176 _refSys_1_ComboBox = new QComboBox;
177 _refSys_1_ComboBox->setEditable(false);
178 _refSys_1_ComboBox->addItems(QString("IGS05,ETRF2000").split(","));
179 int ii = _refSys_1_ComboBox->findText(settings.value("refSys_1").toString());
180 if (ii != -1) {
181 _refSys_1_ComboBox->setCurrentIndex(ii);
182 }
183 _outFile_1_LineEdit = new QLineEdit(settings.value("outFile_1").toString());
184
185 // Ephemeris Corrections II Options
186 // --------------------------------
187 _outHost_2_LineEdit = new QLineEdit(settings.value("outHost2").toString());
188 _outPort_2_LineEdit = new QLineEdit(settings.value("outPort2").toString());
189 _password_2_LineEdit = new QLineEdit(settings.value("password2").toString());
190 _password_2_LineEdit->setEchoMode(QLineEdit::Password);
191 _mountpoint_2_LineEdit = new QLineEdit(settings.value("mountpoint_2").toString());
192 _refSys_2_ComboBox = new QComboBox;
193 _refSys_2_ComboBox->setEditable(false);
194 _refSys_2_ComboBox->addItems(QString("IGS05,ETRF2000").split(","));
195 ii = _refSys_2_ComboBox->findText(settings.value("refSys_2").toString());
196 if (ii != -1) {
197 _refSys_2_ComboBox->setCurrentIndex(ii);
198 }
199 _outFile_2_LineEdit = new QLineEdit(settings.value("outFile_2").toString());
200
201 // RINEX Clocks Options
202 // --------------------
203 _rnxPathLineEdit = new QLineEdit(settings.value("rnxPath").toString());
204 _rnxIntrComboBox = new QComboBox;
205 _rnxIntrComboBox->setEditable(false);
206 _rnxIntrComboBox->addItems(QString("1 min,2 min,5 min,10 min,15 min,30 min,1 hour,1 day").split(","));
207 ii = _rnxIntrComboBox->findText(settings.value("rnxIntr").toString());
208 if (ii != -1) {
209 _rnxIntrComboBox->setCurrentIndex(ii);
210 }
211 _rnxSamplSpinBox = new QSpinBox;
212 _rnxSamplSpinBox->setMinimum(0);
213 _rnxSamplSpinBox->setMaximum(60);
214 _rnxSamplSpinBox->setSingleStep(5);
215 _rnxSamplSpinBox->setMaximumWidth(9*ww);
216 _rnxSamplSpinBox->setValue(settings.value("rnxSampl").toInt());
217 _rnxSamplSpinBox->setSuffix(" sec");
218
219 // SP3 Orbits Options
220 // ------------------
221 _sp3PathLineEdit = new QLineEdit(settings.value("sp3Path").toString());
222 _sp3IntrComboBox = new QComboBox;
223 _sp3IntrComboBox->setEditable(false);
224 _sp3IntrComboBox->addItems(QString("1 min,2 min,5 min,10 min,15 min,30 min,1 hour,1 day").split(","));
225 ii = _sp3IntrComboBox->findText(settings.value("sp3Intr").toString());
226 if (ii != -1) {
227 _sp3IntrComboBox->setCurrentIndex(ii);
228 }
229 _sp3SamplSpinBox = new QSpinBox;
230 _sp3SamplSpinBox->setMinimum(0);
231 _sp3SamplSpinBox->setMaximum(900);
232 _sp3SamplSpinBox->setSingleStep(60);
233 _sp3SamplSpinBox->setMaximumWidth(9*ww);
234 _sp3SamplSpinBox->setValue(settings.value("sp3Sampl").toInt());
235 _sp3SamplSpinBox->setSuffix(" sec");
236
237 // Whats This
238 // ----------
239 _proxyHostLineEdit->setWhatsThis(tr("<p>If you are running BNS within a protected Local Area Network (LAN), you might need to use a proxy server to access the Internet. Enter your proxy server IP and port number in case one is operated in front of BNS. If you do not know the IP and port of your proxy server, check the proxy server settings in your Internet browser or ask your network administrator.</p><p>Note that IP streaming is sometimes not allowed in a LAN. In this case you need to ask your network administrator for an appropriate modification of the local security policy or for the installation of a TCP relay to the NTRIP broadcasters. If these are not possible, you might need to run BNS outside your LAN on a network that has unobstructed connection to the Internet.</p>"));
240 _proxyPortLineEdit->setWhatsThis(tr("<p>Enter your proxy server port number in case one is operated in front of BNS.</p>"));
241 _logFileLineEdit->setWhatsThis(tr("<p>Records of BNS activities are shown in the Log section on the bottom of this window. They can be saved into a file when a valid path is specified in the 'Logfile (full path)' field.</p>"));
242 _fileAppendCheckBox->setWhatsThis(tr("<p>When BNS is started, new files are created by default and any existing files with the same name will be overwritten. However, users might want to append already existing files following a restart of BNS, a system crash or when BNS crashed. Tick 'Append files' to continue with existing files and keep what has been recorded so far.</p>"));
243 _inpEchoLineEdit->setWhatsThis(tr("Specify the full path to a file where incoming clocks and orbits are saved. Beware that the size of this file can rapidly increase. Default is an empty option field meaning that incoming clocks and orbits are not saved."));
244 _ephHostLineEdit->setWhatsThis(tr("BNS reads Broadcast Ephemeris in RINEX Version 3 Navigation file format from an IP address. Specify the host IP e.g. of a BNC installation providing this information."));
245 _ephPortLineEdit->setWhatsThis(tr("BNS reads Broadcast Ephemeris in RINEX Version 3 Navigation file format from an IP address. Specify the IP port e.g. of a BNC installation providing this information."));
246 _ephEchoLineEdit->setWhatsThis(tr("Specify the full path to a file where incoming Broadcast Ephemeris are saved. Beware that the size of this file can rapidly increase. Default is an empty option field meaning that incoming Broadcast Ephemeris are not saved."));
247 _clkPortLineEdit->setWhatsThis(tr("BNS reads Clocks & Orbits referring to the IGS system (X,Y,Z, ECEF) in SP3 format from an IP port. Specify a local IP port e.g. for an RTNet installation to provide this information."));
248 _outHost_1_LineEdit->setWhatsThis(tr("BNS can stream clock and orbit corrections to Broadcast Ephemeris in RTCM Version 3 format. Specify the host IP of an NTRIP Broadcaster to upload the stream. An empty option field means that you don't want to upload corrections."));
249 _outPort_1_LineEdit->setWhatsThis(tr("Specify the IP port of an NTRIP Broadcaster to upload the stream. Default is port 80."));
250 _password_1_LineEdit->setWhatsThis(tr("Specify the stream upload password protecting the mounpoint on an NTRIP Broadcaster."));
251 _mountpoint_1_LineEdit->setWhatsThis(tr("Specify the mounpoint for stream upload to an NTRIP Broadcaster."));
252 _refSys_1_ComboBox->setWhatsThis(tr("Select the target reference system for outgoing clock and orbit corrections."));
253 _outHost_2_LineEdit->setWhatsThis(tr("BNS can stream clock and orbit corrections to Broadcast Ephemeris in RTCM Version 3 format. Specify the host IP of an NTRIP Broadcaster to upload the stream. An empty option field means that you don't want to upload corrections."));
254 _outPort_2_LineEdit->setWhatsThis(tr("Specify the IP port of an NTRIP Broadcaster to upload the stream. Default is port 80."));
255 _password_2_LineEdit->setWhatsThis(tr("Specify the stream upload password protecting the mounpoint on an NTRIP Broadcaster."));
256 _mountpoint_2_LineEdit->setWhatsThis(tr("Specify the mounpoint for stream upload to an NTRIP Broadcaster."));
257 _refSys_2_ComboBox->setWhatsThis(tr("Select the target reference system for outgoing clock and orbit corrections."));
258 _outFile_1_LineEdit->setWhatsThis(tr("Specify the full path to a file where outgoing clock and orbit corrections to Broadcast Ephemeris are saved. Beware that the size of this file can rapidly increase. Default is an empty option field meaning that outgoing corrections are not saved."));
259 _outFile_2_LineEdit->setWhatsThis(tr("Specify the full path to a file where outgoing clock and orbit corrections to Broadcast Ephemeris are saved. Beware that the size of this file can rapidly increase. Default is an empty option field meaning that outgoing corrections are not saved."));
260 _rnxPathLineEdit->setWhatsThis(tr("Specify the path for saving the generated clock corrections as Clock RINEX files. If the specified directory does not exist, BNS will not create Clock RINEX files."));
261 _rnxIntrComboBox->setWhatsThis(tr("Select the length of the Clock RINEX file."));
262 _rnxSamplSpinBox->setWhatsThis(tr("Select the Clock RINEX file sampling interval in seconds. A value of zero '0' tells BNS to store all available samples into Clock RINEX files."));
263 _sp3PathLineEdit->setWhatsThis(tr("Specify the path for saving the generated orbit corrections as SP3 orbit files. If the specified directory does not exist, BNS will not create SP3 orbit files."));
264 _sp3IntrComboBox->setWhatsThis(tr("Select the length of the SP3 orbit file."));
265 _sp3SamplSpinBox->setWhatsThis(tr("Select the SP3 orbit file sampling interval in seconds. A value of zero '0' tells BNS to store all available samples into SP3 orbit files."));
266 _autoStartCheckBox->setWhatsThis(tr("<p>Tick 'Auto start' for auto-start of BNS at startup time in window mode with preassigned processing options.</p>"));
267
268
269 // TabWidget
270 // ---------
271 tabs = new QTabWidget();
272
273 // Proxy Tab
274 // ---------
275 QWidget* tab_prx = new QWidget();
276 tabs->setMaximumHeight(20*ww);
277 tabs->addTab(tab_prx, "Proxy");
278
279 QGridLayout* layout_prx = new QGridLayout;
280
281 layout_prx->setColumnMinimumWidth(0,9*ww);
282 _proxyPortLineEdit->setMaximumWidth(9*ww);
283
284 layout_prx->addWidget(new QLabel("Host"), 0, 0);
285 layout_prx->addWidget(_proxyHostLineEdit, 0, 1, 1, 10);
286 layout_prx->addWidget(new QLabel("Port"), 1, 0);
287 layout_prx->addWidget(_proxyPortLineEdit, 1, 1);
288 layout_prx->addWidget(new QLabel("Settings for the proxy in protected networks, leave boxes blank if none."),2, 0, 1, 50, Qt::AlignLeft);
289 layout_prx->addWidget(new QLabel(" "), 3, 0);
290
291 tab_prx->setLayout(layout_prx);
292
293 connect(_proxyHostLineEdit, SIGNAL(textChanged(const QString &)),
294 this, SLOT(bnsText(const QString &)));
295 if (_proxyHostLineEdit->text().isEmpty()) {
296 _proxyPortLineEdit->setStyleSheet("background-color: lightGray");
297 _proxyPortLineEdit->setEnabled(false);
298 }
299
300 // General Tab
301 // -----------
302 QWidget* tab_gen = new QWidget();
303 tabs->addTab(tab_gen, "General");
304
305 QGridLayout* layout_gen = new QGridLayout;
306
307 layout_gen->setColumnMinimumWidth(0,9*ww);
308 _logFileLineEdit->setMaximumWidth(40*ww);
309
310 layout_gen->addWidget(new QLabel("Logfile (full path) "), 0, 0);
311 layout_gen->addWidget(_logFileLineEdit, 0, 1);
312 layout_gen->addWidget(new QLabel("Append files"), 1, 0);
313 layout_gen->addWidget(_fileAppendCheckBox, 1, 1);
314 layout_gen->addWidget(new QLabel("Auto start"), 2, 0);
315 layout_gen->addWidget(_autoStartCheckBox, 2, 1);
316 layout_gen->addWidget(new QLabel("General settings for logfile and file handling."), 3, 0, 1, 50, Qt::AlignLeft);
317
318 tab_gen->setLayout(layout_gen);
319
320 // RINEX Ephemeris Tab
321 // -------------------
322 QWidget* tab_eph = new QWidget();
323 tabs->addTab(tab_eph, "RINEX Ephemeris");
324
325 QGridLayout* layout_eph = new QGridLayout;
326
327 layout_eph->setColumnMinimumWidth(0, 9*ww);
328 _ephPortLineEdit->setMaximumWidth(9*ww);
329
330 layout_eph->addWidget(new QLabel("Host"), 0, 0);
331 layout_eph->addWidget(_ephHostLineEdit, 0, 1, 1, 10);
332 layout_eph->addWidget(new QLabel("Port"), 1, 0);
333 layout_eph->addWidget(_ephPortLineEdit, 1, 1);
334 layout_eph->addWidget(new QLabel("Save (full path)"), 2, 0);
335 layout_eph->addWidget(_ephEchoLineEdit, 2, 1, 1, 26);
336 layout_eph->addWidget(new QLabel("Read broadcast ephemeris in RINEX Version 3 Navigation format."), 3, 0, 1, 50, Qt::AlignLeft);
337
338 tab_eph->setLayout(layout_eph);
339
340 // Clocks & Orbits Tab
341 // -------------------
342 QWidget* tab_co = new QWidget();
343 tabs->addTab(tab_co,"Clocks && Orbits");
344
345 QGridLayout* layout_co = new QGridLayout;
346
347 layout_co->setColumnMinimumWidth(0, 9*ww);
348 _clkPortLineEdit->setMaximumWidth(9*ww);
349
350 layout_co->addWidget(new QLabel("Listening port"), 0, 0);
351 layout_co->addWidget(_clkPortLineEdit, 0, 1);
352 layout_co->addWidget(new QLabel("Save (full path) "), 1, 0);
353 layout_co->addWidget(_inpEchoLineEdit, 1, 1);
354 layout_co->addWidget(new QLabel("Read clocks and orbits in SP3 format."), 2, 0, 1, 50, Qt::AlignLeft);
355 layout_co->addWidget(new QLabel(""), 3, 0);
356
357 tab_co->setLayout(layout_co);
358
359 // Ephemeris Corrections I Tab
360 // ---------------------------
361 QWidget* tab_cas1 = new QWidget();
362 tabs->addTab(tab_cas1, "Ephemeris Corrections I");
363
364 QGridLayout* layout_cas1 = new QGridLayout;
365
366 layout_cas1->setColumnMinimumWidth(0, 9*ww);
367 _outPort_1_LineEdit->setMaximumWidth(9*ww);
368 _password_1_LineEdit->setMaximumWidth(9*ww);
369 _mountpoint_1_LineEdit->setMaximumWidth(12*ww);
370 _refSys_1_ComboBox->setMaximumWidth(12*ww);
371
372 layout_cas1->addWidget(new QLabel("Host"), 0, 0);
373 layout_cas1->addWidget(_outHost_1_LineEdit, 0, 1, 1, 3);
374 layout_cas1->addWidget(new QLabel(" Port"), 0, 4, Qt::AlignRight);
375 layout_cas1->addWidget(_outPort_1_LineEdit, 0, 5);
376 layout_cas1->addWidget(new QLabel("Mountpoint"), 1, 0);
377 layout_cas1->addWidget(_mountpoint_1_LineEdit, 1, 1);
378 layout_cas1->addWidget(new QLabel("Password"), 1, 2, Qt::AlignRight);
379 layout_cas1->addWidget(_password_1_LineEdit, 1, 3);
380 layout_cas1->addWidget(new QLabel(" "), 1, 4);
381 layout_cas1->addWidget(new QLabel(" "), 1, 5);
382 layout_cas1->addWidget(new QLabel("System"), 2, 0);
383 layout_cas1->addWidget(_refSys_1_ComboBox, 2, 1);
384 layout_cas1->addWidget(new QLabel(" Save (full path)"), 2, 2, Qt::AlignRight);
385 layout_cas1->addWidget(_outFile_1_LineEdit, 2, 3, 1, 30);
386 layout_cas1->addWidget(new QLabel("Produce broadcast ephemeris corrections, upload to caster, reference system, local storage."), 3, 0, 1, 50);
387
388 tab_cas1->setLayout(layout_cas1);
389
390 connect(_outHost_1_LineEdit, SIGNAL(textChanged(const QString &)),
391 this, SLOT(bnsText(const QString &)));
392 if (_outHost_1_LineEdit->text().isEmpty()) {
393 _outPort_1_LineEdit->setStyleSheet("background-color: lightGray");
394 _mountpoint_1_LineEdit->setStyleSheet("background-color: lightGray");
395 _password_1_LineEdit->setStyleSheet("background-color: lightGray");
396 _outFile_1_LineEdit->setStyleSheet("background-color: lightGray");
397 _refSys_1_ComboBox->setStyleSheet("background-color: lightGray");
398 _outPort_1_LineEdit->setEnabled(false);
399 _mountpoint_1_LineEdit->setEnabled(false);
400 _password_1_LineEdit->setEnabled(false);
401 _outFile_1_LineEdit->setEnabled(false);
402 _refSys_1_ComboBox->setEnabled(false);
403 }
404
405 // Ephemeris Corrections II Tab
406 // ----------------------------
407 QWidget* tab_cas2 = new QWidget();
408 tabs->addTab(tab_cas2, "Ephemeris Corrections II");
409
410 QGridLayout* layout_cas2 = new QGridLayout;
411
412 layout_cas2->setColumnMinimumWidth(0, 9*ww);
413 _outPort_2_LineEdit->setMaximumWidth(9*ww);
414 _password_2_LineEdit->setMaximumWidth(9*ww);
415 _mountpoint_2_LineEdit->setMaximumWidth(12*ww);
416 _refSys_2_ComboBox->setMaximumWidth(12*ww);
417
418 layout_cas2->addWidget(new QLabel("Host"), 0, 0);
419 layout_cas2->addWidget(_outHost_2_LineEdit, 0, 1, 1, 3);
420 layout_cas2->addWidget(new QLabel(" Port"), 0, 4, Qt::AlignRight);
421 layout_cas2->addWidget(_outPort_2_LineEdit, 0, 5);
422 layout_cas2->addWidget(new QLabel("Mountpoint"), 1, 0);
423 layout_cas2->addWidget(_mountpoint_2_LineEdit, 1, 1);
424 layout_cas2->addWidget(new QLabel("Password"), 1, 2, Qt::AlignRight);
425 layout_cas2->addWidget(_password_2_LineEdit, 1, 3);
426 layout_cas2->addWidget(new QLabel(" "), 1, 4);
427 layout_cas2->addWidget(new QLabel(" "), 1, 5);
428 layout_cas2->addWidget(new QLabel("System"), 2, 0);
429 layout_cas2->addWidget(_refSys_2_ComboBox, 2, 1);
430 layout_cas2->addWidget(new QLabel(" Save (full path)"), 2, 2, Qt::AlignRight);
431 layout_cas2->addWidget(_outFile_2_LineEdit, 2, 3, 1, 30);
432 layout_cas2->addWidget(new QLabel("Produce broadcast ephemeris corrections, upload to caster, reference system, local storage."), 3, 0, 1, 50);
433
434 tab_cas2->setLayout(layout_cas2);
435
436 connect(_outHost_2_LineEdit, SIGNAL(textChanged(const QString &)),
437 this, SLOT(bnsText(const QString &)));
438 if (_outHost_2_LineEdit->text().isEmpty()) {
439 _outPort_2_LineEdit->setStyleSheet("background-color: lightGray");
440 _mountpoint_2_LineEdit->setStyleSheet("background-color: lightGray");
441 _password_2_LineEdit->setStyleSheet("background-color: lightGray");
442 _outFile_2_LineEdit->setStyleSheet("background-color: lightGray");
443 _refSys_2_ComboBox->setStyleSheet("background-color: lightGray");
444 _outPort_2_LineEdit->setEnabled(false);
445 _mountpoint_2_LineEdit->setEnabled(false);
446 _password_2_LineEdit->setEnabled(false);
447 _outFile_2_LineEdit->setEnabled(false);
448 _refSys_2_ComboBox->setEnabled(false);
449 }
450
451 // RINEX Clocks Tab
452 // ----------------
453 QWidget* tab_rin = new QWidget();
454 tabs->addTab(tab_rin, "RINEX Clocks ");
455
456 QGridLayout* layout_rin = new QGridLayout;
457
458 layout_rin->setColumnMinimumWidth(0, 9*ww);
459 _rnxIntrComboBox->setMaximumWidth(9*ww);
460
461 layout_rin->addWidget(new QLabel("Directory"), 0, 0);
462 layout_rin->addWidget(_rnxPathLineEdit, 0, 1, 1, 27);
463 layout_rin->addWidget(new QLabel("Interval"), 1, 0);
464 layout_rin->addWidget(_rnxIntrComboBox, 1, 1);
465 layout_rin->addWidget(new QLabel("Sampling"), 2, 0);
466 layout_rin->addWidget(_rnxSamplSpinBox, 2, 1);
467 layout_rin->addWidget(new QLabel("Save clock corrections in Clock RINEX file format."), 3, 0, 1, 50, Qt::AlignLeft);
468 layout_rin->addWidget(new QLabel(" "), 3, 0);
469
470 tab_rin->setLayout(layout_rin);
471
472 connect(_rnxPathLineEdit, SIGNAL(textChanged(const QString &)),
473 this, SLOT(bnsText(const QString &)));
474 if (_rnxPathLineEdit->text().isEmpty()) {
475 _rnxIntrComboBox->setStyleSheet("background-color: lightGray");
476 _rnxSamplSpinBox->setStyleSheet("background-color: lightGray");
477 _rnxIntrComboBox->setEnabled(false);
478 _rnxSamplSpinBox->setEnabled(false);
479 }
480
481 // SP3 Orbits Tab
482 // --------------
483 QWidget* tab_sp3 = new QWidget();
484 tabs->addTab(tab_sp3, "SP3 Orbits");
485
486 QGridLayout* layout_sp3 = new QGridLayout;
487
488 layout_sp3->setColumnMinimumWidth(0, 9*ww);
489 _sp3IntrComboBox->setMaximumWidth(9*ww);
490
491 layout_sp3->addWidget(new QLabel("Directory"), 0, 0);
492 layout_sp3->addWidget(_sp3PathLineEdit, 0, 1, 1, 27);
493 layout_sp3->addWidget(new QLabel("Interval"), 1, 0);
494 layout_sp3->addWidget(_sp3IntrComboBox, 1, 1);
495 layout_sp3->addWidget(new QLabel("Sampling"), 2, 0);
496 layout_sp3->addWidget(_sp3SamplSpinBox, 2, 1);
497 layout_sp3->addWidget(new QLabel("Save orbit corrections in SP3 file format."), 3, 0, 1, 50, Qt::AlignLeft);
498 layout_sp3->addWidget(new QLabel(" "), 3, 0);
499
500 tab_sp3->setLayout(layout_sp3);
501
502 connect(_sp3PathLineEdit, SIGNAL(textChanged(const QString &)),
503 this, SLOT(bnsText(const QString &)));
504 if (_sp3PathLineEdit->text().isEmpty()) {
505 _sp3IntrComboBox->setStyleSheet("background-color: lightGray");
506 _sp3SamplSpinBox->setStyleSheet("background-color: lightGray");
507 _sp3IntrComboBox->setEnabled(false);
508 _sp3SamplSpinBox->setEnabled(false);
509 }
510
511 tabs->setCurrentIndex(settings.value("startTab").toInt());
512
513 // Log
514 // ---
515 _log = new QTextBrowser();
516 _log->setReadOnly(true);
517 _log->setWhatsThis(tr("Records of BNS's activities are shown in the Log section."));
518
519 // Status
520 // ------
521 _status = new QGroupBox(tr("Status"));
522 QGridLayout* layout_status = new QGridLayout;
523
524 _statusLbl[0] = new QLabel("0 byte(s)"); _statusCnt[0] = 0;
525 _statusLbl[1] = new QLabel("0 byte(s)"); _statusCnt[1] = 0;
526 _statusLbl[2] = new QLabel("0 byte(s)"); _statusCnt[2] = 0;
527 _statusLbl[7] = new QLabel("RINEX Ephemeris:");
528 _statusLbl[4] = new QLabel("Clocks & Orbits:");
529 _statusLbl[5] = new QLabel("Ephemeris Corrections I:");
530 _statusLbl[6] = new QLabel("Ephemeris Corrections II:");
531 _statusLbl[3] = new QLabel("0 byte(s)"); _statusCnt[3] = 0;
532
533 _statusLbl[0]->setWhatsThis(tr("Status of incoming broadcast ephemeris."));
534 _statusLbl[1]->setWhatsThis(tr("Status of incoming stream of clocks and orbits."));
535 _statusLbl[2]->setWhatsThis(tr("Status of outgoing stream to NTRIP broadcaster."));
536 _statusLbl[7]->setWhatsThis(tr("Status of incoming broadcast ephemeris."));
537 _statusLbl[4]->setWhatsThis(tr("Status of incoming stream of clocks and orbits I."));
538 _statusLbl[5]->setWhatsThis(tr("Status of outgoing stream to NTRIP broadcaster I."));
539 _statusLbl[6]->setWhatsThis(tr("Status of outgoing stream to NTRIP broadcaster II."));
540 _statusLbl[3]->setWhatsThis(tr("Status of outgoing stream to NTRIP broadcaster II."));
541
542 layout_status->addWidget(_statusLbl[7], 0, 0);
543 layout_status->addWidget(_statusLbl[0], 0, 1);
544 layout_status->addWidget(_statusLbl[4], 1, 0);
545 layout_status->addWidget(_statusLbl[1], 1, 1);
546 layout_status->addWidget(_statusLbl[5], 0, 2);
547 layout_status->addWidget(_statusLbl[2], 0, 3);
548 layout_status->addWidget(_statusLbl[6], 1, 2);
549 layout_status->addWidget(_statusLbl[3], 1, 3);
550 _status->setLayout(layout_status);
551
552 // Main Layout
553 // -----------
554 QVBoxLayout* mainLayout = new QVBoxLayout;
555 mainLayout->addWidget(tabs);
556 mainLayout->addWidget(_log);
557 mainLayout->addWidget(_status);
558
559 _canvas->setLayout(mainLayout);
560
561 // Auto start
562 // ----------
563 if ( Qt::CheckState(settings.value("autoStart").toInt()) == Qt::Checked) {
564 slotStart();
565 }
566
567}
568
569// Destructor
570////////////////////////////////////////////////////////////////////////////
571bnsWindow::~bnsWindow() {
572}
573
574// Close Application gracefully
575////////////////////////////////////////////////////////////////////////////
576void bnsWindow::closeEvent(QCloseEvent* event) {
577
578int iRet = QMessageBox::question(this, "Close", "Save Options?",
579 QMessageBox::Yes, QMessageBox::No,
580 QMessageBox::Cancel);
581
582 if (iRet == QMessageBox::Cancel) {
583 event->ignore();
584 return;
585 }
586 else if (iRet == QMessageBox::Yes) {
587 slotSaveOptions();
588 }
589
590 QMainWindow::closeEvent(event);
591}
592
593// About Message
594////////////////////////////////////////////////////////////////////////////
595void bnsWindow::slotAbout() {
596 new bnsAboutDlg(0);
597}
598
599// Flowchart
600////////////////////////////////////////////////////////////////////////////
601void bnsWindow::slotFlowchart() {
602 new bnsFlowchartDlg(0);
603}
604
605// Help Window
606////////////////////////////////////////////////////////////////////////////
607void bnsWindow::slotHelp() {
608 QUrl url;
609 url.setPath(":bnshelp.html");
610 new bnsHlpDlg(0, url);
611}
612
613// Select Fonts
614////////////////////////////////////////////////////////////////////////////
615void bnsWindow::slotFontSel() {
616 bool ok;
617 QFont newFont = QFontDialog::getFont(&ok, this->font(), this);
618 if (ok) {
619 bnsSettings settings;
620 settings.setValue("font", newFont.toString());
621 QApplication::setFont(newFont);
622 int ww = QFontMetrics(newFont).width('w');
623 setMinimumSize(77*ww, 65*ww);
624 }
625}
626
627// Whats This Help
628////////////////////////////////////////////////////////////////////////////
629void bnsWindow::slotWhatsThis() {
630QWhatsThis::enterWhatsThisMode();
631}
632
633// Create Menus
634////////////////////////////////////////////////////////////////////////////
635void bnsWindow::CreateMenu() {
636 _menuFile = menuBar()->addMenu(tr("&File"));
637 _menuFile->addAction(_actFontSel);
638 _menuFile->addSeparator();
639 _menuFile->addAction(_actSaveOpt);
640 _menuFile->addSeparator();
641 _menuFile->addAction(_actQuit);
642
643 _menuHlp = menuBar()->addMenu(tr("&Help"));
644 _menuHlp->addAction(_actHelp);
645 _menuHlp->addAction(_actFlowchart);
646 _menuHlp->addAction(_actAbout);
647}
648
649// Tool (Command) Bar
650////////////////////////////////////////////////////////////////////////////
651void bnsWindow::AddToolbar() {
652 QToolBar* toolBar = new QToolBar;
653 addToolBar(Qt::BottomToolBarArea, toolBar);
654 toolBar->setMovable(false);
655 toolBar->addAction(_actStart);
656 toolBar->addAction(_actStop);
657 toolBar->addWidget(new QLabel(" "));
658 toolBar->addAction(_actWhatsThis);
659}
660
661// Save Options
662////////////////////////////////////////////////////////////////////////////
663void bnsWindow::slotSaveOptions() {
664 bnsSettings settings;
665 settings.setValue("proxyHost", _proxyHostLineEdit->text());
666 settings.setValue("proxyPort", _proxyPortLineEdit->text());
667 settings.setValue("logFile", _logFileLineEdit->text());
668 settings.setValue("fileAppend", _fileAppendCheckBox->checkState());
669 settings.setValue("autoStart", _autoStartCheckBox->checkState());
670 settings.setValue("refSys_1", _refSys_1_ComboBox->currentText());
671 settings.setValue("refSys_2", _refSys_2_ComboBox->currentText());
672 settings.setValue("inpEcho", _inpEchoLineEdit->text());
673 settings.setValue("ephHost", _ephHostLineEdit->text());
674 settings.setValue("ephPort", _ephPortLineEdit->text());
675 settings.setValue("ephEcho", _ephEchoLineEdit->text());
676 settings.setValue("clkPort", _clkPortLineEdit->text());
677 settings.setValue("outHost1", _outHost_1_LineEdit->text());
678 settings.setValue("outPort1", _outPort_1_LineEdit->text());
679 settings.setValue("outHost2", _outHost_2_LineEdit->text());
680 settings.setValue("outPort2", _outPort_2_LineEdit->text());
681 settings.setValue("mountpoint_1",_mountpoint_1_LineEdit->text());
682 settings.setValue("mountpoint_2",_mountpoint_2_LineEdit->text());
683 settings.setValue("outFile_1", _outFile_1_LineEdit->text());
684 settings.setValue("outFile_2", _outFile_2_LineEdit->text());
685 settings.setValue("password1", _password_1_LineEdit->text());
686 settings.setValue("password2", _password_2_LineEdit->text());
687 settings.setValue("rnxPath", _rnxPathLineEdit->text());
688 settings.setValue("rnxIntr", _rnxIntrComboBox->currentText());
689 settings.setValue("rnxSampl", _rnxSamplSpinBox->value());
690 settings.setValue("sp3Path", _sp3PathLineEdit->text());
691 settings.setValue("sp3Intr", _sp3IntrComboBox->currentText());
692 settings.setValue("sp3Sampl", _sp3SamplSpinBox->value());
693 settings.setValue("startTab", tabs->currentIndex());
694}
695
696// Display Program Messages
697////////////////////////////////////////////////////////////////////////////
698void bnsWindow::slotMessage(const QByteArray msg) {
699
700 const int maxBufferSize = 10000;
701
702 QString txt = _log->toPlainText() + "\n" +
703 QDateTime::currentDateTime().toUTC().toString("yy-MM-dd hh:mm:ss ") + msg;
704 _log->clear();
705 _log->append(txt.right(maxBufferSize));
706}
707
708// Delete bns
709////////////////////////////////////////////////////////////////////////////
710void bnsWindow::deleteBns() {
711 _actStart->setEnabled(true);
712 _actStop->setEnabled(false);
713 _bns->terminate();
714 _bns->wait(100);
715 delete _bns;
716 _bns = 0;
717}
718
719// Error in bns
720////////////////////////////////////////////////////////////////////////////
721void bnsWindow::slotError(const QByteArray msg) {
722 slotMessage(msg);
723 deleteBns();
724}
725
726// Stop
727////////////////////////////////////////////////////////////////////////////
728void bnsWindow::slotStop() {
729 int iRet = QMessageBox::question(this, "Stop", "Do you want to stop?",
730 QMessageBox::Yes, QMessageBox::No,
731 QMessageBox::NoButton);
732 if (iRet == QMessageBox::Yes) {
733 deleteBns();
734 }
735}
736
737// Start
738////////////////////////////////////////////////////////////////////////////
739void bnsWindow::slotStart() {
740 slotSaveOptions();
741
742 _actStart->setEnabled(false);
743 _actStop->setEnabled(true);
744
745 _bns = new t_bns(0);
746
747 connect(_bns, SIGNAL(newMessage(QByteArray)),
748 this, SLOT(slotMessage(const QByteArray)));
749
750 connect(_bns, SIGNAL(error(QByteArray)),
751 this, SLOT(slotError(const QByteArray)));
752
753 connect(_bns, SIGNAL(newEphBytes(int)), this, SLOT(slotEphBytes(int)));
754 connect(_bns, SIGNAL(newClkBytes(int)), this, SLOT(slotClkBytes(int)));
755 connect(_bns, SIGNAL(newOutBytes1(int)), this, SLOT(slotOutBytes1(int)));
756 connect(_bns, SIGNAL(newOutBytes2(int)), this, SLOT(slotOutBytes2(int)));
757
758 _bns->start();
759}
760
761// Input and output bytes statistics
762////////////////////////////////////////////////////////////////////////////
763void bnsWindow::slotEphBytes(int nBytes) {
764 updateStatus(0, nBytes);
765}
766void bnsWindow::slotClkBytes(int nBytes) {
767 updateStatus(1, nBytes);
768}
769void bnsWindow::slotOutBytes1(int nBytes) {
770 updateStatus(2, nBytes);
771}
772void bnsWindow::slotOutBytes2(int nBytes) {
773 updateStatus(3, nBytes);
774}
775
776void bnsWindow::updateStatus(int ii, int nBytes) {
777 QMutexLocker locker(&_mutex);
778
779 _statusCnt[ii] += nBytes;
780
781 if (_statusCnt[ii] < 1e3) {
782 _statusLbl[ii]->setText(QString("%1 byte(s)").arg((int)_statusCnt[ii]));
783 }
784 else if (_statusCnt[ii] < 1e6) {
785 _statusLbl[ii]->setText(QString("%1 kb").arg(_statusCnt[ii]/1.e3, 5));
786 }
787 else {
788 _statusLbl[ii]->setText(QString("%1 Mb").arg(_statusCnt[ii]/1.e6, 5));
789 }
790}
791
792// Bns Text
793////////////////////////////////////////////////////////////////////////////
794void bnsWindow::bnsText(const QString &text){
795
796 bool isEmpty = text.isEmpty();
797
798 QPalette palette;
799 QColor lightGray(230, 230, 230);
800 QColor white(255, 255, 255);
801
802 // Enable/disable Proxy Options
803 // -----
804 if (tabs->currentIndex() == 0) {
805 if (!isEmpty) {
806 _proxyPortLineEdit->setStyleSheet("background-color: white");
807 _proxyPortLineEdit->setEnabled(true);
808 } else {
809 _proxyPortLineEdit->setStyleSheet("background-color: lightGray");
810 _proxyPortLineEdit->setEnabled(false);
811 }
812 }
813
814 // Enable/disable Ephemeris Corrections I Options
815 // -----------------------------------------------
816 if (tabs->currentIndex() == 4) {
817 if (!isEmpty) {
818 _outPort_1_LineEdit->setStyleSheet("background-color: white");
819 _mountpoint_1_LineEdit->setStyleSheet("background-color: white");
820 _password_1_LineEdit->setStyleSheet("background-color: white");
821 _outFile_1_LineEdit->setStyleSheet("background-color: white");
822 _refSys_1_ComboBox->setStyleSheet("background-color: white");
823 _outPort_1_LineEdit->setEnabled(true);
824 _mountpoint_1_LineEdit->setEnabled(true);
825 _password_1_LineEdit->setEnabled(true);
826 _outFile_1_LineEdit->setEnabled(true);
827 _refSys_1_ComboBox->setEnabled(true);
828 } else {
829 _outPort_1_LineEdit->setStyleSheet("background-color: lightGray");
830 _mountpoint_1_LineEdit->setStyleSheet("background-color: lightGray");
831 _password_1_LineEdit->setStyleSheet("background-color: lightGray");
832 _outFile_1_LineEdit->setStyleSheet("background-color: lightGray");
833 _refSys_1_ComboBox->setStyleSheet("background-color: lightGray");
834 _outPort_1_LineEdit->setEnabled(false);
835 _mountpoint_1_LineEdit->setEnabled(false);
836 _password_1_LineEdit->setEnabled(false);
837 _outFile_1_LineEdit->setEnabled(false);
838 _refSys_1_ComboBox->setEnabled(false);
839 }
840 }
841
842 // Enable/disable Ephemeris Corrections II Options
843 // -----------------------------------------------
844 if (tabs->currentIndex() == 5) {
845 if (!isEmpty) {
846 _outPort_2_LineEdit->setStyleSheet("background-color: white");
847 _mountpoint_2_LineEdit->setStyleSheet("background-color: white");
848 _password_2_LineEdit->setStyleSheet("background-color: white");
849 _outFile_2_LineEdit->setStyleSheet("background-color: white");
850 _refSys_2_ComboBox->setStyleSheet("background-color: white");
851 _outPort_2_LineEdit->setEnabled(true);
852 _mountpoint_2_LineEdit->setEnabled(true);
853 _password_2_LineEdit->setEnabled(true);
854 _outFile_2_LineEdit->setEnabled(true);
855 _refSys_2_ComboBox->setEnabled(true);
856 } else {
857 _outPort_2_LineEdit->setStyleSheet("background-color: lightGray");
858 _mountpoint_2_LineEdit->setStyleSheet("background-color: lightGray");
859 _password_2_LineEdit->setStyleSheet("background-color: lightGray");
860 _outFile_2_LineEdit->setStyleSheet("background-color: lightGray");
861 _refSys_2_ComboBox->setStyleSheet("background-color: lightGray");
862 _outPort_2_LineEdit->setEnabled(false);
863 _mountpoint_2_LineEdit->setEnabled(false);
864 _password_2_LineEdit->setEnabled(false);
865 _outFile_2_LineEdit->setEnabled(false);
866 _refSys_2_ComboBox->setEnabled(false);
867 }
868 }
869
870 // Enable/disable RINEX Clocks Options
871 // -----------------------------------
872 if (tabs->currentIndex() == 6) {
873 if (!isEmpty) {
874 _rnxIntrComboBox->setStyleSheet("background-color: white");
875 _rnxSamplSpinBox->setStyleSheet("background-color: white");
876 _rnxIntrComboBox->setEnabled(true);
877 _rnxSamplSpinBox->setEnabled(true);
878 } else {
879 _rnxIntrComboBox->setStyleSheet("background-color: lightGray");
880 _rnxSamplSpinBox->setStyleSheet("background-color: lightGray");
881 _rnxIntrComboBox->setEnabled(false);
882 _rnxSamplSpinBox->setEnabled(false);
883 }
884 }
885
886 // Enable/disable SP3 Orbits Options
887 // ---------------------------------
888 if (tabs->currentIndex() == 7) {
889 if (!isEmpty) {
890 _sp3IntrComboBox->setStyleSheet("background-color: white");
891 _sp3SamplSpinBox->setStyleSheet("background-color: white");
892 _sp3IntrComboBox->setEnabled(true);
893 _sp3SamplSpinBox->setEnabled(true);
894 } else {
895 _sp3IntrComboBox->setStyleSheet("background-color: lightGray");
896 _sp3SamplSpinBox->setStyleSheet("background-color: lightGray");
897 _sp3IntrComboBox->setEnabled(false);
898 _sp3SamplSpinBox->setEnabled(false);
899 }
900 }
901
902}
Note: See TracBrowser for help on using the repository browser.