signalk-polar-performance-plugin 0.0.12 → 0.0.13
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 +33 -19
package/package.json
CHANGED
package/plugin/index.js
CHANGED
|
@@ -198,40 +198,52 @@ module.exports = function (app) {
|
|
|
198
198
|
if (TWA < halfPi) {
|
|
199
199
|
// app.debug('Upwind')
|
|
200
200
|
if (options.beatAngle == true) {
|
|
201
|
-
//
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
201
|
+
// Take beat angle
|
|
202
|
+
if (typeof polar[indexTWS]['Beat angle'] != 'undefined') {
|
|
203
|
+
let beatLower = polar[indexTWS]['Beat angle']
|
|
204
|
+
let beatUpper = polar[indexTWS+1]['Beat angle']
|
|
205
|
+
performance.beatAngle = beatLower + ((beatUpper - beatLower) * twsGapRatio)
|
|
206
|
+
}
|
|
205
207
|
}
|
|
206
208
|
// Calculate optimum wind angle (B&G thing)
|
|
207
209
|
if (options.optimumWindAngle == true) {
|
|
208
|
-
|
|
210
|
+
if (typeof performance.beatAngle != 'undefined') {
|
|
211
|
+
performance.optimumWindAngle = (TWA - performance.beatAngle) * port
|
|
212
|
+
}
|
|
209
213
|
}
|
|
210
214
|
// Calculate beat VMG
|
|
211
215
|
if (options.beatVMG == true) {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
216
|
+
if (typeof polar[indexTWS]['Beat VMG'] != 'undefined') {
|
|
217
|
+
let VMGLower = polar[indexTWS]['Beat VMG']
|
|
218
|
+
let VMGUpper = polar[indexTWS+1]['Beat VMG']
|
|
219
|
+
performance.beatVMG = VMGLower + ((VMGUpper - VMGLower) * twsGapRatio)
|
|
220
|
+
}
|
|
215
221
|
}
|
|
216
222
|
} else {
|
|
217
223
|
// app.debug('Downwind')
|
|
218
224
|
if (options.beatAngle == true) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
225
|
+
if (typeof polar[indexTWS]['Run angle'] != 'undefined') {
|
|
226
|
+
// Calculate run angle
|
|
227
|
+
let runLower = polar[indexTWS]['Run angle']
|
|
228
|
+
let runUpper = polar[indexTWS+1]['Run angle']
|
|
229
|
+
//app.debug('runLower: %s runUpper: %s', runLower, runUpper)
|
|
230
|
+
performance.runAngle = runLower + ((runUpper - runLower) * twsGapRatio)
|
|
231
|
+
}
|
|
224
232
|
}
|
|
225
233
|
if (options.optimumWindAngle == true) {
|
|
226
|
-
|
|
227
|
-
|
|
234
|
+
if (typeof performance.runAngle != 'undefined') {
|
|
235
|
+
// Calculate optimum wind angle
|
|
236
|
+
performance.optimumWindAngle = (performance.runAngle - TWA) * port * -1
|
|
237
|
+
}
|
|
228
238
|
}
|
|
229
239
|
if (options.beatVMG == true) {
|
|
230
240
|
// Calculate run VMG
|
|
231
|
-
|
|
232
|
-
|
|
241
|
+
if (typeof polar[indexTWS]['Run VMG'] != 'undefined') {
|
|
242
|
+
let VMGLower = polar[indexTWS]['Run VMG']
|
|
243
|
+
let VMGUpper = polar[indexTWS+1]['Run VMG']
|
|
233
244
|
//app.debug('VMGLower: %s VMGUpper: %s', VMGLower, VMGUpper)
|
|
234
|
-
|
|
245
|
+
performance.runVMG = VMGLower + ((VMGUpper - VMGLower) * twsGapRatio)
|
|
246
|
+
}
|
|
235
247
|
}
|
|
236
248
|
}
|
|
237
249
|
// Calculate polar target boat speed
|
|
@@ -371,8 +383,10 @@ module.exports = function (app) {
|
|
|
371
383
|
}
|
|
372
384
|
let tbs = ktsToMs(Number(row[index+1]))
|
|
373
385
|
let Obj = {"twa": angle, "tbs": tbs}
|
|
386
|
+
app.debug('Adding Obj: %s', JSON.stringify(Obj))
|
|
374
387
|
polar[index]['twa'] = polar[index]['twa'].concat(Obj)
|
|
375
|
-
if
|
|
388
|
+
// See if this a new Max speed
|
|
389
|
+
if (typeof polar[index]['Max speed'] == 'undefined' || tbs > polar[index]['Max speed']) {
|
|
376
390
|
polar[index]['Max speed'] = tbs
|
|
377
391
|
polar[index]['Max speed angle'] = angle
|
|
378
392
|
}
|