Skip to content

Commit

Permalink
feature: object valued properties under value in full model (#103)
Browse files Browse the repository at this point in the history
Adjust code to match changes in SignalK/specification#315.
Update @signalk/signalk-schema to version 0.0.1-12
  • Loading branch information
tkurki authored Nov 4, 2017
1 parent fe80a6c commit f2105d1
Show file tree
Hide file tree
Showing 19 changed files with 59 additions and 61 deletions.
6 changes: 2 additions & 4 deletions aisShipTypeMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ module.exports = function (type) {
var name
if (typeof num !== 'undefined' && (name = schema.getAISShipTypeName(num))) {
return {
value: {
'id': num,
'name': name
}
'id': num,
'name': name
}
} else {
return null
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"through": ">=2.2.7 <3"
},
"devDependencies": {
"@signalk/signalk-schema": "0.0.1-11",
"@signalk/signalk-schema": "0.0.1-12",
"chai": "~4.1.0",
"chai-things": "0.2",
"github-changes": "^1.0.4",
Expand Down
6 changes: 2 additions & 4 deletions pgns/129041.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ module.exports = [
const num = nameMapping[n2k.fields['AtoN Type']]
if (typeof num !== 'undefined' && (name = schema.getAtonTypeName(num))) {
return {
value: {
'id': num,
'name': name
}
'id': num,
'name': name
}
} else {
return null
Expand Down
12 changes: 7 additions & 5 deletions pgns/129284.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,16 @@ module.exports = [
},
{
node: function (n2k, state) {
return 'navigation.course' + calculationType(n2k, state) + '.nextPoint'
return (
'navigation.course' +
calculationType(n2k, state) +
'.nextPoint.position'
)
},
value: function (n2k) {
return {
position: {
longitude: Number(n2k.fields['Destination Longitude']),
latitude: Number(n2k.fields['Destination Latitude'])
}
longitude: Number(n2k.fields['Destination Longitude']),
latitude: Number(n2k.fields['Destination Latitude'])
}
}
},
Expand Down
6 changes: 3 additions & 3 deletions test/127257_attitude.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ describe('127257_attitude', function () {
'{"timestamp":"2013-10-08-15:47:28.263Z","prio":"2","src":"204","dst":"255","pgn":"127257","description":"Attitude","fields":{"Yaw":"37.190","Pitch":"0.464","Roll":"-2.496"}}'
)
)
tree.should.have.nested.property('navigation.attitude.yaw', 37.19)
tree.should.have.nested.property('navigation.attitude.pitch', 0.464)
tree.should.have.nested.property('navigation.attitude.roll', -2.496)
tree.should.have.nested.property('navigation.attitude.value.yaw', 37.19)
tree.should.have.nested.property('navigation.attitude.value.pitch', 0.464)
tree.should.have.nested.property('navigation.attitude.value.roll', -2.496)
tree.should.be.validSignalKVesselIgnoringIdentity
})
})
24 changes: 12 additions & 12 deletions test/127489_engine_params.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ describe('127489 engine parameters Port', function () {
tree.should.have.nested.property('propulsion.port.engineLoad.value', 0.2)
tree.should.have.nested.property('propulsion.port.engineTorque.value', 0.57)
tree.should.have.nested.property(
'notifications.propulsion.port.lowOilPressure.state',
'notifications.propulsion.port.lowOilPressure.value.state',
'alarm')
tree.should.have.nested.property(
'notifications.propulsion.port.lowCoolantLevel.state',
'notifications.propulsion.port.lowCoolantLevel.value.state',
'alarm')
tree.should.have.nested.property(
'notifications.propulsion.port.warningLevel1.state',
'notifications.propulsion.port.warningLevel1.value.state',
'alarm')
tree.should.have.nested.property(
'notifications.propulsion.port.maintenanceNeeded.state',
'notifications.propulsion.port.maintenanceNeeded.value.state',
'alarm')
tree.should.be.validSignalKVesselIgnoringIdentity
})
Expand Down Expand Up @@ -85,16 +85,16 @@ describe('127489 engine parameters Starboard', function () {
0.57
)
tree.should.have.nested.property(
'notifications.propulsion.starboard.lowOilPressure.state',
'notifications.propulsion.starboard.lowOilPressure.value.state',
'alarm')
tree.should.have.nested.property(
'notifications.propulsion.starboard.lowCoolantLevel.state',
'notifications.propulsion.starboard.lowCoolantLevel.value.state',
'alarm')
tree.should.have.nested.property(
'notifications.propulsion.starboard.warningLevel1.state',
'notifications.propulsion.starboard.warningLevel1.value.state',
'alarm')
tree.should.have.nested.property(
'notifications.propulsion.starboard.maintenanceNeeded.state',
'notifications.propulsion.starboard.maintenanceNeeded.value.state',
'alarm')
tree.should.be.validSignalKVesselIgnoringIdentity

Expand All @@ -104,16 +104,16 @@ describe('127489 engine parameters Starboard', function () {
)
)
tree.should.have.nested.property(
'notifications.propulsion.starboard.lowOilPressure.state',
'notifications.propulsion.starboard.lowOilPressure.value.state',
'alarm')
tree.should.have.nested.property(
'notifications.propulsion.starboard.lowCoolantLevel.state',
'notifications.propulsion.starboard.lowCoolantLevel.value.state',
'normal')
tree.should.have.nested.property(
'notifications.propulsion.starboard.warningLevel1.state',
'notifications.propulsion.starboard.warningLevel1.value.state',
'normal')
tree.should.have.nested.property(
'notifications.propulsion.starboard.maintenanceNeeded.state',
'notifications.propulsion.starboard.maintenanceNeeded.value.state',
'normal')
tree.should.be.validSignalKVesselIgnoringIdentity
})
Expand Down
4 changes: 2 additions & 2 deletions test/129025_position.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ var msg = JSON.parse(
describe('129025 Position, rapid update ', function () {
it('complete sentence converts to tree', function () {
var tree = require('./testMapper').toNested(msg)
tree.navigation.position.longitude.should.equal(24.7921348)
tree.navigation.position.latitude.should.equal(60.144554)
tree.navigation.position.value.longitude.should.equal(24.7921348)
tree.navigation.position.value.latitude.should.equal(60.144554)
tree.should.be.validSignalKVesselIgnoringIdentity
})

Expand Down
4 changes: 2 additions & 2 deletions test/129029_position_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const invalidDataMsg = JSON.parse(
describe('129029 Position Data ', function () {
it('complete sentence converts', function () {
var tree = require('./testMapper').toNested(msg)
tree.navigation.position.longitude.should.equal(-76.3972731)
tree.navigation.position.latitude.should.equal(39.0536632)
tree.navigation.position.value.longitude.should.equal(-76.3972731)
tree.navigation.position.value.latitude.should.equal(39.0536632)
tree.navigation.gnss.antennaAltitude.value.should.equal(1.0)
tree.navigation.gnss.satellites.value.should.equal(18)
tree.navigation.gnss.horizontalDilution.value.should.equal(0.73)
Expand Down
4 changes: 2 additions & 2 deletions test/129038_ais_class_a.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ describe('129038 Class A Update', function () {
)
tree.should.have.nested.property('navigation.speedOverGround')
tree.should.have.nested.property('navigation.speedOverGround.value', 2.26)
tree.navigation.position.longitude.should.equal(25.2026083)
tree.navigation.position.latitude.should.equal(60.217615)
tree.navigation.position.value.longitude.should.equal(25.2026083)
tree.navigation.position.value.latitude.should.equal(60.217615)
tree.should.have.nested.property('navigation.rateOfTurn')
tree.should.have.nested.property('navigation.rateOfTurn.value', 0.047)
tree.should.have.nested.property('navigation.headingTrue')
Expand Down
4 changes: 2 additions & 2 deletions test/129039_ais_class_b.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ describe('129039 Class B Update', function () {
)
tree.should.have.nested.property('navigation.speedOverGround')
tree.should.have.nested.property('navigation.speedOverGround.value', 3.75)
tree.navigation.position.longitude.should.equal(24.9024733)
tree.navigation.position.latitude.should.equal(60.03951)
tree.navigation.position.value.longitude.should.equal(24.9024733)
tree.navigation.position.value.latitude.should.equal(60.03951)
tree.should.have.nested.property('navigation.headingTrue')
tree.should.have.nested.property('navigation.headingTrue.value', 153.0)
tree.should.be.validSignalKVesselIgnoringIdentity
Expand Down
6 changes: 3 additions & 3 deletions test/129040_class_b_extended.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ describe('129040 AIS Class B Extended Position Repeat', function () {
delta.updates[0].values[0].path.should.equal('')
delta.updates[0].values[0].value.name.should.equal('RESCUE RAUTAUOMA')
var tree = mapper.toNested(msg)
tree.should.have.nested.property('design.length.overall', 16.0)
tree.should.have.nested.property('design.length.value.overall', 16.0)
tree.should.have.nested.property('design.aisShipType.value.id', 51)
tree.should.have.nested.property('design.aisShipType.value.name', 'SAR')
tree.should.have.nested.property('design.beam.value', 4.0)
tree.should.have.nested.property(
'navigation.destination.commonName.value',
'HELSINKI LIFEBOAT'
)
tree.navigation.position.longitude.should.equal(25.2026083)
tree.navigation.position.latitude.should.equal(60.217615)
tree.navigation.position.value.longitude.should.equal(25.2026083)
tree.navigation.position.value.latitude.should.equal(60.217615)
tree.should.have.nested.property('navigation.courseOverGroundTrue')
tree.should.have.nested.property(
'navigation.courseOverGroundTrue.value',
Expand Down
4 changes: 2 additions & 2 deletions test/129041_aton_report.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ describe('129041 AIS Aids to Navigation (AtoN) Report', function () {
'Beacon, Port Hand'
)
tree.should.have.nested.property('atonType.value.id', 13)
tree.navigation.position.latitude.should.equal(38.99384)
tree.navigation.position.longitude.should.equal(-76.3847132)
tree.navigation.position.value.latitude.should.equal(38.99384)
tree.navigation.position.value.longitude.should.equal(-76.3847132)
// tree.should.be.validSignalKAtoNIgnoringIdentity;
})
})
4 changes: 2 additions & 2 deletions test/129284_navigation_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ describe('129284 Navigation Data', function () {
2.7651
)
tree.should.have.nested.property(
'navigation.courseGreatCircle.nextPoint.position.latitude',
'navigation.courseGreatCircle.nextPoint.position.value.latitude',
60.1366607
)
tree.should.have.nested.property(
'navigation.courseGreatCircle.nextPoint.position.longitude',
'navigation.courseGreatCircle.nextPoint.position.value.longitude',
24.9068518
)
tree.should.have.nested.property(
Expand Down
8 changes: 4 additions & 4 deletions test/129291_set_drift_rapid_update.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ describe('129291 set & drift rapid update complete sentence', function () {
)
)
it('result has correct values', function () {
tree.should.have.nested.property('environment.current.setTrue')
tree.should.have.nested.property('environment.current.setTrue', 212.6)
tree.should.have.nested.property('environment.current.drift')
tree.should.have.nested.property('environment.current.drift', 0.24)
tree.should.have.nested.property('environment.current.value.setTrue')
tree.should.have.nested.property('environment.current.value.setTrue', 212.6)
tree.should.have.nested.property('environment.current.value.drift')
tree.should.have.nested.property('environment.current.value.drift', 0.24)
})
it('result is valid SignalK', function () {
tree.should.be.validSignalKVesselIgnoringIdentity
Expand Down
4 changes: 2 additions & 2 deletions test/129794_ais_class_a_static_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ describe('129794 AIS Class A Static and Voyage Related Data', function () {
delta.updates[0].values[0].value.name.should.equal('SILVER GWEN')
// console.log(JSON.stringify(delta, null, 2))
var tree = mapper.toNested(msg)
tree.should.have.nested.property('design.draft.maximum', 10.6)
tree.should.have.nested.property('design.length.overall', 183.0)
tree.should.have.nested.property('design.draft.value.maximum', 10.6)
tree.should.have.nested.property('design.length.value.overall', 183.0)
tree.should.have.nested.property('design.aisShipType.value.id', 83)
tree.should.have.nested.property(
'design.aisShipType.value.name',
Expand Down
4 changes: 2 additions & 2 deletions test/130577_direction_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ describe('130577 direction_data sentence with drift', function () {
'navigation.courseOverGroundTrue.value',
206.9
)
tree.should.have.nested.property('environment.current.setTrue', 58.9)
tree.should.have.nested.property('environment.current.drift', 0.28)
tree.should.have.nested.property('environment.current.value.setTrue', 58.9)
tree.should.have.nested.property('environment.current.value.drift', 0.28)
})
it('is valid SignalK', function () {
tree.should.be.validSignalKVesselIgnoringIdentity
Expand Down
6 changes: 3 additions & 3 deletions test/130820_fusion.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ describe('130820 Fusion Stereo', function () {
)
)
tree.should.have.nested.property(
'entertainment.device.fusion1.output.zone1.equalizer.bass',
'entertainment.device.fusion1.output.zone1.equalizer.value.bass',
1
)
tree.should.have.nested.property(
'entertainment.device.fusion1.output.zone1.equalizer.mid',
'entertainment.device.fusion1.output.zone1.equalizer.value.mid',
2
)
tree.should.have.nested.property(
'entertainment.device.fusion1.output.zone1.equalizer.treble',
'entertainment.device.fusion1.output.zone1.equalizer.value.treble',
3
)
// tree.should.be.validSignalKVesselIgnoringIdentity;
Expand Down
2 changes: 1 addition & 1 deletion test/130842_simnet_class_b_extended.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('130842 Simnet AIS Class B static data', function () {
delta.context.should.equal('vessels.urn:mrn:imo:mmsi:338184313')
var tree = mapper.toNested(msg)
tree.should.have.nested.property('mmsi', '338184313')
tree.should.have.nested.property('design.length.overall', 9.0)
tree.should.have.nested.property('design.length.value.overall', 9.0)
tree.should.have.nested.property('design.aisShipType.value.id', 36)
tree.should.have.nested.property('design.aisShipType.value.name', 'Sailing')
tree.should.have.nested.property('design.beam.value', 4.0)
Expand Down
10 changes: 5 additions & 5 deletions test/65288_seatalk_alarm.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ describe('65288 Seatalk Alarm', function () {
)
)
tree.should.have.nested.property(
'notifications.autopilot.PilotWayPointAdvance.state',
'notifications.autopilot.PilotWayPointAdvance.value.state',
'alarm'
)
tree.notifications.autopilot.PilotWayPointAdvance.method.should.eql([
tree.notifications.autopilot.PilotWayPointAdvance.value.method.should.eql([
'visual',
'sound'
])
Expand All @@ -29,7 +29,7 @@ describe('65288 Seatalk Alarm', function () {
)
)
tree.should.have.nested.property(
'notifications.autopilot.PilotWayPointAdvance.state',
'notifications.autopilot.PilotWayPointAdvance.value.state',
'normal'
)
// https://github.com/SignalK/specification/issues/281
Expand All @@ -43,10 +43,10 @@ describe('65288 Seatalk Alarm', function () {
)
)
tree.should.have.nested.property(
'notifications.autopilot.PilotWayPointAdvance.state',
'notifications.autopilot.PilotWayPointAdvance.value.state',
'alarm'
)
tree.notifications.autopilot.PilotWayPointAdvance.method.should.eql([
tree.notifications.autopilot.PilotWayPointAdvance.value.method.should.eql([
'visual'
])
// https://github.com/SignalK/specification/issues/281
Expand Down

0 comments on commit f2105d1

Please sign in to comment.