source: ntrip/trunk/BNC/src/upload/bncephuploadcaster.cpp@ 6441

Last change on this file since 6441 was 6441, checked in by mervart, 9 years ago
File size: 2.9 KB
Line 
1/* -------------------------------------------------------------------------
2 * BKG NTRIP Server
3 * -------------------------------------------------------------------------
4 *
5 * Class: bncEphUploadCaster
6 *
7 * Purpose: Connection to NTRIP Caster for Ephemeris
8 *
9 * Author: L. Mervart
10 *
11 * Created: 03-Apr-2011
12 *
13 * Changes:
14 *
15 * -----------------------------------------------------------------------*/
16
17#include <iostream>
18#include <math.h>
19#include "bncephuploadcaster.h"
20#include "bncsettings.h"
21#include "RTCM3/ephEncoder.h"
22
23using namespace std;
24
25// Constructor
26////////////////////////////////////////////////////////////////////////////
27bncEphUploadCaster::bncEphUploadCaster() : bncEphUser(true) {
28 bncSettings settings;
29
30 QString mountpoint = settings.value("uploadEphMountpoint").toString();
31 if (mountpoint.isEmpty()) {
32 _ephUploadCaster = 0;
33 }
34 else {
35 QString outHost = settings.value("uploadEphHost").toString();
36 int outPort = settings.value("uploadEphPort").toInt();
37 QString password = settings.value("uploadEphPassword").toString();
38 int sampl = settings.value("uploadEphSample").toInt();
39
40 _ephUploadCaster = new bncUploadCaster(mountpoint, outHost, outPort,
41 password, -1, sampl);
42
43 connect(_ephUploadCaster, SIGNAL(newBytes(QByteArray,double)),
44 this, SIGNAL(newBytes(QByteArray,double)));
45
46 _ephUploadCaster->start();
47 }
48}
49
50// Destructor
51////////////////////////////////////////////////////////////////////////////
52bncEphUploadCaster::~bncEphUploadCaster() {
53 if (_ephUploadCaster) {
54 _ephUploadCaster->deleteSafely();
55 }
56}
57
58// List of Stored Ephemeris changed (virtual)
59////////////////////////////////////////////////////////////////////////////
60void bncEphUploadCaster::ephBufferChanged() {
61 if (_ephUploadCaster) {
62 QByteArray outBuffer;
63 QMapIterator<QString, t_ephPair*> it(_eph);
64 while (it.hasNext()) {
65 it.next();
66
67 t_eph* eph = it.value()->last;
68 unsigned char Array[80];
69 int size = 0;
70 t_ephGPS* ephGPS = dynamic_cast<t_ephGPS*>(eph);
71 t_ephGlo* ephGlo = dynamic_cast<t_ephGlo*>(eph);
72 t_ephGal* ephGal = dynamic_cast<t_ephGal*>(eph);
73 t_ephSBAS* ephSBAS = dynamic_cast<t_ephSBAS*>(eph);
74 t_ephCompass* ephCompass = dynamic_cast<t_ephCompass*>(eph);
75 if (ephGPS) {
76 size = t_ephEncoder::RTCM3(*ephGPS, Array);
77 }
78 else if (ephGlo) {
79 size = t_ephEncoder::RTCM3(*ephGlo, Array);
80 }
81 else if (ephGal) {
82 size = t_ephEncoder::RTCM3(*ephGal, Array);
83 }
84 else if (ephSBAS) {
85 size = t_ephEncoder::RTCM3(*ephSBAS, Array);
86 }
87 else if (ephCompass) {
88 size = t_ephEncoder::RTCM3(*ephCompass, Array);
89 }
90 if (size > 0) {
91 outBuffer += QByteArray((char*) Array, size);
92 }
93 }
94 if (outBuffer.size() > 0) {
95 _ephUploadCaster->setOutBuffer(outBuffer);
96 }
97 }
98}
Note: See TracBrowser for help on using the repository browser.