source: ntrip/trunk/BNS/bnseph.cpp@ 759

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

* empty log message *

File size: 1.5 KB
Line 
1/* -------------------------------------------------------------------------
2 * BKG NTRIP Server
3 * -------------------------------------------------------------------------
4 *
5 * Class: bnseph
6 *
7 * Purpose: Retrieve broadcast ephemeris from BNC
8 *
9 * Author: L. Mervart
10 *
11 * Created: 29-Mar-2008
12 *
13 * Changes:
14 *
15 * -----------------------------------------------------------------------*/
16
17#include "bnseph.h"
18
19using namespace std;
20
21// Constructor
22////////////////////////////////////////////////////////////////////////////
23t_bnseph::t_bnseph(QObject* parent) : QThread(parent) {
24 _socket = 0;
25}
26
27// Destructor
28////////////////////////////////////////////////////////////////////////////
29t_bnseph::~t_bnseph() {
30 delete _socket;
31}
32
33// Start
34////////////////////////////////////////////////////////////////////////////
35void t_bnseph::run() {
36
37 emit(newMessage("bnseph::run Start"));
38
39 // Connect the Socket
40 // ------------------
41 QSettings settings;
42 QString host = settings.value("ephHost").toString();
43 int port = settings.value("ephPort").toInt();
44
45 _socket = new QTcpSocket();
46 _socket->connectToHost(host, port);
47
48 const int timeOut = 10*1000; // 10 seconds
49 if (!_socket->waitForConnected(timeOut)) {
50 emit(newMessage("bnseph::run Connect Timeout"));
51 delete _socket; _socket = 0;
52 return;
53 }
54
55 while (true) {
56 if (_socket->canReadLine()) {
57 QByteArray line = _socket->readLine();
58 emit(newMessage(line));
59 }
60 else {
61 _socket->waitForReadyRead(10);
62 }
63 }
64}
65
Note: See TracBrowser for help on using the repository browser.