@meri-imperiumi/signalk-triplogger 1.1.0 → 1.2.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/.github/workflows/publish.yml +4 -4
- package/.github/workflows/test.yml +3 -3
- package/README.md +4 -0
- package/index.js +48 -16
- package/package.json +3 -3
|
@@ -9,8 +9,8 @@ jobs:
|
|
|
9
9
|
build:
|
|
10
10
|
runs-on: ubuntu-latest
|
|
11
11
|
steps:
|
|
12
|
-
- uses: actions/checkout@
|
|
13
|
-
- uses: actions/setup-node@
|
|
12
|
+
- uses: actions/checkout@v3.0.2
|
|
13
|
+
- uses: actions/setup-node@v3.4.1
|
|
14
14
|
with:
|
|
15
15
|
node-version: 12
|
|
16
16
|
- run: npm install
|
|
@@ -20,8 +20,8 @@ jobs:
|
|
|
20
20
|
needs: build
|
|
21
21
|
runs-on: ubuntu-latest
|
|
22
22
|
steps:
|
|
23
|
-
- uses: actions/checkout@
|
|
24
|
-
- uses: actions/setup-node@
|
|
23
|
+
- uses: actions/checkout@v3.0.2
|
|
24
|
+
- uses: actions/setup-node@v3.4.1
|
|
25
25
|
with:
|
|
26
26
|
node-version: 12
|
|
27
27
|
registry-url: https://registry.npmjs.org/
|
|
@@ -10,9 +10,9 @@ jobs:
|
|
|
10
10
|
matrix:
|
|
11
11
|
node-version: [12.x]
|
|
12
12
|
steps:
|
|
13
|
-
- uses: actions/checkout@
|
|
13
|
+
- uses: actions/checkout@v3.0.2
|
|
14
14
|
- name: Use Node.js ${{ matrix.node-version }}
|
|
15
|
-
uses: actions/setup-node@
|
|
15
|
+
uses: actions/setup-node@v3.4.1
|
|
16
16
|
with:
|
|
17
17
|
node-version: ${{ matrix.node-version }}
|
|
18
18
|
- run: npm install
|
|
@@ -24,6 +24,6 @@ jobs:
|
|
|
24
24
|
needs: test
|
|
25
25
|
runs-on: ubuntu-latest
|
|
26
26
|
steps:
|
|
27
|
-
- uses: ridedott/merge-me-action@v2.
|
|
27
|
+
- uses: ridedott/merge-me-action@v2.10.22
|
|
28
28
|
with:
|
|
29
29
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
package/README.md
CHANGED
|
@@ -6,6 +6,10 @@ The plugin monitors vessel `navigation.state` as set by the [signalk-autostate](
|
|
|
6
6
|
|
|
7
7
|
## Changes
|
|
8
8
|
|
|
9
|
+
* 1.2.0 (April 27th 2023)
|
|
10
|
+
- Added support for populating `navigation.log` for totals
|
|
11
|
+
* 1.1.1 (February 28th 2023)
|
|
12
|
+
- Fix issue when `navigation.position` doesn't contain coordinates
|
|
9
13
|
* 1.1.0 (March 4th 2022)
|
|
10
14
|
- Persist logs for current day/month/year, also by sailing/motoring
|
|
11
15
|
* 1.0.1 (February 18th 2022)
|
package/index.js
CHANGED
|
@@ -16,6 +16,7 @@ module.exports = (app) => {
|
|
|
16
16
|
const dateString = new Date().toISOString();
|
|
17
17
|
return [
|
|
18
18
|
'current', // Current trip
|
|
19
|
+
'total', // Total log
|
|
19
20
|
dateString.substr(0, 4), // Annual log
|
|
20
21
|
dateString.substr(0, 7), // Monthly log
|
|
21
22
|
dateString.substr(0, 10), // Daily log
|
|
@@ -74,6 +75,24 @@ module.exports = (app) => {
|
|
|
74
75
|
function resetTrip() {
|
|
75
76
|
logs.current.reset();
|
|
76
77
|
const resetTime = logs.current.log.started;
|
|
78
|
+
const values = [
|
|
79
|
+
{
|
|
80
|
+
path: 'navigation.trip.log',
|
|
81
|
+
value: logs.current.log.total,
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
path: 'navigation.trip.lastReset',
|
|
85
|
+
value: resetTime,
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
if (options.totals) {
|
|
89
|
+
const base = options.totals_base || 0;
|
|
90
|
+
values.push({
|
|
91
|
+
path: 'navigation.log',
|
|
92
|
+
value: logs.total.log.total + base,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
77
96
|
app.handleMessage(plugin.id, {
|
|
78
97
|
context: `vessels.${app.selfId}`,
|
|
79
98
|
updates: [
|
|
@@ -82,16 +101,7 @@ module.exports = (app) => {
|
|
|
82
101
|
label: plugin.id,
|
|
83
102
|
},
|
|
84
103
|
timestamp: (new Date().toISOString()),
|
|
85
|
-
values
|
|
86
|
-
{
|
|
87
|
-
path: 'navigation.trip.log',
|
|
88
|
-
value: logs.current.log.total,
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
path: 'navigation.trip.lastReset',
|
|
92
|
-
value: resetTime,
|
|
93
|
-
},
|
|
94
|
-
],
|
|
104
|
+
values,
|
|
95
105
|
},
|
|
96
106
|
],
|
|
97
107
|
});
|
|
@@ -106,6 +116,19 @@ module.exports = (app) => {
|
|
|
106
116
|
return logs[logName].save();
|
|
107
117
|
})))
|
|
108
118
|
.then(() => {
|
|
119
|
+
const values = [
|
|
120
|
+
{
|
|
121
|
+
path: 'navigation.trip.log',
|
|
122
|
+
value: logs.current.log.total,
|
|
123
|
+
},
|
|
124
|
+
];
|
|
125
|
+
if (options.totals) {
|
|
126
|
+
const base = options.totals_base || 0;
|
|
127
|
+
values.push({
|
|
128
|
+
path: 'navigation.log',
|
|
129
|
+
value: logs.total.log.total + base,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
109
132
|
app.handleMessage(plugin.id, {
|
|
110
133
|
context: `vessels.${app.selfId}`,
|
|
111
134
|
updates: [
|
|
@@ -114,12 +137,7 @@ module.exports = (app) => {
|
|
|
114
137
|
label: plugin.id,
|
|
115
138
|
},
|
|
116
139
|
timestamp: (new Date().toISOString()),
|
|
117
|
-
values
|
|
118
|
-
{
|
|
119
|
-
path: 'navigation.trip.log',
|
|
120
|
-
value: logs.current.log.total,
|
|
121
|
-
},
|
|
122
|
-
],
|
|
140
|
+
values,
|
|
123
141
|
},
|
|
124
142
|
],
|
|
125
143
|
});
|
|
@@ -163,6 +181,10 @@ module.exports = (app) => {
|
|
|
163
181
|
handleState(v.value);
|
|
164
182
|
}
|
|
165
183
|
if (v.path === 'navigation.position') {
|
|
184
|
+
if (Number.isNaN(Number(v.value.latitude))
|
|
185
|
+
|| Number.isNaN(Number(v.value.longitude))) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
166
188
|
const newPosition = new Point(v.value.latitude, v.value.longitude);
|
|
167
189
|
if (lastPosition) {
|
|
168
190
|
const distance = lastPosition.distanceTo(newPosition) * 1000;
|
|
@@ -198,6 +220,16 @@ module.exports = (app) => {
|
|
|
198
220
|
default: 10000,
|
|
199
221
|
title: 'How often to update log, in milliseconds',
|
|
200
222
|
},
|
|
223
|
+
totals: {
|
|
224
|
+
type: 'boolean',
|
|
225
|
+
default: true,
|
|
226
|
+
title: 'Publish a total number in navigation.log',
|
|
227
|
+
},
|
|
228
|
+
totals_base: {
|
|
229
|
+
type: 'number',
|
|
230
|
+
default: 0,
|
|
231
|
+
title: 'Add this number to the totals (in meters)',
|
|
232
|
+
},
|
|
201
233
|
},
|
|
202
234
|
};
|
|
203
235
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meri-imperiumi/signalk-triplogger",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Log the length of the current trip",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"where": "^0.4.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"eslint": "^
|
|
30
|
-
"eslint-config-airbnb-base": "^
|
|
29
|
+
"eslint": "^8.14.0",
|
|
30
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
31
31
|
"eslint-plugin-import": "^2.18.2"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|