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

Last change on this file since 760 was 760, 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 = 3*1000; // 3 seconds
49 if (!_socket->waitForConnected(timeOut)) {
50 emit(error("bnseph::run Connect Timeout"));
51 }
52 else {
53 while (true) {
54 if (_socket->canReadLine()) {
55 QByteArray line = _socket->readLine();
56 emit(newMessage(line));
57 }
58 else {
59 _socket->waitForReadyRead(10);
60 }
61 }
62 }
63}
64
Note: See TracBrowser for help on using the repository browser.