source: ntrip/trunk/BNC/bncserialport.cpp@ 4158

Last change on this file since 4158 was 3802, checked in by weber, 13 years ago

RTNET format specified in online help

File size: 9.5 KB
Line 
1// Part of BNC, a utility for retrieving decoding and
2// converting GNSS data streams from NTRIP broadcasters.
3//
4// Copyright (C) 2009
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: bncSerialPort
30 *
31 * Purpose: Select serial port for stream retrieval
32 *
33 * Author: G. Weber
34 *
35 * Created: 18-Feb-2009
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
41#include <iostream>
42
43#include "bncserialport.h"
44
45using namespace std;
46
47// Constructor
48////////////////////////////////////////////////////////////////////////////
49bncSerialPort::bncSerialPort(QWidget* parent) : QDialog(parent) {
50
51 setMinimumSize(400,150);
52 QVBoxLayout* mainLayout = new QVBoxLayout(this);
53 QGridLayout* editLayout = new QGridLayout;
54
55 setWindowTitle(tr("Add Stream from Serial Port"));
56
57 _serialMountpointLineEdit = new QLineEdit();
58 _serialPortLineEdit = new QLineEdit();
59 _serialFormatLineEdit = new QLineEdit();
60 _serialBaudRateComboBox = new QComboBox();
61 _serialFlowControlComboBox = new QComboBox();
62 _serialDataBitsComboBox = new QComboBox();
63 _serialParityComboBox = new QComboBox();
64 _serialStopBitsComboBox = new QComboBox();
65 _serialLatLineEdit = new QLineEdit();
66 _serialLonLineEdit = new QLineEdit();
67
68 _serialBaudRateComboBox->addItems(QString("110,300,600,"
69 "1200,2400,4800,9600,19200,38400,57600,115200").split(","));
70 _serialFlowControlComboBox->addItems(QString("OFF,XONXOFF,HARDWARE").split(","));
71 _serialDataBitsComboBox->addItems(QString("5,6,7,8").split(","));
72 _serialParityComboBox->addItems(QString("NONE,ODD,EVEN,SPACE").split(","));
73 _serialStopBitsComboBox->addItems(QString("1,2").split(","));
74
75 _serialBaudRateComboBox->setCurrentIndex(7);
76 _serialDataBitsComboBox->setCurrentIndex(3);
77
78 int ww = QFontMetrics(font()).width('w');
79 _serialMountpointLineEdit->setMaximumWidth(11*ww);
80 _serialPortLineEdit->setMaximumWidth(11*ww);
81 _serialBaudRateComboBox->setMaximumWidth(9*ww);
82 _serialFlowControlComboBox->setMaximumWidth(11*ww);
83 _serialDataBitsComboBox->setMaximumWidth(5*ww);
84 _serialParityComboBox->setMaximumWidth(9*ww);
85 _serialStopBitsComboBox->setMaximumWidth(5*ww);
86 _serialLatLineEdit->setMaximumWidth(9*ww);
87 _serialLonLineEdit->setMaximumWidth(9*ww);
88 _serialFormatLineEdit->setMaximumWidth(9*ww);
89
90 // WhatsThis
91 // ---------
92 _serialMountpointLineEdit->setWhatsThis(tr("<p>BNC allows to retrieve streams via serial port without using the NTRIP transport protocol.</p><p>Specify a mountpoint. Recommended is a 4-character station ID.<br>Example: FFMJ</p>"));
93 _serialPortLineEdit->setWhatsThis(tr("<p>Enter the serial 'Port name' selected for communication with your serial connected device. Valid port names are</p><pre>Windows: COM1, COM2<br>Linux: /dev/ttyS0, /dev/ttyS1<br>FreeBSD: /dev/ttyd0, /dev/ttyd1<br>Digital Unix: /dev/tty01, /dev/tty02<br>HP-UX: /dev/tty1p0, /dev/tty2p0<br>SGI/IRIX: /dev/ttyf1, /dev/ttyf2<br>SunOS/Solaris: /dev/ttya, /dev/ttyb</pre><p>Note that you must plug a serial cable in the port defined here before you start BNC.</p>"));
94 _serialFormatLineEdit->setWhatsThis(tr("<p>Specify the stream format.</p><p>Available options are 'RTCM_2', 'RTCM_3', 'RTNET', and 'ZERO'.</p>"));
95 _serialBaudRateComboBox->setWhatsThis(tr("<p>Select a 'Baud rate' for the serial input link.</p><p>Note that your selection must equal the baud rate configured to the serial connected device. Note further that using a high baud rate is recommended.</p>"));
96 _serialFlowControlComboBox->setWhatsThis(tr("<p>Select a 'Flow control' for the serial input link.</p><p>Note that your selection must equal the flow control configured to the serial connected device. Select 'OFF' if you don't know better.</p>"));
97 _serialDataBitsComboBox->setWhatsThis(tr("<p>Select the number of 'Data bits' for the serial input link.</p><p>Note that your selection must equal the number of data bits configured to the serial connected device. Note further that often 8 data bits are used.</p>"));
98 _serialParityComboBox->setWhatsThis(tr("<p>Select the 'Parity' for the serial input link.</p><p>Note that your selection must equal the parity selection configured to the serial connected device. Note further that parity is often set to 'NONE'.</p>"));
99 _serialStopBitsComboBox->setWhatsThis(tr("<p>Select the number of 'Stop bits' for the serial input link.</p><p>Note that your selection must equal the number of stop bits configured to the serial connected device. Note further that often 1 stop bit is used.</p>"));
100 _serialLatLineEdit->setWhatsThis(tr("<p>Enter the approximate latitude of the stream providing receiver in degrees.<p></p>Example: 45.32</p>"));
101 _serialLonLineEdit->setWhatsThis(tr("<p>Enter the approximate latitude of the stream providing receiver in degrees.<p></p>Example: 45.32</p>"));
102
103 editLayout->addWidget(new QLabel(tr("Mountpoint")), 0, 0, Qt::AlignRight);
104 editLayout->addWidget(_serialMountpointLineEdit, 0, 1);
105 editLayout->addWidget(new QLabel(tr("Format")), 0, 2, Qt::AlignRight);
106 editLayout->addWidget(_serialFormatLineEdit, 0, 3);
107 editLayout->addWidget(new QLabel(tr("Latitude")), 1, 0, Qt::AlignRight);
108 editLayout->addWidget(_serialLatLineEdit, 1, 1);
109 editLayout->addWidget(new QLabel(tr("Longitude")), 1, 2, Qt::AlignRight);
110 editLayout->addWidget(_serialLonLineEdit, 1, 3);
111 editLayout->addWidget(new QLabel(tr("Port name")), 2, 0, Qt::AlignRight);
112 editLayout->addWidget(_serialPortLineEdit, 2, 1);
113 editLayout->addWidget(new QLabel(tr("Baud rate")), 2, 2, Qt::AlignRight);
114 editLayout->addWidget(_serialBaudRateComboBox, 2, 3);
115 editLayout->addWidget(new QLabel(tr("Data bits")), 3, 0, Qt::AlignRight);
116 editLayout->addWidget(_serialDataBitsComboBox, 3, 1);
117 editLayout->addWidget(new QLabel(tr("Parity")), 3, 2, Qt::AlignRight);
118 editLayout->addWidget(_serialParityComboBox, 3, 3);
119 editLayout->addWidget(new QLabel(tr("Stop bits")), 4, 0, Qt::AlignRight);
120 editLayout->addWidget(_serialStopBitsComboBox, 4, 1);
121 editLayout->addWidget(new QLabel(tr("Flow control")),4, 2, Qt::AlignRight);
122 editLayout->addWidget(_serialFlowControlComboBox, 4, 3);
123
124 mainLayout->addLayout(editLayout);
125
126 _buttonWhatsThis = new QPushButton(tr("Help=Shift+F1"), this);
127 connect(_buttonWhatsThis, SIGNAL(clicked()), this, SLOT(slotWhatsThis()));
128
129 _buttonCancel = new QPushButton(tr("Cancel"), this);
130 connect(_buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
131
132 _buttonOK = new QPushButton(tr("OK"), this);
133 connect(_buttonOK, SIGNAL(clicked()), this, SLOT(accept()));
134
135 _buttonOK->setDefault(true);
136
137 QHBoxLayout* buttonLayout = new QHBoxLayout;
138
139 buttonLayout->addWidget(_buttonWhatsThis);
140 buttonLayout->addStretch(1);
141 buttonLayout->addWidget(_buttonCancel);
142 buttonLayout->addWidget(_buttonOK);
143
144 mainLayout->addLayout(buttonLayout);
145}
146
147// Destructor
148////////////////////////////////////////////////////////////////////////////
149bncSerialPort::~bncSerialPort() {
150 delete _buttonCancel;
151 delete _buttonOK;
152 delete _buttonWhatsThis;
153}
154
155// Accept slot
156////////////////////////////////////////////////////////////////////////////
157void bncSerialPort::accept() {
158
159 QStringList* mountPoints = new QStringList;
160
161 QString _serialBaudRate = _serialBaudRateComboBox->currentText();
162 QString _serialFlowControl = _serialFlowControlComboBox->currentText();
163 QString _serialDataBits = _serialDataBitsComboBox->currentText();
164 QString _serialParity = _serialParityComboBox->currentText();
165 QString _serialStopBits = _serialStopBitsComboBox->currentText();
166
167 if ( !_serialMountpointLineEdit->text().isEmpty() &&
168 !_serialPortLineEdit->text().isEmpty() &&
169 !_serialFormatLineEdit->text().isEmpty() &&
170 !_serialLatLineEdit->text().isEmpty() &&
171 !_serialLonLineEdit->text().isEmpty() ) {
172 mountPoints->push_back("//"
173 + _serialPortLineEdit->text().replace("/","-").replace(QRegExp("^[-]"), "") + "-"
174 + _serialDataBits + "-"
175 + _serialParity + "-"
176 + _serialStopBits + "-"
177 + _serialFlowControl + "-"
178 + _serialBaudRate + "/"
179 + _serialMountpointLineEdit->text() + " "
180 + _serialFormatLineEdit->text() + " "
181 + _serialLatLineEdit->text() + " "
182 + _serialLonLineEdit->text() + " "
183 + "no S");
184 } else {
185 QMessageBox::warning(this, tr("Warning"),
186 tr("Incomplete settings"),
187 QMessageBox::Ok);
188 }
189
190 emit newMountPoints(mountPoints);
191
192 QDialog::accept();
193}
194
195// Whats This Help
196void bncSerialPort::slotWhatsThis() {
197QWhatsThis::enterWhatsThisMode();
198}
199
Note: See TracBrowser for help on using the repository browser.