INSTINCT Code Coverage Report


Directory: src/
File: Nodes/DataLogger/GNSS/UartDataLogger.cpp
Date: 2025-11-25 23:34:18
Exec Total Coverage
Lines: 13 43 30.2%
Functions: 4 12 33.3%
Branches: 9 52 17.3%

Line Branch Exec Source
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 #include "UartDataLogger.hpp"
10
11 #include "NodeData/General/UartPacket.hpp"
12
13 #include "util/Logger.hpp"
14
15 #include <iomanip> // std::setprecision
16
17 #include "internal/FlowManager.hpp"
18
19 114 NAV::UartDataLogger::UartDataLogger()
20
3/6
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 114 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 114 times.
✗ Branch 9 not taken.
114 : Node(typeStatic())
21 {
22 LOG_TRACE("{}: called", name);
23
24 114 _fileType = FileType::BINARY;
25
26 114 _hasConfig = true;
27 114 _guiConfigDefaultWindowSize = { 380, 70 };
28
29
4/8
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 114 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 114 times.
✓ Branch 9 taken 114 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
342 CreateInputPin("writeObservation", Pin::Type::Flow, { NAV::UartPacket::type() }, &UartDataLogger::writeObservation);
30 228 }
31
32 228 NAV::UartDataLogger::~UartDataLogger()
33 {
34 LOG_TRACE("{}: called", nameId());
35 228 }
36
37 228 std::string NAV::UartDataLogger::typeStatic()
38 {
39
1/2
✓ Branch 1 taken 228 times.
✗ Branch 2 not taken.
456 return "UartDataLogger";
40 }
41
42 std::string NAV::UartDataLogger::type() const
43 {
44 return typeStatic();
45 }
46
47 114 std::string NAV::UartDataLogger::category()
48 {
49
1/2
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
228 return "Data Logger";
50 }
51
52 void NAV::UartDataLogger::guiConfig()
53 {
54 if (FileWriter::guiConfig(".ubx", { ".ubx" }, size_t(id), nameId()))
55 {
56 flow::ApplyChanges();
57 doDeinitialize();
58 }
59 }
60
61 [[nodiscard]] json NAV::UartDataLogger::save() const
62 {
63 LOG_TRACE("{}: called", nameId());
64
65 json j;
66
67 j["FileWriter"] = FileWriter::save();
68
69 return j;
70 }
71
72 void NAV::UartDataLogger::restore(json const& j)
73 {
74 LOG_TRACE("{}: called", nameId());
75
76 if (j.contains("FileWriter"))
77 {
78 FileWriter::restore(j.at("FileWriter"));
79 }
80 }
81
82 void NAV::UartDataLogger::flush()
83 {
84 _filestream.flush();
85 }
86
87 bool NAV::UartDataLogger::initialize()
88 {
89 LOG_TRACE("{}: called", nameId());
90
91 return FileWriter::initialize();
92 }
93
94 void NAV::UartDataLogger::deinitialize()
95 {
96 LOG_TRACE("{}: called", nameId());
97
98 FileWriter::deinitialize();
99 }
100
101 void NAV::UartDataLogger::writeObservation(NAV::InputPin::NodeDataQueue& queue, size_t /* pinIdx */)
102 {
103 auto obs = std::static_pointer_cast<const UartPacket>(queue.extract_front());
104
105 if (obs->raw.getRawDataLength() > 0)
106 {
107 _filestream.write(reinterpret_cast<const char*>(obs->raw.getRawData().data()), static_cast<std::streamsize>(obs->raw.getRawDataLength()));
108 }
109 else
110 {
111 LOG_ERROR("{}: Tried to write binary, but observation had no binary data.", nameId());
112 }
113 }
114