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 20-02-2020, 07:49   #1
Registered User
 
Antipole's Avatar

Join Date: Oct 2019
Location: Emsworth, UK
Boat: Alubat Ovni 395
Posts: 286
JavaScript Plugin for OpenCPN?

Background

For ten years I have used FileMaker (FM) for my onboard log system. I have recently re-worked it to log information directly from the NMEA data stream. Processing the NMEA data would have been hard work in FM scripting, so I installed an FM plugin which adds the ability to run JavaScripts. Checking the NMEA checksum and parsing the data into JSON to return it to FM was straight forward in JavaScript. (I looked at the OpenCPN Logbook plugin but have chosen to stay with my own approach so as to remain compatible with my past log history.)

I also use the BetterTouchTool app on my MacBook Pro to enhance the Touch Bar and provide Touch Bar controls for OpenCPN. Recently BetterTouchTool has added JavaScript capability to allow users to create bespoke actions.

Both the above use Node.js, which is being widely adopted to provide JavaScripting. Its ability to stand alone outside an HTML context and to compile scripts for more efficient execution is an important advantage.

What if?

I have been musing on the possibility of a JavaScript plugin to provide scripting for OpenCPN. I am imagining a plugin that allows the user to specify a file (or files) of JavaScript to be run. The plugin would need to provide JavaScript methods to access the OpenCPN API.

As I understand it, the API makes use of JSON and, given JavaScript’s affinity with JSON, this could be elegant. Signal-K also uses JSON and could provide the JSON structures for navigational data.

Now that JavaScript has native support for promises, scripting routines to handle asynchronous OpenCPN events, such as the receipt of a fix, arrival at a waypoint etc. could be handled elegantly.

A JavaScript plugin could make it much easier for users to tailor OpenCPN to their needs and reduce the burden of requests to the core developers for enhancements.

How to proceed?

I am not an OpenCPN plugin developer. I have got as far as having a look at the WatchDog plugin as a possible model but have decided the project is beyond me. I am somewhat long in the tooth, being more at home programming in B (the Bell Labs language that was eventually succeeded by C) and the level of C++ required is rather a challenge for me. I am sure there are younger bloods around who would make lighter work of it.

I am open to comments and suggestions for a way forward. I would certainly be interested in developing ideas, testing any prototypes and offering feedback.
Antipole is offline   Reply With Quote
Old 21-02-2020, 08:15   #2
Registered User
 
Canne's Avatar

Join Date: Aug 2014
Posts: 246
Re: JavaScript Plugin for OpenCPN?

Dear Antipole,

You may be interested in this JS instrument class on a O plug-in, 1..n instances, 1Hz threads executing JS through an interface driving an event driven JS application developed using node.js and webpack. Class subscribes the JS application to C++ function callbacks which are fed by events occurring in O/plug-in/SignalK. Resulting app here. Back-end not suitable for you, perhaps: strip the GUI and make the events to write into sockets instead and you can have node.js as back-end. Developer's guide. Nothing about FM, though!

Best regards,

Petri
Canne is offline   Reply With Quote
Old 16-02-2022, 06:44   #3
Registered User
 
rgleason's Avatar

Join Date: Mar 2012
Location: Boston, MA
Boat: 1981 Bristol 32 Sloop
Posts: 17,632
Images: 2
Re: JavaScript Plugin for OpenCPN?

Source for some good scripts for Navigation

https://www.movable-type.co.uk/scripts/latlong.html
rgleason is offline   Reply With Quote
Reply

Tags
enc, opencpn, 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
OpenCPN PlugIn Development bdbcat OpenCPN 161 04-09-2019 12:50
Plugin development... How to receive chart objects in my plugin? dmartinez OpenCPN 6 04-08-2017 00:56
Winlink Express problems with GRIB map and Javascript Slow Boat To... Marine Electronics 0 29-04-2017 14:23
Driving Revenue JavaScript S/V_Surya Forum Tech Support & Site Help 22 06-04-2011 12:26
New History Plugin for OpenCPN seandepagnier OpenCPN 11 04-10-2010 14:11

Advertise Here


All times are GMT -7. The time now is 21: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.