@airframes/acars-decoder 1.9.3 → 1.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -805,6 +805,9 @@ var ResultFormatter = class {
805
805
  }
806
806
  }
807
807
  static version(decodeResult, value) {
808
+ if (isNaN(value)) {
809
+ return;
810
+ }
808
811
  decodeResult.raw.version = value;
809
812
  decodeResult.formatted.items.push({
810
813
  type: "version",
@@ -841,6 +844,9 @@ var ResultFormatter = class {
841
844
  });
842
845
  }
843
846
  static desiredAltitude(decodeResult, value) {
847
+ if (isNaN(value)) {
848
+ return;
849
+ }
844
850
  decodeResult.raw.desired_alt = value;
845
851
  decodeResult.formatted.items.push({
846
852
  type: "desired_altitude",
@@ -1415,6 +1421,9 @@ var Arinc702Helper = class _Arinc702Helper {
1415
1421
  case "TD":
1416
1422
  processTimeOfDeparture(decodeResult, data2.split(","));
1417
1423
  break;
1424
+ case "TR":
1425
+ processTR(decodeResult, data2.split(","));
1426
+ break;
1418
1427
  case "TS":
1419
1428
  _Arinc702Helper.processTimeStamp(decodeResult, data2.split(","));
1420
1429
  break;
@@ -1595,6 +1604,21 @@ function processLandingReport(decodeResult, data) {
1595
1604
  ResultFormatter.unknown(decodeResult, data.join(","));
1596
1605
  }
1597
1606
  }
1607
+ function processTR(decodeResult, data) {
1608
+ if (data.length !== 21) {
1609
+ ResultFormatter.unknownArr(decodeResult, data, ",");
1610
+ return;
1611
+ }
1612
+ ResultFormatter.unknownArr(decodeResult, data.slice(0, 5), ",");
1613
+ ResultFormatter.off(decodeResult, DateTimeUtils.convertHHMMSSToTod(data[5]));
1614
+ ResultFormatter.unknownArr(decodeResult, data.slice(6, 11), ",");
1615
+ ResultFormatter.departureAirport(decodeResult, data[11]);
1616
+ ResultFormatter.arrivalAirport(decodeResult, data[12]);
1617
+ ResultFormatter.departureRunway(decodeResult, data[13]);
1618
+ ResultFormatter.unknownArr(decodeResult, data.slice(14, 16), ",");
1619
+ ResultFormatter.flightNumber(decodeResult, data[16]);
1620
+ ResultFormatter.unknownArr(decodeResult, data.slice(17), ",");
1621
+ }
1598
1622
  function processCenterOfGravity(decodeResult, data) {
1599
1623
  if (data.length === 1) {
1600
1624
  if (data[0] !== void 0 && data[0] !== "") {
@@ -1655,6 +1679,8 @@ function processIMI(decodeResult, type) {
1655
1679
  decodeResult.formatted.description = "Load Distribution Information";
1656
1680
  } else if (type === "PER") {
1657
1681
  decodeResult.formatted.description = "Performance Report";
1682
+ } else if (type === "PRF") {
1683
+ decodeResult.formatted.description = "Profile Report";
1658
1684
  } else if (type === "POS") {
1659
1685
  decodeResult.formatted.description = "Position Report";
1660
1686
  } else if (type === "PRG") {
@@ -4680,91 +4706,60 @@ var Label_ColonComma = class extends DecoderPlugin {
4680
4706
  }
4681
4707
  };
4682
4708
 
4683
- // lib/plugins/Label_H2_02E.ts
4684
- var Label_H2_02E = class extends DecoderPlugin {
4685
- name = "label-h2-02e";
4709
+ // lib/plugins/Label_H1_76401.ts
4710
+ var Label_H1_76401 = class extends DecoderPlugin {
4711
+ name = "label-h1-76401";
4686
4712
  qualifiers() {
4687
4713
  return {
4688
- labels: ["H2"],
4689
- preambles: ["02E"]
4714
+ labels: ["H1"],
4715
+ preambles: ["76401\r\n"]
4690
4716
  };
4691
4717
  }
4692
4718
  decode(message2, options = {}) {
4693
- let decodeResult = this.defaultResult();
4694
- decodeResult.decoder.name = this.name;
4695
- decodeResult.formatted.description = "Weather Report";
4696
- decodeResult.message = message2;
4697
- const parts = message2.text.split(" ");
4698
- if (parts[parts.length - 1] !== "Q") {
4699
- decodeResult.remaining.text = message2.text;
4700
- decodeResult.decoded = false;
4701
- decodeResult.decoder.decodeLevel = "none";
4719
+ const decodeResult = this.initResult(message2, "Position Report");
4720
+ const lines = message2.text.split("\r\n");
4721
+ if (lines.length < 3) {
4702
4722
  return decodeResult;
4703
4723
  }
4704
- const windData = [];
4705
- decodeResult.remaining.text = "";
4706
- const header = parts[0];
4707
- if (header.length === 45) {
4708
- ResultFormatter.day(decodeResult, parseInt(header.substring(3, 5), 10));
4709
- ResultFormatter.departureAirport(decodeResult, header.substring(5, 9));
4710
- ResultFormatter.arrivalAirport(decodeResult, header.substring(9, 13));
4711
- const firstWind = this.parseWeatherReport(header.substring(13));
4712
- if (firstWind) {
4713
- windData.push(firstWind);
4724
+ ResultFormatter.unknown(decodeResult, lines[0], "\r\n");
4725
+ ResultFormatter.unknown(decodeResult, lines[1].substring(0, 5), "\r\n");
4726
+ ResultFormatter.departureAirport(decodeResult, lines[1].substring(5, 9));
4727
+ ResultFormatter.arrivalAirport(decodeResult, lines[1].substring(9, 13));
4728
+ ResultFormatter.unknown(decodeResult, lines[1].substring(13), "");
4729
+ const waypoints = [];
4730
+ for (const line of lines.slice(2)) {
4731
+ const position = CoordinateUtils.decodeStringCoordinates(
4732
+ line.substring(0, 13)
4733
+ );
4734
+ if (position) {
4735
+ waypoints.push({
4736
+ name: CoordinateUtils.coordinateString(position),
4737
+ latitude: position.latitude,
4738
+ longitude: position.longitude,
4739
+ time: DateTimeUtils.convertHHMMSSToTod(line.substring(13, 19))
4740
+ });
4714
4741
  } else {
4715
- decodeResult.remaining.text += (decodeResult.remaining.text ? " " : "") + header.substring(13);
4742
+ ResultFormatter.unknown(decodeResult, line.substring(0, 19), "");
4716
4743
  }
4744
+ ResultFormatter.unknown(decodeResult, line.substring(19), "\r\n");
4717
4745
  }
4718
- for (let i = 1; i < parts.length - 1; i++) {
4719
- const part = parts[i];
4720
- if (part[0] !== "Q") {
4721
- decodeResult.remaining.text += (decodeResult.remaining.text ? " " : "") + part;
4722
- continue;
4746
+ ResultFormatter.route(decodeResult, { waypoints });
4747
+ if (waypoints.length > 0) {
4748
+ const lastWaypoint = waypoints[waypoints.length - 1];
4749
+ if (lastWaypoint.latitude !== void 0 && lastWaypoint.longitude !== void 0) {
4750
+ ResultFormatter.position(decodeResult, {
4751
+ latitude: lastWaypoint.latitude,
4752
+ longitude: lastWaypoint.longitude
4753
+ });
4723
4754
  }
4724
- const wind = this.parseWeatherReport(part.substring(1));
4725
- if (wind) {
4726
- windData.push(wind);
4727
- } else {
4728
- decodeResult.remaining.text += (decodeResult.remaining.text ? " " : "") + part;
4755
+ if (lastWaypoint.time !== void 0) {
4756
+ ResultFormatter.timestamp(decodeResult, lastWaypoint.time);
4729
4757
  }
4730
4758
  }
4731
- ResultFormatter.windData(decodeResult, windData);
4732
4759
  decodeResult.decoded = true;
4733
- decodeResult.decoder.decodeLevel = decodeResult.remaining.text.length === 0 ? "full" : "partial";
4760
+ decodeResult.decoder.decodeLevel = "partial";
4734
4761
  return decodeResult;
4735
4762
  }
4736
- parseWeatherReport(text) {
4737
- const posString = text.substring(0, 13);
4738
- const pos = CoordinateUtils.decodeStringCoordinatesDecimalMinutes(posString);
4739
- if (text.length !== 32 || !pos) {
4740
- return null;
4741
- }
4742
- const tod = DateTimeUtils.convertHHMMSSToTod(text.substring(13, 17));
4743
- const flightLevel = parseInt(text.substring(17, 20), 10);
4744
- const tempSign = text[21] === "M" ? -1 : 1;
4745
- const tempDegreesRaw = parseInt(text.substring(22, 25), 10);
4746
- const tempDegrees = tempSign * (tempDegreesRaw / 10);
4747
- const windDirection = parseInt(text.substring(25, 28), 10);
4748
- const windSpeed = parseInt(text.substring(28, 31), 10);
4749
- if (text[31] !== "G") {
4750
- return null;
4751
- }
4752
- return {
4753
- waypoint: {
4754
- name: posString,
4755
- latitude: pos.latitude,
4756
- longitude: pos.longitude,
4757
- time: tod
4758
- },
4759
- flightLevel,
4760
- windDirection,
4761
- windSpeed,
4762
- temperature: {
4763
- flightLevel,
4764
- degreesC: tempDegrees
4765
- }
4766
- };
4767
- }
4768
4763
  };
4769
4764
 
4770
4765
  // lib/plugins/Label_H1_ATIS.ts
@@ -5422,6 +5417,93 @@ var Label_H1_WRN = class extends DecoderPlugin {
5422
5417
  }
5423
5418
  };
5424
5419
 
5420
+ // lib/plugins/Label_H2_02E.ts
5421
+ var Label_H2_02E = class extends DecoderPlugin {
5422
+ name = "label-h2-02e";
5423
+ qualifiers() {
5424
+ return {
5425
+ labels: ["H2"],
5426
+ preambles: ["02E"]
5427
+ };
5428
+ }
5429
+ decode(message2, options = {}) {
5430
+ let decodeResult = this.defaultResult();
5431
+ decodeResult.decoder.name = this.name;
5432
+ decodeResult.formatted.description = "Weather Report";
5433
+ decodeResult.message = message2;
5434
+ const parts = message2.text.split(" ");
5435
+ if (parts[parts.length - 1] !== "Q") {
5436
+ decodeResult.remaining.text = message2.text;
5437
+ decodeResult.decoded = false;
5438
+ decodeResult.decoder.decodeLevel = "none";
5439
+ return decodeResult;
5440
+ }
5441
+ const windData = [];
5442
+ decodeResult.remaining.text = "";
5443
+ const header = parts[0];
5444
+ if (header.length === 45) {
5445
+ ResultFormatter.day(decodeResult, parseInt(header.substring(3, 5), 10));
5446
+ ResultFormatter.departureAirport(decodeResult, header.substring(5, 9));
5447
+ ResultFormatter.arrivalAirport(decodeResult, header.substring(9, 13));
5448
+ const firstWind = this.parseWeatherReport(header.substring(13));
5449
+ if (firstWind) {
5450
+ windData.push(firstWind);
5451
+ } else {
5452
+ decodeResult.remaining.text += (decodeResult.remaining.text ? " " : "") + header.substring(13);
5453
+ }
5454
+ }
5455
+ for (let i = 1; i < parts.length - 1; i++) {
5456
+ const part = parts[i];
5457
+ if (part[0] !== "Q") {
5458
+ decodeResult.remaining.text += (decodeResult.remaining.text ? " " : "") + part;
5459
+ continue;
5460
+ }
5461
+ const wind = this.parseWeatherReport(part.substring(1));
5462
+ if (wind) {
5463
+ windData.push(wind);
5464
+ } else {
5465
+ decodeResult.remaining.text += (decodeResult.remaining.text ? " " : "") + part;
5466
+ }
5467
+ }
5468
+ ResultFormatter.windData(decodeResult, windData);
5469
+ decodeResult.decoded = true;
5470
+ decodeResult.decoder.decodeLevel = decodeResult.remaining.text.length === 0 ? "full" : "partial";
5471
+ return decodeResult;
5472
+ }
5473
+ parseWeatherReport(text) {
5474
+ const posString = text.substring(0, 13);
5475
+ const pos = CoordinateUtils.decodeStringCoordinatesDecimalMinutes(posString);
5476
+ if (text.length !== 32 || !pos) {
5477
+ return null;
5478
+ }
5479
+ const tod = DateTimeUtils.convertHHMMSSToTod(text.substring(13, 17));
5480
+ const flightLevel = parseInt(text.substring(17, 20), 10);
5481
+ const tempSign = text[21] === "M" ? -1 : 1;
5482
+ const tempDegreesRaw = parseInt(text.substring(22, 25), 10);
5483
+ const tempDegrees = tempSign * (tempDegreesRaw / 10);
5484
+ const windDirection = parseInt(text.substring(25, 28), 10);
5485
+ const windSpeed = parseInt(text.substring(28, 31), 10);
5486
+ if (text[31] !== "G") {
5487
+ return null;
5488
+ }
5489
+ return {
5490
+ waypoint: {
5491
+ name: posString,
5492
+ latitude: pos.latitude,
5493
+ longitude: pos.longitude,
5494
+ time: tod
5495
+ },
5496
+ flightLevel,
5497
+ windDirection,
5498
+ windSpeed,
5499
+ temperature: {
5500
+ flightLevel,
5501
+ degreesC: tempDegrees
5502
+ }
5503
+ };
5504
+ }
5505
+ };
5506
+
5425
5507
  // lib/plugins/Label_HX.ts
5426
5508
  var Label_HX = class extends DecoderPlugin {
5427
5509
  name = "label-hx";
@@ -5494,8 +5576,8 @@ function ascii85Decode(input) {
5494
5576
  if (digit < 0 || digit > 84) return null;
5495
5577
  value = value * 85 + digit;
5496
5578
  }
5497
- if (chunkLen === 5 && value > 4294967295) return null;
5498
- const v = value >>> 0;
5579
+ if (value > 4294967295) return null;
5580
+ const v = value;
5499
5581
  const numBytes = chunkLen === 5 ? 4 : chunkLen - 1;
5500
5582
  if (numBytes >= 1) output.push(v >>> 24 & 255);
5501
5583
  if (numBytes >= 2) output.push(v >>> 16 & 255);
@@ -6757,7 +6839,7 @@ var pluginClasses = [
6757
6839
  Label_4T_AGFSR,
6758
6840
  Label_4T_ETA,
6759
6841
  Label_B6_Forwardslash,
6760
- Label_H2_02E,
6842
+ Label_H1_76401,
6761
6843
  Label_H1_ATIS,
6762
6844
  Label_H1_EZF,
6763
6845
  Label_H1_FLR,
@@ -6767,6 +6849,7 @@ var pluginClasses = [
6767
6849
  Label_H1_Paren,
6768
6850
  Label_H1_WRN,
6769
6851
  Label_H1_StarPOS,
6852
+ Label_H2_02E,
6770
6853
  Label_HX,
6771
6854
  Label_58,
6772
6855
  Label_80,
@@ -6812,6 +6895,9 @@ var MessageDecoder = class {
6812
6895
  this.wildcardSet.add(plugin);
6813
6896
  const wildcardInsertIndex = this.wildcardEntries.length - 1;
6814
6897
  for (const bucket of this.candidatesByLabel.values()) {
6898
+ if (bucket.some((e) => e.plugin === plugin)) {
6899
+ continue;
6900
+ }
6815
6901
  bucket.splice(wildcardInsertIndex, 0, entry);
6816
6902
  }
6817
6903
  }