speedandcurrent 1.5.1 → 1.6.0

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/index.js +31 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -51,6 +51,12 @@ module.exports = function (app) {
51
51
  plugin.schema = {
52
52
  type: "object",
53
53
  properties: {
54
+ sogFallback: {
55
+ type: "boolean",
56
+ title: "SOG fallback",
57
+ description: "Allow fallback to SOG when paddlewheel is blocked.",
58
+ default: true
59
+ },
54
60
  startWithNewTable: {
55
61
  type: "boolean",
56
62
  title: "Start with new table",
@@ -148,6 +154,7 @@ module.exports = function (app) {
148
154
 
149
155
  plugin.uiSchema = {
150
156
  'ui:order': [
157
+ "sogFallback",
151
158
  "estimateBoatSpeed",
152
159
  "updateCorrectionTable",
153
160
  "assumeCurrent",
@@ -164,6 +171,9 @@ module.exports = function (app) {
164
171
  "attitudeSource",
165
172
  "preventDuplication"
166
173
  ],
174
+ sogFallback: {
175
+ "ui:widget": "checkbox"
176
+ },
167
177
  startWithNewTable: {
168
178
  "ui:widget": "checkbox"
169
179
  },
@@ -343,6 +353,18 @@ module.exports = function (app) {
343
353
  smoothedBoatSpeed.onChange = () => {
344
354
  const wellUnderway = started < new Date() - 60 * 1000;
345
355
  const minSpeed = SI.fromKnots(settings.speedStep / 2);
356
+
357
+ if (settings.sogFallback && fallingBackToSog( minSpeed) ){
358
+ app.setPluginStatus("Falling back to Speed Over Ground");
359
+ app.debug("Falling back");
360
+ return;
361
+ }
362
+ if (!wellUnderway) {
363
+ app.setPluginStatus("Stabilizing");
364
+ }
365
+ else {
366
+ app.setPluginStatus("Running");
367
+ }
346
368
  if (settings.estimateBoatSpeed) correct(wellUnderway);
347
369
  if (settings.updateCorrectionTable && wellUnderway) {
348
370
  updateTable(settings.assumeCurrent, minSpeed);
@@ -390,6 +412,15 @@ module.exports = function (app) {
390
412
  });
391
413
  };
392
414
 
415
+ function fallingBackToSog( minSpeed) {
416
+ if (!rawBoatSpeed.stale && rawBoatSpeed.magnitude > 0) return false;
417
+ if (rawGroundSpeed.stale || rawGroundSpeed.magnitude < minSpeed) return false;
418
+ // Fallback to SOG
419
+ correctedBoatSpeed.setVectorValue({ x: rawGroundSpeed.magnitude, y: 0 });
420
+ Polar.send(app, plugin.id, [correctedBoatSpeed]);
421
+ return true;
422
+ }
423
+
393
424
  /**
394
425
  * Estimates and applies corrections to boat speed, leeway, and current.
395
426
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "speedandcurrent",
3
- "version": "1.5.1",
3
+ "version": "1.6.0",
4
4
  "description": "A plugin that automatically corrects boat speed and calculates current and leeway using sensor fusion.",
5
5
  "main": "index.js",
6
6
  "scripts": {