Go to the documentation of this file.
251 #include "NewNavInc.h"
252 #include <gnsstk/BasicFramework.hpp>
254 #include <gnsstk/TimeString.hpp>
255 #include <gnsstk/TimeConstants.hpp>
257 #include <gnsstk/ANSITime.hpp>
258 #include <gnsstk/CivilTime.hpp>
259 #include <gnsstk/GPSWeekSecond.hpp>
260 #include <gnsstk/GPSWeekZcount.hpp>
261 #include <gnsstk/JulianDate.hpp>
262 #include <gnsstk/MJD.hpp>
263 #include <gnsstk/UnixTime.hpp>
264 #include <gnsstk/YDSTime.hpp>
265 #include <gnsstk/SystemTime.hpp>
267 #include <gnsstk/CommandOptionWithCommonTimeArg.hpp>
268 #include <gnsstk/EnumIterator.hpp>
269 #include <gnsstk/BasicTimeSystemConverter.hpp>
270 #include <gnsstk/NavTimeSystemConverter.hpp>
271 #include <gnsstk/MultiFormatNavDataFactory.hpp>
287 const std::string& loOpt,
288 const std::string& desc)
297 void printHelp(std::ostream& out,
bool pretty =
true)
override
299 out <<
"Available Time Systems:" << endl;
314 virtual void process();
354 :
BasicFramework(arg0,
"Converts from a given input time specification"
355 " to other time formats. Include the quotation marks."
356 " All year values are four digit years.\n\nWhen"
357 " converting between time systems, GPS is the default"
358 " source time system when a time is specified, while UTC"
359 " is the default source time system when a time is not"
361 ANSITimeOption(
'A',
"ansi",
"%K",
"\"ANSI-Second\""),
362 CivilTimeOption(
'c',
"civil",
"%m %d %Y %H:%M:%f",
363 "\"Month(numeric) DayOfMonth Year"
364 " Hour:Minute:Second\""),
365 RinexFileTimeOption(
'R',
"rinex-file",
"%y %m %d %H %M %S",
366 "\"Year(2-digit) Month(numeric) DayOfMonth Hour"
368 GPSEWSOption(
'o',
"ews",
"%E %G %g",
369 "\"GPSEpoch 10bitGPSweek SecondOfWeek\""),
370 GPSWSOption(
'f',
"ws",
"%F %g",
"\"FullGPSWeek SecondOfWeek\""),
371 GPSWZOption(
'w',
"wz",
"%F %Z",
"\"FullGPSWeek Zcount\""),
372 GPSZ29Option(0,
"z29",
"%E %c",
"\"29bitZcount\""),
373 GPSZ32Option(
'Z',
"z32",
"%C",
"\"32bitZcount\""),
374 JDOption(
'j',
"julian",
"%J",
"\"JulianDate\""),
375 MJDOption(
'm',
"mjd",
"%Q",
"\"ModifiedJulianDate\""),
376 UnixTimeOption(
'u',
"unixtime",
"%U %u",
377 "\"UnixSeconds UnixMicroseconds\""),
378 YDSTimeOption(
'y',
"doy",
"%Y %j %s",
379 "\"Year DayOfYear SecondsOfDay\""),
380 inputFormatOption(0,
"input-format",
"Time format to use on input"),
381 inputTimeOption(0,
"input-time",
382 "Time to be parsed by \"input-format\" option"),
383 formatOption(
'F',
"format",
"Time format to use on output"),
384 addOption(
'a',
"add-offset",
"Add NUM seconds to specified time"),
385 subOption(
's',
"sub-offset",
386 "Subtract NUM seconds from specified time"),
387 timeSystemHelpOption(0,
"systems",
"List available time systems"),
388 srcTSOption(0,
"src-sys",
"Source time system when converting between"
390 tgtTSOption(0,
"tgt-sys",
"Target time system when converting between"
392 navOption(0,
"nav",
"if you see this, we failed"),
393 offsOnlyOption(0,
"offset",
"Only display the offset at the reference"
395 offsetTgtTSOption(&tgtTSOption, &offsOnlyOption)
400 ndfp = std::make_shared<gnsstk::MultiFormatNavDataFactory>();
402 ndfp->setTypeFilter({NavMessageType::TimeOffset});
404 ndfp->getFactoryFormats() +
".");
454 CommonTime::tsConv = make_shared<NavTimeSystemConverter>();
456 CommonTime::tsConv.get());
459 ntsc->
navLib = make_shared<NavLibrary>();
464 for (
size_t i=0; i<values.size(); i++)
466 if (!
ndfp->addDataSource(values[i]))
468 cerr <<
"Unable to load \"" << values[i] <<
"\"" << endl;
470 exitCode = BasicFramework::EXIST_ERROR;
494 CommonTime::tsConv = make_shared<BasicTimeSystemConverter>();
539 for (i = 0; i < addOptions; i++)
541 for (i = 0; i < subOptions; i++)
551 if (!CommonTime::tsConv->getOffset(ct.
getTimeSystem(), ts, ct, offset))
553 cerr <<
"Unable to change time systems" << endl;
558 cout << setprecision(20) << offset << endl;
566 cerr <<
"Unable to change time systems" << endl;
580 string eight(8,
' ');
586 << eight <<
leftJustify(
"Month/Day/Year H:M:S", 32)
589 << eight <<
leftJustify(
"Modified Julian Date", 32)
590 << setprecision(15) <<
MJD(ct).
printf(
"%15.9Q") << endl
592 << eight <<
leftJustify(
"GPSweek DayOfWeek SecOfWeek", 32)
596 << wz.
printf(
"%F % 6z") << endl
598 << eight <<
leftJustify(
"Year DayOfYear SecondOfDay", 32)
601 << eight <<
leftJustify(
"Unix: Second Microsecond", 32)
604 << eight <<
leftJustify(
"Zcount: 29-bit (32-bit)", 32)
605 << wz.
printf(
"%c (%C)") << endl
614 int main(
int argc,
char* argv[])
616 #include "NewNavInit.h"
629 catch(std::exception& e)
631 cout << e.
what() << endl;
635 cout <<
"unknown error" << endl;
638 return BasicFramework::EXCEPTION_ERROR;
CommandOptionWithAnyArg inputFormatOption
void printHelp(std::ostream &out, bool pretty=true) override
CommandOptionWithCommonTimeArg GPSWZOption
CommandOptionNoArg offsOnlyOption
CommandOptionWithCommonTimeArg GPSEWSOption
CommandOptionMutex offsetOrFormatOption
void addOption(CommandOption *opt)
Add an option to the list of mutually exclusive options.
int debugLevel
Debug level for this run of the program.
int main(int argc, char *argv[])
virtual std::string printf(const std::string &fmt) const
CommandOptionHelpTimeSystem timeSystemHelpOption
std::string what() const
Dump to a string.
virtual unsigned long getCount() const
std::string asString(IonexStoreStrategy e)
Convert a IonexStoreStrategy to a whitespace-free string name.
CommandOptionWithCommonTimeArg GPSWSOption
CommonTime & setTimeSystem(TimeSystem timeSystem)
CommandOptionMutex mutexOption
CommandOptionWithAnyArg srcTSOption
Source time system.
EnumIterator< TimeSystem, TimeSystem::Unknown, TimeSystem::Last > TimeSystemIterator
CommandOptionAllOf inputFormatAndTimeOption
CommandOption * whichOne() const
CommandOptionWithAnyArg inputTimeOption
CommandOptionWithAnyArg formatOption
CommandOptionWithCommonTimeArg RinexFileTimeOption
std::shared_ptr< NavDataFactory > NavDataFactoryPtr
Managed pointer to NavDataFactory.
CommandOptionHelpTimeSystem(const char shOpt, const std::string &loOpt, const std::string &desc)
void mixedScanTime(CommonTime &t, const string &str, const string &fmt)
CommandOptionWithCommonTimeArg MJDOption
TimeSystem asTimeSystem(const std::string &s)
Convert a string representation of TimeSystem to an enum.
CommandOptionWithCommonTimeArg GPSZ32Option
CommandOptionWithCommonTimeArg UnixTimeOption
virtual std::string printf(const std::string &fmt) const
virtual std::string printf(const std::string &fmt) const
gnsstk::NavDataFactoryPtr ndfp
nav data file reader
CommandOptionWithNumberArg subOption
CommandOptionWithNumberArg addOption
CommandOptionWithCommonTimeArg JDOption
TimeSystem
Definition of various time systems.
CommandOptionWithCommonTimeArg GPSZ29Option
double asDouble(const std::string &s)
@ Full
Include all detailed information.
CommandOptionWithAnyArg tgtTSOption
Target time system.
CommandOptionWithCommonTimeArg CivilTimeOption
TimeSystem getTimeSystem() const
Obtain time system info (enum).
std::string printTime(const CommonTime &t, const std::string &fmt)
@ Brief
Limit output to <= 5 lines of minimal information.
std::shared_ptr< NavLibrary > navLib
Pointer to the nav library from which we will get time offset data.
const std::vector< CommonTime > & getTime() const
Return the times scanned in from the command line.
const std::vector< std::string > & getValue() const
virtual std::string printf(const std::string &fmt) const
virtual std::string printf(const std::string &fmt) const
virtual bool initialize(int argc, char *argv[], bool pretty=true) noexcept
@ OneLine
Limit output to minimal information on a single line.
std::string & leftJustify(std::string &s, const std::string::size_type length, const char pad=' ')
CommandOptionDependent offsetTgtTSOption
bool changeTimeSystem(TimeSystem timeSystem, TimeSystemConverter *conv)
CommandOptionWithAnyArg navOption
Navigation data input files.
CommandOptionWithCommonTimeArg ANSITimeOption
CommandOptionWithCommonTimeArg YDSTimeOption
CommandOption & setMaxCount(const unsigned long l)
void setDescription(const std::string &desc)
virtual std::string printf(const std::string &fmt) const
gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:42