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

Last change on this file since 8275 was 8275, checked in by stuerze, 6 years ago

some preparation to allow Ntrip version 2 stream upload in future

File size: 4.3 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 int sampl = settings.value("uploadSamplRtcmEph").toInt();
30
31 // List of upload casters
32 // ----------------------
33 int iRow = -1;
34 QListIterator<QString> it(settings.value("uploadEphMountpointsOut").toStringList());
35 while (it.hasNext()) {
36 QStringList hlp = it.next().split(",");
37 if (hlp.size() > 5) {
38 ++iRow;
39 int outPort = hlp[1].toInt();
40 bncUploadCaster* newCaster = new bncUploadCaster(hlp[2], hlp[0], outPort,
41 hlp[3], hlp[4],
42 hlp[5], iRow, sampl);
43
44 connect(newCaster, SIGNAL(newBytes(QByteArray,double)),
45 this, SIGNAL(newBytes(QByteArray,double)));
46
47 newCaster->start();
48 _casters.push_back(newCaster);
49 }
50 }
51}
52
53// Destructor
54////////////////////////////////////////////////////////////////////////////
55bncEphUploadCaster::~bncEphUploadCaster() {
56 for (int ic = 0; ic < _casters.size(); ic++) {
57 _casters[ic]->deleteSafely();
58 }
59}
60
61// List of Stored Ephemeris changed (virtual)
62////////////////////////////////////////////////////////////////////////////
63void bncEphUploadCaster::ephBufferChanged() {
64 bncSettings settings;
65 int iRow = -1;
66 QListIterator<QString> it(settings.value("uploadEphMountpointsOut").toStringList());
67 while (it.hasNext()) {
68 QStringList hlp = it.next().split(",");
69 if (hlp.size() > 3) {
70 ++iRow;
71 QString system = hlp[4];
72 QByteArray outBuffer;
73
74 QDateTime now = currentDateAndTimeGPS();
75 bncTime currentTime(now.toString(Qt::ISODate).toStdString());
76
77 QListIterator<QString> it(prnList());
78 while (it.hasNext()) {
79 const t_eph* eph = ephLast(it.next());
80
81 bncTime toc = eph->TOC();
82 double timeDiff = fabs(toc - currentTime);
83
84 const t_ephGPS* ephGPS = dynamic_cast<const t_ephGPS*>(eph);
85 const t_ephGlo* ephGlo = dynamic_cast<const t_ephGlo*>(eph);
86 const t_ephGal* ephGal = dynamic_cast<const t_ephGal*>(eph);
87 const t_ephSBAS* ephSBAS = dynamic_cast<const t_ephSBAS*>(eph);
88 const t_ephBDS* ephBDS = dynamic_cast<const t_ephBDS*>(eph);
89
90 unsigned char Array[80];
91 int size = 0;
92
93 if (ephGPS && ephGPS->type() == t_eph::GPS &&
94 (system == "ALL" || system == "GPS")) {
95 if (timeDiff <= 4*3600) {
96 size = t_ephEncoder::RTCM3(*ephGPS, Array);
97 }
98 }
99 else if (ephGPS && ephGPS->type() == t_eph::QZSS &&
100 (system == "ALL" || system == "QZSS")) {
101 if (timeDiff <= 4*3600) {
102 size = t_ephEncoder::RTCM3(*ephGPS, Array);
103 }
104 }
105 else if (ephGlo && (system == "ALL" || system == "GLONASS")) {
106 if (timeDiff <= 1*3600) {
107 size = t_ephEncoder::RTCM3(*ephGlo, Array);
108 }
109 }
110 else if (ephGal && (system == "ALL" || system == "Galileo")) {
111 if (timeDiff <= 4*3600) {
112 size = t_ephEncoder::RTCM3(*ephGal, Array);
113 }
114 }
115 else if (ephSBAS && (system == "ALL" || system == "SBAS")) {
116 if (timeDiff <= 600) {
117 size = t_ephEncoder::RTCM3(*ephSBAS, Array);
118 }
119 }
120 else if (ephBDS && (system == "ALL" || system == "BDS")) {
121 if (timeDiff <= 6*3600) {
122 size = t_ephEncoder::RTCM3(*ephBDS, Array);
123 }
124 }
125 if (size > 0) {
126 outBuffer += QByteArray((char*) Array, size);
127 }
128 }
129 if (outBuffer.size() > 0) {
130 _casters.at(iRow)->setOutBuffer(outBuffer);
131 }
132 }
133 }
134}
Note: See TracBrowser for help on using the repository browser.