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, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 **************************************************************************/
19
25#ifndef DATA_MONITOR_DLG_
26#define DATA_MONITOR_DLG_
27
28#include <fstream>
29
30#include <wx/frame.h>
31
33#include "tty_scroll.h"
34#include "std_filesystem.h"
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
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};
72
74class DataMonitor : public wxFrame, public NmeaLog {
75public:
76 explicit DataMonitor(wxWindow* parent);
77
79 void Add(const Logline& ll) override;
80
81 bool IsVisible() const override;
82
83 void OnHide();
84
85private:
86 static void OnFilterListChange();
87 void OnFilterUpdate(const std::string& name) const;
88 void OnFilterApply(const std::string& name);
89
90 DataMonitorSrc m_monitor_src;
91 wxWindow* m_quick_filter;
92 DataLogger m_logger;
93 ObsListener m_filter_list_lstnr;
94 ObsListener m_filter_update_lstnr;
95 ObsListener m_filter_apply_lstnr;
96 std::string m_current_filter;
97};
98
99#endif // DATA_MONITOR_DLG_
Internal helper class.
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().
Generic event handling between MVC Model and Controller based on a shared EventVar variable.
NMEA Log Interface.
Definition nmea_log.h:72
Define an action to be performed when a KeyProvider is notified.
Definition observable.h:257
Provide a data stream of input messages for the Data Monitor.
Item in the log window.
Definition nmea_log.h:34
Scrolled TTY-like window for logging, related utilities.