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

Last change on this file since 11215 was 11215, checked in by stuerze, 44 minutes ago

Upload Ephemeris: majority vote included

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