Skip to content

Commit f60fa28

Browse files
authored
feat(126983): expose alert location text in notification value (#330)
PGN 126985 (Alert Text) carries two strings: the alert description and an optional location description (alertLocationTextDescription). The 126985 handler already caches both, but the 126983 (Alert) handler only read textDescription back out, so the location was silently dropped from the SignalK notification even though the device sends it. Add a `location` field to the notification value, sourced from the cached locationTextDescription and defaulting to '' when absent.
1 parent 9933173 commit f60fa28

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

pgns/126983.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ module.exports = [
7070
state: resolved.sk,
7171
method: ['visual', 'sound'],
7272
message: state.alerts[alertId].textDescription,
73+
location: state.alerts[alertId].locationTextDescription || '',
7374
alertType: n2k.fields.alertType,
7475
alertCategory: n2k.fields.alertCategory,
7576
alertSystem: n2k.fields.alertSystem,

test/126983_alert.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var state = {
1212
alerts: {
1313
'23480': {
1414
languageId: 'English (US)',
15-
locationTextDescription: '',
15+
locationTextDescription: 'Engine Room',
1616
textDescription: 'TEST: Temperature over 0'
1717
}
1818
}
@@ -23,6 +23,7 @@ var value = {
2323
state: 'warn',
2424
method: ['visual', 'sound'],
2525
message: 'TEST: Temperature over 0',
26+
location: 'Engine Room',
2627
alertType: 'Warning',
2728
alertCategory: 'Navigational',
2829
alertSystem: 20,
@@ -153,4 +154,27 @@ describe('126983 Alert', function () {
153154
else process.env.NO_CANBOATJS = saved
154155
}
155156
})
157+
158+
it('defaults location to empty string when no location text is present', function () {
159+
var noLocationState = {
160+
'40': {
161+
alerts: {
162+
'23480': {
163+
languageId: 'English (US)',
164+
locationTextDescription: '',
165+
textDescription: 'TEST: Temperature over 0'
166+
}
167+
}
168+
}
169+
}
170+
171+
var msg = JSON.parse(
172+
'{"canId":166725416,"prio":2,"src":40,"dst":255,"pgn":126983,"direction":"R","time":"15:48:36.090","fields":{"Alert Type":"Warning","Alert Category":"Navigational","Alert System":20,"Alert ID":23480,"Data Source Network ID NAME":6458553273545042000,"Data Source Instance":0,"Data Source Index-Source":0,"Alert Occurrence Number":1,"Temporary Silence Status":"Not Temporary Silence","Acknowledge Status":"Not Acknowledged","Escalation Status":"Not Escalated","Temporary Silence Support":"Yes","Acknowledge Support":"Yes","Escalation Support":"Not Supported","Acknowledge Source Network ID NAME":1233993542451364400,"Trigger Condition":"Auto","Threshold Status":"Threshold Exceeded","Alert Priority":187,"Alert State":"Active"},"description":"Alert","timestamp":"2020-03-03T15:48:36.494Z"}'
173+
)
174+
var tree = mapper.toNested(msg, noLocationState)
175+
176+
tree.notifications.nmea.warning.navigational[20][23480].value.location.should.equal(
177+
''
178+
)
179+
})
156180
})

0 commit comments

Comments
 (0)