diff --git a/pgns/127505.js b/pgns/127505.js index 8b1d784..08f92c2 100644 --- a/pgns/127505.js +++ b/pgns/127505.js @@ -9,7 +9,10 @@ module.exports = [ '.currentLevel' ) }, - source: 'Level' + value: function (n2k) { + var ratio100 = Number(n2k.fields['Level']) + return ratio100 / 100 + } }, { node: function (n2k) { diff --git a/pgns/130311.js b/pgns/130311.js index 69aa80c..1119dfc 100644 --- a/pgns/130311.js +++ b/pgns/130311.js @@ -19,7 +19,13 @@ module.exports = [ '.humidity' ) }, - source: 'Humidity' + filter: function (n2k) { + return typeof n2k.fields['Humidity'] !== 'undefined' + }, + value: function (n2k) { + var ratio100 = Number(n2k.fields['Humidity']) + return ratio100 / 100 + } }, { node: 'environment.outside.pressure', diff --git a/test/127505_fluid_level.js b/test/127505_fluid_level.js index 4bbc0ce..95b6d61 100644 --- a/test/127505_fluid_level.js +++ b/test/127505_fluid_level.js @@ -10,7 +10,7 @@ describe('127505 fuel', function () { '{"timestamp":"2015-01-15-16:15:30.984Z","prio":"6","src":"17","dst":"255","pgn":"127505","description":"Fluid Level","fields":{"Instance":"0","Type":"Fuel","Level":"131.068"}}' ) ) - tree.should.have.nested.property('tanks.fuel.0.currentLevel.value', 131.068) + tree.should.have.nested.property('tanks.fuel.0.currentLevel.value', 1.31068) tree.should.be.validSignalKVesselIgnoringIdentity }) it('level and capacity', function () { @@ -19,7 +19,7 @@ describe('127505 fuel', function () { '{"timestamp":"2015-01-15-16:15:33.341Z","prio":"6","src":"112","dst":"255","pgn":"127505","description":"Fluid Level","fields":{"Instance":"1","Type":"Fuel","Level":"64.284","Capacity":"41.6"}}' ) ) - tree.should.have.nested.property('tanks.fuel.1.currentLevel.value', 64.284) + tree.tanks.fuel['1'].currentLevel.value.should.be.closeTo(0.64284, 0.000005) tree.should.have.nested.property('tanks.fuel.1.capacity.value', 41.6) tree.should.be.validSignalKVesselIgnoringIdentity }) @@ -32,9 +32,9 @@ describe('127505 water', function () { '{"timestamp":"2015-01-15-16:15:33.366Z","prio":"6","src":"114","dst":"255","pgn":"127505","description":"Fluid Level","fields":{"Instance":"0","Type":"Water","Level":"88.596","Capacity":"71.9"}}' ) ) - tree.should.have.nested.property( - 'tanks.freshWater.0.currentLevel.value', - 88.596 + tree.tanks.freshWater['0'].currentLevel.value.should.be.closeTo( + 0.88596, + 0.000005 ) tree.should.have.nested.property('tanks.freshWater.0.capacity.value', 71.9) tree.should.be.validSignalKVesselIgnoringIdentity @@ -50,7 +50,7 @@ describe('127505 grayWater', function () { ) tree.should.have.nested.property( 'tanks.wasteWater.0.currentLevel.value', - 90.24 + 0.9024 ) tree.should.have.nested.property('tanks.wasteWater.0.capacity.value', 37.9) tree.should.be.validSignalKVesselIgnoringIdentity