| 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 |
|
|---|
| 26 | using namespace std;
|
|---|
| 27 |
|
|---|
| 28 | // Constructor
|
|---|
| 29 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 30 | t_bns::t_bns(QObject* parent) : QThread(parent) {
|
|---|
| 31 |
|
|---|
| 32 | this->setTerminationEnabled(true);
|
|---|
| 33 |
|
|---|
| 34 | connect(this, SIGNAL(moveSocket(QThread*)),
|
|---|
| 35 | this, SLOT(slotMoveSocket(QThread*)));
|
|---|
| 36 |
|
|---|
| 37 | QSettings settings;
|
|---|
| 38 |
|
|---|
| 39 | // Set Proxy (application-wide)
|
|---|
| 40 | // ----------------------------
|
|---|
| 41 | QString proxyHost = settings.value("proxyHost").toString();
|
|---|
| 42 | int proxyPort = settings.value("proxyPort").toInt();
|
|---|
| 43 |
|
|---|
| 44 | QNetworkProxy proxy;
|
|---|
| 45 | if (proxyHost.isEmpty()) {
|
|---|
| 46 | proxy.setType(QNetworkProxy::NoProxy);
|
|---|
| 47 | }
|
|---|
| 48 | else {
|
|---|
| 49 | proxy.setType(QNetworkProxy::Socks5Proxy);
|
|---|
| 50 | proxy.setHostName(proxyHost);
|
|---|
| 51 | proxy.setPort(proxyPort);
|
|---|
| 52 | }
|
|---|
| 53 | QNetworkProxy::setApplicationProxy(proxy);
|
|---|
| 54 |
|
|---|
| 55 | // Thread that handles broadcast ephemeris
|
|---|
| 56 | // ---------------------------------------
|
|---|
| 57 | _bnseph = new t_bnseph(parent);
|
|---|
| 58 |
|
|---|
| 59 | connect(_bnseph, SIGNAL(newEph(t_eph*, int)),
|
|---|
| 60 | this, SLOT(slotNewEph(t_eph*, int)));
|
|---|
| 61 | connect(_bnseph, SIGNAL(newMessage(QByteArray)),
|
|---|
| 62 | this, SLOT(slotMessage(const QByteArray)));
|
|---|
| 63 | connect(_bnseph, SIGNAL(error(QByteArray)),
|
|---|
| 64 | this, SLOT(slotError(const QByteArray)));
|
|---|
| 65 |
|
|---|
| 66 | // Server listening for rtnet results
|
|---|
| 67 | // ----------------------------------
|
|---|
| 68 | _clkSocket = 0;
|
|---|
| 69 | _clkServer = new QTcpServer;
|
|---|
| 70 | _clkServer->listen(QHostAddress::Any, settings.value("clkPort").toInt());
|
|---|
| 71 | connect(_clkServer, SIGNAL(newConnection()),this, SLOT(slotNewConnection()));
|
|---|
| 72 |
|
|---|
| 73 | // Socket and file for outputting the results
|
|---|
| 74 | // -------------------------------------------
|
|---|
| 75 | for (int ic = 1; ic <= 2; ic++) {
|
|---|
| 76 |
|
|---|
| 77 | QString mountpoint = settings.value(QString("mountpoint_%1").arg(ic)).toString();
|
|---|
| 78 | if (!mountpoint.isEmpty()) {
|
|---|
| 79 | QString outFileName = settings.value(QString("outFile_%1").arg(ic)).toString();
|
|---|
| 80 | QString refSys = settings.value(QString("refSys_%1").arg(ic)).toString();
|
|---|
| 81 |
|
|---|
| 82 | _caster.push_back(new t_bnscaster(mountpoint, outFileName, refSys));
|
|---|
| 83 | connect(_caster.back(), SIGNAL(error(const QByteArray)),
|
|---|
| 84 | this, SLOT(slotError(const QByteArray)));
|
|---|
| 85 | connect(_caster.back(), SIGNAL(newMessage(const QByteArray)),
|
|---|
| 86 | this, SLOT(slotMessage(const QByteArray)));
|
|---|
| 87 | }
|
|---|
| 88 | }
|
|---|
| 89 |
|
|---|
| 90 | // Log File
|
|---|
| 91 | // --------
|
|---|
| 92 | QIODevice::OpenMode oMode;
|
|---|
| 93 | if (Qt::CheckState(settings.value("fileAppend").toInt()) == Qt::Checked) {
|
|---|
| 94 | oMode = QIODevice::WriteOnly | QIODevice::Unbuffered | QIODevice::Append;
|
|---|
| 95 | }
|
|---|
| 96 | else {
|
|---|
| 97 | oMode = QIODevice::WriteOnly | QIODevice::Unbuffered;
|
|---|
| 98 | }
|
|---|
| 99 |
|
|---|
| 100 | QString logFileName = settings.value("logFile").toString();
|
|---|
| 101 | if (logFileName.isEmpty()) {
|
|---|
| 102 | _logFile = 0;
|
|---|
| 103 | _logStream = 0;
|
|---|
| 104 | }
|
|---|
| 105 | else {
|
|---|
| 106 | _logFile = new QFile(logFileName);
|
|---|
| 107 | if (_logFile->open(oMode)) {
|
|---|
| 108 | _logStream = new QTextStream(_logFile);
|
|---|
| 109 | }
|
|---|
| 110 | else {
|
|---|
| 111 | _logStream = 0;
|
|---|
| 112 | }
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | // Echo input from RTNet into a file
|
|---|
| 116 | // ---------------------------------
|
|---|
| 117 | QString echoFileName = settings.value("inpEcho").toString();
|
|---|
| 118 | if (echoFileName.isEmpty()) {
|
|---|
| 119 | _echoFile = 0;
|
|---|
| 120 | _echoStream = 0;
|
|---|
| 121 | }
|
|---|
| 122 | else {
|
|---|
| 123 | _echoFile = new QFile(echoFileName);
|
|---|
| 124 | if (_echoFile->open(oMode)) {
|
|---|
| 125 | _echoStream = new QTextStream(_echoFile);
|
|---|
| 126 | }
|
|---|
| 127 | else {
|
|---|
| 128 | _echoStream = 0;
|
|---|
| 129 | }
|
|---|
| 130 | }
|
|---|
| 131 |
|
|---|
| 132 | // RINEX writer
|
|---|
| 133 | // ------------
|
|---|
| 134 | if ( settings.value("rnxPath").toString().isEmpty() ) {
|
|---|
| 135 | _rnx = 0;
|
|---|
| 136 | }
|
|---|
| 137 | else {
|
|---|
| 138 | QString prep = "BNS";
|
|---|
| 139 | QString ext = ".clk";
|
|---|
| 140 | QString path = settings.value("rnxPath").toString();
|
|---|
| 141 | QString intr = settings.value("rnxIntr").toString();
|
|---|
| 142 | int sampl = settings.value("rnxSampl").toInt();
|
|---|
| 143 | _rnx = new bnsRinex(prep, ext, path, intr, sampl);
|
|---|
| 144 | }
|
|---|
| 145 |
|
|---|
| 146 | // SP3 writer
|
|---|
| 147 | // ----------
|
|---|
| 148 | if ( settings.value("sp3Path").toString().isEmpty() ) {
|
|---|
| 149 | _sp3 = 0;
|
|---|
| 150 | }
|
|---|
| 151 | else {
|
|---|
| 152 | QString prep = "BNS";
|
|---|
| 153 | QString ext = ".sp3";
|
|---|
| 154 | QString path = settings.value("sp3Path").toString();
|
|---|
| 155 | QString intr = settings.value("sp3Intr").toString();
|
|---|
| 156 | int sampl = settings.value("sp3Sampl").toInt();
|
|---|
| 157 | _sp3 = new bnsSP3(prep, ext, path, intr, sampl);
|
|---|
| 158 | }
|
|---|
| 159 | }
|
|---|
| 160 |
|
|---|
| 161 | // Destructor
|
|---|
| 162 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 163 | t_bns::~t_bns() {
|
|---|
| 164 | deleteBnsEph();
|
|---|
| 165 | delete _clkServer;
|
|---|
| 166 | delete _clkSocket;
|
|---|
| 167 | for (int ic = 0; ic < _caster.size(); ic++) {
|
|---|
| 168 | delete _caster.at(ic);
|
|---|
| 169 | }
|
|---|
| 170 | delete _logStream;
|
|---|
| 171 | delete _logFile;
|
|---|
| 172 | delete _echoStream;
|
|---|
| 173 | delete _echoFile;
|
|---|
| 174 | QMapIterator<QString, t_ephPair*> it(_ephList);
|
|---|
| 175 | while (it.hasNext()) {
|
|---|
| 176 | it.next();
|
|---|
| 177 | delete it.value();
|
|---|
| 178 | }
|
|---|
| 179 | delete _rnx;
|
|---|
| 180 | delete _sp3;
|
|---|
| 181 | }
|
|---|
| 182 |
|
|---|
| 183 | // Delete bns thread
|
|---|
| 184 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 185 | void t_bns::deleteBnsEph() {
|
|---|
| 186 | if (_bnseph) {
|
|---|
| 187 | _bnseph->terminate();
|
|---|
| 188 | _bnseph->wait(100);
|
|---|
| 189 | delete _bnseph;
|
|---|
| 190 | _bnseph = 0;
|
|---|
| 191 | }
|
|---|
| 192 | }
|
|---|
| 193 |
|
|---|
| 194 | // Write a Program Message
|
|---|
| 195 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 196 | void t_bns::slotMessage(const QByteArray msg) {
|
|---|
| 197 | if (_logStream) {
|
|---|
| 198 | *_logStream << msg << endl;
|
|---|
| 199 | _logStream->flush();
|
|---|
| 200 | }
|
|---|
| 201 | emit(newMessage(msg));
|
|---|
| 202 | }
|
|---|
| 203 |
|
|---|
| 204 | // Write a Program Message
|
|---|
| 205 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 206 | void t_bns::slotError(const QByteArray msg) {
|
|---|
| 207 | if (_logStream) {
|
|---|
| 208 | *_logStream << msg << endl;
|
|---|
| 209 | _logStream->flush();
|
|---|
| 210 | }
|
|---|
| 211 | deleteBnsEph();
|
|---|
| 212 | emit(error(msg));
|
|---|
| 213 | }
|
|---|
| 214 |
|
|---|
| 215 | // New Connection
|
|---|
| 216 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 217 | void t_bns::slotNewConnection() {
|
|---|
| 218 | slotMessage("t_bns::slotNewConnection");
|
|---|
| 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 | QByteArray line = _clkSocket->readLine();
|
|---|
| 292 |
|
|---|
| 293 | if (_echoStream) {
|
|---|
| 294 | *_echoStream << line;
|
|---|
| 295 | _echoStream->flush();
|
|---|
| 296 | }
|
|---|
| 297 |
|
|---|
| 298 | emit(newClkBytes(line.length()));
|
|---|
| 299 |
|
|---|
| 300 | if (line.indexOf('*') == -1) {
|
|---|
| 301 | return;
|
|---|
| 302 | }
|
|---|
| 303 |
|
|---|
| 304 | QTextStream in(line);
|
|---|
| 305 |
|
|---|
| 306 | QString hlp;
|
|---|
| 307 | int GPSweek, numSat;
|
|---|
| 308 | double GPSweeks;
|
|---|
| 309 |
|
|---|
| 310 | in >> hlp >> GPSweek >> GPSweeks >> numSat;
|
|---|
| 311 |
|
|---|
| 312 | if (numSat > 0) {
|
|---|
| 313 |
|
|---|
| 314 | QStringList prns;
|
|---|
| 315 |
|
|---|
| 316 | for (int ic = 0; ic < _caster.size(); ic++) {
|
|---|
| 317 | _caster.at(ic)->open();
|
|---|
| 318 |
|
|---|
| 319 | cout << "caster number " << ic+1 << endl;
|
|---|
| 320 |
|
|---|
| 321 | for (int oldEph = 0; oldEph <= 0; oldEph++) { // TODO: handle old ephemeris
|
|---|
| 322 |
|
|---|
| 323 | struct ClockOrbit co;
|
|---|
| 324 | memset(&co, 0, sizeof(co));
|
|---|
| 325 | co.GPSEpochTime = (int)GPSweeks;
|
|---|
| 326 | co.GLONASSEpochTime = (int)fmod(GPSweeks, 86400.0);
|
|---|
| 327 | co.ClockDataSupplied = 1;
|
|---|
| 328 | co.OrbitDataSupplied = 1;
|
|---|
| 329 | co.SatRefPoint = POINT_CENTER;
|
|---|
| 330 | co.SatRefDatum = DATUM_ITRF;
|
|---|
| 331 |
|
|---|
| 332 | for (int ii = 1; ii <= numSat; ii++) {
|
|---|
| 333 |
|
|---|
| 334 | QString prn;
|
|---|
| 335 | ColumnVector xx(5);
|
|---|
| 336 | t_eph* ep = 0;
|
|---|
| 337 |
|
|---|
| 338 | if (oldEph == 0 && ic == 0) {
|
|---|
| 339 | line = _clkSocket->readLine();
|
|---|
| 340 |
|
|---|
| 341 | if (_echoStream) {
|
|---|
| 342 | *_echoStream << line;
|
|---|
| 343 | _echoStream->flush();
|
|---|
| 344 | }
|
|---|
| 345 |
|
|---|
| 346 | QTextStream in(line);
|
|---|
| 347 | in >> prn;
|
|---|
| 348 | prns << prn;
|
|---|
| 349 | if ( _ephList.contains(prn) ) {
|
|---|
| 350 | in >> xx(1) >> xx(2) >> xx(3) >> xx(4) >> xx(5); xx(4) *= 1e-6;
|
|---|
| 351 |
|
|---|
| 352 | //// beg test (zero clock correction for Gerhard Wuebbena)
|
|---|
| 353 | //// xx(4) -= xx(5) / 299792458.0;
|
|---|
| 354 | //// end test
|
|---|
| 355 |
|
|---|
| 356 | t_ephPair* pair = _ephList[prn];
|
|---|
| 357 | pair->xx = xx;
|
|---|
| 358 | ep = pair->eph;
|
|---|
| 359 | }
|
|---|
| 360 | }
|
|---|
| 361 | else {
|
|---|
| 362 | prn = prns[ii-1];
|
|---|
| 363 | if ( _ephList.contains(prn) ) {
|
|---|
| 364 | t_ephPair* pair = _ephList[prn];
|
|---|
| 365 | prn = pair->eph->prn();
|
|---|
| 366 | xx = pair->xx;
|
|---|
| 367 | ep = pair->oldEph;
|
|---|
| 368 | }
|
|---|
| 369 | }
|
|---|
| 370 |
|
|---|
| 371 | if (ep != 0) {
|
|---|
| 372 | struct ClockOrbit::SatData* sd = 0;
|
|---|
| 373 | if (prn[0] == 'G') {
|
|---|
| 374 | sd = co.Sat + co.NumberOfGPSSat;
|
|---|
| 375 | ++co.NumberOfGPSSat;
|
|---|
| 376 | }
|
|---|
| 377 | else if (prn[0] == 'R') {
|
|---|
| 378 | sd = co.Sat + CLOCKORBIT_NUMGPS + co.NumberOfGLONASSSat;
|
|---|
| 379 | ++co.NumberOfGLONASSSat;
|
|---|
| 380 | }
|
|---|
| 381 | if (sd) {
|
|---|
| 382 | QString outLine;
|
|---|
| 383 | processSatellite(oldEph, _caster.at(ic)->crdTrafo(), ep, GPSweek,
|
|---|
| 384 | GPSweeks, prn, xx, sd, outLine);
|
|---|
| 385 | cout << outLine.toAscii().data();
|
|---|
| 386 | _caster.at(ic)->printAscii(outLine);
|
|---|
| 387 | }
|
|---|
| 388 | }
|
|---|
| 389 | }
|
|---|
| 390 |
|
|---|
| 391 | if ( _caster.at(ic)->used() &&
|
|---|
| 392 | (co.NumberOfGPSSat > 0 || co.NumberOfGLONASSSat > 0) ) {
|
|---|
| 393 | char obuffer[CLOCKORBIT_BUFFERSIZE];
|
|---|
| 394 | int len = MakeClockOrbit(&co, COTYPE_AUTO, 0, obuffer, sizeof(obuffer));
|
|---|
| 395 | if (len > 0) {
|
|---|
| 396 | emit(newOutBytes(len));
|
|---|
| 397 | _caster.at(ic)->write(obuffer, len);
|
|---|
| 398 | }
|
|---|
| 399 | }
|
|---|
| 400 | }
|
|---|
| 401 | }
|
|---|
| 402 | }
|
|---|
| 403 | }
|
|---|
| 404 |
|
|---|
| 405 | //
|
|---|
| 406 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 407 | void t_bns::processSatellite(int oldEph, bool trafo, t_eph* ep, int GPSweek,
|
|---|
| 408 | double GPSweeks, const QString& prn,
|
|---|
| 409 | const ColumnVector& xx,
|
|---|
| 410 | struct ClockOrbit::SatData* sd,
|
|---|
| 411 | QString& outLine) {
|
|---|
| 412 |
|
|---|
| 413 | ColumnVector xB(4);
|
|---|
| 414 | ColumnVector vv(3);
|
|---|
| 415 |
|
|---|
| 416 | ep->position(GPSweek, GPSweeks, xB, vv);
|
|---|
| 417 |
|
|---|
| 418 | ColumnVector xyz = xx.Rows(1,3);
|
|---|
| 419 | if (trafo) {
|
|---|
| 420 | crdTrafo(GPSweek, xyz);
|
|---|
| 421 | }
|
|---|
| 422 |
|
|---|
| 423 | ColumnVector dx = xyz - xB.Rows(1,3);
|
|---|
| 424 |
|
|---|
| 425 | double dClk = (xx(4) - xB(4)) * 299792458.0;
|
|---|
| 426 | ColumnVector rsw(3);
|
|---|
| 427 |
|
|---|
| 428 | XYZ_to_RSW(xB.Rows(1,3), vv, dx, rsw);
|
|---|
| 429 |
|
|---|
| 430 | if (sd) {
|
|---|
| 431 | sd->ID = prn.mid(1).toInt();
|
|---|
| 432 | sd->IOD = ep->IOD();
|
|---|
| 433 | sd->Clock.DeltaA0 = dClk;
|
|---|
| 434 | sd->Orbit.DeltaRadial = rsw(1);
|
|---|
| 435 | sd->Orbit.DeltaAlongTrack = rsw(2);
|
|---|
| 436 | sd->Orbit.DeltaCrossTrack = rsw(3);
|
|---|
| 437 | }
|
|---|
| 438 |
|
|---|
| 439 | char oldCh = (oldEph ? '!' : ' ');
|
|---|
| 440 | outLine.sprintf("%c %d %.1f %s %3d %10.3f %8.3f %8.3f %8.3f\n",
|
|---|
| 441 | oldCh, GPSweek, GPSweeks, ep->prn().toAscii().data(),
|
|---|
| 442 | ep->IOD(), dClk, rsw(1), rsw(2), rsw(3));
|
|---|
| 443 |
|
|---|
| 444 | if (!oldEph) {
|
|---|
| 445 | if (_rnx) {
|
|---|
| 446 | _rnx->write(GPSweek, GPSweeks, prn, xx);
|
|---|
| 447 | }
|
|---|
| 448 | if (_sp3) {
|
|---|
| 449 | _sp3->write(GPSweek, GPSweeks, prn, xx);
|
|---|
| 450 | }
|
|---|
| 451 | }
|
|---|
| 452 | }
|
|---|
| 453 |
|
|---|
| 454 | //
|
|---|
| 455 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 456 | void t_bns::slotMoveSocket(QThread* tt) {
|
|---|
| 457 | _clkSocket->setParent(0);
|
|---|
| 458 | _clkSocket->moveToThread(tt);
|
|---|
| 459 | slotMessage("bns::slotMoveSocket");
|
|---|
| 460 | }
|
|---|
| 461 |
|
|---|
| 462 | // Transform Coordinates IGS -> ETRF
|
|---|
| 463 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 464 | void t_bns::crdTrafo(int GPSWeek, ColumnVector& xyz) {
|
|---|
| 465 |
|
|---|
| 466 | ColumnVector dx(3);
|
|---|
| 467 | dx(1) = 0.054;
|
|---|
| 468 | dx(2) = 0.051;
|
|---|
| 469 | dx(3) = -0.048;
|
|---|
| 470 | const static double arcSec = 180.0 * 3600.0 / M_PI;
|
|---|
| 471 | const static double ox = 0.000081 / arcSec;
|
|---|
| 472 | const static double oy = 0.000490 / arcSec;
|
|---|
| 473 | const static double oz = -0.000792 / arcSec;
|
|---|
| 474 |
|
|---|
| 475 | Matrix rMat(3,3); rMat = 0.0;
|
|---|
| 476 | rMat(1,2) = -oz;
|
|---|
| 477 | rMat(1,3) = oy;
|
|---|
| 478 | rMat(2,1) = oz;
|
|---|
| 479 | rMat(2,3) = -ox;
|
|---|
| 480 | rMat(3,1) = -oy;
|
|---|
| 481 | rMat(3,2) = ox;
|
|---|
| 482 |
|
|---|
| 483 | // Current epoch minus 1989.0 in years
|
|---|
| 484 | // ------------------------------------
|
|---|
| 485 | double dt = (GPSWeek - 469.0) / 365.2422 * 7.0;
|
|---|
| 486 |
|
|---|
| 487 | xyz += dx + dt * rMat * xyz;
|
|---|
| 488 | }
|
|---|