@signalk/freeboard-sk 2.20.0 → 2.21.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.
package/README.md CHANGED
@@ -187,11 +187,9 @@ The following features require that the Signal K server have plugins / providers
187
187
 
188
188
  The following plugins are recommended for installation on the Signal K Server to enable full functionality:
189
189
 
190
- - @signalk/course-provider _(Course calculations e.g. XTE, DTG, etc.)_
191
- - @signalk/charts-plugin *(Mapbox tiles chart provider)*
192
- - signalk-pmtiles-plugin *(ProtoMaps chart provider)*
193
- - signalk-anchoralarm-plugin _(Anchor alarm settings & notifications)_
194
- - signalk-simple-notifications _(Depth alarm notifications)_
190
+ - Charts: `@signalk/charts-plugin`, `signalk-chart-provider-simple`, `signalk-pmtiles-plugin`, etc.
191
+ - Anchor Watch: `signalk-anchoralarm-plugin`
192
+ - Weather Forcasts: `signalk-openweather-provider`
195
193
 
196
194
  ---
197
195
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signalk/freeboard-sk",
3
- "version": "2.20.0",
3
+ "version": "2.21.0",
4
4
  "description": "Openlayers chart plotter implementation for Signal K",
5
5
  "keywords": [
6
6
  "signalk-webapp",
@@ -40,7 +40,7 @@
40
40
  ],
41
41
  "license": "Apache-v2",
42
42
  "dependencies": {
43
- "@signalk/server-api": "^2.22.0",
43
+ "@signalk/server-api": "^2.24.0",
44
44
  "geolib": "^3.3.3",
45
45
  "google-protobuf": "^4.0.1",
46
46
  "tslib": "^2.0.0",
@@ -7,19 +7,6 @@ const uuid = tslib_1.__importStar(require("uuid"));
7
7
  const geolib_1 = require("geolib");
8
8
  const AREA_TRIGGERS = ['entry', 'exit'];
9
9
  const AREA_GEOMETRIES = ['polygon', 'circle', 'region'];
10
- const STANDARD_ALARMS = [
11
- 'mob',
12
- 'fire',
13
- 'sinking',
14
- 'flooding',
15
- 'collision',
16
- 'grounding',
17
- 'listing',
18
- 'adrift',
19
- 'piracy',
20
- 'abandon',
21
- 'aground'
22
- ];
23
10
  const ALARM_API_PATH = '/signalk/v2/api/alarms';
24
11
  class AreaAlarmManager {
25
12
  alarms;
@@ -62,7 +49,6 @@ class AreaAlarmManager {
62
49
  * @param id Area identifier
63
50
  */
64
51
  silence(id) {
65
- // clean up notification
66
52
  const n = getSelfPathValue(`notifications.area.${id}`);
67
53
  if (n?.value && Array.isArray(n.value.method)) {
68
54
  const m = n.value.method.filter((i) => i !== 'sound');
@@ -98,7 +84,6 @@ class AreaAlarmManager {
98
84
  notify = true;
99
85
  server.debug(`*** active -> to inactive (${id})`);
100
86
  }
101
- alarm.lastUpdate == Date.now();
102
87
  }
103
88
  else {
104
89
  if (condition === 'outside' && !alarm.active) {
@@ -115,6 +100,7 @@ class AreaAlarmManager {
115
100
  }
116
101
  }
117
102
  if (notify) {
103
+ alarm.lastUpdate = Date.now();
118
104
  const msg = area.trigger === 'entry'
119
105
  ? alarm.active
120
106
  ? `Monitored area ${area.name ? area.name + ' ' : ''}has been entered.`
@@ -147,13 +133,6 @@ const initAlarms = (app, id) => {
147
133
  server = app;
148
134
  pluginId = id;
149
135
  server.debug(`** initAlarms() **`);
150
- if (server.registerActionHandler) {
151
- server.debug(`** Registering Alarm Action Handler(s) **`);
152
- STANDARD_ALARMS.forEach((i) => {
153
- server.debug(`** Registering ${i} Handler **`);
154
- server.registerPutHandler('vessels.self', `notifications.${i}`, handleV1PutRequest, pluginId);
155
- });
156
- }
157
136
  initAlarmEndpoints();
158
137
  setTimeout(() => parseRegionList(), 5000);
159
138
  // subscribe to deltas
@@ -351,147 +330,6 @@ const initAlarmEndpoints = async () => {
351
330
  });
352
331
  }
353
332
  });
354
- const f = await server.getFeatures();
355
- // test for notifications API
356
- if (!f.apis.includes('notifications')) {
357
- // standard alarms
358
- server.post(`${ALARM_API_PATH}/:alarmType`, (req, res, next) => {
359
- server.debug(`** ${req.method} ${ALARM_API_PATH}/${req.params.alarmType}`);
360
- if (!STANDARD_ALARMS.includes(req.params.alarmType)) {
361
- next();
362
- return;
363
- }
364
- try {
365
- const id = uuid.v4();
366
- const msg = req.body.message
367
- ? req.body.message
368
- : req.params.alarmType;
369
- const r = handleAlarm('vessels.self', `notifications.${req.params.alarmType}.${id}`, Object.assign({
370
- message: msg,
371
- method: [server_api_1.ALARM_METHOD.sound, server_api_1.ALARM_METHOD.visual],
372
- state: server_api_1.ALARM_STATE.emergency
373
- }, buildAlarmData()));
374
- res.status(r.statusCode).json(Object.assign(r, { id: id }));
375
- }
376
- catch (e) {
377
- res.status(400).json({
378
- state: 'FAILED',
379
- statusCode: 400,
380
- message: e.message
381
- });
382
- }
383
- });
384
- server.post(`${ALARM_API_PATH}/:alarmType/:id/silence`, (req, res) => {
385
- server.debug(`** ${req.method} ${req.path}`);
386
- if (!STANDARD_ALARMS.includes(req.params.alarmType)) {
387
- res.status(200).json({
388
- state: 'COMPLETED',
389
- statusCode: 200,
390
- message: `Unsupported Alarm (${req.params.alarmType}).`
391
- });
392
- return;
393
- }
394
- try {
395
- const al = getSelfPathValue(`notifications.${req.params.alarmType}.${req.params.id}`);
396
- if (al?.value) {
397
- server.debug('Alarm value....');
398
- if (al.value.method &&
399
- al.value.method.includes(server_api_1.ALARM_METHOD.sound)) {
400
- server.debug('Alarm has sound... silence!!!');
401
- al.value.method = al.value.method.filter((i) => i !== server_api_1.ALARM_METHOD.sound);
402
- const r = handleAlarm('vessels.self', `notifications.${req.params.alarmType}.${req.params.id}`, al.value);
403
- res.status(r.statusCode).json(r);
404
- }
405
- else {
406
- server.debug('Alarm has no sound... no action required.');
407
- res.status(200).json({
408
- state: 'COMPLETED',
409
- statusCode: 200,
410
- message: `Alarm (${req.params.alarmType}) is already silent.`
411
- });
412
- }
413
- }
414
- else {
415
- throw new Error(`Alarm (${req.params.alarmType}.${req.params.id}) has no value or was not found!`);
416
- }
417
- }
418
- catch (e) {
419
- res.status(400).json({
420
- state: 'FAILED',
421
- statusCode: 400,
422
- message: e.message
423
- });
424
- }
425
- });
426
- server.delete(`${ALARM_API_PATH}/:alarmType/:id`, (req, res, next) => {
427
- server.debug(`** ${req.method} ${ALARM_API_PATH}/${req.params.alarmType}`);
428
- if (!STANDARD_ALARMS.includes(req.params.alarmType)) {
429
- next();
430
- return;
431
- }
432
- try {
433
- const r = handleAlarm('vessels.self', `notifications.${req.params.alarmType}.${req.params.id}`, {
434
- message: '',
435
- method: [],
436
- state: server_api_1.ALARM_STATE.normal
437
- });
438
- res.status(r.statusCode).json(r);
439
- }
440
- catch (e) {
441
- res.status(400).json({
442
- state: 'FAILED',
443
- statusCode: 400,
444
- message: e.message
445
- });
446
- }
447
- });
448
- }
449
- };
450
- const handleV1PutRequest = (context, path, value, cb) => {
451
- cb(handleAlarm(context, path, value));
452
- };
453
- const buildAlarmData = () => {
454
- const pos = getSelfPathValue('navigation.position');
455
- const r = {
456
- createdAt: new Date().toISOString()
457
- };
458
- if (pos?.value) {
459
- r.position = pos.value;
460
- }
461
- return r;
462
- };
463
- const handleAlarm = (context, path, value) => {
464
- server.debug(`context: ${context}`);
465
- server.debug(`path: ${path}`);
466
- server.debug(`value: ${JSON.stringify(value)}`);
467
- if (!path) {
468
- server.debug('Error: no path provided!');
469
- return {
470
- state: 'COMPLETED',
471
- resultStatus: 400,
472
- statusCode: 400,
473
- message: `Invalid reference!`
474
- };
475
- }
476
- const pa = path.split('.');
477
- const alarmType = pa[1];
478
- server.debug(`alarmType: ${JSON.stringify(alarmType)}`);
479
- if (STANDARD_ALARMS.includes(alarmType)) {
480
- server.debug(`****** Sending Delta (Std Alarm Notification): ******`);
481
- emitNotification({
482
- path: path,
483
- value: value ?? null
484
- });
485
- return { state: 'COMPLETED', resultStatus: 200, statusCode: 200 };
486
- }
487
- else {
488
- return {
489
- state: 'COMPLETED',
490
- resultStatus: 400,
491
- statusCode: 400,
492
- message: `Invalid reference!`
493
- };
494
- }
495
333
  };
496
334
  // emit notification delta message **
497
335
  const emitNotification = (msg) => {
package/plugin/index.js CHANGED
@@ -4,7 +4,7 @@ const tslib_1 = require("tslib");
4
4
  const server_api_1 = require("@signalk/server-api");
5
5
  const alarms_1 = require("./alarms/alarms");
6
6
  const openapi = tslib_1.__importStar(require("./openApi.json"));
7
- const defaultPollInterval = 60;
7
+ //const defaultPollInterval = 60;
8
8
  const CONFIG_SCHEMA = {
9
9
  properties: {}
10
10
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "openapi": "3.0.0",
3
3
  "info": {
4
- "version": "2.18.0",
4
+ "version": "2.20.0",
5
5
  "title": "Freeboard-SK API",
6
6
  "description": "API endpoints exposed by Freeboard-SK to support application functionality and experimental features.",
7
7
  "termsOfService": "http://signalk.org/terms/",
@@ -14,16 +14,7 @@
14
14
  "url": "http://signalk.org/specification/",
15
15
  "description": "Signal K specification."
16
16
  },
17
- "servers": [
18
- {
19
- "url": "/"
20
- }
21
- ],
22
17
  "tags": [
23
- {
24
- "name": "Alarms",
25
- "description": "Standard alarms."
26
- },
27
18
  {
28
19
  "name": "Areas",
29
20
  "description": "Area alarms."
@@ -142,28 +133,6 @@
142
133
  "schema": {
143
134
  "type": "number"
144
135
  }
145
- },
146
- "AlarmTypeParam": {
147
- "in": "path",
148
- "required": true,
149
- "name": "alarmType",
150
- "description": "Alarm type.",
151
- "schema": {
152
- "type": "string",
153
- "enum": [
154
- "mob",
155
- "fire",
156
- "sinking",
157
- "flooding",
158
- "collision",
159
- "grounding",
160
- "listing",
161
- "adrift",
162
- "piracy",
163
- "abandon",
164
- "aground"
165
- ]
166
- }
167
136
  }
168
137
  },
169
138
  "securitySchemes": {
@@ -182,16 +151,19 @@
182
151
  "security": [{ "cookieAuth": [] }, { "bearerAuth": [] }],
183
152
  "paths": {
184
153
  "/signalk/v2/api/alarms/area": {
185
- "post": {
154
+ "get": {
186
155
  "tags": ["Areas"],
187
- "summary": "Set Alarm area.",
156
+ "summary": "List Area Alarms.",
188
157
  "requestBody": {
189
- "description": "Sets the defined area to monitor for vessel entry /exit.",
158
+ "description": "Lists the areas to monitor for vessel entry /exit.",
190
159
  "required": true,
191
160
  "content": {
192
161
  "application/json": {
193
162
  "schema": {
194
- "$ref": "#/components/schemas/AreaAlarmDef"
163
+ "type": "array",
164
+ "items": {
165
+ "$ref": "#/components/schemas/AreaAlarmDef"
166
+ }
195
167
  }
196
168
  }
197
169
  }
@@ -204,19 +176,12 @@
204
176
  "$ref": "#/components/responses/ErrorResponse"
205
177
  }
206
178
  }
207
- }
208
- },
209
- "/signalk/v2/api/alarms/area/{id}": {
210
- "parameters": [
211
- {
212
- "$ref": "#/components/parameters/AlarmIdParam"
213
- }
214
- ],
215
- "put": {
179
+ },
180
+ "post": {
216
181
  "tags": ["Areas"],
217
- "summary": "Update Alarm area OR Set the `Region` resource with the supplied identifier as the alarm area.",
182
+ "summary": "Set Alarm area.",
218
183
  "requestBody": {
219
- "description": "Updates the area details for the supplied area identfier.",
184
+ "description": "Sets the defined area to monitor for vessel entry /exit.",
220
185
  "required": true,
221
186
  "content": {
222
187
  "application/json": {
@@ -234,62 +199,24 @@
234
199
  "$ref": "#/components/responses/ErrorResponse"
235
200
  }
236
201
  }
237
- },
238
- "delete": {
239
- "tags": ["Areas"],
240
- "summary": "Clear / cancel Area Alarm.",
241
- "responses": {
242
- "200ActionResponse": {
243
- "$ref": "#/components/responses/200OKResponse"
244
- },
245
- "default": {
246
- "$ref": "#/components/responses/ErrorResponse"
247
- }
248
- }
249
202
  }
250
203
  },
251
- "/signalk/v2/api/alarms/area/{id}/silence": {
204
+ "/signalk/v2/api/alarms/area/{id}": {
252
205
  "parameters": [
253
206
  {
254
207
  "$ref": "#/components/parameters/AlarmIdParam"
255
208
  }
256
209
  ],
257
- "post": {
210
+ "put": {
258
211
  "tags": ["Areas"],
259
- "summary": "Silence Area Alarm.",
260
- "responses": {
261
- "200ActionResponse": {
262
- "$ref": "#/components/responses/200OKResponse"
263
- },
264
- "default": {
265
- "$ref": "#/components/responses/ErrorResponse"
266
- }
267
- }
268
- }
269
- },
270
- "/signalk/v2/api/alarms/{alarmType}": {
271
- "parameters": [
272
- {
273
- "$ref": "#/components/parameters/AlarmTypeParam"
274
- }
275
- ],
276
- "post": {
277
- "tags": ["Alarms"],
278
- "summary": "Raise Alarm.",
212
+ "summary": "Update Alarm area OR Set the `Region` resource with the supplied identifier as the alarm area.",
279
213
  "requestBody": {
280
- "description": "Alarm message text.",
281
- "required": false,
214
+ "description": "Updates the area details for the supplied area identfier.",
215
+ "required": true,
282
216
  "content": {
283
217
  "application/json": {
284
218
  "schema": {
285
- "type": "object",
286
- "properties": {
287
- "message": {
288
- "type": "string",
289
- "description": "Alarm message text.",
290
- "example": "Person overboard!"
291
- }
292
- }
219
+ "$ref": "#/components/schemas/AreaAlarmDef"
293
220
  }
294
221
  }
295
222
  }
@@ -302,20 +229,10 @@
302
229
  "$ref": "#/components/responses/ErrorResponse"
303
230
  }
304
231
  }
305
- }
306
- },
307
- "/signalk/v2/api/alarms/{alarmType}/{id}": {
308
- "parameters": [
309
- {
310
- "$ref": "#/components/parameters/AlarmTypeParam"
311
- },
312
- {
313
- "$ref": "#/components/parameters/AlarmIdParam"
314
- }
315
- ],
232
+ },
316
233
  "delete": {
317
- "tags": ["Alarms"],
318
- "summary": "Clear / cancel Alarm.",
234
+ "tags": ["Areas"],
235
+ "summary": "Clear / cancel Area Alarm.",
319
236
  "responses": {
320
237
  "200ActionResponse": {
321
238
  "$ref": "#/components/responses/200OKResponse"
@@ -326,18 +243,15 @@
326
243
  }
327
244
  }
328
245
  },
329
- "/signalk/v2/api/alarms/{alarmType}/{id}/silence": {
246
+ "/signalk/v2/api/alarms/area/{id}/silence": {
330
247
  "parameters": [
331
- {
332
- "$ref": "#/components/parameters/AlarmTypeParam"
333
- },
334
248
  {
335
249
  "$ref": "#/components/parameters/AlarmIdParam"
336
250
  }
337
251
  ],
338
252
  "post": {
339
- "tags": ["Alarms"],
340
- "summary": "Silence Alarm.",
253
+ "tags": ["Areas"],
254
+ "summary": "Silence Area Alarm.",
341
255
  "responses": {
342
256
  "200ActionResponse": {
343
257
  "$ref": "#/components/responses/200OKResponse"
@@ -220,7 +220,9 @@
220
220
  <tr>
221
221
  <td>Chart display</td>
222
222
  <td>
223
- <b>@signalk/charts-plugin</b>
223
+ <b>@signalk/charts-plugin</b><br />
224
+ <b>signalk-charts-provider-simple</b><br />
225
+ <b>signalk-pmtiles-plugin</b>
224
226
  </td>
225
227
  </tr>
226
228
  <tr>
@@ -2275,7 +2277,9 @@
2275
2277
  <br />
2276
2278
  <b>Distance Units</b>: <i>Kilometres</i> / <i>Nautical Miles</i>
2277
2279
  <br />
2278
- <b>Depth Units</b>: <i>Metres</i> / <i>Feet</i>
2280
+ <b>Depth Units</b>: <i>Metres</i> / <i>Feet</i> / <i>Fathom</i>
2281
+ <br />
2282
+ <b>Length Units</b>: <i>Metres</i> / <i>Feet</i>
2279
2283
  <br />
2280
2284
  <b>Speed Units</b>: <i>Knots</i> / <i>m/sec</i> / <i>km/h</i> /
2281
2285
  <i>mph</i>
@@ -2339,6 +2343,7 @@
2339
2343
  </li>
2340
2344
  </ul>
2341
2345
  <b>Vector Charts:</b><br />
2346
+ Options that apply to S57 charts.
2342
2347
  <ul>
2343
2348
  <li>
2344
2349
  <b>Graphics Style</b>: Select this option in order to a close a
@@ -2351,6 +2356,10 @@
2351
2356
  <li><b>Shallow Depth</b>: Enter the depth in meters.</li>
2352
2357
  <li><b>Safety Depth</b>: Enter the depth in meters.</li>
2353
2358
  <li><b>Deep Depth</b>: Enter the depth in meters.</li>
2359
+ <li>
2360
+ <b>Layers</b>: Select S57 layers to display
2361
+ <i>(when avaiable)</i>.
2362
+ </li>
2354
2363
  </ul>
2355
2364
  <hr />
2356
2365
 
@@ -2427,7 +2436,7 @@
2427
2436
  <b>Default</b>: Calculates the length of the line displayed
2428
2437
  based on the vessel SOG and the map scale.
2429
2438
  </li>
2430
- <li><b>(x) NM</b> Length of the line to display.</li>
2439
+ <li><b>(x) nmi</b> Length of the line to display.</li>
2431
2440
  </ul>
2432
2441
  </li>
2433
2442
  <li>