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

Last change on this file since 7905 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
RevLine 
[3248]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 *
[7716]13 * Changes:
[3248]14 *
15 * -----------------------------------------------------------------------*/
16
[3258]17#include <iostream>
[3248]18#include <math.h>
[7716]19#include "bncephuploadcaster.h"
[3253]20#include "bncsettings.h"
[5855]21#include "RTCM3/ephEncoder.h"
[3248]22
23using namespace std;
24
25// Constructor
26////////////////////////////////////////////////////////////////////////////
[6441]27bncEphUploadCaster::bncEphUploadCaster() : bncEphUser(true) {
[3253]28 bncSettings settings;
[7889]29 int sampl = settings.value("uploadSamplRtcmEph").toInt();
[3253]30
[7889]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);
[3253]42
[7889]43 connect(newCaster, SIGNAL(newBytes(QByteArray,double)),
44 this, SIGNAL(newBytes(QByteArray,double)));
[3254]45
[7889]46 newCaster->start();
47 _casters.push_back(newCaster);
48 }
[3255]49 }
[3248]50}
51
52// Destructor
53////////////////////////////////////////////////////////////////////////////
54bncEphUploadCaster::~bncEphUploadCaster() {
[7889]55 for (int ic = 0; ic < _casters.size(); ic++) {
56 _casters[ic]->deleteSafely();
[3255]57 }
[3248]58}
59
60// List of Stored Ephemeris changed (virtual)
61////////////////////////////////////////////////////////////////////////////
62void bncEphUploadCaster::ephBufferChanged() {
[7889]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;
[6443]72
[7889]73 QDateTime now = currentDateAndTimeGPS();
74 bncTime currentTime(now.toString(Qt::ISODate).toStdString());
[7716]75
[7889]76 QListIterator<QString> it(prnList());
77 while (it.hasNext()) {
78 const t_eph* eph = ephLast(it.next());
[3256]79
[7889]80 bncTime toc = eph->TOC();
81 double timeDiff = fabs(toc - currentTime);
[7716]82
[7889]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);
[6443]88
[7889]89 unsigned char Array[80];
90 int size = 0;
[6443]91
[7889]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 }
[7716]97 }
[7889]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 }
[7716]103 }
[7889]104 else if (ephGlo && (system == "ALL" || system == "GLONASS")) {
105 if (timeDiff <= 1*3600) {
106 size = t_ephEncoder::RTCM3(*ephGlo, Array);
107 }
[7716]108 }
[7889]109 else if (ephGal && (system == "ALL" || system == "Galileo")) {
110 if (timeDiff <= 4*3600) {
111 size = t_ephEncoder::RTCM3(*ephGal, Array);
112 }
[7716]113 }
[7889]114 else if (ephSBAS && (system == "ALL" || system == "SBAS")) {
115 if (timeDiff <= 600) {
116 size = t_ephEncoder::RTCM3(*ephSBAS, Array);
117 }
[7716]118 }
[7889]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 }
[6403]127 }
[7889]128 if (outBuffer.size() > 0) {
129 _casters.at(iRow)->setOutBuffer(outBuffer);
[3256]130 }
131 }
[3255]132 }
[3248]133}
Note: See TracBrowser for help on using the repository browser.