source: ntrip/branches/BNC_2.12/src/bncserialport.cpp@ 7956

Last change on this file since 7956 was 7673, checked in by weber, 8 years ago

Documentation completed

File size: 9.9 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 _serialCountryLineEdit = new QLineEdit();
68
69 _serialBaudRateComboBox->addItems(QString("110,300,600,"
70 "1200,2400,4800,9600,19200,38400,57600,115200").split(","));
71 _serialFlowControlComboBox->addItems(QString("OFF,XONXOFF,HARDWARE").split(","));
72 _serialDataBitsComboBox->addItems(QString("5,6,7,8").split(","));
73 _serialParityComboBox->addItems(QString("NONE,ODD,EVEN,SPACE").split(","));
74 _serialStopBitsComboBox->addItems(QString("1,2").split(","));
75
76 _serialBaudRateComboBox->setCurrentIndex(7);
77 _serialDataBitsComboBox->setCurrentIndex(3);
78
79 int ww = QFontMetrics(font()).width('w');
80 _serialMountpointLineEdit->setMaximumWidth(11*ww);
81 _serialPortLineEdit->setMaximumWidth(11*ww);
82 _serialBaudRateComboBox->setMaximumWidth(9*ww);
83 _serialFlowControlComboBox->setMaximumWidth(11*ww);
84 _serialDataBitsComboBox->setMaximumWidth(5*ww);
85 _serialParityComboBox->setMaximumWidth(9*ww);
86 _serialStopBitsComboBox->setMaximumWidth(5*ww);
87 _serialLatLineEdit->setMaximumWidth(11*ww);
88 _serialLonLineEdit->setMaximumWidth(9*ww);
89 _serialFormatLineEdit->setMaximumWidth(9*ww);
90 _serialCountryLineEdit->setMaximumWidth(11*ww);
91
92 // WhatsThis, Add Stream from Serial Port
93 // --------------------------------------
94 _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>"));
95 _serialFormatLineEdit->setWhatsThis(tr("<p>Specify the stream format.</p><p>Available options are 'RTCM_2', 'RTCM_3', 'RTNET', and 'ZERO'.</p>"));
96 _serialLatLineEdit->setWhatsThis(tr("<p>Enter the approximate latitude of the stream providing receiver in degrees.<p></p>Example: 45.32</p>"));
97 _serialLonLineEdit->setWhatsThis(tr("<p>Enter the approximate latitude of the stream providing receiver in degrees.<p></p>Example: 45.32</p>"));
98 _serialCountryLineEdit->setWhatsThis(tr("<p>Specify the country code.</p><p>Follow the ISO 3166-1 alpha-3a code.<br>Example, Germany: DEU</p>"));
99 _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>You must plug a serial cable in the port defined here before you start BNC.</p>"));
100 _serialBaudRateComboBox->setWhatsThis(tr("<p>Select a 'Baud rate' for the serial input link.</p><p>Your selection must equal the baud rate configured to the serial connected device. Note that using a high baud rate is recommended.</p>"));
101 _serialDataBitsComboBox->setWhatsThis(tr("<p>Select the number of 'Data bits' for the serial input link.</p><p>Your selection must equal the number of data bits configured to the serial connected device. Note that often 8 data bits are used.</p>"));
102 _serialParityComboBox->setWhatsThis(tr("<p>Select the 'Parity' for the serial input link.</p><p>Your selection must equal the parity selection configured to the serial connected device. Note that parity is often set to 'NONE'.</p>"));
103 _serialStopBitsComboBox->setWhatsThis(tr("<p>Select the number of 'Stop bits' for the serial input link.</p><p>Your selection must equal the number of stop bits configured to the serial connected device. Note that often 1 stop bit is used.</p>"));
104 _serialFlowControlComboBox->setWhatsThis(tr("<p>Select a 'Flow control' for the serial input link.</p><p>Your selection must equal the flow control configured to the serial connected device. Select 'OFF' if you don't know better.</p>"));
105
106 editLayout->addWidget(new QLabel(tr("Mountpoint")), 0, 0, Qt::AlignRight);
107 editLayout->addWidget(_serialMountpointLineEdit, 0, 1);
108 editLayout->addWidget(new QLabel(tr("Format")), 0, 2, Qt::AlignRight);
109 editLayout->addWidget(_serialFormatLineEdit, 0, 3);
110 editLayout->addWidget(new QLabel(tr("Latitude")), 1, 0, Qt::AlignRight);
111 editLayout->addWidget(_serialLatLineEdit, 1, 1);
112 editLayout->addWidget(new QLabel(tr("Longitude")), 1, 2, Qt::AlignRight);
113 editLayout->addWidget(_serialLonLineEdit, 1, 3);
114 editLayout->addWidget(new QLabel(tr("Country")), 2, 0, Qt::AlignRight);
115 editLayout->addWidget(_serialCountryLineEdit, 2, 1);
116 editLayout->addWidget(new QLabel(tr("Port name")), 3, 0, Qt::AlignRight);
117 editLayout->addWidget(_serialPortLineEdit, 3, 1);
118 editLayout->addWidget(new QLabel(tr("Baud rate")), 3, 2, Qt::AlignRight);
119 editLayout->addWidget(_serialBaudRateComboBox, 3, 3);
120 editLayout->addWidget(new QLabel(tr("Data bits")), 4, 0, Qt::AlignRight);
121 editLayout->addWidget(_serialDataBitsComboBox, 4, 1);
122 editLayout->addWidget(new QLabel(tr("Parity")), 4, 2, Qt::AlignRight);
123 editLayout->addWidget(_serialParityComboBox, 4, 3);
124 editLayout->addWidget(new QLabel(tr("Stop bits")), 5, 0, Qt::AlignRight);
125 editLayout->addWidget(_serialStopBitsComboBox, 5, 1);
126 editLayout->addWidget(new QLabel(tr("Flow control")),5, 2, Qt::AlignRight);
127 editLayout->addWidget(_serialFlowControlComboBox, 5, 3);
128
129 mainLayout->addLayout(editLayout);
130
131 _buttonWhatsThis = new QPushButton(tr("Help=Shift+F1"), this);
132 connect(_buttonWhatsThis, SIGNAL(clicked()), this, SLOT(slotWhatsThis()));
133
134 _buttonCancel = new QPushButton(tr("Cancel"), this);
135 connect(_buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
136
137 _buttonOK = new QPushButton(tr("OK"), this);
138 connect(_buttonOK, SIGNAL(clicked()), this, SLOT(accept()));
139
140 _buttonOK->setDefault(true);
141
142 QHBoxLayout* buttonLayout = new QHBoxLayout;
143
144 buttonLayout->addWidget(_buttonWhatsThis);
145 buttonLayout->addStretch(1);
146 buttonLayout->addWidget(_buttonCancel);
147 buttonLayout->addWidget(_buttonOK);
148
149 mainLayout->addLayout(buttonLayout);
150}
151
152// Destructor
153////////////////////////////////////////////////////////////////////////////
154bncSerialPort::~bncSerialPort() {
155 delete _buttonCancel;
156 delete _buttonOK;
157 delete _buttonWhatsThis;
158}
159
160// Accept slot
161////////////////////////////////////////////////////////////////////////////
162void bncSerialPort::accept() {
163
164 QStringList* mountPoints = new QStringList;
165
166 QString _serialBaudRate = _serialBaudRateComboBox->currentText();
167 QString _serialFlowControl = _serialFlowControlComboBox->currentText();
168 QString _serialDataBits = _serialDataBitsComboBox->currentText();
169 QString _serialParity = _serialParityComboBox->currentText();
170 QString _serialStopBits = _serialStopBitsComboBox->currentText();
171
172 if ( !_serialMountpointLineEdit->text().isEmpty() &&
173 !_serialPortLineEdit->text().isEmpty() &&
174 !_serialFormatLineEdit->text().isEmpty() &&
175 !_serialCountryLineEdit->text().isEmpty() &&
176 !_serialLatLineEdit->text().isEmpty() &&
177 !_serialLonLineEdit->text().isEmpty() ) {
178 mountPoints->push_back("//"
179 + _serialPortLineEdit->text().replace("/","-").replace(QRegExp("^[-]"), "") + "-"
180 + _serialDataBits + "-"
181 + _serialParity + "-"
182 + _serialStopBits + "-"
183 + _serialFlowControl + "-"
184 + _serialBaudRate + "/"
185 + _serialMountpointLineEdit->text() + " "
186 + _serialFormatLineEdit->text() + " "
187 + _serialCountryLineEdit->text() + " "
188 + _serialLatLineEdit->text() + " "
189 + _serialLonLineEdit->text() + " "
190 + "no S");
191 } else {
192 QMessageBox::warning(this, tr("Warning"),
193 tr("Incomplete settings"),
194 QMessageBox::Ok);
195 }
196
197 emit newMountPoints(mountPoints);
198
199 QDialog::accept();
200}
201
202// Whats This Help
203void bncSerialPort::slotWhatsThis() {
204QWhatsThis::enterWhatsThisMode();
205}
206
Note: See TracBrowser for help on using the repository browser.