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

Last change on this file since 11216 was 11216, checked in by stuerze, 13 days ago

Upload Ephemeris: majority vote approach improved

File size: 4.7 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;
[10754]29 int sampl = settings.value("uploadSamplRtcmEph").toInt();
[3253]30
[10754]31 // List of upload ephUploadCasters
32 // -------------------------------
[7889]33 int iRow = -1;
34 QListIterator<QString> it(settings.value("uploadEphMountpointsOut").toStringList());
35 while (it.hasNext()) {
36 QStringList hlp = it.next().split(",");
[8275]37 if (hlp.size() > 5) {
[7889]38 ++iRow;
39 int outPort = hlp[1].toInt();
40 bncUploadCaster* newCaster = new bncUploadCaster(hlp[2], hlp[0], outPort,
[8275]41 hlp[3], hlp[4],
42 hlp[5], iRow, sampl);
[3253]43
[7889]44 connect(newCaster, SIGNAL(newBytes(QByteArray,double)),
45 this, SIGNAL(newBytes(QByteArray,double)));
[3254]46
[7889]47 newCaster->start();
48 _casters.push_back(newCaster);
49 }
[3255]50 }
[11216]51
52 // vote (and hold back new data sets) only for an actual upload
53 if (!_casters.isEmpty()) {
54 enableVoting();
55 }
[3248]56}
57
58// Destructor
59////////////////////////////////////////////////////////////////////////////
60bncEphUploadCaster::~bncEphUploadCaster() {
[7889]61 for (int ic = 0; ic < _casters.size(); ic++) {
62 _casters[ic]->deleteSafely();
[3255]63 }
[3248]64}
65
66// List of Stored Ephemeris changed (virtual)
67////////////////////////////////////////////////////////////////////////////
68void bncEphUploadCaster::ephBufferChanged() {
[7889]69 bncSettings settings;
70 int iRow = -1;
71 QListIterator<QString> it(settings.value("uploadEphMountpointsOut").toStringList());
72 while (it.hasNext()) {
73 QStringList hlp = it.next().split(",");
74 if (hlp.size() > 3) {
75 ++iRow;
[8352]76 QString system = hlp[6];
[7889]77 QByteArray outBuffer;
[6443]78
[7889]79 QDateTime now = currentDateAndTimeGPS();
80 bncTime currentTime(now.toString(Qt::ISODate).toStdString());
[7716]81
[7889]82 QListIterator<QString> it(prnList());
83 while (it.hasNext()) {
[11216]84 const t_eph* eph = ephUpload(it.next());
[3256]85
[7889]86 bncTime toc = eph->TOC();
[9410]87 double dt = currentTime -toc;
[7716]88
[7889]89 const t_ephGPS* ephGPS = dynamic_cast<const t_ephGPS*>(eph);
90 const t_ephGlo* ephGlo = dynamic_cast<const t_ephGlo*>(eph);
91 const t_ephGal* ephGal = dynamic_cast<const t_ephGal*>(eph);
92 const t_ephSBAS* ephSBAS = dynamic_cast<const t_ephSBAS*>(eph);
93 const t_ephBDS* ephBDS = dynamic_cast<const t_ephBDS*>(eph);
[6443]94
[7889]95 unsigned char Array[80];
96 int size = 0;
[6443]97
[10587]98 if (ephGPS && ephGPS->system() == t_eph::GPS && (system == "ALL" || system.contains('G'))) {
[11137]99 if (dt < 14400.0 && dt > -7200.0) {
[7889]100 size = t_ephEncoder::RTCM3(*ephGPS, Array);
101 }
[7716]102 }
[10587]103 else if (ephGPS && ephGPS->system() == t_eph::QZSS && (system == "ALL" || system.contains('J'))) {
[11137]104 if (dt < 7200.0 && dt > -3600.0) {
[7889]105 size = t_ephEncoder::RTCM3(*ephGPS, Array);
106 }
[7716]107 }
[9436]108 else if (ephGlo && (system == "ALL" || system.contains('R'))) {
[11137]109 if (dt < 3900.0 && dt > -2100.0) {
[7889]110 size = t_ephEncoder::RTCM3(*ephGlo, Array);
111 }
[7716]112 }
[9436]113 else if (ephGal && (system == "ALL" || system.contains('E'))) {
[11137]114 if (dt < 14400.0 && dt > 0.0) {
[7889]115 size = t_ephEncoder::RTCM3(*ephGal, Array);
116 }
[7716]117 }
[9436]118 else if (ephSBAS && (system == "ALL" || system.contains('S'))) {
[11137]119 if (dt < 600.0 && dt > -600.0) {
[7889]120 size = t_ephEncoder::RTCM3(*ephSBAS, Array);
121 }
[7716]122 }
[9436]123 else if (ephBDS && (system == "ALL" || system.contains('C'))) {
[11137]124 if (dt < 3900.0 && dt > 0.0) {
[7889]125 size = t_ephEncoder::RTCM3(*ephBDS, Array);
126 }
127 }
[10619]128 else if (ephGPS && ephGPS->system() == t_eph::NavIC && (system == "ALL" || system.contains('I'))) {
[11137]129 if (fabs(dt) < 86400.0) {
[8904]130 size = t_ephEncoder::RTCM3(*ephGPS, Array);
131 }
132 }
[7889]133 if (size > 0) {
134 outBuffer += QByteArray((char*) Array, size);
135 }
[6403]136 }
[7889]137 if (outBuffer.size() > 0) {
138 _casters.at(iRow)->setOutBuffer(outBuffer);
[3256]139 }
140 }
[3255]141 }
[3248]142}
Note: See TracBrowser for help on using the repository browser.