From 0962be6b8b0939546e246c555832b4a799d5e240 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Mon, 26 Aug 2019 15:58:01 +0200 Subject: [PATCH] the whole thingus --- Makefile | 10 +- beidou.hh | 5 +- ephemeris.hh | 36 +- ext/CLI11/CLI/App.hpp | 1276 +++++++++++++++++++++++++++++++++ ext/CLI11/CLI/CLI.hpp | 16 + ext/CLI11/CLI/Error.hpp | 165 +++++ ext/CLI11/CLI/Ini.hpp | 115 +++ ext/CLI11/CLI/Option.hpp | 460 ++++++++++++ ext/CLI11/CLI/Split.hpp | 90 +++ ext/CLI11/CLI/StringTools.hpp | 190 +++++ ext/CLI11/CLI/Timer.hpp | 121 ++++ ext/CLI11/CLI/TypeTools.hpp | 114 +++ ext/CLI11/CLI/Validators.hpp | 83 +++ html/doalles.js | 26 +- navdump.cc | 11 + navnexus.cc | 2 +- navparse.cc | 186 ++++- ubxtool.cc | 504 ++++++++----- 18 files changed, 3177 insertions(+), 233 deletions(-) create mode 100644 ext/CLI11/CLI/App.hpp create mode 100644 ext/CLI11/CLI/CLI.hpp create mode 100644 ext/CLI11/CLI/Error.hpp create mode 100644 ext/CLI11/CLI/Ini.hpp create mode 100644 ext/CLI11/CLI/Option.hpp create mode 100644 ext/CLI11/CLI/Split.hpp create mode 100644 ext/CLI11/CLI/StringTools.hpp create mode 100644 ext/CLI11/CLI/Timer.hpp create mode 100644 ext/CLI11/CLI/TypeTools.hpp create mode 100644 ext/CLI11/CLI/Validators.hpp diff --git a/Makefile b/Makefile index bb6868c..9e7594a 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -CXXFLAGS:= -std=gnu++17 -Wall -O3 -MMD -MP -ggdb -fno-omit-frame-pointer -Iext/fmt-5.2.1/include/ -Iext/powerblog/ext/simplesocket -Iext/powerblog/ext/ +CXXFLAGS:= -std=gnu++17 -Wall -O3 -MMD -MP -ggdb -fno-omit-frame-pointer -Iext/CLI11 -Iext/fmt-5.2.1/include/ -Iext/powerblog/ext/simplesocket -Iext/powerblog/ext/ -I/usr/local/opt/openssl/include/ -Wno-delete-non-virtual-dtor PROGRAMS = navparse ubxtool navnexus navrecv navdump @@ -12,10 +12,10 @@ clean: H2OPP=ext/powerblog/h2o-pp.o SIMPLESOCKETS=ext/powerblog/ext/simplesocket/swrappers.o ext/powerblog/ext/simplesocket/sclasses.o ext/powerblog/ext/simplesocket/comboaddress.o -navparse: navparse.o ext/fmt-5.2.1/src/format.o $(H2OPP) $(SIMPLESOCKETS) minicurl.o ubx.o bits.o navmon.pb.o gps.o ephemeris.o - $(CXX) -std=gnu++17 $^ -o $@ -pthread -L/usr/local/lib -lh2o-evloop -lssl -lcrypto -lz -lcurl -lprotobuf # -lwslay +navparse: navparse.o ext/fmt-5.2.1/src/format.o $(H2OPP) $(SIMPLESOCKETS) minicurl.o ubx.o bits.o navmon.pb.o gps.o ephemeris.o beidou.o glonass.o + $(CXX) -std=gnu++17 $^ -o $@ -pthread -L/usr/local/lib -L/usr/local/opt/openssl/lib/ -lh2o-evloop -lssl -lcrypto -lz -lcurl -lprotobuf # -lwslay -navdump: navdump.o ext/fmt-5.2.1/src/format.o bits.o navmon.pb.o gps.o ephemeris.o +navdump: navdump.o ext/fmt-5.2.1/src/format.o bits.o navmon.pb.o gps.o ephemeris.o beidou.o glonass.o $(CXX) -std=gnu++17 $^ -o $@ -pthread -lprotobuf @@ -29,6 +29,6 @@ navrecv: navrecv.o ext/fmt-5.2.1/src/format.o $(SIMPLESOCKETS) navmon.pb.o stora navmon.pb.cc: navmon.proto protoc --cpp_out=./ navmon.proto -ubxtool: navmon.pb.o ubxtool.o ubx.o bits.o ext/fmt-5.2.1/src/format.o galileo.o gps.o +ubxtool: navmon.pb.o ubxtool.o ubx.o bits.o ext/fmt-5.2.1/src/format.o galileo.o gps.o beidou.o $(CXX) -std=gnu++17 $^ -o $@ -lprotobuf diff --git a/beidou.hh b/beidou.hh index d4ae692..118df9a 100644 --- a/beidou.hh +++ b/beidou.hh @@ -22,7 +22,7 @@ struct BeidouMessage }; - int fraid, sow; // part of every message (thanks!) + int fraid{-1}, sow{-1}; // part of every message (thanks!) int parse(std::basic_string_view cond, uint8_t* pageno) { @@ -99,6 +99,7 @@ struct BeidouMessage e = bbitu(133,32); cus = bbits(181, 18); crc = bbits(199, 18); + crs = bbits(225, 18); sqrtA = bbitu(251, 32); t0eMSB = bbitu(291, 2); @@ -126,7 +127,7 @@ struct BeidouMessage i0 = bbits(66, 32); cic = bbits(106, 18); omegadot = bbits(132, 24); - cis = bbits(160, 18); + cis = bbits(164, 18); idot = bbits(190, 14); Omega0 = bbits(212, 32); omega = bbits(252, 32); diff --git a/ephemeris.hh b/ephemeris.hh index 8fbb171..02f001b 100644 --- a/ephemeris.hh +++ b/ephemeris.hh @@ -10,30 +10,30 @@ void getCoordinates(int wn, double tow, const T& iod, Point* p, bool quiet=true) using namespace std; // here goes - const double mu = 3.986004418 * pow(10.0, 14.0); - const double omegaE = 7.2921151467 * pow(10.0, -5); + const double mu = iod.getMu(); + const double omegaE = iod.getOmegaE(); - double sqrtA = 1.0*iod.sqrtA / (1ULL<<19); - double deltan = M_PI * 1.0*iod.deltan / (1LL<<43); - double t0e = iod.t0e; // t0e is PRE-SCALED - double m0 = M_PI * 1.0*iod.m0 / (1LL<<31); - double e = 1.0*iod.e / (1ULL<<33); - double omega = M_PI * 1.0*iod.omega / (1LL<<31); + const double sqrtA = iod.getSqrtA(); + const double deltan = iod.getDeltan(); + const double t0e = iod.getT0e(); + const double m0 = iod.getM0(); + const double e = iod.getE(); + const double omega = iod.getOmega(); - double cuc = 1.0*iod.cuc / (1LL<<29); - double cus = 1.0*iod.cus / (1LL<<29); + const double cuc = iod.getCuc(); + const double cus = iod.getCus(); - double crc = 1.0*iod.crc / (1LL<<5); - double crs = 1.0*iod.crs / (1LL<<5); + const double crc = iod.getCrc(); + const double crs = iod.getCrs(); - double cic = 1.0*iod.cic / (1LL<<29); - double cis = 1.0*iod.cis / (1LL<<29); + const double cic = iod.getCic(); + const double cis = iod.getCis(); - double idot = M_PI * 1.0*iod.idot / (1LL<<43); - double i0 = M_PI * 1.0*iod.i0 / (1LL << 31); + const double idot = iod.getIdot(); + const double i0 = iod.getI0(); - double Omegadot = M_PI * 1.0*iod.omegadot / (1LL << 43); - double Omega0 = M_PI * 1.0*iod.omega0 / (1LL << 31); + const double Omegadot = iod.getOmegadot(); + const double Omega0 = iod.getOmega0(); // NO IOD BEYOND THIS POINT! if(!quiet) { diff --git a/ext/CLI11/CLI/App.hpp b/ext/CLI11/CLI/App.hpp new file mode 100644 index 0000000..cdb91ab --- /dev/null +++ b/ext/CLI11/CLI/App.hpp @@ -0,0 +1,1276 @@ +#pragma once + +// Distributed under the 3-Clause BSD License. See accompanying +// file LICENSE or https://github.com/CLIUtils/CLI11 for details. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// CLI Library includes +#include "CLI/Error.hpp" +#include "CLI/Ini.hpp" +#include "CLI/Option.hpp" +#include "CLI/Split.hpp" +#include "CLI/StringTools.hpp" +#include "CLI/TypeTools.hpp" + +namespace CLI { + +namespace detail { +enum class Classifer { NONE, POSITIONAL_MARK, SHORT, LONG, SUBCOMMAND }; +struct AppFriend; +} // namespace detail + +class App; + +using App_p = std::unique_ptr; + +/// Creates a command line program, with very few defaults. +/** To use, create a new `Program()` instance with `argc`, `argv`, and a help description. The templated +* add_option methods make it easy to prepare options. Remember to call `.start` before starting your +* program, so that the options can be evaluated and the help option doesn't accidentally run your program. */ +class App { + friend Option; + friend detail::AppFriend; + + protected: + // This library follows the Google style guide for member names ending in underscores + + /// @name Basics + ///@{ + + /// Subcommand name or program name (from parser) + std::string name_{"program"}; + + /// Description of the current program/subcommand + std::string description_; + + /// If true, allow extra arguments (ie, don't throw an error). + bool allow_extras_{false}; + + /// If true, return immediatly on an unrecognised option (implies allow_extras) + bool prefix_command_{false}; + + /// This is a function that runs when complete. Great for subcommands. Can throw. + std::function callback_; + + ///@} + /// @name Options + ///@{ + + /// The list of options, stored locally + std::vector options_; + + /// A pointer to the help flag if there is one + Option *help_ptr_{nullptr}; + + ///@} + /// @name Parsing + ///@{ + + using missing_t = std::vector>; + + /// Pair of classifier, string for missing options. (extra detail is removed on returning from parse) + /// + /// This is faster and cleaner than storing just a list of strings and reparsing. This may contain the -- separator. + missing_t missing_; + + /// This is a list of pointers to options with the orignal parse order + std::vector