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

Last change on this file since 1058 was 1058, checked in by mervart, 16 years ago

* empty log message *

File size: 24.2 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
23using namespace std;
24
25// About Dialog - Constructor
26////////////////////////////////////////////////////////////////////////////
27bnsAboutDlg::bnsAboutDlg(QWidget* parent) :
28 QDialog(parent) {
29
30 QTextBrowser* tb = new QTextBrowser;
31 QUrl url; url.setPath(":bnsabout.html");
32 tb->setSource(url);
33 tb->setReadOnly(true);
34
35 int ww = QFontMetrics(font()).width('w');
36 QPushButton* _closeButton = new QPushButton("Close");
37 _closeButton->setMaximumWidth(10*ww);
38 connect(_closeButton, SIGNAL(clicked()), this, SLOT(close()));
39
40 QGridLayout* dlgLayout = new QGridLayout();
41 QLabel* img = new QLabel();
42 img->setPixmap(QPixmap(":ntrip-logo.png"));
43 dlgLayout->addWidget(img, 0,0);
44 dlgLayout->addWidget(new QLabel("BKG Ntrip State Space Server (BNS) Version 1.0"), 0,1);
45 dlgLayout->addWidget(tb,1,0,1,2);
46 dlgLayout->addWidget(_closeButton,2,1,Qt::AlignRight);
47
48 setLayout(dlgLayout);
49 resize(60*ww, 60*ww);
50 show();
51}
52
53// About Dialog - Destructor
54////////////////////////////////////////////////////////////////////////////
55bnsAboutDlg::~bnsAboutDlg() {
56};
57
58// Flowchart Dialog - Constructor
59////////////////////////////////////////////////////////////////////////////
60bnsFlowchartDlg::bnsFlowchartDlg(QWidget* parent) :
61 QDialog(parent) {
62
63 int ww = QFontMetrics(font()).width('w');
64 QPushButton* _closeButton = new QPushButton("Close");
65 _closeButton->setMaximumWidth(10*ww);
66 connect(_closeButton, SIGNAL(clicked()), this, SLOT(close()));
67
68 QGridLayout* dlgLayout = new QGridLayout();
69 QLabel* img = new QLabel();
70 img->setPixmap(QPixmap(":bnsflowchart.png"));
71 dlgLayout->addWidget(img, 0,0);
72 dlgLayout->addWidget(_closeButton,1,0,Qt::AlignLeft);
73
74 setLayout(dlgLayout);
75 show();
76}
77
78// Flowchart Dialog - Destructor
79////////////////////////////////////////////////////////////////////////////
80bnsFlowchartDlg::~bnsFlowchartDlg() {
81};
82
83// Constructor
84////////////////////////////////////////////////////////////////////////////
85bnsWindow::bnsWindow() {
86
87 _bns = 0;
88
89 QSettings settings;
90
91 QString fontString = settings.value("font").toString();
92 if ( !fontString.isEmpty() ) {
93 QFont newFont;
94 if (newFont.fromString(fontString)) {
95 QApplication::setFont(newFont);
96 }
97 }
98
99 int ww = QFontMetrics(this->font()).width('w');
100 setMinimumSize(77*ww, 65*ww);
101 setWindowTitle(tr("BKG Ntrip State Space Server (BNS) Version 1.0"));
102 setWindowIcon(QPixmap(":ntrip-logo.png"));
103
104 // Create Actions
105 // --------------
106 _actHelp = new QAction(tr("&Help Contents"),this);
107 connect(_actHelp, SIGNAL(triggered()), SLOT(slotHelp()));
108
109 _actAbout = new QAction(tr("&About BNS"),this);
110 connect(_actAbout, SIGNAL(triggered()), SLOT(slotAbout()));
111
112 _actFlowchart = new QAction(tr("&Flow Chart"),this);
113 connect(_actFlowchart, SIGNAL(triggered()), SLOT(slotFlowchart()));
114
115 _actFontSel = new QAction(tr("Select &Font"),this);
116 connect(_actFontSel, SIGNAL(triggered()), SLOT(slotFontSel()));
117
118 _actSaveOpt = new QAction(tr("&Save Options"),this);
119 connect(_actSaveOpt, SIGNAL(triggered()), SLOT(slotSaveOptions()));
120
121 _actQuit = new QAction(tr("&Quit"),this);
122 connect(_actQuit, SIGNAL(triggered()), SLOT(close()));
123
124 _actWhatsThis= new QAction(tr("Help=Shift+F1"),this);
125 connect(_actWhatsThis, SIGNAL(triggered()), SLOT(slotWhatsThis()));
126
127 _actStart = new QAction(tr("Sta&rt"),this);
128 connect(_actStart, SIGNAL(triggered()), SLOT(slotStart()));
129
130 _actStop = new QAction(tr("Sto&p"),this);
131 connect(_actStop, SIGNAL(triggered()), SLOT(slotStop()));
132 _actStop->setEnabled(false);
133
134 CreateMenu();
135 AddToolbar();
136
137 // Canvas with Editable Fields
138 // ---------------------------
139 _canvas = new QWidget;
140 setCentralWidget(_canvas);
141
142 _proxyHostLineEdit = new QLineEdit(settings.value("proxyHost").toString());
143 _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>"));
144 _proxyPortLineEdit = new QLineEdit(settings.value("proxyPort").toString());
145 _proxyPortLineEdit->setWhatsThis(tr("<p>Enter your proxy server port number in case one is operated in front of BNS.</p>"));
146 _proxyPortLineEdit->setMaximumWidth(9*ww);
147
148 _logFileLineEdit = new QLineEdit(settings.value("logFile").toString());
149 _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>"));
150 _fileAppendCheckBox = new QCheckBox();
151 _fileAppendCheckBox->setCheckState(Qt::CheckState(settings.value("fileAppend").toInt()));
152 _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>"));
153
154 _refSysComboBox = new QComboBox;
155 _refSysComboBox->setMaximumWidth(9*ww);
156 _refSysComboBox->setEditable(false);
157 _refSysComboBox->addItems(QString("IGS05,ETRS89").split(","));
158 int ii = _refSysComboBox->findText(settings.value("refSys").toString());
159 if (ii != -1) {
160 _refSysComboBox->setCurrentIndex(ii);
161 }
162 _refSysComboBox->setWhatsThis(tr("Select the target reference system for outgoing clock and orbit corrections."));
163
164 _ephHostLineEdit = new QLineEdit(settings.value("ephHost").toString());
165 _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."));
166 _ephPortLineEdit = new QLineEdit(settings.value("ephPort").toString());
167 _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."));
168 _ephPortLineEdit->setMaximumWidth(9*ww);
169
170 _clkPortLineEdit = new QLineEdit(settings.value("clkPort").toString());
171 _clkPortLineEdit->setWhatsThis(tr("BNS reads Clocks & Orbits referring to the IGS system (X,Y,Z, ECEF) in plain ASCII format from an IP port. Specify a local IP port e.g. for an RTNet installation to provide this information."));
172 _clkPortLineEdit->setMaximumWidth(9*ww);
173
174 _outHostLineEdit = new QLineEdit(settings.value("outHost").toString());
175 _outHostLineEdit->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."));
176 _outPortLineEdit = new QLineEdit(settings.value("outPort").toString());
177 _outPortLineEdit->setWhatsThis(tr("Specify the IP port of an NTRIP Broadcaster to upload the stream. Default is port 80."));
178 _outPortLineEdit->setMaximumWidth(9*ww);
179 _mountpointLineEdit = new QLineEdit(settings.value("mountpoint").toString());
180 _mountpointLineEdit->setWhatsThis(tr("Specify the mounpoint for stream upload to an NTRIP Broadcaster."));
181 _mountpointLineEdit->setMaximumWidth(9*ww);
182 _passwordLineEdit = new QLineEdit(settings.value("password").toString());
183 _passwordLineEdit->setWhatsThis(tr("Specify the stream upload password protecting the mounpoint on an NTRIP Broadcaster."));
184 _passwordLineEdit->setMaximumWidth(9*ww);
185 _passwordLineEdit->setEchoMode(QLineEdit::Password);
186 _outFileLineEdit = new QLineEdit(settings.value("outFile").toString());
187 _outFileLineEdit->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."));
188
189 _rnxPathLineEdit = new QLineEdit(settings.value("rnxPath").toString());
190 _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."));
191 _rnxIntrComboBox = new QComboBox;
192 _rnxIntrComboBox->setMaximumWidth(9*ww);
193 _rnxIntrComboBox->setEditable(false);
194 _rnxIntrComboBox->addItems(QString("1 min,2 min,5 min,10 min,15 min,30 min,1 hour,1 day").split(","));
195 ii = _rnxIntrComboBox->findText(settings.value("rnxIntr").toString());
196 if (ii != -1) {
197 _rnxIntrComboBox->setCurrentIndex(ii);
198 }
199 _rnxIntrComboBox->setWhatsThis(tr("Select the length of the Clock RINEX file."));
200 _rnxSamplSpinBox = new QSpinBox;
201 _rnxSamplSpinBox->setMinimum(0);
202 _rnxSamplSpinBox->setMaximum(60);
203 _rnxSamplSpinBox->setSingleStep(5);
204 _rnxSamplSpinBox->setMaximumWidth(9*ww);
205 _rnxSamplSpinBox->setValue(settings.value("rnxSampl").toInt());
206 _rnxSamplSpinBox->setSuffix(" sec");
207 _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."));
208
209 _sp3PathLineEdit = new QLineEdit(settings.value("sp3Path").toString());
210 _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."));
211 _sp3IntrComboBox = new QComboBox;
212 _sp3IntrComboBox->setMaximumWidth(9*ww);
213 _sp3IntrComboBox->setEditable(false);
214 _sp3IntrComboBox->addItems(QString("1 min,2 min,5 min,10 min,15 min,30 min,1 hour,1 day").split(","));
215 ii = _sp3IntrComboBox->findText(settings.value("sp3Intr").toString());
216 if (ii != -1) {
217 _sp3IntrComboBox->setCurrentIndex(ii);
218 }
219 _sp3IntrComboBox->setWhatsThis(tr("Select the length of the SP3 orbit file."));
220 _sp3SamplSpinBox = new QSpinBox;
221 _sp3SamplSpinBox->setMinimum(0);
222 _sp3SamplSpinBox->setMaximum(900);
223 _sp3SamplSpinBox->setSingleStep(60);
224 _sp3SamplSpinBox->setMaximumWidth(9*ww);
225 _sp3SamplSpinBox->setValue(settings.value("sp3Sampl").toInt());
226 _sp3SamplSpinBox->setSuffix(" sec");
227 _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."));
228
229 // TabWidget
230 // ---------
231 QTabWidget* tabs = new QTabWidget();
232
233 // Proxy Tab
234 // ---------
235 QWidget* tab_prx = new QWidget();
236 tabs->setMaximumHeight(20*ww);
237 tabs->addTab(tab_prx, "Proxy");
238
239 QGridLayout* layout_prx = new QGridLayout;
240 layout_prx->setColumnMinimumWidth(0,9*ww);
241
242 layout_prx->addWidget(new QLabel("Proxy host"), 0, 0, Qt::AlignLeft);
243 layout_prx->addWidget(_proxyHostLineEdit, 0, 1);
244 layout_prx->addWidget(new QLabel("Proxy port"), 1, 0, Qt::AlignLeft);
245 layout_prx->addWidget(_proxyPortLineEdit, 1, 1);
246 layout_prx->addWidget(new QLabel("Settings for the proxy in protected networks, leave boxes blank if none."),2, 0, 1, 2, Qt::AlignLeft);
247 layout_prx->addWidget(new QLabel(" "), 3, 0);
248 layout_prx->addWidget(new QLabel(" "), 4, 0);
249
250 tab_prx->setLayout(layout_prx);
251
252 // General Tab
253 // -----------
254 QWidget* tab_gen = new QWidget();
255 tabs->addTab(tab_gen, "General");
256
257 QGridLayout* layout_gen = new QGridLayout;
258 layout_gen->setColumnMinimumWidth(0,9*ww);
259
260 layout_gen->addWidget(new QLabel("Logfile (full path)"), 0, 0);
261 layout_gen->addWidget(_logFileLineEdit, 0, 1);
262 layout_gen->addWidget(new QLabel("Append files"), 1, 0);
263 layout_gen->addWidget(_fileAppendCheckBox, 1, 1);
264 layout_gen->addWidget(new QLabel("Reference System"), 2, 0);
265 layout_gen->addWidget(_refSysComboBox, 2, 1);
266 layout_gen->addWidget(new QLabel("General settings for logfile, file handling and target reference system."),3, 0, 1, 2, Qt::AlignLeft);
267 layout_gen->addWidget(new QLabel(" "), 4, 0);
268
269 tab_gen->setLayout(layout_gen);
270
271 // Input Tab
272 // ---------
273 QWidget* tab_inp = new QWidget();
274 tabs->addTab(tab_inp, "Input");
275
276 QGridLayout* layout_inp = new QGridLayout;
277 layout_inp->setColumnMinimumWidth(0, 9*ww);
278
279 layout_inp->addWidget(new QLabel("Ephemeris"), 0, 0, Qt::AlignLeft);
280 layout_inp->addWidget(new QLabel("Host"), 0, 1, Qt::AlignRight);
281 layout_inp->addWidget(_ephHostLineEdit, 0, 2);
282 layout_inp->addWidget(new QLabel("Port"), 0, 3, Qt::AlignLeft);
283 layout_inp->addWidget(_ephPortLineEdit, 0, 4);
284 layout_inp->addWidget(new QLabel("Clocks & Orbits"), 1, 0, Qt::AlignLeft);
285 layout_inp->addWidget(new QLabel("BNS listening on Port"), 1, 1, 1, 3, Qt::AlignRight);
286 layout_inp->addWidget(_clkPortLineEdit, 1, 4);
287 layout_inp->addWidget(new QLabel("Read broadcast ephemeris and IGS clocks and orbits."), 2, 0, 1, 6, Qt::AlignLeft);
288 layout_inp->addWidget(new QLabel(""), 3, 0);
289 layout_inp->addWidget(new QLabel(""), 4, 0);
290
291 tab_inp->setLayout(layout_inp);
292
293 // NTRIP Caster Tab
294 // ----------------
295 QWidget* tab_cas = new QWidget();
296 tabs->addTab(tab_cas, "NTRIP Caster");
297
298 QGridLayout* layout_cas = new QGridLayout;
299 layout_cas->setColumnMinimumWidth(0, 9*ww);
300
301 layout_cas->addWidget(new QLabel("Host"), 0, 0, Qt::AlignLeft);
302 layout_cas->addWidget(_outHostLineEdit, 0, 1);
303 layout_cas->addWidget(new QLabel("Port"), 0, 3, Qt::AlignLeft);
304 layout_cas->addWidget(_outPortLineEdit, 0, 4);
305 layout_cas->addWidget(new QLabel("Mountpoint"), 1, 0, Qt::AlignLeft);
306 layout_cas->addWidget(_mountpointLineEdit, 1, 1);
307 layout_cas->addWidget(new QLabel("Password"), 1, 3, Qt::AlignLeft);
308 layout_cas->addWidget(_passwordLineEdit, 1, 4);
309 layout_cas->addWidget(new QLabel("Save stream (full path)"), 2, 0, Qt::AlignLeft);
310 layout_cas->addWidget(_outFileLineEdit, 2, 1);
311 layout_cas->addWidget(new QLabel("Stream upload of clock and orbit corrections to NTRIP broadcaster."), 3, 0, 1, 4, Qt::AlignLeft);
312 layout_cas->addWidget(new QLabel(""), 4, 0);
313
314 tab_cas->setLayout(layout_cas);
315
316 // RINEX Tab
317 // ---------
318 QWidget* tab_rin = new QWidget();
319 tabs->addTab(tab_rin, "RINEX Clocks ");
320
321 QGridLayout* layout_rin = new QGridLayout;
322 layout_rin->setColumnMinimumWidth(0, 9*ww);
323
324 layout_rin->addWidget(new QLabel("Directory"), 0, 0);
325 layout_rin->addWidget(_rnxPathLineEdit, 0, 1);
326 layout_rin->addWidget(new QLabel("Interval"), 1, 0);
327 layout_rin->addWidget(_rnxIntrComboBox, 1, 1);
328 layout_rin->addWidget(new QLabel("Sampling"), 2, 0);
329 layout_rin->addWidget(_rnxSamplSpinBox, 2, 1);
330 layout_rin->addWidget(new QLabel("Save clock corrections in Clock RINEX file format."), 3, 0, 1, 2, Qt::AlignLeft);
331 layout_rin->addWidget(new QLabel(""), 4, 0);
332
333 tab_rin->setLayout(layout_rin);
334
335 // SP3 Tab
336 // -------
337 QWidget* tab_sp3 = new QWidget();
338 tabs->addTab(tab_sp3, "SP3 Orbits");
339
340 QGridLayout* layout_sp3 = new QGridLayout;
341 layout_sp3->setColumnMinimumWidth(0, 9*ww);
342
343 layout_sp3->addWidget(new QLabel("Directory"), 0, 0);
344 layout_sp3->addWidget(_sp3PathLineEdit, 0, 1);
345 layout_sp3->addWidget(new QLabel("Interval"), 1, 0);
346 layout_sp3->addWidget(_sp3IntrComboBox, 1, 1);
347 layout_sp3->addWidget(new QLabel("Sampling"), 2, 0);
348 layout_sp3->addWidget(_sp3SamplSpinBox, 2, 1);
349 layout_sp3->addWidget(new QLabel("Save orbit corrections in SP3 file format."), 3, 0, 1, 2, Qt::AlignLeft);
350 layout_sp3->addWidget(new QLabel(""), 4, 0);
351
352 tab_sp3->setLayout(layout_sp3);
353
354 // Log
355 // ---
356 _log = new QTextBrowser();
357 _log->setReadOnly(true);
358 _log->setWhatsThis(tr("Records of BNS's activities are shown in the Log section."));
359
360 // Status
361 // ------
362 _status = new QWidget();
363 QGridLayout* layout_status = new QGridLayout;
364
365 _statusLbl[0] = new QLabel("0 byte(s)"); _statusCnt[0] = 0;
366 _statusLbl[1] = new QLabel("0 byte(s)"); _statusCnt[1] = 0;
367 _statusLbl[2] = new QLabel("0 byte(s)"); _statusCnt[2] = 0;
368 _statusLbl[3] = new QLabel("Input Ephemeris");
369 _statusLbl[4] = new QLabel("Input Clock & Orbits");
370 _statusLbl[5] = new QLabel("Output");
371
372 layout_status->addWidget(_statusLbl[3], 0, 0);
373 layout_status->addWidget(_statusLbl[0], 0, 1);
374 layout_status->addWidget(_statusLbl[4], 0, 2);
375 layout_status->addWidget(_statusLbl[1], 0, 3);
376 layout_status->addWidget(_statusLbl[5], 1, 2);
377 layout_status->addWidget(_statusLbl[2], 1, 3);
378 _status->setLayout(layout_status);
379
380 // Main Layout
381 // -----------
382 QVBoxLayout* mainLayout = new QVBoxLayout;
383 mainLayout->addWidget(tabs);
384 mainLayout->addWidget(_log);
385 mainLayout->addWidget(_status);
386
387 _canvas->setLayout(mainLayout);
388}
389
390// Destructor
391////////////////////////////////////////////////////////////////////////////
392bnsWindow::~bnsWindow() {
393}
394
395// Close Application gracefully
396////////////////////////////////////////////////////////////////////////////
397void bnsWindow::closeEvent(QCloseEvent* event) {
398
399int iRet = QMessageBox::question(this, "Close", "Save Options?",
400 QMessageBox::Yes, QMessageBox::No,
401 QMessageBox::Cancel);
402
403 if (iRet == QMessageBox::Cancel) {
404 event->ignore();
405 return;
406 }
407 else if (iRet == QMessageBox::Yes) {
408 slotSaveOptions();
409 }
410
411 QMainWindow::closeEvent(event);
412}
413
414// About Message
415////////////////////////////////////////////////////////////////////////////
416void bnsWindow::slotAbout() {
417 new bnsAboutDlg(0);
418}
419
420//Flowchart
421////////////////////////////////////////////////////////////////////////////
422void bnsWindow::slotFlowchart() {
423 new bnsFlowchartDlg(0);
424}
425
426// Help Window
427////////////////////////////////////////////////////////////////////////////
428void bnsWindow::slotHelp() {
429 QUrl url;
430 url.setPath(":bnshelp.html");
431 new bnsHlpDlg(0, url);
432}
433
434// Select Fonts
435////////////////////////////////////////////////////////////////////////////
436void bnsWindow::slotFontSel() {
437 bool ok;
438 QFont newFont = QFontDialog::getFont(&ok, this->font(), this);
439 if (ok) {
440 QSettings settings;
441 settings.setValue("font", newFont.toString());
442 QApplication::setFont(newFont);
443 int ww = QFontMetrics(newFont).width('w');
444 setMinimumSize(77*ww, 65*ww);
445 }
446}
447
448// Whats This Help
449////////////////////////////////////////////////////////////////////////////
450void bnsWindow::slotWhatsThis() {
451QWhatsThis::enterWhatsThisMode();
452}
453
454// Create Menus
455////////////////////////////////////////////////////////////////////////////
456void bnsWindow::CreateMenu() {
457 _menuFile = menuBar()->addMenu(tr("&File"));
458 _menuFile->addAction(_actFontSel);
459 _menuFile->addSeparator();
460 _menuFile->addAction(_actSaveOpt);
461 _menuFile->addSeparator();
462 _menuFile->addAction(_actQuit);
463
464 _menuHlp = menuBar()->addMenu(tr("&Help"));
465 _menuHlp->addAction(_actHelp);
466 _menuHlp->addAction(_actFlowchart);
467 _menuHlp->addAction(_actAbout);
468}
469
470// Tool (Command) Bar
471////////////////////////////////////////////////////////////////////////////
472void bnsWindow::AddToolbar() {
473 QToolBar* toolBar = new QToolBar;
474 addToolBar(Qt::BottomToolBarArea, toolBar);
475 toolBar->setMovable(false);
476 toolBar->addAction(_actStart);
477 toolBar->addAction(_actStop);
478 toolBar->addWidget(new QLabel(" "));
479 toolBar->addAction(_actWhatsThis);
480}
481
482// Save Options
483////////////////////////////////////////////////////////////////////////////
484void bnsWindow::slotSaveOptions() {
485 QSettings settings;
486 settings.setValue("proxyHost", _proxyHostLineEdit->text());
487 settings.setValue("proxyPort", _proxyPortLineEdit->text());
488 settings.setValue("logFile", _logFileLineEdit->text());
489 settings.setValue("fileAppend", _fileAppendCheckBox->checkState());
490 settings.setValue("refSys", _refSysComboBox->currentText());
491 settings.setValue("ephHost", _ephHostLineEdit->text());
492 settings.setValue("ephPort", _ephPortLineEdit->text());
493 settings.setValue("clkPort", _clkPortLineEdit->text());
494 settings.setValue("outHost", _outHostLineEdit->text());
495 settings.setValue("outPort", _outPortLineEdit->text());
496 settings.setValue("mountpoint", _mountpointLineEdit->text());
497 settings.setValue("outFile", _outFileLineEdit->text());
498 settings.setValue("password", _passwordLineEdit->text());
499 settings.setValue("rnxPath", _rnxPathLineEdit->text());
500 settings.setValue("rnxIntr", _rnxIntrComboBox->currentText());
501 settings.setValue("rnxSampl", _rnxSamplSpinBox->value());
502 settings.setValue("sp3Path", _sp3PathLineEdit->text());
503 settings.setValue("sp3Intr", _sp3IntrComboBox->currentText());
504 settings.setValue("sp3Sampl", _sp3SamplSpinBox->value());
505}
506
507// Display Program Messages
508////////////////////////////////////////////////////////////////////////////
509void bnsWindow::slotMessage(const QByteArray msg) {
510
511 const int maxBufferSize = 10000;
512
513 QString txt = _log->toPlainText() + "\n" +
514 QDateTime::currentDateTime().toUTC().toString("yy-MM-dd hh:mm:ss ") + msg;
515 _log->clear();
516 _log->append(txt.right(maxBufferSize));
517}
518
519// Delete bns
520////////////////////////////////////////////////////////////////////////////
521void bnsWindow::deleteBns() {
522 _actStart->setEnabled(true);
523 _actStop->setEnabled(false);
524 _bns->terminate();
525 _bns->wait(100);
526 delete _bns;
527 _bns = 0;
528}
529
530// Error in bns
531////////////////////////////////////////////////////////////////////////////
532void bnsWindow::slotError(const QByteArray msg) {
533 slotMessage(msg);
534 deleteBns();
535}
536
537// Stop
538////////////////////////////////////////////////////////////////////////////
539void bnsWindow::slotStop() {
540 int iRet = QMessageBox::question(this, "Stop", "Do you want to stop?",
541 QMessageBox::Yes, QMessageBox::No,
542 QMessageBox::NoButton);
543 if (iRet == QMessageBox::Yes) {
544 deleteBns();
545 }
546}
547
548// Start
549////////////////////////////////////////////////////////////////////////////
550void bnsWindow::slotStart() {
551 slotSaveOptions();
552
553 _actStart->setEnabled(false);
554 _actStop->setEnabled(true);
555
556 _bns = new t_bns(0);
557
558 connect(_bns, SIGNAL(newMessage(QByteArray)),
559 this, SLOT(slotMessage(const QByteArray)));
560
561 connect(_bns, SIGNAL(error(QByteArray)),
562 this, SLOT(slotError(const QByteArray)));
563
564 connect(_bns, SIGNAL(newEphBytes(int)), this, SLOT(slotEphBytes(int)));
565 connect(_bns, SIGNAL(newClkBytes(int)), this, SLOT(slotClkBytes(int)));
566 connect(_bns, SIGNAL(newOutBytes(int)), this, SLOT(slotOutBytes(int)));
567
568 _bns->start();
569}
570
571// Input and output bytes statistics
572////////////////////////////////////////////////////////////////////////////
573void bnsWindow::slotEphBytes(int nBytes) {
574 updateStatus(0, nBytes);
575}
576void bnsWindow::slotClkBytes(int nBytes) {
577 updateStatus(1, nBytes);
578}
579void bnsWindow::slotOutBytes(int nBytes) {
580 updateStatus(2, nBytes);
581}
582
583void bnsWindow::updateStatus(int ii, int nBytes) {
584 QMutexLocker locker(&_mutex);
585
586 _statusCnt[ii] += nBytes;
587
588 if (_statusCnt[ii] < 1e3) {
589 _statusLbl[ii]->setText(QString("%1 byte(s)").arg((int)_statusCnt[ii]));
590 }
591 else if (_statusCnt[ii] < 1e6) {
592 _statusLbl[ii]->setText(QString("%1 kb").arg(_statusCnt[ii]/1.e3, 5));
593 }
594 else {
595 _statusLbl[ii]->setText(QString("%1 Mb").arg(_statusCnt[ii]/1.e6, 5));
596 }
597}
Note: See TracBrowser for help on using the repository browser.