OpenCPN Partial API docs
|
Implement various ocpn_plugin.h methods. More...
#include <memory>
#include <sstream>
#include <vector>
#include <wx/event.h>
#include <wx/jsonval.h>
#include <wx/jsonreader.h>
#include "model/base_platform.h"
#include "model/comm_appmsg.h"
#include "model/comm_drv_n0183_net.h"
#include "model/comm_drv_n0183_serial.h"
#include "model/comm_drv_n2k.h"
#include "model/comm_drv_registry.h"
#include "model/comm_navmsg_bus.h"
#include "ocpn_plugin.h"
Go to the source code of this file.
Functions | |
vector< uint8_t > | GetN2000Payload (NMEA2000Id id, ObservedEvt ev) |
Return N2K payload for a received n2000 message of type id in ev. | |
std::string | GetN2000Source (NMEA2000Id id, ObservedEvt ev) |
Return source identifier (iface) of a received n2000 message of type id in ev. | |
std::string | GetN0183Payload (NMEA0183Id id, ObservedEvt ev) |
Return payload in a received n0183 message of type id in ev. | |
std::string | GetPluginMsgPayload (PluginMsgId id, ObservedEvt ev) |
Retrieve the string in a plugin message, internal or received on the REST insterface. | |
std::shared_ptr< void > | GetSignalkPayload (ObservedEvt ev) |
Get SignalK status payload after receiving a message. | |
shared_ptr< ObservableListener > | GetListener (NMEA2000Id id, wxEventType et, wxEvtHandler *eh) |
std::shared_ptr< ObservableListener > | GetListener (NMEA0183Id id, wxEventType et, wxEvtHandler *eh) |
shared_ptr< ObservableListener > | GetListener (SignalkId id, wxEventType et, wxEvtHandler *eh) |
shared_ptr< ObservableListener > | GetListener (NavDataId id, wxEventType et, wxEvtHandler *eh) |
std::shared_ptr< ObservableListener > | GetListener (PluginMsgId id, wxEventType et, wxEvtHandler *eh) |
Return listener for plugin messages, internal or received on the REST interface. | |
PluginNavdata | GetEventNavdata (ObservedEvt ev) |
Return BasicNavDataMsg decoded data available in ev. | |
std::vector< DriverHandle > | GetActiveDrivers () |
Comm port plugin TX support methods | |
const std::unordered_map< std::string, std::string > | GetAttributes (DriverHandle handle) |
Query a specific driver for attributes | |
CommDriverResult | WriteCommDriver (DriverHandle handle, const std::shared_ptr< std::vector< uint8_t > > &payload) |
Send a non-NMEA2000 message. | |
CommDriverResult | WriteCommDriverN2K (DriverHandle handle, int PGN, int destinationCANAddress, int priority, const std::shared_ptr< std::vector< uint8_t > > &payload) |
Send a PGN message to an NMEA2000 address. | |
CommDriverResult | RegisterTXPGNs (DriverHandle handle, std::vector< int > &pgn_list) |
Register PGNs that this application intends to transmit for some NMEA 2000 adapters like Actisense NGT-1. | |
wxString * | GetpPrivateApplicationDataLocation (void) |
Implement various ocpn_plugin.h methods.
Definition in file plugin_api.cpp.
std::vector< DriverHandle > GetActiveDrivers | ( | ) |
Comm port plugin TX support methods
Query OCPN core for a list of active drivers
Definition at line 131 of file plugin_api.cpp.
const std::unordered_map< std::string, std::string > GetAttributes | ( | DriverHandle | handle | ) |
Query a specific driver for attributes
Query driver attributes
Definition at line 142 of file plugin_api.cpp.
PluginNavdata GetEventNavdata | ( | ObservedEvt | ev | ) |
Return BasicNavDataMsg decoded data available in ev.
Definition at line 115 of file plugin_api.cpp.
shared_ptr< ObservableListener > GetListener | ( | NavDataId | id, |
wxEventType | et, | ||
wxEvtHandler * | eh | ||
) |
Definition at line 105 of file plugin_api.cpp.
std::shared_ptr< ObservableListener > GetListener | ( | NMEA0183Id | id, |
wxEventType | et, | ||
wxEvtHandler * | eh | ||
) |
Definition at line 95 of file plugin_api.cpp.
shared_ptr< ObservableListener > GetListener | ( | NMEA2000Id | id, |
wxEventType | et, | ||
wxEvtHandler * | eh | ||
) |
Definition at line 90 of file plugin_api.cpp.
std::shared_ptr< ObservableListener > GetListener | ( | PluginMsgId | id, |
wxEventType | et, | ||
wxEvtHandler * | eh | ||
) |
Return listener for plugin messages, internal or received on the REST interface.
Definition at line 110 of file plugin_api.cpp.
shared_ptr< ObservableListener > GetListener | ( | SignalkId | id, |
wxEventType | et, | ||
wxEvtHandler * | eh | ||
) |
Definition at line 100 of file plugin_api.cpp.
std::string GetN0183Payload | ( | NMEA0183Id | id, |
ObservedEvt | ev | ||
) |
Return payload in a received n0183 message of type id in ev.
Definition at line 55 of file plugin_api.cpp.
vector< uint8_t > GetN2000Payload | ( | NMEA2000Id | id, |
ObservedEvt | ev | ||
) |
Return N2K payload for a received n2000 message of type id in ev.
The vector returned is described in the following example
[147,19, // Header bytes, unused 3, // N2K priority 16,240,1, // example pgn 126992 encoded little endian 255, // N2K destination address 1, // N2K origin address 255,255,255,255, // timestamp, unused 8, // count of following NMEA2000 data 13,240,207,76,208,3,94,40, // NMEA2000 data 85 // CRC byte, unused,not included in count ];
Definition at line 45 of file plugin_api.cpp.
std::string GetN2000Source | ( | NMEA2000Id | id, |
ObservedEvt | ev | ||
) |
Return source identifier (iface) of a received n2000 message of type id in ev.
Definition at line 50 of file plugin_api.cpp.
std::string GetPluginMsgPayload | ( | PluginMsgId | id, |
ObservedEvt | ev | ||
) |
Retrieve the string in a plugin message, internal or received on the REST insterface.
Definition at line 60 of file plugin_api.cpp.
wxString * GetpPrivateApplicationDataLocation | ( | void | ) |
Definition at line 255 of file plugin_api.cpp.
std::shared_ptr< void > GetSignalkPayload | ( | ObservedEvt | ev | ) |
Get SignalK status payload after receiving a message.
auto ptr = GetSignalkPayload(ev); const auto msg = *std::static_pointer_cast<const wxJSONValue>(payload);The map contains the following entries:
Definition at line 65 of file plugin_api.cpp.
CommDriverResult RegisterTXPGNs | ( | DriverHandle | handle, |
std::vector< int > & | pgn_list | ||
) |
Register PGNs that this application intends to transmit for some NMEA 2000 adapters like Actisense NGT-1.
This function is required specifically for NMEA 2000 adapters like the Actisense NGT-1. For these devices, registration of transmit PGNs is required before sending any messages. This is an adapter-specific requirement, not a requirement of the NMEA 2000 standard itself.
This function is only implemented for serial NMEA 2000 adapters (specifically the Actisense NGT-1). For other connection types (TCP, UDP), the function will return success and perform no registration.
handle | The driver handle obtained from GetActiveDrivers() |
pgn_list | List of PGNs this application will transmit |
Example usage:
Definition at line 222 of file plugin_api.cpp.
CommDriverResult WriteCommDriver | ( | DriverHandle | handle, |
const std::shared_ptr< std::vector< uint8_t > > & | payload | ||
) |
Send a non-NMEA2000 message.
The call is not blocking.
handle | Obtained from GetActiveDrivers() |
payload | Message data, for example a complete Nmea0183 message. From 1.19: if the handle "protocol" attribute is "internal" it is parsed as <id><space><message> where the id is used when listening/ subscribing to message. |
Definition at line 156 of file plugin_api.cpp.
CommDriverResult WriteCommDriverN2K | ( | DriverHandle | handle, |
int | PGN, | ||
int | destinationCANAddress, | ||
int | priority, | ||
const std::shared_ptr< std::vector< uint8_t > > & | payload | ||
) |