David Godin - Issue with Polar Performance. For...
Issue with Polar Performance. For some reason I'm not receiving updates past the first one. Here is a debug log if it helps:
Jun 21 23:24:48 2024-06-22T03:24:48.372Z signalk-polar-performance-plugin sendUpdates: [{"path":"performance.boatSpeedDamped","value":0},{"path":"environment.wind.angleTrueWaterDamped","value":0.363},{"path":"performance.beatAngle","value":0.691},{"path":"performance.beatAngleVelocityMadeGood","value":2.473},{"path":"performance.targetSpeed","value":3.209},{"path":"performance.polarSpeed","value":1.064},{"path":"performance.polarSpeedRatio","value":0}]
Jun 21 23:24:48 2024-06-22T03:24:48.470Z signalk-polar-performance-plugin environment.wind.angleTrueWater (TWA): 0.38400000000000006 applyDamping: 0.36447406848531283 port: 1
Jun 21 23:24:48 2024-06-22T03:24:48.470Z signalk-polar-performance-plugin performance.polarSpeedRatio = BSP (0.00)/ performance.polarSpeed (2.09)
Jun 21 23:24:48 2024-06-22T03:24:48.470Z signalk-polar-performance-plugin sendUpdates: [{"path":"performance.boatSpeedDamped","value":0},{"path":"environment.wind.angleTrueWaterDamped","value":0.364},{"path":"performance.beatAngle","value":0.691},{"path":"performance.beatAngleVelocityMadeGood","value":2.472},{"path":"performance.targetSpeed","value":3.207},{"path":"performance.polarSpeed","value":1.075},{"path":"performance.polarSpeedRatio","value":0}]
20 Replies
I have a breakpoint filtering on
update.$source == "signalk-polar-performance-plugin"
It's like the server only sends the first Delta updates when the source is signalk-polar-performance-plugin
. I get updates for performance.velocityMadeGood
but it's from derived-data
The data updates fine in SK Data Browser.I find it unlikely that the server would treat data from a specific plugin differently for Kip. ” it is like…” - are you getting updates over websocket or not?
I know!!! Maybe I was just tired…
I have breakpoint while parsing delta updates that looks for all $source that are from performance source. It’s low level and I only get one update. That’s why I’m asking as it’s pretty strange. Is there a simple trick to look at sent path data with another tool?
(Edit): found the problem. KIP either processes
meta
or values
delta keys and both are sent every time, except on connection where values come in first with no meta
key.
@HansT Hi Hans. Are the owner of signalk-polar-performance-plugin
I looked at delta updates
a bit deeper. Here is what I found:
1- The updates
delta array items for $source: "signalk-polar-performance-plugin"
always contains both meta
and values
keys. If I understood correctly, it should either contain meta
or values
, right? KIP follows this guideline and processes either one or the other key. It can be easily changed but if it's not how meta/values should be sent, I'd rather we fix the plugin.
2- meta
array items are sent too often and always contain the same information. It's should probably only be sent on initial connection, and when there are meta
value changes, which I don't think is a use case as meta for those path are pretty much static; they contain unit
and description
. This would reduce unnecessary delta update traffic.
3- values
array items (path value) are updated very frequently (could be as much as 15 times per second) due to the nature of this plugin. All path values, 16 paths or so, are sent everytime, even if the path values don't change. This could be improved to only send new values, or reemit old values after some period if required. It would significantly reduce delta update traffic.
The above only happens after initial connection delta updates. SK only send values
updates for each path, then after it starts sending both meta
and values
keys.Can you try the version I just pushed (0.45)? That should fix 1 and 2.
@HansT I get the following:
Jun 22 12:10:06 signalk-polar-performance-plugin failed to start: Unexpected end of input
Jun 22 12:10:06 /home/parallels/.signalk/node_modules/signalk-polar-performance-plugin/plugin/index.js:774 SyntaxError: Unexpected end of input at internalCompileFunction (node:internal/vm:73:18) at wrapSafe (node:internal/modules/cjs/loader:1178:20) at Module._compile (node:internal/modules/cjs/loader:1220:27) at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) at Module.load (node:internal/modules/cjs/loader:1119:32) at Module._load (node:internal/modules/cjs/loader:960:12) at Module.require (node:internal/modules/cjs/loader:1143:19) at require (node:internal/modules/cjs/helpers:119:18) at doRegisterPlugin (/usr/local/lib/node_modules/signalk-server/lib/interfaces/plugins.js:397:39) at registerPlugin (/usr/local/lib/node_modules/signalk-server/lib/interfaces/plugins.js:258:13) at /usr/local/lib/node_modules/signalk-server/lib/interfaces/plugins.js:209:13 at Array.forEach (<anonymous>) at startPlugins (/usr/local/lib/node_modules/signalk-server/lib/interfaces/plugins.js:208:85) at Object.start (/usr/local/lib/node_modules/signalk-server/lib/interfaces/plugins.js:46:13) at /usr/local/lib/node_modules/signalk-server/lib/index.js:503:50 at /usr/local/lib/node_modules/signalk-server/node_modules/lodash/lodash.js:4967:15 at Function.forIn (/usr/local/lib/node_modules/signalk-server/node_modules/lodash/lodash.js:13018:11) at startInterfaces (/usr/local/lib/node_modules/signalk-server/lib/index.js:480:22) at Server.<anonymous> (/usr/local/lib/node_modules/signalk-server/lib/index.js:328:17) at Generator.next (<anonymous>) at fulfilled (/usr/local/lib/node_modules/signalk-server/lib/index.js:23:58) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
My bad, try 0.46.
@HansT fantastic!
@HansT point 3 would be great, if doable, and you find time...
Not sure about 3 yet. The overhead of timestamp checking might be more than the processing of the values.
@HansT nice to work together. I'll do some performance widgets at some point so I'll probably bug you to make sure I get it right and leverage what you built 😉
Happy to help where I can! And nice work on the widgets!
True. I think the question is more of a: do I need to resend the path value every time. Maybe some paths don't need to update that often, eliminating the need to have timers and such
What I mean is, as an example, beatAngle could probably only be sent when it changes, else don't send it.
Ah, yes. I'll have a look to see how to do this.
cool. because the way it is now, it's updating all 16 paths 10 to 15 times/sec
In most updates, only 1 or 2 path have new values
It won't reduce the overall update frequency, but it will reduce packet size, and most important, it will significantly reduce client app that work with path reactive event for processing. In KIP, when the path value is updated, it triggers path Observer processing. I could filter for new values only but it would add unnecessary processing to all path updates. Better to only receive when value really change. In our case, this would reduce update events from 16 paths 10-15 time per second, down to maybe 1 or 2
@HansT I just noticed after leaving the debugger running and tacking meta updates that I got meta updates with 2 paths. One from
performance.gybeAngle
and some second path (sorry I clicked too fast and missed it's path value).
There is probably some logic that, later in the code, update meta values.
It took a while to show up and I have not seen it since, so it's probably not that criticalStrange. As you can see in the code, the metas[] is build up and then only sent once:
if (firstUpdate) {
app.handleMessage(plugin.id, { updates: [
{
meta: metas,
}
]})
firstUpdate = false
}
I've not seen it since... Probably a fluke on my end.