RFC: A location property for notifications

Aperta
#694 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, json, openapi

Direzione di ricerca

Start by reading the Notification value schema and the Notifications API OpenAPI and AsyncAPI schemas named in the proposal. Trace how raise() and update() accept and expose notification fields, including their REST counterparts, and check the existing location data from @signalk/n2k-signalk. Done means the optional property is specified consistently across the schemas and API surfaces, with the compatibility and open questions resolved.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

Add an optional location string to the Notification value: a human-readable place on the vessel or installation the notification refers to, such as "ER Port" or "Galley". Clients show it together with message, so an alarm reads "Highwater – ER Port" instead of "Highwater".

Motivation

An NMEA 2000 alert (PGN 126985 Alert Text) carries two strings: the alert text and the alert location text. Alerting systems such as Maretron N2KView put the condition in the first and the place in the second, so the text alone is often ambiguous. On one boat, ten alerts include "Highwater" twice and "CO 8Ohm" four times, and only the location tells them apart:

Text Location
CO 8Ohm Port Fwd Cabin
CO 8 Ohm Port Mid Cabin
CO 8Ohm Galley
CO 8Ohm Masercabin
Highwater Vorpiek Stb
Highwater ER Port

@signalk/n2k-signalk has published the location since 4.7.0, as a location property next to message in notifications.nmea.*. The Notification schema has no such property, so clients do not know it exists. Freeboard-SK, for example, builds its alert from message and the Notifications API fields only, and shows "Highwater" with no way to tell which bilge is flooding.

Putting the place into message would work in every client today, but it mixes two pieces of information that a client may want to present differently (a column, a filter, a second line), and every producer would format it its own way. A defined property keeps them apart and gives producers one place to put it.

Proposal

Specification

In the Notification value, next to state, method and message:

"location": {
  "type": "string",
  "description": "Where on the vessel or installation the condition is, in human-readable form, e.g. \"ER Port\" or \"Galley\". Not a geographic position; see position."
}
  • Optional. Absent and empty mean "no location given".
  • Free text, set by the producer. No vocabulary is defined, because installations name their spaces themselves.
  • Distinct from position, which is the vessel's geographic position when the notification was raised.

The property is named location because that is what n2k-signalk already emits, so the existing N2K mapping becomes conformant without any change.

Server
  • Notification in @signalk/server-api gains location?: string.
  • The Notifications API OpenAPI and AsyncAPI schemas document it.
  • raise() and update() in the Notifications API, and their REST counterparts, accept location, so plugins raising alarms can set it.
  • Notifications that arrive as deltas already keep the whole value, so location passes through to clients unchanged.
Clients

A client that shows a notification's message should show location with it when present. The exact form ("Highwater – ER Port", a second line, a column) is the client's choice.

Producers
  • @signalk/n2k-signalk: no change; it already sets location from PGN 126985.
  • Plugins that know the place of a condition (bilge, fire and gas sensors, tank alarms) can set it instead of writing it into message.

Compatibility

Purely additive. A client that ignores location behaves as today, and a producer that does not set it is unaffected.

Open questions

  1. Should the Notifications API's own alarms (MOB, for instance) ever set location? Probably not, since position covers them.
  2. Should location be translatable, given that PGN 126985 carries a language id? This RFC treats it as display text in whatever language the producer has.
Lingua principale
JavaScript
Stelle
105
Fork
72
Merge medio
11h 49m
PR unite (30g)
5

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di SignalK/specification

Tutte le issue di SignalK/specification

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.