UNPKG

extended-nmea

Version:

A TypeScript library for parsing NMEA0183-like sentences with support for custom and proprietary sentences.

48 lines 2.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TalkerSentence = void 0; const ChecksumSentence_1 = require("./ChecksumSentence"); const NmeaSentence_1 = require("./NmeaSentence"); const SentenceType_1 = require("../SentenceType"); class TalkerSentence extends ChecksumSentence_1.ChecksumSentence { /** * Create a NMEA0183 "talker sentence" from a string and an optional talker id length. * * @param data The data to interpret as an NMEA0183 talker sentence. Can also be an existing Sentence. * @param talkerIdLength The length of the talker id in this sentence. * @param prefix The prefix to use when validating the sentence. * @param suffix The suffix to use when validating the sentence. */ constructor(data, talkerIdLength = 2, prefix = NmeaSentence_1.NmeaSentence.Prefix, suffix = NmeaSentence_1.NmeaSentence.Suffix) { super(data, SentenceType_1.SentenceType.Talker, prefix, suffix); this.talkerIdLength = talkerIdLength; } /** * By default, returns the first two characters in the first field as per NMEA0183 standard. Can return more than * two characters if specified otherwise in the constructor. */ get talkerId() { return this.idField.substr(0, this.talkerIdLength); } /** * Returns all characters between the talker id and the end of the first field, excluding all characters from the * talker id. */ get sentenceId() { return this.idField.substr(this.talkerIdLength); } /** * The first field in the sentence (usually includes a talker id/sentence id). */ get idField() { return this.fields[0]; } /** * Returns all data fields of the sentence. I.e. all fields separated by comma, excluding the first one. */ get dataFields() { return this.fields.splice(1); } } exports.TalkerSentence = TalkerSentence; //# sourceMappingURL=TalkerSentence.js.map