28#include <unordered_map>
42 const std::function<
void(
ObservedEvt)>& on_message) {
43 ol.
Init(msg, on_message);
47 : m_sink_func(sink_func) {
48 new_msg_lstnr.
Init(NavMsgBus::GetInstance().new_msg_event,
54void DataMonitorSrc::OnNewMessage() {
56 for (
const auto& msg : messages) {
57 auto found = m_listeners.find(msg);
58 if (found == m_listeners.end()) {
60 std::string type(msg);
62 NavAddr::Bus bus = NavAddr::Bus::Undef;
63 if ((pos = type.find(
"::")) != std::string::npos) {
64 auto bus_str = type.substr(0, pos);
65 bus = NavAddr::StringToBus(bus_str);
66 type = type.substr(pos + 2);
67 if ((pos = type.find(
'-')) != std::string::npos)
68 type = type.substr(pos + 1);
69 m_listeners[msg] = std::move(listener);
74 case NavAddr::Bus::N0183: {
76 InitListener(m_listeners[msg], type_msg, listen_action);
78 case NavAddr::Bus::N2000: {
81 InitListener(m_listeners[msg], type_msg, listen_action);
83 wxLogMessage(
"Bad Nmea2000 type: %s", type.c_str());
86 case NavAddr::Bus::Plugin: {
88 InitListener(m_listeners[msg], type_msg, listen_action);
90 case NavAddr::Bus::Signalk: {
92 InitListener(m_listeners[msg], type_msg, listen_action);
103 auto ptr = UnpackEvtPointer<NavMsg>(ev);
104 if (ptr && ptr->to_string() != m_last_payload) {
105 m_last_payload = ptr->to_string();
EventVar evt_dropped_msg
Updated by drivers with a shared Navmsg pointer when receiving data otherwise dropped,...
DataMonitorSrc(const SinkFunc &sink_func)
Create instance which listens and forwards messages using the sink_func callback function.
const std::set< std::string > & GetActiveMessages()
Return list of message types sent or received.
Actual data sent between application and transport layer.
A regular Nmea0183 message.
See: https://github.com/OpenCPN/OpenCPN/issues/2729#issuecomment-1179506343.
Define an action to be performed when a KeyProvider is notified.
void Init(const KeyProvider &kp, const std::function< void(ObservedEvt &ev)> &action)
Initiate an object yet not listening.
Custom event class for OpenCPN's notification system.
A plugin to plugin json message over the REST interface.
A parsed SignalK message over ipv4.
Driver registration container, a singleton.
Raw, undecoded messages definitions.
Raw messages layer, supports sending and recieving navmsg messages.
Provide a data stream of input messages for the Data Monitor.
General observable implementation with several specializations.
Miscellaneous utilities, many of which string related.