signalk-polar-performance-plugin 0.0.32 → 0.0.33

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/plugin/index.js +12 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "signalk-polar-performance-plugin",
3
- "version": "0.0.32",
3
+ "version": "0.0.33",
4
4
  "description": "A plugin that calculates performance information based on a (CSV) polar diagram.",
5
5
  "main": "plugin/index.js",
6
6
  "scripts": {
package/plugin/index.js CHANGED
@@ -285,6 +285,7 @@ module.exports = function (app) {
285
285
  if (typeof polar[indexTWS]['Beat angle'] != 'undefined') {
286
286
  let beatLower = polar[indexTWS]['Beat angle']
287
287
  let beatUpper = polar[indexTWS+1]['Beat angle']
288
+ //app.debug('beatLower: %s beatUpper: %s', beatLower, beatUpper)
288
289
  performance.beatAngle = beatLower + ((beatUpper - beatLower) * twsGapRatio)
289
290
  targetTWA = performance.beatAngle
290
291
  }
@@ -298,6 +299,7 @@ module.exports = function (app) {
298
299
  if (typeof polar[indexTWS]['Beat VMG'] != 'undefined') {
299
300
  let VMGLower = polar[indexTWS]['Beat VMG']
300
301
  let VMGUpper = polar[indexTWS+1]['Beat VMG']
302
+ //app.debug('VMGLower: %s VMGUpper: %s', VMGLower, VMGUpper)
301
303
  performance.beatVMG = VMGLower + ((VMGUpper - VMGLower) * twsGapRatio)
302
304
  performance.targetVMG = performance.beatVMG
303
305
  }
@@ -321,7 +323,7 @@ module.exports = function (app) {
321
323
  if (typeof polar[indexTWS]['Run VMG'] != 'undefined') {
322
324
  let VMGLower = polar[indexTWS]['Run VMG']
323
325
  let VMGUpper = polar[indexTWS+1]['Run VMG']
324
- //app.debug('VMGLower: %s VMGUpper: %s', VMGLower, VMGUpper)
326
+ //app.debug('VMGLower: %s VMGUpper: %s', VMGLower, VMGUpper)
325
327
  performance.runVMG = VMGLower + ((VMGUpper - VMGLower) * twsGapRatio)
326
328
  performance.targetVMG = performance.runVMG
327
329
  }
@@ -346,7 +348,7 @@ module.exports = function (app) {
346
348
  // Interpolate Define the 4 near data points
347
349
  let lowerTWA = polar[indexTWS].twa
348
350
  let upperTWA = polar[indexTWS+1].twa
349
- // app.debug('TWAlower: %s', JSON.stringify(TWAlower))
351
+ // app.debug('lowerTWA: %s', JSON.stringify(lowerTWA))
350
352
  // First find lowerTWA
351
353
  for (let indexTWA = 0 ; indexTWA < lowerTWA.length-1; indexTWA++) {
352
354
  let lowerTWAlower = lowerTWA[indexTWA]
@@ -420,7 +422,7 @@ module.exports = function (app) {
420
422
  if (options.VMG == true) {
421
423
  performance.velocityMadeGood = 0
422
424
  performance.polarVelocityMadeGood = 0
423
- performance.polarRatioVelocityMadeGood = 0
425
+ performance.polarVelocityMadeGoodRatio = 0
424
426
  }
425
427
  }
426
428
  return performance
@@ -478,9 +480,11 @@ module.exports = function (app) {
478
480
  }
479
481
  let Obj = {"twa": angle, "tbs": tbs, "vmg": vmg}
480
482
  polar[index]['twa'] = polar[index]['twa'].concat(Obj)
483
+ app.debug('Finding max speed')
481
484
  if (typeof polar[index]['Max speed'] == 'undefined' || tbs > polar[index]['Max speed']) {
482
485
  polar[index]['Max speed'] = tbs
483
486
  polar[index]['Max speed angle'] = angle
487
+ app.debug('Found max speed: %s', JSON.stringify(polar[index]))
484
488
  }
485
489
  }
486
490
  }
@@ -503,6 +507,7 @@ module.exports = function (app) {
503
507
  if (typeof polar[index]['Max speed'] == 'undefined' || tbs > polar[index]['Max speed']) {
504
508
  polar[index]['Max speed'] = tbs
505
509
  polar[index]['Max speed angle'] = angle
510
+ app.debug('Found max speed: %s', JSON.stringify(polar[index]))
506
511
  }
507
512
  }
508
513
  }
@@ -563,10 +568,12 @@ module.exports = function (app) {
563
568
  'Beat VMG': polar[0]['Beat VMG'],
564
569
  'Run angle': polar[0]['Run angle'],
565
570
  'Run VMG': polar[0]['Run VMG'],
571
+ 'Max speed': 0,
572
+ 'Max speed angle': polar[0]['Max speed angle'],
566
573
  twa: []
567
574
  }
568
- Object.keys(polar[0].twa).forEach(twaObj => {
569
- Obj.twa.push({twa: twaObj.twa, tbs: 0})
575
+ Object.values(polar[0].twa).forEach(twaObj => {
576
+ Obj.twa.push({twa: twaObj.twa, tbs: 0, vmg: 0})
570
577
  })
571
578
  polar.unshift(Obj)
572
579
  }