OpenCPN Partial API docs
Loading...
Searching...
No Matches
comm_plugin_api.cpp
1/***************************************************************************
2 *
3 * Project: OpenCPN
4 * Purpose: Implement communications defined in ocpn_plugin.h
5 * Author: David Register, Alec Leamas
6 *
7 ***************************************************************************
8 * Copyright (C) 2022 by David Register, Alec Leamas *
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
24 **************************************************************************/
25#include <memory>
26#include <sstream>
27#include <vector>
28
29#include <wx/event.h>
30
31#include "ocpn_plugin.h"
32#include "comm_navmsg_bus.h"
33#include "comm_appmsg.h"
34
35using namespace std;
36
37vector<uint8_t> GetN2000Payload(NMEA2000Id id, ObservedEvt ev) {
38 auto msg = UnpackEvtPointer<Nmea2000Msg>(ev);
39 return msg->payload;
40}
41
42std::string GetN2000Source(NMEA2000Id id, ObservedEvt ev) {
43 auto msg = UnpackEvtPointer<Nmea2000Msg>(ev);
44 return msg->source->to_string();
45}
46
47std::string GetN0183Payload(NMEA0183Id id, ObservedEvt ev) {
48 auto msg = UnpackEvtPointer<Nmea0183Msg>(ev);
49 return msg->payload;
50}
51
52shared_ptr<ObservableListener> GetListener(NMEA2000Id id, wxEventType et,
53 wxEvtHandler* eh) {
54 return make_shared<ObservableListener>(Nmea2000Msg(id.id), eh,
55 et);
56}
57
58std::shared_ptr<ObservableListener> GetListener(NMEA0183Id id, wxEventType et,
59 wxEvtHandler* eh) {
60 return make_shared<ObservableListener>(Nmea0183Msg(id.id), eh, et);
61}
62
63shared_ptr<ObservableListener> GetListener(SignalkId id, wxEventType et,
64 wxEvtHandler* eh) {
65 return make_shared<ObservableListener>(SignalkMsg(), eh, et);
66}
67
68shared_ptr<ObservableListener> GetListener(NavDataId id, wxEventType et,
69 wxEvtHandler* eh) {
70 return make_shared<ObservableListener>(BasicNavDataMsg(), eh, et);
71}
72
73PluginNavdata GetEventNavdata(ObservedEvt ev) {
74 auto msg = UnpackEvtPointer<BasicNavDataMsg>(ev);
75 PluginNavdata data;
76
77 data.lat = msg->pos.lat;
78 data.lon = msg->pos.lon;
79 data.sog = msg->sog;
80 data.cog = msg->cog;
81 data.var = msg->var;
82 data.hdt = msg->hdt;
83 data.time = msg->time;
84 return data;
85}
Global heartbeat message with decoded values for position, speed course, etc.
Definition: comm_appmsg.h:161
A regular Nmea0183 message.
Definition: comm_navmsg.h:241
See: https://github.com/OpenCPN/OpenCPN/issues/2729#issuecomment-1179506343.
Definition: comm_navmsg.h:217
Adds a std::shared<void> element to wxCommandEvent.
Definition: ocpn_plugin.h:1615
A parsed, raw SignalK message.
Definition: comm_navmsg.h:283
Facade for NavAddr0183.
Definition: ocpn_plugin.h:1647
Facade for NavAddr2000.
Definition: ocpn_plugin.h:1638
Facade for BasicNavDataMsg.
Definition: ocpn_plugin.h:1675
Available decoded data for plugins.
Definition: ocpn_plugin.h:1684
Facade for NavAddrSignalK.
Definition: ocpn_plugin.h:1656