@signalk/streams 2.2.1 → 2.3.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/canboatjs.js +4 -3
- package/n2kAnalyzer.js +4 -1
- package/package.json +1 -1
- package/simple.js +35 -2
package/canboatjs.js
CHANGED
|
@@ -25,7 +25,7 @@ function CanboatJs(options) {
|
|
|
25
25
|
|
|
26
26
|
this.fromPgn = new FromPgn(options)
|
|
27
27
|
const createDebug = options.createDebug || require('debug')
|
|
28
|
-
const debug = createDebug('signalk:streams:
|
|
28
|
+
const debug = createDebug('signalk:streams:canboatjs')
|
|
29
29
|
|
|
30
30
|
this.fromPgn.on('warning', (pgn, warning) => {
|
|
31
31
|
debug(`[warning] ${pgn.pgn} ${warning}`)
|
|
@@ -36,6 +36,7 @@ function CanboatJs(options) {
|
|
|
36
36
|
})
|
|
37
37
|
|
|
38
38
|
this.app = options.app
|
|
39
|
+
this.analyzerOutEvent = options.analyzerOutEvent || 'N2KAnalyzerOut'
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
require('util').inherits(CanboatJs, Transform)
|
|
@@ -46,13 +47,13 @@ CanboatJs.prototype._transform = function (chunk, encoding, done) {
|
|
|
46
47
|
if (pgnData) {
|
|
47
48
|
pgnData.timestamp = new Date(Number(chunk.timestamp)).toISOString()
|
|
48
49
|
this.push(pgnData)
|
|
49
|
-
this.app.emit(
|
|
50
|
+
this.app.emit(this.analyzerOutEvent, pgnData)
|
|
50
51
|
}
|
|
51
52
|
} else {
|
|
52
53
|
const pgnData = this.fromPgn.parse(chunk)
|
|
53
54
|
if (pgnData) {
|
|
54
55
|
this.push(pgnData)
|
|
55
|
-
this.app.emit(
|
|
56
|
+
this.app.emit(this.analyzerOutEvent, pgnData)
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
done()
|
package/n2kAnalyzer.js
CHANGED
|
@@ -20,6 +20,9 @@ function N2KAnalyzer(options) {
|
|
|
20
20
|
Transform.call(this, {
|
|
21
21
|
objectMode: true,
|
|
22
22
|
})
|
|
23
|
+
|
|
24
|
+
this.analyzerOutEvent = options.analyzerOutEvent || 'N2KAnalyzerOut'
|
|
25
|
+
|
|
23
26
|
if (process.platform === 'win32') {
|
|
24
27
|
this.analyzerProcess = require('child_process').spawn('cmd', [
|
|
25
28
|
'/c',
|
|
@@ -47,7 +50,7 @@ function N2KAnalyzer(options) {
|
|
|
47
50
|
try {
|
|
48
51
|
parsed = JSON.parse(data)
|
|
49
52
|
that.push(parsed)
|
|
50
|
-
options.app.emit(
|
|
53
|
+
options.app.emit(this.analyzerOutEvent, parsed)
|
|
51
54
|
} catch (ex) {
|
|
52
55
|
console.error(data)
|
|
53
56
|
console.error(ex.stack)
|
package/package.json
CHANGED
package/simple.js
CHANGED
|
@@ -20,6 +20,7 @@ const TimestampThrottle = require('./timestamp-throttle')
|
|
|
20
20
|
const CanboatJs = require('./canboatjs')
|
|
21
21
|
const iKonvert = require('@canboat/canboatjs').iKonvert
|
|
22
22
|
const Ydwg02 = require('@canboat/canboatjs').Ydwg02
|
|
23
|
+
const W2k01 = require('@canboat/canboatjs').W2k01
|
|
23
24
|
const gpsd = require('./gpsd')
|
|
24
25
|
const pigpioSeatalk = require('./pigpio-seatalk')
|
|
25
26
|
|
|
@@ -58,7 +59,9 @@ function Simple(options) {
|
|
|
58
59
|
if (options.type === 'NMEA2000' && options.subOptions) {
|
|
59
60
|
if (
|
|
60
61
|
options.subOptions.type === 'ngt-1-canboatjs' ||
|
|
61
|
-
options.subOptions.type === 'canbus-canboatjs'
|
|
62
|
+
options.subOptions.type === 'canbus-canboatjs' ||
|
|
63
|
+
options.subOptions.type === 'w2k-1-n2k-actisense-canboatjs' ||
|
|
64
|
+
options.subOptions.type === 'w2k-1-n2k-ascii-canboatjs'
|
|
62
65
|
) {
|
|
63
66
|
mappingType = 'NMEA2000JS'
|
|
64
67
|
} else if (
|
|
@@ -203,6 +206,20 @@ const dataTypeMapping = {
|
|
|
203
206
|
}
|
|
204
207
|
return result.concat([new N2kToSignalK(options.subOptions)])
|
|
205
208
|
},
|
|
209
|
+
NMEA2000W2K_ASCII: (options) => {
|
|
210
|
+
const result = [new W2k01({ format: 'ascii', ...options.subOptions })]
|
|
211
|
+
if (options.type === 'FileStream') {
|
|
212
|
+
result.push(new TimestampThrottle())
|
|
213
|
+
}
|
|
214
|
+
return result.concat([new N2kToSignalK(options.subOptions)])
|
|
215
|
+
},
|
|
216
|
+
NMEA2000W2K_ACTISENSE: (options) => {
|
|
217
|
+
const result = [new W2k01({ format: 'actisense', ...options.subOptions })]
|
|
218
|
+
if (options.type === 'FileStream') {
|
|
219
|
+
result.push(new TimestampThrottle())
|
|
220
|
+
}
|
|
221
|
+
return result.concat([new N2kToSignalK(options.subOptions)])
|
|
222
|
+
},
|
|
206
223
|
Multiplexed: (options) => [new MultiplexedLog(options.subOptions)],
|
|
207
224
|
}
|
|
208
225
|
|
|
@@ -224,7 +241,6 @@ function nmea2000input(subOptions, logging) {
|
|
|
224
241
|
return [
|
|
225
242
|
new actisenseSerial({
|
|
226
243
|
...subOptions,
|
|
227
|
-
outEvent: 'nmea2000out',
|
|
228
244
|
plainText: logging,
|
|
229
245
|
}),
|
|
230
246
|
]
|
|
@@ -268,6 +284,23 @@ function nmea2000input(subOptions, logging) {
|
|
|
268
284
|
}),
|
|
269
285
|
new Liner(subOptions),
|
|
270
286
|
]
|
|
287
|
+
} else if (subOptions.type === 'w2k-1-n2k-ascii-canboatjs') {
|
|
288
|
+
return [
|
|
289
|
+
new Tcp({
|
|
290
|
+
...subOptions,
|
|
291
|
+
outEvent: 'w2k-1-out',
|
|
292
|
+
}),
|
|
293
|
+
new Liner(subOptions),
|
|
294
|
+
new W2k01(subOptions, 'ascii', 'w2k-1-out'),
|
|
295
|
+
]
|
|
296
|
+
} else if (subOptions.type === 'w2k-1-n2k-actisense-canboatjs') {
|
|
297
|
+
return [
|
|
298
|
+
new Tcp({
|
|
299
|
+
...subOptions,
|
|
300
|
+
outEvent: 'w2k-1-out',
|
|
301
|
+
}),
|
|
302
|
+
new W2k01(subOptions, 'actisense', 'w2k-1-out'),
|
|
303
|
+
]
|
|
271
304
|
} else if (subOptions.type === 'navlink2-udp-canboatjs') {
|
|
272
305
|
return [new Udp(subOptions), new Liner(subOptions)]
|
|
273
306
|
} else if (subOptions.type === 'ydwg02-usb-canboatjs') {
|