-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add pgns for raymarine and simrad display info (#269)
- Loading branch information
Showing
7 changed files
with
176 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
const debug = require('debug')('n2k-signalk-130845') | ||
const camelCase = require('camelcase') | ||
|
||
module.exports = [ | ||
{ | ||
filter: function (n2k) { | ||
return ( | ||
n2k.fields['Manufacturer Code'] === 'Simrad' && | ||
n2k.fields['Display Group'] !== 'undefined' && | ||
n2k.fields['Key'] === 'Backlight level' | ||
) | ||
}, | ||
node: (n2k) => { return `electrical.displays.navico.${camelCase(n2k.fields['Display Group'])}.brightness` }, | ||
allowNull: true, | ||
value: (n2k) => { | ||
let val = n2k.fields['Value'] | ||
return val !== 'undefined' ? val / 100.0 : null | ||
} | ||
}, | ||
{ | ||
filter: function (n2k) { | ||
return ( | ||
n2k.fields['Manufacturer Code'] === 'Simrad' && | ||
n2k.fields['Display Group'] !== 'undefined' && | ||
n2k.fields['Key'] === 'Night mode' | ||
) | ||
}, | ||
node: (n2k) => { return `electrical.displays.navico.${camelCase(n2k.fields['Display Group'])}.nightMode.state` }, | ||
allowNull: true, | ||
value: (n2k) => { | ||
return n2k.fields['Value'] === 4 ? 1 : 0 | ||
} | ||
}, | ||
{ | ||
filter: function (n2k) { | ||
return ( | ||
n2k.fields['Manufacturer Code'] === 'Simrad' && | ||
n2k.fields['Display Group'] !== 'undefined' && | ||
n2k.fields['Key'] === 'Night mode color' | ||
) | ||
}, | ||
node: (n2k) => { return `electrical.displays.navico.${camelCase(n2k.fields['Display Group'])}.nightModeColor` }, | ||
allowNull: true, | ||
value: (n2k) => { | ||
let val = nightModeColorMapping[n2k.fields['Value']] | ||
return val ? val : 'unknown' | ||
} | ||
}, | ||
] | ||
|
||
const nightModeColorMapping = { | ||
0: 'red', | ||
1: 'green', | ||
2: 'blue', | ||
3: 'white', | ||
4: 'magenta' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
130845: require('./130845.js') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
var chai = require('chai') | ||
chai.Should() | ||
chai.use(require('chai-things')) | ||
chai.use(require('@signalk/signalk-schema').chaiModule) | ||
|
||
describe('126720 Seatalk Displays', function () { | ||
it('birghtness converts', function () { | ||
var tree = require('./testMapper').toNested( | ||
JSON.parse( | ||
'{"timestamp":"2016-10-18T15:52:49.048Z","prio":7,"src":115,"dst":255,"pgn":126720, "description": "Seatalk1: Display Brightness", "fields":{"Manufacturer Code":"Raymarine","Industry Code":"Marine Industry", "Proprietary ID": 3212, "Command": "Brightness", "Group": "Helm 1", "Brightness":50}}' | ||
) | ||
) | ||
tree.should.have.nested.property( | ||
'electrical.displays.raymarine.helm1.brightness.value', | ||
0.5 | ||
) | ||
}) | ||
|
||
it('display color converts', function () { | ||
var tree = require('./testMapper').toNested( | ||
JSON.parse( | ||
'{"timestamp":"2016-10-18T15:52:49.048Z","prio":7,"src":115,"dst":255,"pgn":126720, "description": "Seatalk1: Display Color", "fields":{"Manufacturer Code":"Raymarine","Industry Code":"Marine Industry", "Proprietary ID": 3212, "Command": "Color", "Group": "Helm 1", "Color":"Red/Black"}}' | ||
) | ||
) | ||
tree.should.have.nested.property( | ||
'electrical.displays.raymarine.helm1.color.value', | ||
'red/black' | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
var chai = require('chai') | ||
chai.Should() | ||
chai.use(require('chai-things')) | ||
chai.use(require('@signalk/signalk-schema').chaiModule) | ||
|
||
describe('130845 Simrad Displays', function () { | ||
it('birghtness converts', function () { | ||
var tree = require('./testMapper').toNested( | ||
JSON.parse( | ||
'{"timestamp":"2016-10-18T15:52:49.048Z","prio":7,"src":115,"dst":255,"pgn":130845,"fields":{"Manufacturer Code":"Simrad","Industry Code":"Marine Industry","Display Group": "Group 1", "Key":"Backlight level","Value":50}}' | ||
) | ||
) | ||
tree.should.have.nested.property( | ||
'electrical.displays.navico.group1.brightness.value', | ||
0.5 | ||
) | ||
}) | ||
|
||
it('night mode converts', function () { | ||
var tree = require('./testMapper').toNested( | ||
JSON.parse( | ||
'{"timestamp":"2016-10-18T15:52:49.048Z","prio":7,"src":115,"dst":255,"pgn":130845,"fields":{"Manufacturer Code":"Simrad","Industry Code":"Marine Industry","Display Group": "Group 1", "Key":"Night mode","Value":4}}' | ||
) | ||
) | ||
tree.should.have.nested.property( | ||
'electrical.displays.navico.group1.nightMode.state.value', | ||
1 | ||
) | ||
}) | ||
|
||
it('night mode color converts', function () { | ||
var tree = require('./testMapper').toNested( | ||
JSON.parse( | ||
'{"timestamp":"2016-10-18T15:52:49.048Z","prio":7,"src":115,"dst":255,"pgn":130845,"fields":{"Manufacturer Code":"Simrad","Industry Code":"Marine Industry","Display Group": "Group 1", "Key":"Night mode color","Value":1}}' | ||
) | ||
) | ||
tree.should.have.nested.property( | ||
'electrical.displays.navico.group1.nightModeColor.value', | ||
'green' | ||
) | ||
}) | ||
}) |