signalk-polar-performance-plugin 0.0.39 → 0.0.41
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 +1 -1
- package/plugin/index.js +14 -16
package/package.json
CHANGED
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
|
|
@@ -197,14 +196,14 @@ module.exports = function (app) {
|
|
|
197
196
|
let metas = []
|
|
198
197
|
values.push({path: 'performance.boatSpeedDamped', value: roundDec(BSP)})
|
|
199
198
|
metas.push({path: 'performance.boatSpeedDamped', value: {"units": "m/s"}})
|
|
200
|
-
values.push({path: 'environment.wind.angleTrueWaterDamped', value: roundDec(TWA)})
|
|
199
|
+
values.push({path: 'environment.wind.angleTrueWaterDamped', value: roundDec(TWA) * port})
|
|
201
200
|
metas.push({path: 'environment.wind.angleTrueWaterDamped', value: {"units": "rad"}})
|
|
202
201
|
if (typeof perfObj.beatAngle != 'undefined') {
|
|
203
202
|
if (options.beatAngle == true) {
|
|
204
|
-
values.push({path: 'performance.beatAngle', value: roundDec(perfObj.beatAngle)})
|
|
203
|
+
values.push({path: 'performance.beatAngle', value: roundDec(perfObj.beatAngle * port)})
|
|
205
204
|
}
|
|
206
205
|
if (options.targetTWA == true) {
|
|
207
|
-
values.push({path: 'performance.targetAngle', value: roundDec(perfObj.beatAngle)})
|
|
206
|
+
values.push({path: 'performance.targetAngle', value: roundDec(perfObj.beatAngle * port)})
|
|
208
207
|
}
|
|
209
208
|
}
|
|
210
209
|
if (typeof perfObj.beatVMG != 'undefined') {
|
|
@@ -216,10 +215,10 @@ module.exports = function (app) {
|
|
|
216
215
|
}
|
|
217
216
|
if (typeof perfObj.runAngle != 'undefined') {
|
|
218
217
|
if (options.beatAngle == true) {
|
|
219
|
-
values.push({path: 'performance.gybeAngle', value: roundDec(perfObj.runAngle)})
|
|
218
|
+
values.push({path: 'performance.gybeAngle', value: roundDec(perfObj.runAngle * port)})
|
|
220
219
|
}
|
|
221
220
|
if (options.targetTWA == true) {
|
|
222
|
-
values.push({path: 'performance.targetAngle', value: roundDec(perfObj.runAngle)})
|
|
221
|
+
values.push({path: 'performance.targetAngle', value: roundDec(perfObj.runAngle * port)})
|
|
223
222
|
}
|
|
224
223
|
}
|
|
225
224
|
if (typeof perfObj.runVMG != 'undefined') {
|
|
@@ -310,6 +309,7 @@ module.exports = function (app) {
|
|
|
310
309
|
//app.debug('VMGLower: %s VMGUpper: %s', VMGLower, VMGUpper)
|
|
311
310
|
performance.beatVMG = VMGLower + ((VMGUpper - VMGLower) * twsGapRatio)
|
|
312
311
|
performance.targetVMG = performance.beatVMG
|
|
312
|
+
performance.targetSpeed = performance.beatVMG / Math.cos(targetTWA)
|
|
313
313
|
}
|
|
314
314
|
} else {
|
|
315
315
|
// app.debug('Downwind')
|
|
@@ -334,6 +334,7 @@ module.exports = function (app) {
|
|
|
334
334
|
//app.debug('VMGLower: %s VMGUpper: %s', VMGLower, VMGUpper)
|
|
335
335
|
performance.runVMG = VMGLower + ((VMGUpper - VMGLower) * twsGapRatio)
|
|
336
336
|
performance.targetVMG = performance.runVMG
|
|
337
|
+
performance.targetSpeed = performance.runVMG / Math.abs(Math.cos(targetTWA))
|
|
337
338
|
}
|
|
338
339
|
}
|
|
339
340
|
// Calculate opposite Tack True
|
|
@@ -728,16 +729,13 @@ module.exports = function (app) {
|
|
|
728
729
|
|
|
729
730
|
plugin.stop = function () {
|
|
730
731
|
// Here we put logic we need when the plugin stops
|
|
731
|
-
app.debug('Plugin stopped')
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
};
|
|
739
|
-
|
|
740
|
-
};
|
|
732
|
+
app.debug('Plugin stopped')
|
|
733
|
+
unsubscribes.forEach(f => f())
|
|
734
|
+
unsubscribes = []
|
|
735
|
+
timers.forEach(timer => {
|
|
736
|
+
clearInterval(timer)
|
|
737
|
+
})
|
|
738
|
+
}
|
|
741
739
|
|
|
742
740
|
return plugin;
|
|
743
741
|
};
|