| 1 | /* -------------------------------------------------------------------------
|
|---|
| 2 | * BKG NTRIP Server
|
|---|
| 3 | * -------------------------------------------------------------------------
|
|---|
| 4 | *
|
|---|
| 5 | * Class: bns
|
|---|
| 6 | *
|
|---|
| 7 | * Purpose: This class implements the main application behaviour
|
|---|
| 8 | *
|
|---|
| 9 | * Author: L. Mervart
|
|---|
| 10 | *
|
|---|
| 11 | * Created: 29-Mar-2008
|
|---|
| 12 | *
|
|---|
| 13 | * Changes:
|
|---|
| 14 | *
|
|---|
| 15 | * -----------------------------------------------------------------------*/
|
|---|
| 16 |
|
|---|
| 17 | #include <math.h>
|
|---|
| 18 | #include <iostream>
|
|---|
| 19 | #include <newmatio.h>
|
|---|
| 20 |
|
|---|
| 21 | #include "bns.h"
|
|---|
| 22 | #include "bnsutils.h"
|
|---|
| 23 | #include "bnsrinex.h"
|
|---|
| 24 | #include "bnssp3.h"
|
|---|
| 25 | #include "bnssettings.h"
|
|---|
| 26 |
|
|---|
| 27 | using namespace std;
|
|---|
| 28 |
|
|---|
| 29 | // Constructor
|
|---|
| 30 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 31 | t_bns::t_bns(QObject* parent) : QThread(parent) {
|
|---|
| 32 |
|
|---|
| 33 | this->setTerminationEnabled(true);
|
|---|
| 34 |
|
|---|
| 35 | connect(this, SIGNAL(moveSocket(QThread*)),
|
|---|
| 36 | this, SLOT(slotMoveSocket(QThread*)));
|
|---|
| 37 |
|
|---|
| 38 | bnsSettings settings;
|
|---|
| 39 |
|
|---|
| 40 | // Set Proxy (application-wide)
|
|---|
| 41 | // ----------------------------
|
|---|
| 42 | QString proxyHost = settings.value("proxyHost").toString();
|
|---|
| 43 | int proxyPort = settings.value("proxyPort").toInt();
|
|---|
| 44 |
|
|---|
| 45 | QNetworkProxy proxy;
|
|---|
| 46 | if (proxyHost.isEmpty()) {
|
|---|
| 47 | proxy.setType(QNetworkProxy::NoProxy);
|
|---|
| 48 | }
|
|---|
| 49 | else {
|
|---|
| 50 | proxy.setType(QNetworkProxy::Socks5Proxy);
|
|---|
| 51 | proxy.setHostName(proxyHost);
|
|---|
| 52 | proxy.setPort(proxyPort);
|
|---|
| 53 | }
|
|---|
| 54 | QNetworkProxy::setApplicationProxy(proxy);
|
|---|
| 55 |
|
|---|
| 56 | // Thread that handles broadcast ephemeris
|
|---|
| 57 | // ---------------------------------------
|
|---|
| 58 | _bnseph = new t_bnseph(parent);
|
|---|
| 59 |
|
|---|
| 60 | connect(_bnseph, SIGNAL(newEph(t_eph*, int)),
|
|---|
| 61 | this, SLOT(slotNewEph(t_eph*, int)));
|
|---|
| 62 | connect(_bnseph, SIGNAL(newMessage(QByteArray)),
|
|---|
| 63 | this, SLOT(slotMessage(const QByteArray)));
|
|---|
| 64 | connect(_bnseph, SIGNAL(error(QByteArray)),
|
|---|
| 65 | this, SLOT(slotError(const QByteArray)));
|
|---|
| 66 |
|
|---|
| 67 | // Server listening for rtnet results
|
|---|
| 68 | // ----------------------------------
|
|---|
| 69 | _clkSocket = 0;
|
|---|
| 70 | _clkServer = new QTcpServer;
|
|---|
| 71 | _clkServer->listen(QHostAddress::Any, settings.value("clkPort").toInt());
|
|---|
| 72 | connect(_clkServer, SIGNAL(newConnection()),this, SLOT(slotNewConnection()));
|
|---|
| 73 |
|
|---|
| 74 | // Socket and file for outputting the results
|
|---|
| 75 | // -------------------------------------------
|
|---|
| 76 | for (int ic = 1; ic <= 2; ic++) {
|
|---|
| 77 | QString mountpoint = settings.value(QString("mountpoint_%1").arg(ic)).toString();
|
|---|
| 78 | QString outFileName = settings.value(QString("outFile_%1").arg(ic)).toString();
|
|---|
| 79 | if (!mountpoint.isEmpty() || !outFileName.isEmpty()) {
|
|---|
| 80 | _caster.push_back(new t_bnscaster(mountpoint, outFileName, ic));
|
|---|
| 81 | connect(_caster.back(), SIGNAL(error(const QByteArray)),
|
|---|
| 82 | this, SLOT(slotError(const QByteArray)));
|
|---|
| 83 | connect(_caster.back(), SIGNAL(newMessage(const QByteArray)),
|
|---|
| 84 | this, SLOT(slotMessage(const QByteArray)));
|
|---|
| 85 | }
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| 88 | // Log File
|
|---|
| 89 | // --------
|
|---|
| 90 | QIODevice::OpenMode oMode;
|
|---|
| 91 | if (Qt::CheckState(settings.value("fileAppend").toInt()) == Qt::Checked) {
|
|---|
| 92 | oMode = QIODevice::WriteOnly | QIODevice::Unbuffered | QIODevice::Append;
|
|---|
| 93 | }
|
|---|
| 94 | else {
|
|---|
| 95 | oMode = QIODevice::WriteOnly | QIODevice::Unbuffered;
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|
| 98 | QString logFileName = settings.value("logFile").toString();
|
|---|
| 99 | if (logFileName.isEmpty()) {
|
|---|
| 100 | _logFile = 0;
|
|---|
| 101 | _logStream = 0;
|
|---|
| 102 | }
|
|---|
| 103 | else {
|
|---|
| 104 | _logFile = new QFile(logFileName);
|
|---|
| 105 | if (_logFile->open(oMode)) {
|
|---|
| 106 | _logStream = new QTextStream(_logFile);
|
|---|
| 107 | }
|
|---|
| 108 | else {
|
|---|
| 109 | _logStream = 0;
|
|---|
| 110 | }
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | // Echo input from RTNet into a file
|
|---|
| 114 | // ---------------------------------
|
|---|
| 115 | QString echoFileName = settings.value("inpEcho").toString();
|
|---|
| 116 | if (echoFileName.isEmpty()) {
|
|---|
| 117 | _echoFile = 0;
|
|---|
| 118 | _echoStream = 0;
|
|---|
| 119 | }
|
|---|
| 120 | else {
|
|---|
| 121 | _echoFile = new QFile(echoFileName);
|
|---|
| 122 | if (_echoFile->open(oMode)) {
|
|---|
| 123 | _echoStream = new QTextStream(_echoFile);
|
|---|
| 124 | }
|
|---|
| 125 | else {
|
|---|
| 126 | _echoStream = 0;
|
|---|
| 127 | }
|
|---|
| 128 | }
|
|---|
| 129 |
|
|---|
| 130 | // RINEX writer
|
|---|
| 131 | // ------------
|
|---|
| 132 | if ( settings.value("rnxPath").toString().isEmpty() ) {
|
|---|
| 133 | _rnx = 0;
|
|---|
| 134 | }
|
|---|
| 135 | else {
|
|---|
| 136 | QString prep = "BNS";
|
|---|
| 137 | QString ext = ".clk";
|
|---|
| 138 | QString path = settings.value("rnxPath").toString();
|
|---|
| 139 | QString intr = settings.value("rnxIntr").toString();
|
|---|
| 140 | int sampl = settings.value("rnxSampl").toInt();
|
|---|
| 141 | _rnx = new bnsRinex(prep, ext, path, intr, sampl);
|
|---|
| 142 | }
|
|---|
| 143 |
|
|---|
| 144 | // SP3 writer
|
|---|
| 145 | // ----------
|
|---|
| 146 | if ( settings.value("sp3Path").toString().isEmpty() ) {
|
|---|
| 147 | _sp3 = 0;
|
|---|
| 148 | }
|
|---|
| 149 | else {
|
|---|
| 150 | QString prep = "BNS";
|
|---|
| 151 | QString ext = ".sp3";
|
|---|
| 152 | QString path = settings.value("sp3Path").toString();
|
|---|
| 153 | QString intr = settings.value("sp3Intr").toString();
|
|---|
| 154 | int sampl = settings.value("sp3Sampl").toInt();
|
|---|
| 155 | _sp3 = new bnsSP3(prep, ext, path, intr, sampl);
|
|---|
| 156 | }
|
|---|
| 157 | }
|
|---|
| 158 |
|
|---|
| 159 | // Destructor
|
|---|
| 160 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 161 | t_bns::~t_bns() {
|
|---|
| 162 | deleteBnsEph();
|
|---|
| 163 | delete _clkServer;
|
|---|
| 164 | delete _clkSocket;
|
|---|
| 165 | for (int ic = 0; ic < _caster.size(); ic++) {
|
|---|
| 166 | delete _caster.at(ic);
|
|---|
| 167 | }
|
|---|
| 168 | delete _logStream;
|
|---|
| 169 | delete _logFile;
|
|---|
| 170 | delete _echoStream;
|
|---|
| 171 | delete _echoFile;
|
|---|
| 172 | QMapIterator<QString, t_ephPair*> it(_ephList);
|
|---|
| 173 | while (it.hasNext()) {
|
|---|
| 174 | it.next();
|
|---|
| 175 | delete it.value();
|
|---|
| 176 | }
|
|---|
| 177 | delete _rnx;
|
|---|
| 178 | delete _sp3;
|
|---|
| 179 | }
|
|---|
| 180 |
|
|---|
| 181 | // Delete bns thread
|
|---|
| 182 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 183 | void t_bns::deleteBnsEph() {
|
|---|
| 184 | if (_bnseph) {
|
|---|
| 185 | _bnseph->terminate();
|
|---|
| 186 | _bnseph->wait(100);
|
|---|
| 187 | delete _bnseph;
|
|---|
| 188 | _bnseph = 0;
|
|---|
| 189 | }
|
|---|
| 190 | }
|
|---|
| 191 |
|
|---|
| 192 | // Write a Program Message
|
|---|
| 193 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 194 | void t_bns::slotMessage(const QByteArray msg) {
|
|---|
| 195 | if (_logStream) {
|
|---|
| 196 | QString txt = QDateTime::currentDateTime().toUTC().toString("yy-MM-dd hh:mm:ss ");
|
|---|
| 197 | *_logStream << txt << msg << endl;
|
|---|
| 198 | _logStream->flush();
|
|---|
| 199 | }
|
|---|
| 200 | emit(newMessage(msg));
|
|---|
| 201 | }
|
|---|
| 202 |
|
|---|
| 203 | // Write a Program Message
|
|---|
| 204 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 205 | void t_bns::slotError(const QByteArray msg) {
|
|---|
| 206 | if (_logStream) {
|
|---|
| 207 | *_logStream << msg << endl;
|
|---|
| 208 | _logStream->flush();
|
|---|
| 209 | }
|
|---|
| 210 | deleteBnsEph();
|
|---|
| 211 | emit(error(msg));
|
|---|
| 212 | }
|
|---|
| 213 |
|
|---|
| 214 | // New Connection
|
|---|
| 215 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 216 | void t_bns::slotNewConnection() {
|
|---|
| 217 | //slotMessage("t_bns::slotNewConnection");
|
|---|
| 218 | slotMessage("Clocks & orbits port: Waiting for client to connect"); // weber
|
|---|
| 219 | delete _clkSocket;
|
|---|
| 220 | _clkSocket = _clkServer->nextPendingConnection();
|
|---|
| 221 | }
|
|---|
| 222 |
|
|---|
| 223 | //
|
|---|
| 224 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 225 | void t_bns::slotNewEph(t_eph* ep, int nBytes) {
|
|---|
| 226 |
|
|---|
| 227 | QMutexLocker locker(&_mutex);
|
|---|
| 228 |
|
|---|
| 229 | emit(newEphBytes(nBytes));
|
|---|
| 230 |
|
|---|
| 231 | t_ephPair* pair;
|
|---|
| 232 | if ( !_ephList.contains(ep->prn()) ) {
|
|---|
| 233 | pair = new t_ephPair();
|
|---|
| 234 | _ephList.insert(ep->prn(), pair);
|
|---|
| 235 | }
|
|---|
| 236 | else {
|
|---|
| 237 | pair = _ephList[ep->prn()];
|
|---|
| 238 | }
|
|---|
| 239 |
|
|---|
| 240 | if (pair->eph == 0) {
|
|---|
| 241 | pair->eph = ep;
|
|---|
| 242 | }
|
|---|
| 243 | else {
|
|---|
| 244 | if (ep->isNewerThan(pair->eph)) {
|
|---|
| 245 | delete pair->oldEph;
|
|---|
| 246 | pair->oldEph = pair->eph;
|
|---|
| 247 | pair->eph = ep;
|
|---|
| 248 | }
|
|---|
| 249 | else {
|
|---|
| 250 | delete ep;
|
|---|
| 251 | }
|
|---|
| 252 | }
|
|---|
| 253 | }
|
|---|
| 254 |
|
|---|
| 255 | // Start
|
|---|
| 256 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 257 | void t_bns::run() {
|
|---|
| 258 |
|
|---|
| 259 | slotMessage("============ Start BNS ============");
|
|---|
| 260 |
|
|---|
| 261 | // Start Thread that retrieves broadcast Ephemeris
|
|---|
| 262 | // -----------------------------------------------
|
|---|
| 263 | _bnseph->start();
|
|---|
| 264 |
|
|---|
| 265 | // Endless loop
|
|---|
| 266 | // ------------
|
|---|
| 267 | while (true) {
|
|---|
| 268 |
|
|---|
| 269 | if (_clkSocket && _clkSocket->thread() != currentThread()) {
|
|---|
| 270 | emit(moveSocket(currentThread()));
|
|---|
| 271 | }
|
|---|
| 272 |
|
|---|
| 273 | if (_clkSocket && _clkSocket->state() == QAbstractSocket::ConnectedState) {
|
|---|
| 274 | if ( _clkSocket->canReadLine()) {
|
|---|
| 275 | readEpoch();
|
|---|
| 276 | }
|
|---|
| 277 | else {
|
|---|
| 278 | _clkSocket->waitForReadyRead(10);
|
|---|
| 279 | }
|
|---|
| 280 | }
|
|---|
| 281 | else {
|
|---|
| 282 | msleep(10);
|
|---|
| 283 | }
|
|---|
| 284 | }
|
|---|
| 285 | }
|
|---|
| 286 |
|
|---|
| 287 | //
|
|---|
| 288 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 289 | void t_bns::readEpoch() {
|
|---|
| 290 |
|
|---|
| 291 | bnsSettings settings;
|
|---|
| 292 |
|
|---|
| 293 | // Read the first line (if not already read)
|
|---|
| 294 | // -----------------------------------------
|
|---|
| 295 | if (_clkLine.indexOf('*') == -1) {
|
|---|
| 296 | _clkLine = _clkSocket->readLine();
|
|---|
| 297 | if (_echoStream) {
|
|---|
| 298 | *_echoStream << _clkLine;
|
|---|
| 299 | _echoStream->flush();
|
|---|
| 300 | }
|
|---|
| 301 | emit(newClkBytes(_clkLine.length()));
|
|---|
| 302 | }
|
|---|
| 303 |
|
|---|
| 304 | if (_clkLine.indexOf('*') == -1) {
|
|---|
| 305 | return;
|
|---|
| 306 | }
|
|---|
| 307 |
|
|---|
| 308 | QTextStream in(_clkLine);
|
|---|
| 309 |
|
|---|
| 310 | QString hlp;
|
|---|
| 311 | int year, month, day, hour, min;
|
|---|
| 312 | double sec;
|
|---|
| 313 | in >> hlp >> year >> month >> day >> hour >> min >> sec;
|
|---|
| 314 |
|
|---|
| 315 | int GPSweek;
|
|---|
| 316 | double GPSweeks;
|
|---|
| 317 |
|
|---|
| 318 | GPSweekFromYMDhms(year, month, day, hour, min, sec, GPSweek, GPSweeks);
|
|---|
| 319 |
|
|---|
| 320 | QStringList prns;
|
|---|
| 321 |
|
|---|
| 322 | // Loop over all satellites
|
|---|
| 323 | // ------------------------
|
|---|
| 324 | QStringList lines;
|
|---|
| 325 | for (;;) {
|
|---|
| 326 | if (!_clkSocket->canReadLine()) {
|
|---|
| 327 | break;
|
|---|
| 328 | }
|
|---|
| 329 | _clkLine = _clkSocket->readLine();
|
|---|
| 330 | if (_echoStream) {
|
|---|
| 331 | *_echoStream << _clkLine;
|
|---|
| 332 | _echoStream->flush();
|
|---|
| 333 | }
|
|---|
| 334 | if (_clkLine[0] == '*') {
|
|---|
| 335 | return;
|
|---|
| 336 | }
|
|---|
| 337 | if (_clkLine[0] == 'P') {
|
|---|
| 338 | _clkLine.remove(0,1);
|
|---|
| 339 | lines.push_back(_clkLine);
|
|---|
| 340 | }
|
|---|
| 341 | }
|
|---|
| 342 |
|
|---|
| 343 | if (lines.size() > 0) {
|
|---|
| 344 |
|
|---|
| 345 | QStringList prns;
|
|---|
| 346 |
|
|---|
| 347 | for (int ic = 0; ic < _caster.size(); ic++) {
|
|---|
| 348 | _caster.at(ic)->open();
|
|---|
| 349 |
|
|---|
| 350 | for (int oldEph = 0; oldEph <= 0; oldEph++) { // TODO: handle old ephemeris
|
|---|
| 351 |
|
|---|
| 352 | struct ClockOrbit co;
|
|---|
| 353 | memset(&co, 0, sizeof(co));
|
|---|
| 354 | co.GPSEpochTime = (int)GPSweeks;
|
|---|
| 355 | co.GLONASSEpochTime = (int)fmod(GPSweeks, 86400.0);
|
|---|
| 356 | co.ClockDataSupplied = 1;
|
|---|
| 357 | co.OrbitDataSupplied = 1;
|
|---|
| 358 | co.SatRefPoint = POINT_CENTER;
|
|---|
| 359 | co.SatRefDatum = DATUM_ITRF;
|
|---|
| 360 |
|
|---|
| 361 | for (int ii = 0; ii < lines.size(); ii++) {
|
|---|
| 362 |
|
|---|
| 363 | QString prn;
|
|---|
| 364 | ColumnVector xx(5);
|
|---|
| 365 | t_eph* ep = 0;
|
|---|
| 366 |
|
|---|
| 367 | if (oldEph == 0 && ic == 0) {
|
|---|
| 368 | QTextStream in(lines[ii].toAscii());
|
|---|
| 369 | in >> prn;
|
|---|
| 370 | prns << prn;
|
|---|
| 371 | if ( _ephList.contains(prn) ) {
|
|---|
| 372 | in >> xx(1) >> xx(2) >> xx(3) >> xx(4) >> xx(5);
|
|---|
| 373 | xx(1) *= 1e3;
|
|---|
| 374 | xx(2) *= 1e3;
|
|---|
| 375 | xx(3) *= 1e3;
|
|---|
| 376 | xx(4) *= 1e-6;
|
|---|
| 377 |
|
|---|
| 378 | // Clocks without corrections
|
|---|
| 379 | // --------------------------
|
|---|
| 380 | if ( _caster.at(ic)->beClocks() ) {
|
|---|
| 381 | xx(4) -= xx(5) / 299792458.0;
|
|---|
| 382 | }
|
|---|
| 383 |
|
|---|
| 384 | t_ephPair* pair = _ephList[prn];
|
|---|
| 385 | pair->xx = xx;
|
|---|
| 386 | ep = pair->eph;
|
|---|
| 387 | }
|
|---|
| 388 | }
|
|---|
| 389 | else {
|
|---|
| 390 | prn = prns[ii];
|
|---|
| 391 | if ( _ephList.contains(prn) ) {
|
|---|
| 392 | t_ephPair* pair = _ephList[prn];
|
|---|
| 393 | prn = pair->eph->prn();
|
|---|
| 394 | xx = pair->xx;
|
|---|
| 395 | if (oldEph) {
|
|---|
| 396 | ep = pair->oldEph;
|
|---|
| 397 | }
|
|---|
| 398 | else {
|
|---|
| 399 | ep = pair->eph;
|
|---|
| 400 | }
|
|---|
| 401 | }
|
|---|
| 402 | }
|
|---|
| 403 |
|
|---|
| 404 | if (ep != 0) {
|
|---|
| 405 | struct ClockOrbit::SatData* sd = 0;
|
|---|
| 406 | if (prn[0] == 'G') {
|
|---|
| 407 | sd = co.Sat + co.NumberOfGPSSat;
|
|---|
| 408 | ++co.NumberOfGPSSat;
|
|---|
| 409 | }
|
|---|
| 410 | else if (prn[0] == 'R') {
|
|---|
| 411 | sd = co.Sat + CLOCKORBIT_NUMGPS + co.NumberOfGLONASSSat;
|
|---|
| 412 | ++co.NumberOfGLONASSSat;
|
|---|
| 413 | }
|
|---|
| 414 | if (sd) {
|
|---|
| 415 | QString outLine;
|
|---|
| 416 | processSatellite(oldEph, ic, _caster.at(ic)->crdTrafo(), ep,
|
|---|
| 417 | GPSweek, GPSweeks, prn, xx, sd, outLine);
|
|---|
| 418 | _caster.at(ic)->printAscii(outLine);
|
|---|
| 419 | }
|
|---|
| 420 | }
|
|---|
| 421 | }
|
|---|
| 422 |
|
|---|
| 423 | if ( _caster.at(ic)->usedSocket() &&
|
|---|
| 424 | (co.NumberOfGPSSat > 0 || co.NumberOfGLONASSSat > 0) ) {
|
|---|
| 425 | char obuffer[CLOCKORBIT_BUFFERSIZE];
|
|---|
| 426 | int len = MakeClockOrbit(&co, COTYPE_AUTO, 0, obuffer, sizeof(obuffer));
|
|---|
| 427 | if (len > 0) {
|
|---|
| 428 | if (_caster.at(ic)->ic() == 1) { emit(newOutBytes1(len));}
|
|---|
| 429 | if (_caster.at(ic)->ic() == 2) { emit(newOutBytes2(len));}
|
|---|
| 430 | _caster.at(ic)->write(obuffer, len);
|
|---|
| 431 | }
|
|---|
| 432 | }
|
|---|
| 433 | }
|
|---|
| 434 | }
|
|---|
| 435 | }
|
|---|
| 436 | }
|
|---|
| 437 |
|
|---|
| 438 | //
|
|---|
| 439 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 440 | void t_bns::processSatellite(int oldEph, int iCaster, bool trafo, t_eph* ep,
|
|---|
| 441 | int GPSweek, double GPSweeks, const QString& prn,
|
|---|
| 442 | const ColumnVector& xx,
|
|---|
| 443 | struct ClockOrbit::SatData* sd,
|
|---|
| 444 | QString& outLine) {
|
|---|
| 445 |
|
|---|
| 446 | ColumnVector xB(4);
|
|---|
| 447 | ColumnVector vv(3);
|
|---|
| 448 |
|
|---|
| 449 | ep->position(GPSweek, GPSweeks, xB, vv);
|
|---|
| 450 |
|
|---|
| 451 | ColumnVector xyz = xx.Rows(1,3);
|
|---|
| 452 | if (trafo) {
|
|---|
| 453 | crdTrafo(GPSweek, xyz);
|
|---|
| 454 | }
|
|---|
| 455 |
|
|---|
| 456 | ColumnVector dx = xyz - xB.Rows(1,3);
|
|---|
| 457 |
|
|---|
| 458 | double dClk = (xx(4) - xB(4)) * 299792458.0;
|
|---|
| 459 | ColumnVector rsw(3);
|
|---|
| 460 |
|
|---|
| 461 | XYZ_to_RSW(xB.Rows(1,3), vv, dx, rsw);
|
|---|
| 462 |
|
|---|
| 463 | if (sd) {
|
|---|
| 464 | sd->ID = prn.mid(1).toInt();
|
|---|
| 465 | sd->IOD = ep->IOD();
|
|---|
| 466 | sd->Clock.DeltaA0 = dClk;
|
|---|
| 467 | sd->Orbit.DeltaRadial = rsw(1);
|
|---|
| 468 | sd->Orbit.DeltaAlongTrack = rsw(2);
|
|---|
| 469 | sd->Orbit.DeltaCrossTrack = rsw(3);
|
|---|
| 470 | }
|
|---|
| 471 |
|
|---|
| 472 | char oldCh = (oldEph ? '!' : ' ');
|
|---|
| 473 | outLine.sprintf("%c %d %.1f %s %3d %10.3f %8.3f %8.3f %8.3f\n",
|
|---|
| 474 | oldCh, GPSweek, GPSweeks, ep->prn().toAscii().data(),
|
|---|
| 475 | ep->IOD(), dClk, rsw(1), rsw(2), rsw(3));
|
|---|
| 476 |
|
|---|
| 477 | if (!oldEph && iCaster == 0) {
|
|---|
| 478 | if (_rnx) {
|
|---|
| 479 | _rnx->write(GPSweek, GPSweeks, prn, xx);
|
|---|
| 480 | }
|
|---|
| 481 | if (_sp3) {
|
|---|
| 482 | _sp3->write(GPSweek, GPSweeks, prn, xx);
|
|---|
| 483 | }
|
|---|
| 484 | }
|
|---|
| 485 | }
|
|---|
| 486 |
|
|---|
| 487 | //
|
|---|
| 488 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 489 | void t_bns::slotMoveSocket(QThread* tt) {
|
|---|
| 490 | _clkSocket->setParent(0);
|
|---|
| 491 | _clkSocket->moveToThread(tt);
|
|---|
| 492 | //slotMessage("bns::slotMoveSocket");
|
|---|
| 493 | slotMessage("Clocks & orbits port: Socket moved to thread"); // weber
|
|---|
| 494 | }
|
|---|
| 495 |
|
|---|
| 496 | // Transform Coordinates IGS -> ETRF
|
|---|
| 497 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 498 | void t_bns::crdTrafo(int GPSWeek, ColumnVector& xyz) {
|
|---|
| 499 |
|
|---|
| 500 | // Current epoch minus 2000.0 in years
|
|---|
| 501 | // ------------------------------------
|
|---|
| 502 | double dt = (GPSWeek - (1042.0+6.0/7.0)) / 365.2422 * 7.0;
|
|---|
| 503 |
|
|---|
| 504 | ColumnVector dx(3);
|
|---|
| 505 | dx(1) = 0.0541 - dt * 0.0002;
|
|---|
| 506 | dx(2) = 0.0502 + dt * 0.0001;
|
|---|
| 507 | dx(3) = -0.0538 - dt * 0.0018;
|
|---|
| 508 |
|
|---|
| 509 | static const double arcSec = 180.0 * 3600.0 / M_PI;
|
|---|
| 510 | double ox = ( 0.000891 + dt * 0.000081) / arcSec;
|
|---|
| 511 | double oy = ( 0.005390 + dt * 0.000490) / arcSec;
|
|---|
| 512 | double oz = (-0.008712 - dt * 0.000792) / arcSec;
|
|---|
| 513 |
|
|---|
| 514 | double sc = 1.0 + 0.4e-9 + dt * 0.08e-9;
|
|---|
| 515 |
|
|---|
| 516 | Matrix rMat(3,3);
|
|---|
| 517 | rMat(1,1) = 1.0;
|
|---|
| 518 | rMat(1,2) = -oz;
|
|---|
| 519 | rMat(1,3) = oy;
|
|---|
| 520 | rMat(2,1) = oz;
|
|---|
| 521 | rMat(2,2) = 1.0;
|
|---|
| 522 | rMat(2,3) = -ox;
|
|---|
| 523 | rMat(3,1) = -oy;
|
|---|
| 524 | rMat(3,2) = ox;
|
|---|
| 525 | rMat(3,3) = 1.0;
|
|---|
| 526 |
|
|---|
| 527 |
|
|---|
| 528 | xyz = sc * rMat * xyz + dx;
|
|---|
| 529 | }
|
|---|