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

Last change on this file since 11215 was 11215, checked in by stuerze, 2 weeks ago

Upload Ephemeris: majority vote included

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