OpenCPN Partial API docs
Loading...
Searching...
No Matches
data_monitor.h
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2025 Alec Leamas *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
16 **************************************************************************/
17
24#ifndef DATA_MONITOR_DLG_
25#define DATA_MONITOR_DLG_
26
27#include <fstream>
28
29#include <wx/frame.h>
30
32#include "tty_scroll.h"
33#include "std_filesystem.h"
34
40public:
41 enum class Format { kVdr, kDefault, kCsv };
42
43 DataLogger(wxWindow* parent, const fs::path& path);
44
45 explicit DataLogger(wxWindow* parent);
46
47 void SetLogging(bool logging);
48
49 void SetLogfile(const fs::path& path);
50
51 fs::path GetLogfile() const { return m_path; }
52
53 void Add(const Logline& ll);
54
55 void SetFormat(Format format);
56
57 std::string GetFileDlgTypes() const;
58
59 fs::path GetDefaultLogfile();
60
62 obs::EventVar OnNewLogfile;
63
64private:
65 wxWindow* m_parent;
66 fs::path m_path;
67 std::ofstream m_stream;
68 bool m_is_logging;
69 Format m_format;
70 const NavmsgTimePoint m_log_start;
71 std::string m_header;
72};
73
75class DataMonitor : public wxFrame, public NmeaLog {
76public:
77 explicit DataMonitor(wxWindow* parent);
78
80 void Add(const Logline& ll) override;
81
82 bool IsVisible() const override;
83
84 void OnHide();
85
86private:
87 static void OnFilterListChange();
88 void OnFilterUpdate(const std::string& name) const;
89 void OnFilterApply(const std::string& name);
90
91 DataMonitorSrc m_monitor_src;
92 wxWindow* m_quick_filter;
93 DataLogger m_logger;
94 obs::Listener m_filter_list_lstnr;
95 obs::Listener m_filter_update_lstnr;
96 obs::Listener m_filter_apply_lstnr;
97 std::string m_current_filter;
98};
99
100#endif // DATA_MONITOR_DLG_
Internal helper class.
obs::EventVar OnNewLogfile
Notified with new path on filename change.
Create a stream of input messages.
Overall logging handler, outputs to screen and log file.
void Add(const Logline &ll) override
Add an input line to log output.
bool IsVisible() const override
Return true if log is visible i.e., if it's any point using Add().
NMEA Log Interface.
Definition nmea_log.h:70
Provide a data stream of input messages for the Data Monitor.
Item in the log window.
Definition nmea_log.h:32
Scrolled tty like window for logging.