UNPKG

extended-nmea

Version:

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

65 lines 2.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GSV = exports.GsvSatellite = void 0; const TalkerSentence_1 = require("../../types/sentences/TalkerSentence"); class GsvSatellite { constructor(PRN, Elevation, Azimuth, SNR) { this.PRN = PRN; this.Elevation = Elevation; this.Azimuth = Azimuth; this.SNR = SNR; } } exports.GsvSatellite = GsvSatellite; class GSV extends TalkerSentence_1.TalkerSentence { constructor(data) { super(data); } get messageCount() { return parseInt(this.dataFields[0]); } get messageNumber() { return parseInt(this.dataFields[1]); } get totalMessageCount() { return parseInt(this.dataFields[2]); } *satellites() { const data = this.dataFields.slice(3, 19).map(x => x.length > 0 ? x : "0").map(x => parseInt(x)); for (let i = 0; i + 3 < data.length; i += 4) { yield new GsvSatellite(data[i], data[i + 1], data[i + 2], data[i + 3]); } } get signalId() { if (this.dataFields.length % 4 === 0) { return this.dataFields[this.dataFields.length - 1]; } return null; } get valid() { if (!super.valid) { return false; } const dataFieldLength = this.dataFields.length; if ((dataFieldLength - 3) % 4 === 0) { return true; } // NMEA 4.10 and later add a signalId field at the end of the GSV sentence return dataFieldLength % 4 === 0; } get invalidReason() { if (!super.valid) { return super.invalidReason; } if (this.dataFields.length % 4 === 0) { return null; } if ((this.dataFields.length - 3) % 4 === 0) { return null; } return "Invalid number of data fields: must contain a multiple of 4 data fields"; } } exports.GSV = GSV; GSV.ID = "GSV"; //# sourceMappingURL=GSV.js.map