[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 | *
|
---|
| 13 | * Changes:
|
---|
| 14 | *
|
---|
| 15 | * -----------------------------------------------------------------------*/
|
---|
| 16 |
|
---|
[3258] | 17 | #include <iostream>
|
---|
[3248] | 18 | #include <math.h>
|
---|
| 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;
|
---|
| 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 |
|
---|
[3255] | 40 | _ephUploadCaster = new bncUploadCaster(mountpoint, outHost, outPort,
|
---|
[3273] | 41 | password, -1, sampl);
|
---|
[3254] | 42 |
|
---|
[3255] | 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 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 52 | bncEphUploadCaster::~bncEphUploadCaster() {
|
---|
[3255] | 53 | if (_ephUploadCaster) {
|
---|
| 54 | _ephUploadCaster->deleteSafely();
|
---|
| 55 | }
|
---|
[3248] | 56 | }
|
---|
| 57 |
|
---|
| 58 | // List of Stored Ephemeris changed (virtual)
|
---|
| 59 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 60 | void bncEphUploadCaster::ephBufferChanged() {
|
---|
[3255] | 61 | if (_ephUploadCaster) {
|
---|
[3259] | 62 | QByteArray outBuffer;
|
---|
[6443] | 63 |
|
---|
| 64 | QListIterator<QString> it(prnList());
|
---|
[3256] | 65 | while (it.hasNext()) {
|
---|
[6443] | 66 | const t_eph* eph = ephLast(it.next());
|
---|
[3256] | 67 |
|
---|
[6443] | 68 | const t_ephGPS* ephGPS = dynamic_cast<const t_ephGPS*>(eph);
|
---|
| 69 | const t_ephGlo* ephGlo = dynamic_cast<const t_ephGlo*>(eph);
|
---|
| 70 | const t_ephGal* ephGal = dynamic_cast<const t_ephGal*>(eph);
|
---|
| 71 | const t_ephSBAS* ephSBAS = dynamic_cast<const t_ephSBAS*>(eph);
|
---|
| 72 | const t_ephCompass* ephCompass = dynamic_cast<const t_ephCompass*>(eph);
|
---|
| 73 |
|
---|
[3283] | 74 | unsigned char Array[80];
|
---|
[5855] | 75 | int size = 0;
|
---|
[6443] | 76 |
|
---|
[5855] | 77 | if (ephGPS) {
|
---|
| 78 | size = t_ephEncoder::RTCM3(*ephGPS, Array);
|
---|
| 79 | }
|
---|
| 80 | else if (ephGlo) {
|
---|
| 81 | size = t_ephEncoder::RTCM3(*ephGlo, Array);
|
---|
| 82 | }
|
---|
| 83 | else if (ephGal) {
|
---|
| 84 | size = t_ephEncoder::RTCM3(*ephGal, Array);
|
---|
| 85 | }
|
---|
[6403] | 86 | else if (ephSBAS) {
|
---|
| 87 | size = t_ephEncoder::RTCM3(*ephSBAS, Array);
|
---|
| 88 | }
|
---|
| 89 | else if (ephCompass) {
|
---|
| 90 | size = t_ephEncoder::RTCM3(*ephCompass, Array);
|
---|
| 91 | }
|
---|
[3256] | 92 | if (size > 0) {
|
---|
| 93 | outBuffer += QByteArray((char*) Array, size);
|
---|
| 94 | }
|
---|
| 95 | }
|
---|
[3259] | 96 | if (outBuffer.size() > 0) {
|
---|
| 97 | _ephUploadCaster->setOutBuffer(outBuffer);
|
---|
| 98 | }
|
---|
[3255] | 99 | }
|
---|
[3248] | 100 | }
|
---|