Cruisers Forum
 

Go Back   Cruisers & Sailing Forums > Seamanship, Navigation & Boat Handling > OpenCPN
Cruiser Wiki Click Here to Login
Register Vendors FAQ Community Calendar Today's Posts Log in

Reply
  This discussion is proudly sponsored by:
Please support our sponsors and let them know you heard about their products on Cruisers Forums. Advertise Here
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 05-04-2020, 06:43   #1
Registered User
 
Antipole's Avatar

Join Date: Oct 2019
Location: Emsworth, UK
Boat: Alubat Ovni 395
Posts: 287
A steer on getting starting on plugins please

Being locked down by Covid-9 and unable to do fitting out gives me some time to try and understand plugin coding - not helped by my primitive understanding of C++. The advice is to study existing plugins. I have looked at several but find them opaque. I can just about follow oplaydo1.

(A) I am missing a fundamental understanding of the architecture of how the API works.

(B) I have come across a list of calls such as
  1. AddSingleWaypoint(PlugIn_Waypoint *waypoint, bool permament);
  2. GetSingleWaypoint(wxString guid, PlugIn_Waypoint *waypoint);
  3. UpdateSingleWaypoint(PlugIn_Waypoint *waypoint)
but I cannot relate this to getting addresses etc. Is there a list of these?

(C) I am interested in the JSON API but have found nothing about it other than an opinion that it is less efficient than direct calls

Can SKS give me some pointers, please?
Antipole is offline   Reply With Quote
Old 05-04-2020, 08:32   #2
Registered User

Join Date: Oct 2014
Posts: 274
Re: A steer on getting starting on plugins please

Antipole,

Your post did not say where you have searched for info on developing plugins for OpenCPN. The "Developer Manual" at the OpenCPN.org website is a good starting point.

Here is a link:

https://opencpn.org/wiki/dokuwiki/do...veloper_manual


Paul
.Paul. is offline   Reply With Quote
Old 05-04-2020, 08:52   #3
Registered User
 
Antipole's Avatar

Join Date: Oct 2019
Location: Emsworth, UK
Boat: Alubat Ovni 395
Posts: 287
Re: A steer on getting starting on plugins please

Paul.. sorry I was not explicit about that. I have been studying the developer manual at length for days but not found what I need. If you think I have missed what I am looking for, feel free to point me at the relevant section. Thanks.
Antipole is offline   Reply With Quote
Old 05-04-2020, 18:14   #4
Registered User

Join Date: Mar 2011
Posts: 651
Post Re: A steer on getting starting on plugins please

Unfortunately the developer manual does not have a list of API's and examples of their usage.

To find the list of API's you need to peruse the ocpn_plugin.h header file.
And to find examples of the API usage you have to wade through the quagmire of other plugins.

I'm assuming that when you ask
Quote:
but I cannot relate this to getting addresses etc. Is there a list of these?
I think you are attempting to get the list of all waypoints ? If so then this snippet may help.
Code:
PlugIn_Waypoint waypoint;
wxArrayString waypointGUIDS = GetWaypointGUIDArray();
for (auto waypointGUID : waypointGUIDS) {
	GetSingleWaypoint(waypointGUID, &waypoint);
	wxMessageBox(wxString::Format("Waypoint Name: %s\nWaypoint GUID: %s\nLat: %f\nLong: %f", waypoint.m_MarkName, waypoint.m_GUID, waypoint.m_lat, waypoint.m_lon));
}
Have fun...
stevead is offline   Reply With Quote
Old 06-04-2020, 02:23   #5
Registered User

Join Date: May 2012
Posts: 1,206
Re: A steer on getting starting on plugins please

Antipole ...

Ref C): Probably not the best place but you could look at my UKTides_pi plugin:

https://github.com/Rasbats/UKTides_pi/

This uses an API and parses the JSON output. You would need a key from UKHO if you wanted to compile and use your own version of the plugin. UKHO did not want to make the key public.

The plugin also plots waypoints.

Mike
Rasbats is offline   Reply With Quote
Old 07-04-2020, 03:09   #6
Registered User
 
Antipole's Avatar

Join Date: Oct 2019
Location: Emsworth, UK
Boat: Alubat Ovni 395
Posts: 287
Re: A steer on getting starting on plugins please

@stevead... thanks for the pointers. I have studied the ocpn_plugin.h file.

I can see declarations for adding/deleting/updating waypoints, routes and tracks in the section API 1.10. I want to retrieve the active route (if there is one) but cannot see how to access that. Any pointers for that, please?
Tony
Antipole is offline   Reply With Quote
Old 07-04-2020, 06:53   #7
Registered User

Join Date: Mar 2011
Posts: 651
Re: A steer on getting starting on plugins please

I personally have only scratched the surface of the (poorly documented) API's.
I've noticed the following:
Code:
extern DECL_EXP wxString GetSelectedWaypointGUID_Plugin( );
extern DECL_EXP wxString GetSelectedRouteGUID_Plugin( );
extern DECL_EXP wxString GetSelectedTrackGUID_Plugin( );
extern "C" DECL_EXP bool GetActiveRoutepointGPX( char *buffer, unsigned int buffer_length );
My assumption was that the first two functions would return valid GUIDs if a route was active.

Of course assumptions are the mother of all f....ups and the two functions only returned an empty string. I had a quick peruse of the openCPN source, but it's late at night and I'm not going to attempt to debug this now. In anycase, I am unsure of what they are meant to return and under what circumstances.

The last function returns the GPX (XML) text representing the active waypoint on the active route.

If you cannot get the API's to return anything meaningful it may be appropriate to file a bug.
stevead is offline   Reply With Quote
Old 09-04-2020, 23:11   #8
Registered User
 
rooiedirk's Avatar

Join Date: Aug 2010
Location: Netherlands
Boat: Oneoff
Posts: 511
Re: A steer on getting starting on plugins please

Getting the active route is the easiest with a json call I think.

a part of the code in chart1.cpp line 8648

Code:
else if(message_ID == _T("OCPN_ACTIVE_ROUTELEG_REQUEST"))
    {
        wxJSONValue v;
        v[0][_T("error")] = true;
        if( g_pRouteMan->GetpActiveRoute() )
        {
            if( g_pRouteMan->m_bDataValid )
            {
                v[0][_T("error")] = false;
                v[0][_T("range")] = g_pRouteMan->GetCurrentRngToActivePoint();
                v[0][_T("bearing")] = g_pRouteMan->GetCurrentBrgToActivePoint();
                v[0][_T("XTE")] = g_pRouteMan->GetCurrentXTEToActivePoint();
                v[0][_T("active_route_GUID")] = g_pRouteMan->GetpActiveRoute()->m_RouteNameString;
                v[0][_T("active_waypoint_lat")] = g_pRouteMan->GetpActiveRoute()->m_pRouteActivePoint->GetLatitude();
                v[0][_T("active_waypoint_lon")] = g_pRouteMan->GetpActiveRoute()->m_pRouteActivePoint->GetLongitude();
            }
        }
And yes documentation could be better.
__________________
Navigation is know where you are and what to do to get where you want.
But also: Know where you don't want to be and what to do to don't get there.
rooiedirk is offline   Reply With Quote
Old 10-04-2020, 03:19   #9
Registered User
 
Antipole's Avatar

Join Date: Oct 2019
Location: Emsworth, UK
Boat: Alubat Ovni 395
Posts: 287
Re: A steer on getting starting on plugins please

Quote:
Originally Posted by rooiedirk View Post
Getting the active route is the easiest with a json call I think.

a part of the code in chart1.cpp line 8648

[CODE]else if(message_ID == _T("OCPN_ACTIVE_ROUTELEG_REQUEST"))
***snip***
It would be great to get the acive route as json, but, as I understand this, it only gives the active leg - not the whole active route.

I note there is a message _T("OCPN_ROUTE_REQUEST")

Can I determine the active route GUID? Then maybe I could then get that route as a json message?
Antipole is offline   Reply With Quote
Old 10-04-2020, 12:57   #10
Registered User
 
rooiedirk's Avatar

Join Date: Aug 2010
Location: Netherlands
Boat: Oneoff
Posts: 511
Re: A steer on getting starting on plugins please

Quote:
Originally Posted by Antipole View Post
It would be great to get the acive route as json, but, as I understand this, it only gives the active leg - not the whole active route.

I note there is a message _T("OCPN_ROUTE_REQUEST")

Can I determine the active route GUID? Then maybe I could then get that route as a json message?
Yes the active route guid is part of the OCPN_ACTIVE_ROUTELEG_REQUEST reply.
__________________
Navigation is know where you are and what to do to get where you want.
But also: Know where you don't want to be and what to do to don't get there.
rooiedirk is offline   Reply With Quote
Reply

Tags
lease, plug


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Installateur de plugins, Install software for plugins. Gilletarom OpenCPN 3 30-04-2013 05:57
I need help with Open CPN plugins please Mirima Navigation 2 28-01-2013 08:46
Are We Allowed to Steer Members to eBay? Chief Engineer Classifieds Archive 13 04-08-2009 10:34

Advertise Here


All times are GMT -7. The time now is 17:22.


Google+
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Social Knowledge Networks
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2024, vBulletin Solutions, Inc.

ShowCase vBulletin Plugins by Drive Thru Online, Inc.