diff --git a/lowrance/65285.js b/lowrance/65285.js index 293b539c..e829d2f7 100644 --- a/lowrance/65285.js +++ b/lowrance/65285.js @@ -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( + '', + 'default' + ) + } else if (temperatureMapping.path) { + return temperatureMapping.path + } } }, instance: function (n2k) { diff --git a/pgns/130311.js b/pgns/130311.js index 4ab7e784..ed9d98eb 100644 --- a/pgns/130311.js +++ b/pgns/130311.js @@ -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( + '', + 'default' + ) + } else if (temperatureMapping.path) { + return temperatureMapping.path + } } }, source: 'Temperature' diff --git a/temperatureMappings.js b/temperatureMappings.js index 7e1c125d..ab0c187a 100644 --- a/temperatureMappings.js +++ b/temperatureMappings.js @@ -32,11 +32,9 @@ module.exports = { path: 'environment.inside.mainCabin.temperature' }, 'Live Well Temperature': { - path: 'tanks.liveWell.default.temperature', pathWithIndex: 'tanks.liveWell..temperature' }, 'Bait Well Temperature': { - path: 'tanks.baitWell.default.temperature', pathWithIndex: 'tanks.baitWell..temperature' }, 'Refrigeration Temperature': { @@ -66,7 +64,6 @@ module.exports = { path: 'environment.inside.freezer.temperature' }, 'Exhaust Gas Temperature': { - path: 'propulsion.0.exhaustTemperature', pathWithIndex: 'propulsion..exhaustTemperature' } } diff --git a/test/13031_temperature.js b/test/13031_temperature.js index 8307238a..17f98fc8 100644 --- a/test/13031_temperature.js +++ b/test/13031_temperature.js @@ -56,6 +56,11 @@ describe('Temperature: ', function () { 'urn:mrn:imo:mmsi:230099999' ) _.forOwn(temperatureMappings, function (mapping, key) { + + let path = mapping.pathWithIndex ? + mapping.pathWithIndex.replace('','0') + : mapping.path + var delta = { context: 'vessels.urn:mrn:imo:mmsi:230099999', updates: [ @@ -70,7 +75,7 @@ describe('Temperature: ', function () { timestamp: '2016-10-18T15:52:48.152Z', values: [ { - path: mapping.path, + path, value: 0 } ]