source: ntrip/branches/BNC_2.12/src/upload/bncephuploadcaster.cpp@ 9407

Last change on this file since 9407 was 9407, checked in by stuerze, 3 years ago

eph checks harmonized

File size: 3.8 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;
29
30 QString mountpoint = settings.value("uploadEphMountpoint").toString();
[3255]31 if (mountpoint.isEmpty()) {
32 _ephUploadCaster = 0;
33 }
34 else {
[3273]35 QString outHost = settings.value("uploadEphHost").toString();
36 int outPort = settings.value("uploadEphPort").toInt();
37 QString password = settings.value("uploadEphPassword").toString();
[4813]38 int sampl = settings.value("uploadEphSample").toInt();
[3253]39
[7716]40 _ephUploadCaster = new bncUploadCaster(mountpoint, outHost, outPort,
[3273]41 password, -1, sampl);
[3254]42
[7716]43 connect(_ephUploadCaster, SIGNAL(newBytes(QByteArray,double)),
[3254]44 this, SIGNAL(newBytes(QByteArray,double)));
45
[3255]46 _ephUploadCaster->start();
47 }
[3248]48}
49
50// Destructor
51////////////////////////////////////////////////////////////////////////////
52bncEphUploadCaster::~bncEphUploadCaster() {
[3255]53 if (_ephUploadCaster) {
54 _ephUploadCaster->deleteSafely();
55 }
[3248]56}
57
58// List of Stored Ephemeris changed (virtual)
59////////////////////////////////////////////////////////////////////////////
60void bncEphUploadCaster::ephBufferChanged() {
[9407]61 if (_ephUploadCaster) {
62 QByteArray outBuffer;
[6443]63
[9407]64 QDateTime now = currentDateAndTimeGPS();
65 bncTime currentTime(now.toString(Qt::ISODate).toStdString());
[7716]66
[9407]67 QListIterator < QString > it(prnList());
68 while (it.hasNext()) {
69 const t_eph *eph = ephLast(it.next());
[3256]70
[9407]71 bncTime toc = eph->TOC();
72 double dt = currentTime - toc;
[7716]73
[9407]74 const t_ephGPS *ephGPS = dynamic_cast<const t_ephGPS*>(eph);
75 const t_ephGlo *ephGlo = dynamic_cast<const t_ephGlo*>(eph);
76 const t_ephGal *ephGal = dynamic_cast<const t_ephGal*>(eph);
77 const t_ephSBAS *ephSBAS = dynamic_cast<const t_ephSBAS*>(eph);
78 const t_ephBDS *ephBDS = dynamic_cast<const t_ephBDS*>(eph);
[6443]79
[9407]80 unsigned char Array[80];
81 int size = 0;
[6443]82
[9407]83 if (ephGPS && ephGPS->type() == t_eph::GPS && (system == "ALL" || system == "GPS")) {
84 if (dt > 14400.0 || dt < -7200.0) {
85 size = t_ephEncoder::RTCM3(*ephGPS, Array);
86 }
87 } else if (ephGPS && ephGPS->type() == t_eph::QZSS && (system == "ALL" || system == "QZSS")) {
88 if (dt > 7200.0 || dt < -3600.0) {
89 size = t_ephEncoder::RTCM3(*ephGPS, Array);
90 }
91 } else if (ephGlo && (system == "ALL" || system == "GLONASS")) {
92 if (dt > 3900.0 || dt < -2100.0) {
93 size = t_ephEncoder::RTCM3(*ephGlo, Array);
94 }
95 } else if (ephGal && (system == "ALL" || system == "Galileo")) {
96 if (dt > 14400.0 || dt < 0.0) {
97 size = t_ephEncoder::RTCM3(*ephGal, Array);
98 }
99 } else if (ephSBAS && (system == "ALL" || system == "SBAS")) {
100 if (dt > 600.0 || dt < -600.0) {
101 size = t_ephEncoder::RTCM3(*ephSBAS, Array);
102 }
103 } else if (ephBDS && (system == "ALL" || system == "BDS")) {
104 if (dt > 3900.0 || dt < 0.0) {
105 size = t_ephEncoder::RTCM3(*ephBDS, Array);
106 }
107 } else if (ephGPS && ephGPS->type() == t_eph::IRNSS && (system == "ALL" || system == "IRNSS")) {
108 if (fabs(dt > 86400.0)) {
109 size = t_ephEncoder::RTCM3(*ephGPS, Array);
110 }
111 }
112 if (size > 0) {
113 outBuffer += QByteArray((char*) Array, size);
114 }
115 }
116 if (outBuffer.size() > 0) {
117 _ephUploadCaster->setOutBuffer(outBuffer);
118 }
119 }
[3248]120}
Note: See TracBrowser for help on using the repository browser.