signalk-polar-performance-plugin 0.0.37 → 0.0.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "signalk-polar-performance-plugin",
3
- "version": "0.0.37",
3
+ "version": "0.0.40",
4
4
  "description": "A plugin that calculates performance information based on a (CSV) polar diagram.",
5
5
  "main": "plugin/index.js",
6
6
  "scripts": {
@@ -16,6 +16,10 @@
16
16
  "url": "https://github.com/htool/signalk-polar-performance-plugin/issues"
17
17
  },
18
18
  "homepage": "https://github.com/htool/signalk-polar-performance-plugin#readme",
19
+ "signalk": {
20
+ "appIcon": "./signalk-logo.png",
21
+ "displayName": "Polar Performance"
22
+ },
19
23
  "keywords": [
20
24
  "signalk-webapp",
21
25
  "signalk-node-server-plugin",
package/plugin/index.js CHANGED
@@ -88,7 +88,6 @@ module.exports = function (app) {
88
88
  plugin.start = function (options, restartPlugin) {
89
89
  // Here we put our plugin logic
90
90
  app.debug('Plugin started');
91
- var unsubscribes = [];
92
91
  app.debug('Options: %s', JSON.stringify(options))
93
92
 
94
93
  // Load polar table
@@ -163,14 +162,14 @@ module.exports = function (app) {
163
162
  function handleDelta (deltas) {
164
163
  deltas.forEach(delta => {
165
164
  // app.debug('handleData: %s', JSON.stringify(delta))
166
- if (delta.path == 'navigation.speedThroughWater') {
165
+ if (delta.path == 'navigation.speedThroughWater' && options.useSOG == false) {
167
166
  STW = applyDamping (delta.value, 'STW', options.dampingBSP || 0)
168
167
  BSP = STW
169
168
  // app.debug('speedThroughWater (STW): %d', STW)
170
- } else if (delta.path == 'navigation.speedOverGround') {
169
+ } else if (delta.path == 'navigation.speedOverGround' && options.useSOG == true) {
171
170
  SOG = applyDamping (delta.value, 'SOG', options.dampingBSP || 0)
172
171
  BSP = SOG
173
- // app.debug('speedThroughWater (STW): %d', STW)
172
+ // app.debug('speedOverGround (SOG): %d', SOG)
174
173
  } else if (delta.path == 'navigation.headingTrue') {
175
174
  HDG = delta.value
176
175
  // app.debug('heading (HDG): %d', HDG)
@@ -728,16 +727,15 @@ module.exports = function (app) {
728
727
 
729
728
  plugin.stop = function () {
730
729
  // Here we put logic we need when the plugin stops
731
- app.debug('Plugin stopped');
732
- plugin.stop = function () {
733
- unsubscribes.forEach(f => f());
734
- unsubscribes = [];
735
- timers.forEach(timer => {
736
- clearInterval(timer)
737
- })
738
- };
739
-
740
- };
730
+ app.debug('Plugin stopped')
731
+ app.debug('unsubscribes before: %s', JSON.stringify(unsubscribes))
732
+ unsubscribes.forEach(f => f())
733
+ unsubscribes = []
734
+ app.debug('unsubscribes after: %s', JSON.stringify(unsubscribes))
735
+ timers.forEach(timer => {
736
+ clearInterval(timer)
737
+ })
738
+ }
741
739
 
742
740
  return plugin;
743
741
  };
package/public/index.html CHANGED
@@ -195,16 +195,16 @@ function handleData (data) {
195
195
  var value = data.updates[0].values[0].value
196
196
 
197
197
  if (path == 'performance.polarSpeed') {
198
- polarSpeed = msToKts(value)
198
+ polarSpeed = roundDec(msToKts(value), 1)
199
199
  // console.log('polarSpeed set to %s', polarSpeed)
200
200
  chartData.datasets[0].data[0].y = polarSpeed
201
201
  } else if (path == 'environment.wind.angleTrueWaterDamped') {
202
- TWA = radToDeg(value)
202
+ TWA = roundDec(radToDeg(value),1)
203
203
  // console.log('TWA set to %s', TWA)
204
204
  chartData.datasets[0].data[0].x = TWA
205
205
  chartData.datasets[1].data[0].x = TWA
206
206
  } else if (path == 'performance.boatSpeedDamped') {
207
- boatSpeed = msToKts(value)
207
+ boatSpeed = roundDec(msToKts(value),1)
208
208
  // console.log('boatSpeed set to %s', boatSpeed)
209
209
  chartData.datasets[1].data[0].y = boatSpeed
210
210
  }
@@ -227,7 +227,14 @@ function msToKts(ms) {
227
227
  return ms * 1.94384
228
228
  }
229
229
 
230
-
230
+ function roundDec (value, decimals) {
231
+ if (typeof value == 'undefined') {
232
+ return undefined
233
+ } else {
234
+ value = Number(value.toFixed(decimals))
235
+ return value
236
+ }
237
+ }
231
238
 
232
239
  </script>
233
240
 
Binary file
Binary file