Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: cleanup tempermappings with index #262

Merged
merged 1 commit into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions lowrance/65285.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@ module.exports = [
source: 'Actual Temperature',
node: function (n2k) {
var temperatureMapping =
temperatureMappings[n2k.fields['Temperature Source']]
if (temperatureMapping && temperatureMapping.path) {
return temperatureMapping.path
temperatureMappings[n2k.fields['Temperature Source']]

if ( temperatureMappings ) {
if (temperatureMapping.pathWithIndex) {
return temperatureMapping.pathWithIndex.replace(
'<index>',
'default'
)
} else if (temperatureMapping.path) {
return temperatureMapping.path
}
}
},
instance: function (n2k) {
Expand Down
14 changes: 11 additions & 3 deletions pgns/130311.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@ module.exports = [
{
node: function (n2k) {
var temperatureMapping =
temperatureMappings[n2k.fields['Temperature Source']]
if (temperatureMapping && temperatureMapping.path) {
return temperatureMapping.path
temperatureMappings[n2k.fields['Temperature Source']]

if (temperatureMapping) {
if (temperatureMapping.pathWithIndex) {
return temperatureMapping.pathWithIndex.replace(
'<index>',
'default'
)
} else if (temperatureMapping.path) {
return temperatureMapping.path
}
}
},
source: 'Temperature'
Expand Down
3 changes: 0 additions & 3 deletions temperatureMappings.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ module.exports = {
path: 'environment.inside.mainCabin.temperature'
},
'Live Well Temperature': {
path: 'tanks.liveWell.default.temperature',
pathWithIndex: 'tanks.liveWell.<index>.temperature'
},
'Bait Well Temperature': {
path: 'tanks.baitWell.default.temperature',
pathWithIndex: 'tanks.baitWell.<index>.temperature'
},
'Refrigeration Temperature': {
Expand Down Expand Up @@ -66,7 +64,6 @@ module.exports = {
path: 'environment.inside.freezer.temperature'
},
'Exhaust Gas Temperature': {
path: 'propulsion.0.exhaustTemperature',
pathWithIndex: 'propulsion.<index>.exhaustTemperature'
}
}
7 changes: 6 additions & 1 deletion test/13031_temperature.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ describe('Temperature: ', function () {
'urn:mrn:imo:mmsi:230099999'
)
_.forOwn(temperatureMappings, function (mapping, key) {

let path = mapping.pathWithIndex ?
mapping.pathWithIndex.replace('<index>','0')
: mapping.path

var delta = {
context: 'vessels.urn:mrn:imo:mmsi:230099999',
updates: [
Expand All @@ -70,7 +75,7 @@ describe('Temperature: ', function () {
timestamp: '2016-10-18T15:52:48.152Z',
values: [
{
path: mapping.path,
path,
value: 0
}
]
Expand Down
Loading