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

Last change on this file since 7933 was 7889, checked in by stuerze, 9 years ago

BNC's ephemeris upload is extended to allows an upload of more than one stream and to choose a single satellite system

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