add sp3feed tool to stream sp3 data into influxdb

baudrate
bert hubert 2020-06-17 20:48:57 +02:00
parent b677847cca
commit 79ee7139c2
2 changed files with 60 additions and 1 deletions

View File

@ -24,7 +24,7 @@ endif
CHEAT_ARG := $(shell ./update-git-hash-if-necessary)
PROGRAMS = navparse ubxtool navnexus navcat navrecv navdump testrunner navdisplay tlecatch reporter \
PROGRAMS = navparse ubxtool navnexus navcat navrecv navdump testrunner navdisplay tlecatch reporter sp3feed \
galmonmon rinreport rtcmtool
all: navmon.pb.cc $(PROGRAMS)
@ -82,6 +82,10 @@ navparse: navparse.o ext/fmt-6.1.2/src/format.o $(H2OPP) $(SIMPLESOCKETS) minicu
reporter: reporter.o ext/fmt-6.1.2/src/format.o $(SIMPLESOCKETS) minicurl.o ubx.o bits.o navmon.pb.o gps.o ephemeris.o beidou.o glonass.o $(patsubst %.cc,%.o,$(wildcard ext/sgp4/libsgp4/*.cc)) tle.o navmon.o coverage.o osen.o githash.o
$(CXX) -std=gnu++17 $^ -o $@ -pthread -L/usr/local/lib -lprotobuf -lcurl
sp3feed: sp3feed.o ext/fmt-6.1.2/src/format.o $(SIMPLESOCKETS) minicurl.o ubx.o bits.o navmon.pb.o gps.o ephemeris.o beidou.o glonass.o $(patsubst %.cc,%.o,$(wildcard ext/sgp4/libsgp4/*.cc)) tle.o navmon.o coverage.o osen.o influxpush.o githash.o sp3.o
$(CXX) -std=gnu++17 $^ -o $@ -pthread -L/usr/local/lib -lprotobuf -lcurl
tracker: tracker.o ext/fmt-6.1.2/src/format.o $(SIMPLESOCKETS) minicurl.o ubx.o bits.o navmon.pb.o gps.o ephemeris.o beidou.o glonass.o $(patsubst %.cc,%.o,$(wildcard ext/sgp4/libsgp4/*.cc)) tle.o navmon.o coverage.o osen.o githash.o
$(CXX) -std=gnu++17 $^ -o $@ -pthread -L/usr/local/lib -lprotobuf -lcurl

55
sp3feed.cc 100644
View File

@ -0,0 +1,55 @@
#include "sp3.hh"
#include "influxpush.hh"
#include <iostream>
#include "navmon.hh"
#include "fmt/format.h"
#include "fmt/printf.h"
#include "CLI/CLI.hpp"
#include "version.hh"
static char program[]="sp3feed";
using namespace std;
extern const char* g_gitHash;
int main(int argc, char **argv)
{
string influxDBName("galileo2");
bool doVERSION=false;
int sigid=1;
CLI::App app(program);
vector<string> fnames;
app.add_flag("--version", doVERSION, "show program version and copyright");
app.add_option("--sigid,-s", sigid, "Signal identifier. 1 or 5 for Galileo.");
app.add_option("--influxdb", influxDBName, "Name of influxdb database");
app.add_option("files", fnames, "filenames to parse");
try {
app.parse(argc, argv);
} catch(const CLI::Error &e) {
return app.exit(e);
}
if(doVERSION) {
showVersion(program, g_gitHash);
exit(0);
}
InfluxPusher idb(influxDBName);
for(const auto& fn : fnames) {
SP3Reader sp3(fn);
SP3Entry e;
SatID sid;
cout<<fn<<endl;
while(sp3.get(e)) {
sid.gnss = e.gnss;
sid.sigid = sigid;
sid.sv = e.sv;
// XXX LEAP SECOND ADJUSTMENT FIXED AT 18 SECONDS
idb.addValue(sid, "sp3", {{"x", e.x}, {"y", e.y}, {"z", e.z}, {"clock-bias", e.clockBias}}, e.t + 18);
}
}
}