0.5.0
Loading...
Searching...
No Matches
NmeaFile.hpp
Go to the documentation of this file.
1// This file is part of INSTINCT, the INS Toolkit for Integrated
2// Navigation Concepts and Training by the Institute of Navigation of
3// the University of Stuttgart, Germany.
4//
5// This Source Code Form is subject to the terms of the Mozilla Public
6// License, v. 2.0. If a copy of the MPL was not distributed with this
7// file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
9/// @file NmeaFile.hpp
10/// @brief File Reader for NMEA files
11/// @author T. Hobiger (thomas.hobiger@ins.uni-stuttgart.de)
12/// @date 2022-11-03
13
14#pragma once
15
18
19namespace NAV
20{
21/// File Reader for NMEA log files
22class NmeaFile : public Node, public FileReader
23{
24 public:
25 /// @brief Default constructor
26 NmeaFile();
27 /// @brief Destructor
28 ~NmeaFile() override;
29 /// @brief Copy constructor
30 NmeaFile(const NmeaFile&) = delete;
31 /// @brief Move constructor
32 NmeaFile(NmeaFile&&) = delete;
33 /// @brief Copy assignment operator
34 NmeaFile& operator=(const NmeaFile&) = delete;
35 /// @brief Move assignment operator
37
38 /// @brief String representation of the Class Type
39 [[nodiscard]] static std::string typeStatic();
40
41 /// @brief String representation of the Class Type
42 [[nodiscard]] std::string type() const override;
43
44 /// @brief String representation of the Class Category
45 [[nodiscard]] static std::string category();
46
47 /// @brief ImGui config window which is shown on double click
48 /// @attention Don't forget to set _hasConfig to true in the constructor of the node
49 void guiConfig() override;
50
51 /// @brief Saves the node into a json object
52 [[nodiscard]] json save() const override;
53
54 /// @brief Restores the node from a json object
55 /// @param[in] j Json object with the node state
56 void restore(const json& j) override;
57
58 /// @brief Resets the node. Moves the read cursor to the start
59 bool resetNode() override;
60
61 private:
62 constexpr static size_t OUTPUT_PORT_INDEX_NMEA_POS_OBS = 0; ///< @brief Flow (PosVel)
63
64 /// @brief Initialize the node
65 bool initialize() override;
66
67 /// @brief Deinitialize the node
68 void deinitialize() override;
69
70 /// @brief Polls data from the file
71 /// @return The read observation
72 [[nodiscard]] std::shared_ptr<const NodeData> pollData();
73
74 /// @brief Determines the type of the file
75 /// @return The File Type
76 [[nodiscard]] FileType determineFileType() override;
77
78 /// @brief Read the Header of the file
79 void readHeader() override;
80
81 /// @brief Checks whether a ZDA or RMC time tag was read so that UTC can be reconstructed together with the GGA tag
82 bool _hasValidDate = false;
83
84 /// @brief Second of day (SOD) from last GGA stream. This variable is used to check if SOD is increasing, if not, wait for next ZDA stream to get date info
85 double _oldSoD = -1.0;
86
87 /// @brief Current date
88 struct
89 {
90 int year = 0; ///< Year
91 int month = 0; ///< Month 01 to 12
92 int day = 0; ///< Day 01 to 31
94
95 /// @brief Set date info from ZDA steam
96 /// @param[in] line Line that contains a potential $--ZDA stream
97 /// @return True if the $--ZDA stream was read successfully
98 bool setDateFromZDA(const std::string& line);
99
100 /// @brief Set date info from RMC steam
101 /// @param[in] line Line that contains a potential $--RMC stream
102 /// @return True if the $--RMC stream was read successfully
103 bool setDateFromRMC(const std::string& line);
104};
105
106} // namespace NAV
Abstract File Reader class.
nlohmann::json json
json namespace
Node Class.
FileType
File Type Enumeration.
FileReader(const FileReader &)=delete
Copy constructor.
bool setDateFromZDA(const std::string &line)
Set date info from ZDA steam.
Definition NmeaFile.cpp:115
double _oldSoD
Second of day (SOD) from last GGA stream. This variable is used to check if SOD is increasing,...
Definition NmeaFile.hpp:85
NmeaFile & operator=(NmeaFile &&)=delete
Move assignment operator.
bool _hasValidDate
Checks whether a ZDA or RMC time tag was read so that UTC can be reconstructed together with the GGA ...
Definition NmeaFile.hpp:82
void restore(const json &j) override
Restores the node from a json object.
Definition NmeaFile.cpp:81
void deinitialize() override
Deinitialize the node.
Definition NmeaFile.cpp:98
bool initialize() override
Initialize the node.
Definition NmeaFile.cpp:91
static std::string typeStatic()
String representation of the Class Type.
Definition NmeaFile.cpp:38
NmeaFile(const NmeaFile &)=delete
Copy constructor.
struct NAV::NmeaFile::@035207343112113160312011275043304125120067020170 _currentDate
Current date.
int month
Month 01 to 12.
Definition NmeaFile.hpp:91
NmeaFile()
Default constructor.
Definition NmeaFile.cpp:22
json save() const override
Saves the node into a json object.
Definition NmeaFile.cpp:70
~NmeaFile() override
Destructor.
Definition NmeaFile.cpp:33
std::shared_ptr< const NodeData > pollData()
Polls data from the file.
Definition NmeaFile.cpp:193
int year
Year.
Definition NmeaFile.hpp:90
static constexpr size_t OUTPUT_PORT_INDEX_NMEA_POS_OBS
Flow (PosVel)
Definition NmeaFile.hpp:62
void guiConfig() override
ImGui config window which is shown on double click.
Definition NmeaFile.cpp:53
bool resetNode() override
Resets the node. Moves the read cursor to the start.
Definition NmeaFile.cpp:105
static std::string category()
String representation of the Class Category.
Definition NmeaFile.cpp:48
bool setDateFromRMC(const std::string &line)
Set date info from RMC steam.
Definition NmeaFile.cpp:150
std::string type() const override
String representation of the Class Type.
Definition NmeaFile.cpp:43
void readHeader() override
Read the Header of the file.
Definition NmeaFile.cpp:322
int day
Day 01 to 31.
Definition NmeaFile.hpp:92
FileType determineFileType() override
Determines the type of the file.
Definition NmeaFile.cpp:317
NmeaFile & operator=(const NmeaFile &)=delete
Copy assignment operator.
NmeaFile(NmeaFile &&)=delete
Move constructor.
Node(std::string name)
Constructor.
Definition Node.cpp:30