1 | /* -------------------------------------------------------------------------
|
---|
2 | * BKG NTRIP Server
|
---|
3 | * -------------------------------------------------------------------------
|
---|
4 | *
|
---|
5 | * Class: bns
|
---|
6 | *
|
---|
7 | * Purpose: This class implements the main application behaviour
|
---|
8 | *
|
---|
9 | * Author: L. Mervart
|
---|
10 | *
|
---|
11 | * Created: 29-Mar-2008
|
---|
12 | *
|
---|
13 | * Changes:
|
---|
14 | *
|
---|
15 | * -----------------------------------------------------------------------*/
|
---|
16 |
|
---|
17 | #include <iostream>
|
---|
18 |
|
---|
19 | #include "bns.h"
|
---|
20 |
|
---|
21 | using namespace std;
|
---|
22 |
|
---|
23 | // Constructor
|
---|
24 | ////////////////////////////////////////////////////////////////////////////
|
---|
25 | t_bns::t_bns(QObject* parent) : QThread(parent) {
|
---|
26 |
|
---|
27 | _bnseph = new t_bnseph(parent);
|
---|
28 |
|
---|
29 | connect(_bnseph, SIGNAL(newMessage(QByteArray)),
|
---|
30 | this, SLOT(slotMessage(const QByteArray)));
|
---|
31 |
|
---|
32 | connect(_bnseph, SIGNAL(error(QByteArray)),
|
---|
33 | this, SLOT(slotError(const QByteArray)));
|
---|
34 | }
|
---|
35 |
|
---|
36 | // Destructor
|
---|
37 | ////////////////////////////////////////////////////////////////////////////
|
---|
38 | t_bns::~t_bns() {
|
---|
39 | deleteBnsEph();
|
---|
40 | }
|
---|
41 |
|
---|
42 | // Delete bns thread
|
---|
43 | ////////////////////////////////////////////////////////////////////////////
|
---|
44 | void t_bns::deleteBnsEph() {
|
---|
45 | if (_bnseph) {
|
---|
46 | _bnseph->terminate();
|
---|
47 | _bnseph->wait();
|
---|
48 | delete _bnseph;
|
---|
49 | _bnseph = 0;
|
---|
50 | }
|
---|
51 | }
|
---|
52 |
|
---|
53 | // Write a Program Message
|
---|
54 | ////////////////////////////////////////////////////////////////////////////
|
---|
55 | void t_bns::slotMessage(const QByteArray msg) {
|
---|
56 | cout << msg.data() << endl;
|
---|
57 | emit(newMessage(msg));
|
---|
58 | }
|
---|
59 |
|
---|
60 | // Write a Program Message
|
---|
61 | ////////////////////////////////////////////////////////////////////////////
|
---|
62 | void t_bns::slotError(const QByteArray msg) {
|
---|
63 | cerr << msg.data() << endl;
|
---|
64 | deleteBnsEph();
|
---|
65 | emit(error(msg));
|
---|
66 | }
|
---|
67 |
|
---|
68 | // Start
|
---|
69 | ////////////////////////////////////////////////////////////////////////////
|
---|
70 | void t_bns::run() {
|
---|
71 | slotMessage("============ Start BNS ============");
|
---|
72 | _bnseph->start();
|
---|
73 | }
|
---|
74 |
|
---|