From 253a77a56b2de3848228f80df2f70b7dec3f93c1 Mon Sep 17 00:00:00 2001 From: Scott Bender Date: Fri, 3 Mar 2023 15:10:55 -0500 Subject: [PATCH 1/3] WIP: feature add suport for the Actisense W2K-1 --- .../src/views/ServerConfig/BasicProvider.js | 13 +++++ packages/streams/simple.js | 52 ++++++++++++++++++- 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/packages/server-admin-ui/src/views/ServerConfig/BasicProvider.js b/packages/server-admin-ui/src/views/ServerConfig/BasicProvider.js index 6167cbc12..4c9089868 100644 --- a/packages/server-admin-ui/src/views/ServerConfig/BasicProvider.js +++ b/packages/server-admin-ui/src/views/ServerConfig/BasicProvider.js @@ -744,6 +744,8 @@ const NMEA2000 = (props) => { Yacht Devices RAW USB (canboatjs) + + @@ -805,6 +807,17 @@ const NMEA2000 = (props) => { onChange={props.onChange} /> )} + {(props.value.options.type === 'w2k-1-n2k-ascii-canboatjs' || + props.value.options.type === 'w2k-1-n2k-actisense-canboatjs') && ( +
+ + + +
+ )} ) diff --git a/packages/streams/simple.js b/packages/streams/simple.js index e7484c5d6..fdb0edf7f 100644 --- a/packages/streams/simple.js +++ b/packages/streams/simple.js @@ -20,6 +20,7 @@ const TimestampThrottle = require('./timestamp-throttle') const CanboatJs = require('./canboatjs') const iKonvert = require('@canboat/canboatjs').iKonvert const Ydwg02 = require('@canboat/canboatjs').Ydwg02 +const W2k01 = require('@canboat/canboatjs').W2k01 const gpsd = require('./gpsd') const pigpioSeatalk = require('./pigpio-seatalk') @@ -58,7 +59,9 @@ function Simple(options) { if (options.type === 'NMEA2000' && options.subOptions) { if ( options.subOptions.type === 'ngt-1-canboatjs' || - options.subOptions.type === 'canbus-canboatjs' + options.subOptions.type === 'canbus-canboatjs' || + options.subOptions.type === 'w2k-1-n2k-actisense-canboatjs' || + options.subOptions.type === 'w2k-1-n2k-ascii-canboatjs' ) { mappingType = 'NMEA2000JS' } else if ( @@ -203,6 +206,28 @@ const dataTypeMapping = { } return result.concat([new N2kToSignalK(options.subOptions)]) }, + NMEA2000W2K_ASCII: (options) => { + const result = [ + new W2k01( + {format: 'ascii', ...options.subOptions} + ), + ] + if (options.type === 'FileStream') { + result.push(new TimestampThrottle()) + } + return result.concat([new N2kToSignalK(options.subOptions)]) + }, + NMEA2000W2K_ACTISENSE: (options) => { + const result = [ + new W2k01( + {format: 'actisense', ...options.subOptions} + ), + ] + if (options.type === 'FileStream') { + result.push(new TimestampThrottle()) + } + return result.concat([new N2kToSignalK(options.subOptions)]) + }, Multiplexed: (options) => [new MultiplexedLog(options.subOptions)], } @@ -268,6 +293,31 @@ function nmea2000input(subOptions, logging) { }), new Liner(subOptions), ] + } else if (subOptions.type === 'w2k-1-n2k-ascii-canboatjs') { + return [ + new Tcp({ + ...subOptions, + outEvent: 'w2k-1-out', + }), + new Liner(subOptions), + new W2k01( + subOptions, + 'ascii', + 'w2k-1-out' + ), + ] + } else if (subOptions.type === 'w2k-1-n2k-actisense-canboatjs') { + return [ + new Tcp({ + ...subOptions, + outEvent: 'w2k-1-out', + }), + new W2k01( + subOptions, + 'actisense', + 'w2k-1-out' + ), + ] } else if (subOptions.type === 'navlink2-udp-canboatjs') { return [new Udp(subOptions), new Liner(subOptions)] } else if (subOptions.type === 'ydwg02-usb-canboatjs') { From 2590e89bff7f4f0a68901734306d1606157e89ec Mon Sep 17 00:00:00 2001 From: Scott Bender Date: Fri, 3 Mar 2023 15:14:42 -0500 Subject: [PATCH 2/3] chore: fix formatting --- packages/streams/simple.js | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/packages/streams/simple.js b/packages/streams/simple.js index fdb0edf7f..c2755f644 100644 --- a/packages/streams/simple.js +++ b/packages/streams/simple.js @@ -207,22 +207,14 @@ const dataTypeMapping = { return result.concat([new N2kToSignalK(options.subOptions)]) }, NMEA2000W2K_ASCII: (options) => { - const result = [ - new W2k01( - {format: 'ascii', ...options.subOptions} - ), - ] + const result = [new W2k01({ format: 'ascii', ...options.subOptions })] if (options.type === 'FileStream') { result.push(new TimestampThrottle()) } return result.concat([new N2kToSignalK(options.subOptions)]) }, NMEA2000W2K_ACTISENSE: (options) => { - const result = [ - new W2k01( - {format: 'actisense', ...options.subOptions} - ), - ] + const result = [new W2k01({ format: 'actisense', ...options.subOptions })] if (options.type === 'FileStream') { result.push(new TimestampThrottle()) } @@ -300,11 +292,7 @@ function nmea2000input(subOptions, logging) { outEvent: 'w2k-1-out', }), new Liner(subOptions), - new W2k01( - subOptions, - 'ascii', - 'w2k-1-out' - ), + new W2k01(subOptions, 'ascii', 'w2k-1-out'), ] } else if (subOptions.type === 'w2k-1-n2k-actisense-canboatjs') { return [ @@ -312,11 +300,7 @@ function nmea2000input(subOptions, logging) { ...subOptions, outEvent: 'w2k-1-out', }), - new W2k01( - subOptions, - 'actisense', - 'w2k-1-out' - ), + new W2k01(subOptions, 'actisense', 'w2k-1-out'), ] } else if (subOptions.type === 'navlink2-udp-canboatjs') { return [new Udp(subOptions), new Liner(subOptions)] From 5d85f4b77faed37ac3dada42d270e72eb3e99f0f Mon Sep 17 00:00:00 2001 From: Scott Bender Date: Thu, 9 Mar 2023 13:53:49 -0500 Subject: [PATCH 3/3] chore: fix formatting --- .../src/views/ServerConfig/BasicProvider.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/server-admin-ui/src/views/ServerConfig/BasicProvider.js b/packages/server-admin-ui/src/views/ServerConfig/BasicProvider.js index 4c9089868..1e99bc0e3 100644 --- a/packages/server-admin-ui/src/views/ServerConfig/BasicProvider.js +++ b/packages/server-admin-ui/src/views/ServerConfig/BasicProvider.js @@ -744,8 +744,12 @@ const NMEA2000 = (props) => { Yacht Devices RAW USB (canboatjs) - - + + @@ -807,8 +811,8 @@ const NMEA2000 = (props) => { onChange={props.onChange} /> )} - {(props.value.options.type === 'w2k-1-n2k-ascii-canboatjs' || - props.value.options.type === 'w2k-1-n2k-actisense-canboatjs') && ( + {(props.value.options.type === 'w2k-1-n2k-ascii-canboatjs' || + props.value.options.type === 'w2k-1-n2k-actisense-canboatjs') && (