Cruisers Forum
 


Join CruisersForum Today

Reply
 
Thread Tools Rate Thread Display Modes
Old 22-12-2015, 14:09   #1
Registered User

Join Date: May 2013
Location: NSW, Australia
Boat: Richter 42
Posts: 883
OCPN messaging

There are flyspray requests (#FS1881, FS#1587) for a Guard Zone (GZ) for watching AIS targets to see if they are getting too close to a position regardless of whether they are on a collision course or even moving towards the position. Currently the AIS code handles all the processing of information regarding AIS targets and displays the alerts if deemed needed. The concept of a Guard Zone requires drawing the zone on the chart and then watching to see if any AIS target enters this zone.

The OCPN_DRAW (OD) plugin can draw the zone and check to see if any given lat/lon is within the zone. This is currently being done for the Boundary alarms using the Watchdog plugin. The Watchdog plugin communicates with OD through the OCPN messaging process. This seems to work well for this type of interaction where a single lat/lon is checked to see if it is either inside or outside a particular or any boundary.

If the GZ were to be drawn by OD then either the AIS code would need to query OD for each AIS target to ascertain whether it was inside a GZ, or would need to broadcast a message for each target so that others could do the check. At best, if the AIS code does the query, there would be one message for each target sent to OD and a subsequent response message saying the lat/lon is inside or not the GZ Boundary. So for each target there would be two synchronous messages. The more structured case would be a broadcast message for each AIS target, the Watchdog plugin would pick this up and query the OD plugin to see if an alert is needed. This would result in 5 synchronous messages for every AIS target. As there appears to be certain locations that have large numbers of targets (hence the work on scaling the targets) this would result in a large number of messages per timer event in the AIS code.

As mentioned the current messaging in OCPN is using a synchronous model and there is a high probability that that the time taken to process the messages could exceed the timer events causing them. This would either cause the timer to be ignored or double events to be processed.

Is there a need to re-examine the messaging within OCPN to allow for large numbers of messages that, at times, may take longer to process than the time available.

At the moment there are only a few messages being sent around the system, so broadcasting is acceptable. Does this need to change to allow directed messages as well?

Should mainline OCPN code use messages that are sent to specific plugins or should the mainline remain unaware of the plugins? The reverse, i.e. plugins sending messages to the mainline, also needs to be answered.

Do we need to start documenting the messages being sent and the responses to these? Do we need a more structured approach to the message content or should it be left to the parties directly involved in the communications?

Thoughts?

Jon
__________________

__________________
jongough is offline   Reply With Quote
Old 22-12-2015, 22:25   #2
Registered User
 
boat_alexandra's Avatar

Join Date: Aug 2009
Location: Masachusetts
Boat: bristol 27
Posts: 2,803
Re: OCPN messaging

Quote:
Originally Posted by jongough View Post
As mentioned the current messaging in OCPN is using a synchronous model and there is a high probability that that the time taken to process the messages could exceed the timer events causing them. This would either cause the timer to be ignored or double events to be processed.
You can handle the messages asynchronously if you want.

Is it really that slow to check if a point is in a boundary?

Quote:

Is there a need to re-examine the messaging within OCPN to allow for large numbers of messages that, at times, may take longer to process than the time available.
What is the "time available"?
Quote:
At the moment there are only a few messages being sent around the system, so broadcasting is acceptable. Does this need to change to allow directed messages as well?
Maybe because currently each plugin must check each message against each type of message. If we used mailboxes and/or subscriptions it would eliminate a lot of this.
Quote:
Should mainline OCPN code use messages that are sent to specific plugins or should the mainline remain unaware of the plugins? The reverse, i.e. plugins sending messages to the mainline, also needs to be answered.
It is already doing it like with the wmm plugin.
Quote:
Do we need to start documenting the messages being sent and the responses to these? Do we need a more structured approach to the message content or should it be left to the parties directly involved in the communications?

Thoughts?

Jon
I don't see why you couldn't document the messages, it's just a question if you want to rewrite the documentation every time the message changes.

Sean
__________________

__________________
boat_alexandra is offline   Reply With Quote
Old 22-12-2015, 23:29   #3
Registered User

Join Date: May 2013
Location: NSW, Australia
Boat: Richter 42
Posts: 883
Re: OCPN messaging

Sean,
The current plugin api 'SendPluginMessage' appears to be a synchronous process. Each message is sent to each plugin that is currently active. The internal message is sent to an event handler. It is not slow to check a point in a boundary, but if there are many boundaries and many points to check then this will add up. I raised this due to the work going on to scale the AIS targets. Some have mentioned thousands of targets and if there are checks to see if boundaries exist anywhere in a 360deg arc then that dramatically increases the amount of work that has to be done.

The time available is set by the event timers that are being used. Most I have seen are 1sec intervals, but there may be some that are shorter than that.

Running on a grunty desktop machine is all very well, but if you are using an Android tablet or an ARM machine the processing of messages may become an issue. If it does not, then all well and good. If it does it would be nice to have thought it through a little beforehand.

Directed messages is one way, mailboxes another and subscribe yet another. What would be the preferred method(s)? These types of message would really require a message handler that is message agnostic, but gives all parties a standard interface. This would require certain message contents, i.e. recipient address, return address, message type, message number, etc, so that there can be directed responses.

I have found where wmm is sent the message in OCPN to get the variation, but this message is sent to all plugins not just wmm, also wmm is a standard part of OCPN now (was it always?). Do we want each plugin to have code added to chart1.cpp? I thought Dave was trying to get everything out of the mainline to make it easier to maintain. If we are not careful

As to the documentation, at the moment I am currently busy making the OD plugin suitable for release and getting its user documentation up to date. I will then start on the developer documentation and cover the messages that OD will respond to and the content of the response.

At the moment you have to go hunting in the code to understand what messages are being used, how and when. I just thought it may be an idea to make it a bit easier. Message content 'should' be relatively static, but even if changes are made to the 'body' the 'header' information should not change much. In this case the 'body' is the message type and attributes needed to ascertain the information needed and the 'header' is the information needed to allow a 'two way' conversation.

Jon
__________________
jongough is offline   Reply With Quote
Old 26-12-2015, 21:22   #4
Registered User
 
rgleason's Avatar

Join Date: Mar 2012
Location: Boston, MA
Boat: 1981 Bristol 32 Sloop
Posts: 9,360
Re: OCPN messaging

Jon
Tomorrow l'll try an Ais alarm with the very very big ais-vdr file, just to see what happens.
Is there a way to judge the load of messages on memory, cpu etc?
__________________
rgleason is online now   Reply With Quote
Old 26-12-2015, 23:00   #5
Registered User

Join Date: May 2013
Location: NSW, Australia
Boat: Richter 42
Posts: 883
Re: OCPN messaging

Rick,
I would not expect memory to change, but if you do manage to load it up then the CPU usage would be higher than normal and there may be delays in processing messages, i.e. AIS seems slow, or slow chart updates.

The new AIS messaging and Guard Zones are invoked for each AIS message at the time the message has been successfully decoded. The AIS decode sends a message to all plugins, the Watchdog plugin gets this message and checks for Guard Zone alarms. For each of these it sends a message to OD which then uses the information to look at the specified Boundary, based on the GUID, to see if the the Lat/Lon provided is inside the boundary. Then OD sends a message back to the Watchdog plugin to process. When the Watchdog plugin has finished it returns to OD, which then returns to Watchdog which then returns to AIS and the next AIS message can be decoded.

If other plugins start to make use of the AIS messages that will elongate the processing as well. I would not expect a desktop machine to have much of an issue, but low powered devices, i.e. tablets, may start to show slow downs. I just don't know at the moment.

Jon
__________________
jongough is offline   Reply With Quote
Old 26-12-2015, 23:11   #6
Registered User
 
boat_alexandra's Avatar

Join Date: Aug 2009
Location: Masachusetts
Boat: bristol 27
Posts: 2,803
Re: OCPN messaging

If it's a performance issue, we could send the ais info in a struct instead of a message and the watchdog plugin could query the boundary by calling a function directly in the draw plugin rather than with a message.

Currently weather routing will get function pointers from climatology via messages, then after that it can simply call the functions.
__________________
boat_alexandra is offline   Reply With Quote
Old 26-12-2015, 23:19   #7
Registered User

Join Date: May 2013
Location: NSW, Australia
Boat: Richter 42
Posts: 883
Re: OCPN messaging

I don't really want to tie too much stuff together, so using messages decouples the code. There is extra processing for the message to go in and out of JSON format, but apart from that there should not be too much overhead. Its just that most of this is probably happening on a single thread and may overload that. If we could make the messaging occur on a separate thread it may help the mainline code. The problem is I just don't know at the moment. I just want to see if there is a better way to do messaging within OCPN so that we don't get these problems.
__________________
jongough is offline   Reply With Quote
Old 27-12-2015, 07:22   #8
Registered User
 
boat_alexandra's Avatar

Join Date: Aug 2009
Location: Masachusetts
Boat: bristol 27
Posts: 2,803
Re: OCPN messaging

you can stick the message in a queue then process it in a background thread in your plugin if needed.
__________________
boat_alexandra is offline   Reply With Quote
Old 27-12-2015, 07:22   #9
Marine Service Provider
 
bdbcat's Avatar

Join Date: Mar 2008
Posts: 4,883
Re: OCPN messaging

jon...

Lets try some large data sets against the current synchronous implementation. This is what we will ship in O4.2, so we need to know what to expect.

Later, for O5, I think a background thread implementation makes good sense, possibly extended to allow more precise addressing, etc...

Please keep me posted.
Dave
__________________
bdbcat is offline   Reply With Quote
Old 27-12-2015, 08:54   #10
Registered User
 
rgleason's Avatar

Join Date: Mar 2012
Location: Boston, MA
Boat: 1981 Bristol 32 Sloop
Posts: 9,360
Re: OCPN messaging

Here are two screenshots first with the smaller Hakefjord.txt 1mb file and then with the AIS-VDR-LeaseOnLife.7z (5.24mb compressed, unpacks to 33mb) also named vdr-ais-cpuload-reaching-100percent.log which is a huge AIS file from LeaseOnLife.

These are available OpenCPN Beta File Thingie rguser rgpass
look under the nmea directory.

SurfacePro3 with Haswell i5 cpu I believe.

OpenCPN readings using Task Manager
1. No Ais Cpu 0-0.7% Mem 139 mb Network 0%
2. Hakefjord.txt Cpu 2-4% Mem 146 mb Network 0%
3. Vdr-ais...log Cpu 25%-30% Mem 146 mb Network 0%

#3 was playing TDad VDRServer.py python script for both Hakefjord.txt and Vdr-ais...log

While these cpu loads certainly do not cause trouble on this machine, I think it might be a good idea to have in a future version of Opencpn, a structured messaging system, with perhaps critical external functions that can be called and shared by plugins to reduce the message load and cpu load as suggested by others. --background thread...bdcat.

However, Sean and Dave would be able to advise if these loads would be a problem on less powerful cpu's as currently implemented. Perhaps a warning is needed, but most of these users are quite sophisticated users, so the warning may not be needed.
Attached Thumbnails
Click image for larger version

Name:	AIS-Message-Test-with-Hakefjord.txt-file.png
Views:	38
Size:	167.5 KB
ID:	115679   Click image for larger version

Name:	AIS-Message-Test-with-Vdr-Ais-file.png
Views:	41
Size:	173.3 KB
ID:	115680  

__________________

__________________
rgleason is online now   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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
2 Way Satellite Text Messaging System and SOS pistolen08 Health, Safety & Related Gear 9 23-01-2012 11:53
Most Popular Video Messaging for Sailors? Chief Engineer Marine Electronics 5 30-12-2009 17:15
Private Messaging Question? Harriet Forum Tech Support & Site Help 3 08-11-2005 06:28



Copyright 2002- Social Knowledge, LLC All Rights Reserved.

All times are GMT -7. The time now is 10:35.


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

ShowCase vBulletin Plugins by Drive Thru Online, Inc.