Cruisers Forum
 


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 24-01-2019, 12:50   #136
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,208
Re: OpenCPN PlugIn Development

Quote:
Originally Posted by cryptik View Post
I will probably need some pointers, at some point, on how to submit a plugin and/or a PR. I have not done that sort of thing before with git. I am somewhat still old school with SVN...lol
https://help.github.com/articles/cre...-pull-request/ (and https://git-scm.com/book/en/v2 if you want to stop suffering with SVN completely)
nohal is offline   Reply With Quote
Old 25-01-2019, 07:43   #137
Registered User

Join Date: Nov 2012
Location: Orust Sweden
Boat: Najad 34
Posts: 4,147
Re: OpenCPN PlugIn Development

Quote:
Originally Posted by bcn View Post
What might be handy is an interface to edit the voyage related data of the Class A AIS from OpenCPN.

Dirk linked this I never touch before. Thanks!

rooiedirk Re: OpenCPN PlugIn Development
https://github.com/RooieDirk/AIS_VD_pi/tree/master Quote:

After some minor local adjustment it builds fine on Win10 and nicely produce the VSD sentence to all open outgoing connections. See shot
Could be handy if you've a class A connected.
Håkan
Attached Thumbnails
Click image for larger version

Name:	VSD.JPG
Views:	74
Size:	34.4 KB
ID:	184453   Click image for larger version

Name:	AIS_static.JPG
Views:	82
Size:	42.5 KB
ID:	184454  

Hakan is offline   Reply With Quote
Old 11-02-2019, 12:34   #138
Registered User

Join Date: Jun 2018
Posts: 68
Re: OpenCPN PlugIn Development

Trying to get the mouse geo coordinates after clicking on a context menu item. I have a context menu item that I added for my plugin. The scenario is that the user moves the mouse pointer to a location on the chart. They then right click the mouse and select the context menu item. I can trap the callback for the menu click (in OnContextMenuItemCallback()) ...but then I want to get the lat and lon of where the mouse pointer is at the time of the menu click. I am not sure how to do that. I am able to get lat lon using SetCursorLatLon() callback, but is there a call to OCPN that I can make from inside OnContextMenuItemCallback() that will return the cursor Lat and Lon? I have looked through the OCPN plugin API header, but I did not see anything.

thx
Ken
cryptik is offline   Reply With Quote
Old 11-02-2019, 12:41   #139
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,208
Re: OpenCPN PlugIn Development

Quote:
Originally Posted by cryptik View Post
Trying to get the mouse geo coordinates after clicking on a context menu item. I have a context menu item that I added for my plugin. The scenario is that the user moves the mouse pointer to a location on the chart. They then right click the mouse and select the context menu item. I can trap the callback for the menu click (in OnContextMenuItemCallback()) ...but then I want to get the lat and lon of where the mouse pointer is at the time of the menu click. I am not sure how to do that. I am able to get lat lon using SetCursorLatLon() callback, but is there a call to OCPN that I can make from inside OnContextMenuItemCallback() that will return the cursor Lat and Lon? I have looked through the OCPN plugin API header, but I did not see anything.

thx
Ken
Why would you do this? You already do know where the cursor was before the context menu was invoked (as in for example https://github.com/OpenCPN/OpenCPN/b...ib_pi.cpp#L536 and https://github.com/OpenCPN/OpenCPN/b...ib_pi.cpp#L542).
nohal is offline   Reply With Quote
Old 11-02-2019, 12:52   #140
Registered User

Join Date: Jun 2018
Posts: 68
Re: OpenCPN PlugIn Development

LOL, thank you for redirecting me on that. I was actually doing that, and did not understand why it was not working. I went back and looked at my code and found a bug in my implementation of the SetCursorLatLon() callback. Its working now. Thanks man.
cryptik is offline   Reply With Quote
Old 11-02-2019, 12:57   #141
Registered User

Join Date: Jun 2018
Posts: 68
Re: OpenCPN PlugIn Development

I do have two other questions. Where does OCPN store the configuration settings? I was trying to look at the file where OCPN actually stores it's (and the plugin) settings and I can't seem to locate it. The second question is, I have a data file that I store information in relative to the plugin. The data is user specific. The problem I have is that on Windows 10, I can't write to the plugin data folder when OCPN is running as a user. I can manually add users to the plugin data folder. Is there a way to have the installer set the proper permissions on this folder? Or is there another way to write to this folder that does not have the user permissions problem. OCPN seems to be able to write to its log file...and I am not sure how that happens.
cryptik is offline   Reply With Quote
Old 11-02-2019, 13:05   #142
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,208
Re: OpenCPN PlugIn Development

Quote:
Originally Posted by cryptik View Post
I do have two other questions. Where does OCPN store the configuration settings? I was trying to look at the file where OCPN actually stores it's (and the plugin) settings and I can't seem to locate it.
What can't you locate? The file or your saved settings in it? If the former, click on the "?" icon, if the later, make sure the config file was already saved (Close OpenCPN to be 100% sure)
Quote:
The second question is, I have a data file that I store information in relative to the plugin. The data is user specific. The problem I have is that on Windows 10, I can't write to the plugin data folder when OCPN is running as a user. I can manually add users to the plugin data folder. Is there a way to have the installer set the proper permissions on this folder? Or is there another way to write to this folder that does not have the user permissions problem. OCPN seems to be able to write to its log file...and I am not sure how that happens.
Store it like all the others, in the correct user data location, on all platforms: https://github.com/nohal/objsearch_p...rch_pi.cpp#L93
nohal is offline   Reply With Quote
Old 11-02-2019, 13:34   #143
Registered User

Join Date: Jun 2018
Posts: 68
Re: OpenCPN PlugIn Development

ah... your a lifesaver nohal. I could not find the file, but this works great. Also, thanks for the location to store my other file. I was using another calling setup to get the data folder.

wxFileName dFN;
dFN.SetPath(*GetpSharedDataLocation());
dFN.AppendDir(_T("plugins"));
dFN.AppendDir(_T("myPlugin_pi"));
dFN.AppendDir(_T("data"));

The folder above is not writable by default. I will follow the code examples you provided. Perfect. Thanks a million.
cryptik is offline   Reply With Quote
Old 11-02-2019, 14:05   #144
Registered User

Join Date: Jun 2018
Posts: 68
Re: OpenCPN PlugIn Development

Looking at my code, I may be doing this wrong as well. I use the SetPluginMessage() to build an internal AIS target list by parsing the message_id and message_body parameters looking for message_id = AIS. I then build up an internal array with target objects.

I do this because I don't seem to get any calls to SetAISSentence() even with WANTS_AIS_SENTENCES set in the capability statement.

Looking at the AIS radar display plugin, there are calls to get such an array directly from OCPN...GetAISTargetArray()...which I just discovered by looking at the AIS radar display code. The advantage of using this call as opposed to creating my own array is that when targets age out, they are removed from the OCPN array.

My question is that the AIS radar plugin uses the SetAISSentence() event to update its view of the AIS targets. The plugin seems to work well... so I am wondering why I do not get any callbacks to this method? Perhaps this callback is not really necessary or am I missing something else?

Thx,
Ken
cryptik is offline   Reply With Quote
Old 11-02-2019, 14:34   #145
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,208
Re: OpenCPN PlugIn Development

Fixed in https://github.com/OpenCPN/OpenCPN/c...fd4dfdeccbe21e. I'm not sure we don't want to remove this from the API completely and keep just WANTS_NMEA_SENTENCES & SetNMEASentence() though.
nohal is offline   Reply With Quote
Old 11-02-2019, 14:42   #146
Registered User

Join Date: Jun 2018
Posts: 68
Re: OpenCPN PlugIn Development

Okay, no worries. I think it makes sense to remove it from the API. I currently use the SetNMEASentence() and parse the VDM statements... and that seems to work.
cryptik is offline   Reply With Quote
Old 11-02-2019, 14:46   #147
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,208
Re: OpenCPN PlugIn Development

I of course don't know what you are doing, but would probably consume the AIS JSON messages instead myself.
nohal is offline   Reply With Quote
Old 11-02-2019, 14:48   #148
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,208
Re: OpenCPN PlugIn Development

You get them with WANTS_PLUGIN_MESSAGING / SetPluginMessage
and they look like
Code:
AIS : {
   "Msg" : "AIS Target",
   "class" : 0,
   "mmsi" : 366970020,
   "callsign" : "       ",
   "sog" : 11.8,
   "lon" : -122.390815,
   "Source" : "AIS_Decoder",
   "MsgId" : -568852698,
   "active" : true,
   "lat" : 37.80016167,
   "cog" : 147,
   "ownship" : false,
   "lost" : false,
   "Type" : "Information",
   "shipname" : "Unknown             ",
   "hdg" : 144
}
nohal is offline   Reply With Quote
Old 11-02-2019, 15:14   #149
Registered User

Join Date: Jun 2018
Posts: 68
Re: OpenCPN PlugIn Development

Yes, that is what I am doing now... parsing the JSON as you mention... from inside the SetPluginMessage(). What I am doing is building a target array with those JSON messages and then looking through the list to find a user specified MMSI. The plugin lets you then send a ABM message to that MMSI. As part of the GUI, it paints a circle around that target that moves with the target. I basically update my target list in SetPluginMessage() and use it in the Render() call to draw the circle.

The problem I have is that doing it that way, when the target ages out and disappears from the OCPN target list, I can't figure out how to get notification of that. So I was thinking that maybe I should use the GetAISTargetArray() call instead. What happens now is that when the target drops off the map...my circle graphic is still being painted at the last known position...since it is still in my plugin target array. Do you know of another event that I could consume that would tell me a target has dropped from the list?
cryptik is offline   Reply With Quote
Old 11-02-2019, 15:37   #150
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,208
Re: OpenCPN PlugIn Development

You may simply let them time out as well in case you don't receive a message with the MMSI for X amount of time (OpenCPN can be set not to remove lost targets at all, which is probably not exactly always viable if you are implementing live communication methods with them)
To realise that the target is being considered lost by the core program, check if the message with lost set to true (https://github.com/OpenCPN/OpenCPN/c...8bee195488689f)
nohal is offline   Reply With Quote
Reply


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
New Marina Development in China GordMay Pacific & South China Sea 4 29-09-2009 04:33
New Battery Research & Development BlueSovereign Electrical: Batteries, Generators & Solar 7 31-07-2009 14:47
Nautical Development 39 (Morgan 39?) riptide Monohull Sailboats 1 22-07-2009 11:53
Turks and Caicos Development Petition Canibul Atlantic & the Caribbean 5 24-04-2008 18:15

Advertise Here


All times are GMT -7. The time now is 16:28.


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.