[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 |
|
---|
| 23 | using namespace std;
|
---|
| 24 |
|
---|
| 25 | // Constructor
|
---|
| 26 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6441] | 27 | bncEphUploadCaster::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(",");
|
---|
[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 | }
|
---|
[3248] | 51 | }
|
---|
| 52 |
|
---|
| 53 | // Destructor
|
---|
| 54 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 55 | bncEphUploadCaster::~bncEphUploadCaster() {
|
---|
[7889] | 56 | for (int ic = 0; ic < _casters.size(); ic++) {
|
---|
| 57 | _casters[ic]->deleteSafely();
|
---|
[3255] | 58 | }
|
---|
[3248] | 59 | }
|
---|
| 60 |
|
---|
| 61 | // List of Stored Ephemeris changed (virtual)
|
---|
| 62 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 63 | void bncEphUploadCaster::ephBufferChanged() {
|
---|
[7889] | 64 | bncSettings settings;
|
---|
| 65 | int iRow = -1;
|
---|
| 66 | QListIterator<QString> it(settings.value("uploadEphMountpointsOut").toStringList());
|
---|
| 67 | while (it.hasNext()) {
|
---|
| 68 | QStringList hlp = it.next().split(",");
|
---|
| 69 | if (hlp.size() > 3) {
|
---|
| 70 | ++iRow;
|
---|
[8352] | 71 | QString system = hlp[6];
|
---|
[7889] | 72 | QByteArray outBuffer;
|
---|
[6443] | 73 |
|
---|
[7889] | 74 | QDateTime now = currentDateAndTimeGPS();
|
---|
| 75 | bncTime currentTime(now.toString(Qt::ISODate).toStdString());
|
---|
[7716] | 76 |
|
---|
[7889] | 77 | QListIterator<QString> it(prnList());
|
---|
| 78 | while (it.hasNext()) {
|
---|
| 79 | const t_eph* eph = ephLast(it.next());
|
---|
[3256] | 80 |
|
---|
[7889] | 81 | bncTime toc = eph->TOC();
|
---|
| 82 | double timeDiff = fabs(toc - currentTime);
|
---|
[7716] | 83 |
|
---|
[7889] | 84 | const t_ephGPS* ephGPS = dynamic_cast<const t_ephGPS*>(eph);
|
---|
| 85 | const t_ephGlo* ephGlo = dynamic_cast<const t_ephGlo*>(eph);
|
---|
| 86 | const t_ephGal* ephGal = dynamic_cast<const t_ephGal*>(eph);
|
---|
| 87 | const t_ephSBAS* ephSBAS = dynamic_cast<const t_ephSBAS*>(eph);
|
---|
| 88 | const t_ephBDS* ephBDS = dynamic_cast<const t_ephBDS*>(eph);
|
---|
[6443] | 89 |
|
---|
[7889] | 90 | unsigned char Array[80];
|
---|
| 91 | int size = 0;
|
---|
[6443] | 92 |
|
---|
[8904] | 93 | if (ephGPS && ephGPS->type() == t_eph::GPS && (system == "ALL" || system == "GPS")) {
|
---|
[7889] | 94 | if (timeDiff <= 4*3600) {
|
---|
| 95 | size = t_ephEncoder::RTCM3(*ephGPS, Array);
|
---|
| 96 | }
|
---|
[7716] | 97 | }
|
---|
[8904] | 98 | else if (ephGPS && ephGPS->type() == t_eph::QZSS && (system == "ALL" || system == "QZSS")) {
|
---|
[7889] | 99 | if (timeDiff <= 4*3600) {
|
---|
| 100 | size = t_ephEncoder::RTCM3(*ephGPS, Array);
|
---|
| 101 | }
|
---|
[7716] | 102 | }
|
---|
[7889] | 103 | else if (ephGlo && (system == "ALL" || system == "GLONASS")) {
|
---|
| 104 | if (timeDiff <= 1*3600) {
|
---|
| 105 | size = t_ephEncoder::RTCM3(*ephGlo, Array);
|
---|
| 106 | }
|
---|
[7716] | 107 | }
|
---|
[7889] | 108 | else if (ephGal && (system == "ALL" || system == "Galileo")) {
|
---|
[8904] | 109 | if (timeDiff <= 2*3600) {
|
---|
[7889] | 110 | size = t_ephEncoder::RTCM3(*ephGal, Array);
|
---|
| 111 | }
|
---|
[7716] | 112 | }
|
---|
[7889] | 113 | else if (ephSBAS && (system == "ALL" || system == "SBAS")) {
|
---|
[8904] | 114 | if (timeDiff <= 1*3600) {
|
---|
[7889] | 115 | size = t_ephEncoder::RTCM3(*ephSBAS, Array);
|
---|
| 116 | }
|
---|
[7716] | 117 | }
|
---|
[7889] | 118 | else if (ephBDS && (system == "ALL" || system == "BDS")) {
|
---|
| 119 | if (timeDiff <= 6*3600) {
|
---|
| 120 | size = t_ephEncoder::RTCM3(*ephBDS, Array);
|
---|
| 121 | }
|
---|
| 122 | }
|
---|
[8904] | 123 | else if (ephGPS && ephGPS->type() == t_eph::IRNSS && (system == "ALL" || system == "IRNSS")) {
|
---|
| 124 | if (timeDiff <= 24*3600) {
|
---|
| 125 | size = t_ephEncoder::RTCM3(*ephGPS, Array);
|
---|
| 126 | }
|
---|
| 127 | }
|
---|
[7889] | 128 | if (size > 0) {
|
---|
| 129 | outBuffer += QByteArray((char*) Array, size);
|
---|
| 130 | }
|
---|
[6403] | 131 | }
|
---|
[7889] | 132 | if (outBuffer.size() > 0) {
|
---|
| 133 | _casters.at(iRow)->setOutBuffer(outBuffer);
|
---|
[3256] | 134 | }
|
---|
| 135 | }
|
---|
[3255] | 136 | }
|
---|
[3248] | 137 | }
|
---|