@sailingnaturali/signalk-depth-offsets 0.1.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/LICENSE +21 -0
- package/README.md +37 -0
- package/index.js +100 -0
- package/package.json +34 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Bryan Clark
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# @sailingnaturali/signalk-depth-offsets
|
|
2
|
+
|
|
3
|
+
Derive **`environment.depth.belowKeel`** and **`environment.depth.belowSurface`**
|
|
4
|
+
from `environment.depth.belowTransducer` using your vessel's measured transducer
|
|
5
|
+
offsets — for depth sounders that only emit NMEA0183 `DBT` (depth below
|
|
6
|
+
transducer) with no offset field.
|
|
7
|
+
|
|
8
|
+
Zero runtime dependencies.
|
|
9
|
+
|
|
10
|
+
## What it does
|
|
11
|
+
|
|
12
|
+
A `DBT`-only sounder maps to `environment.depth.belowTransducer` in Signal K, but
|
|
13
|
+
the keel/surface-referenced depths you actually navigate by (under-keel clearance)
|
|
14
|
+
are never produced. This plugin derives them, using the canonical Signal K
|
|
15
|
+
convention:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
belowKeel = belowTransducer + transducerToKeel (transducerToKeel < 0)
|
|
19
|
+
belowSurface = belowTransducer + surfaceToTransducer (surfaceToTransducer > 0)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The offsets come from the data model itself —
|
|
23
|
+
`environment.depth.transducerToKeel` and `environment.depth.surfaceToTransducer`
|
|
24
|
+
(typically set from `baseDeltas.json`). This plugin carries no offsets of its own;
|
|
25
|
+
it's the single transform, the profile is the single source of truth. A derived
|
|
26
|
+
path is only emitted when its offset is present.
|
|
27
|
+
|
|
28
|
+
## Install
|
|
29
|
+
|
|
30
|
+
Signal K admin → **Appstore** → search "depth offsets", or
|
|
31
|
+
`npm install @sailingnaturali/signalk-depth-offsets` in your Signal K data dir.
|
|
32
|
+
Set `environment.depth.transducerToKeel` / `surfaceToTransducer` in your vessel's
|
|
33
|
+
`baseDeltas.json` (or any source). No plugin configuration.
|
|
34
|
+
|
|
35
|
+
## License
|
|
36
|
+
|
|
37
|
+
MIT
|
package/index.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* signalk-depth-offsets
|
|
3
|
+
*
|
|
4
|
+
* The Wind Chaser's sounder emits NMEA0183 DBT only, which SignalK maps to
|
|
5
|
+
* environment.depth.belowTransducer. There is no offset field on DBT, so the
|
|
6
|
+
* keel/surface-referenced depths the agents actually reason about
|
|
7
|
+
* (under-keel clearance) are never produced.
|
|
8
|
+
*
|
|
9
|
+
* This plugin derives them from the transducer offsets, using the canonical
|
|
10
|
+
* SignalK convention:
|
|
11
|
+
* belowKeel = belowTransducer + transducerToKeel (transducerToKeel < 0)
|
|
12
|
+
* belowSurface = belowTransducer + surfaceToTransducer (surfaceToTransducer > 0)
|
|
13
|
+
*
|
|
14
|
+
* The offsets themselves (environment.depth.transducerToKeel /
|
|
15
|
+
* surfaceToTransducer) come from baseDeltas.json, which the vessel_config
|
|
16
|
+
* generator renders from the profile (vessels/profiles/*.yaml, offsets.*).
|
|
17
|
+
* The profile is the single source of truth; this plugin carries no offset
|
|
18
|
+
* values of its own — it just reads them back off the data model.
|
|
19
|
+
*/
|
|
20
|
+
module.exports = function (app) {
|
|
21
|
+
const plugin = {
|
|
22
|
+
id: 'signalk-depth-offsets',
|
|
23
|
+
name: 'Depth offsets (belowKeel / belowSurface)',
|
|
24
|
+
description:
|
|
25
|
+
'Derive belowKeel and belowSurface from belowTransducer for DBT-only sounders.',
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
let unsubscribes = [];
|
|
29
|
+
|
|
30
|
+
// No configuration: offsets are sourced from environment.depth.transducerToKeel
|
|
31
|
+
// and surfaceToTransducer (set by baseDeltas from the vessel profile).
|
|
32
|
+
plugin.schema = { type: 'object', properties: {} };
|
|
33
|
+
|
|
34
|
+
// app.getSelfPath returns the full leaf node ({ value, timestamp, ... }) in
|
|
35
|
+
// most server versions, but the bare value in some; handle both.
|
|
36
|
+
function selfNumber(path) {
|
|
37
|
+
const node = app.getSelfPath(path);
|
|
38
|
+
if (node == null) return undefined;
|
|
39
|
+
const v = typeof node === 'object' && 'value' in node ? node.value : node;
|
|
40
|
+
return typeof v === 'number' ? v : undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
plugin.start = function () {
|
|
44
|
+
app.subscriptionmanager.subscribe(
|
|
45
|
+
{
|
|
46
|
+
context: 'vessels.self',
|
|
47
|
+
subscribe: [
|
|
48
|
+
{
|
|
49
|
+
path: 'environment.depth.belowTransducer',
|
|
50
|
+
period: 1000,
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
unsubscribes,
|
|
55
|
+
(err) => app.error(err),
|
|
56
|
+
(delta) => {
|
|
57
|
+
const transducerToKeel = selfNumber('environment.depth.transducerToKeel');
|
|
58
|
+
const surfaceToTransducer = selfNumber(
|
|
59
|
+
'environment.depth.surfaceToTransducer'
|
|
60
|
+
);
|
|
61
|
+
if (transducerToKeel === undefined && surfaceToTransducer === undefined) {
|
|
62
|
+
// Offsets not in the model yet (baseDeltas not applied) — nothing to derive.
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
(delta.updates || []).forEach((update) => {
|
|
66
|
+
(update.values || []).forEach((v) => {
|
|
67
|
+
if (
|
|
68
|
+
v.path === 'environment.depth.belowTransducer' &&
|
|
69
|
+
typeof v.value === 'number'
|
|
70
|
+
) {
|
|
71
|
+
const values = [];
|
|
72
|
+
if (transducerToKeel !== undefined) {
|
|
73
|
+
values.push({
|
|
74
|
+
path: 'environment.depth.belowKeel',
|
|
75
|
+
value: v.value + transducerToKeel,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
if (surfaceToTransducer !== undefined) {
|
|
79
|
+
values.push({
|
|
80
|
+
path: 'environment.depth.belowSurface',
|
|
81
|
+
value: v.value + surfaceToTransducer,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if (values.length) {
|
|
85
|
+
app.handleMessage(plugin.id, { updates: [{ values }] });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
plugin.stop = function () {
|
|
95
|
+
unsubscribes.forEach((f) => f());
|
|
96
|
+
unsubscribes = [];
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
return plugin;
|
|
100
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sailingnaturali/signalk-depth-offsets",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Derive environment.depth.belowKeel and belowSurface from belowTransducer using measured transducer offsets. For DBT-only feeds that carry no offset field.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "node --test"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"signalk-node-server-plugin",
|
|
11
|
+
"signalk-category-utility",
|
|
12
|
+
"depth",
|
|
13
|
+
"marine"
|
|
14
|
+
],
|
|
15
|
+
"author": "Bryan Clark",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/sailingnaturali/signalk-depth-offsets.git"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/sailingnaturali/signalk-depth-offsets#readme",
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/sailingnaturali/signalk-depth-offsets/issues"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"index.js"
|
|
27
|
+
],
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=18"
|
|
33
|
+
}
|
|
34
|
+
}
|