@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.
package/dist/index.mjs CHANGED
@@ -867,6 +867,9 @@ var ResultFormatter = class {
867
867
  }
868
868
  }
869
869
  static version(decodeResult, value) {
870
+ if (isNaN(value)) {
871
+ return;
872
+ }
870
873
  decodeResult.raw.version = value;
871
874
  decodeResult.formatted.items.push({
872
875
  type: "version",
@@ -903,6 +906,9 @@ var ResultFormatter = class {
903
906
  });
904
907
  }
905
908
  static desiredAltitude(decodeResult, value) {
909
+ if (isNaN(value)) {
910
+ return;
911
+ }
906
912
  decodeResult.raw.desired_alt = value;
907
913
  decodeResult.formatted.items.push({
908
914
  type: "desired_altitude",
@@ -1477,6 +1483,9 @@ var Arinc702Helper = class _Arinc702Helper {
1477
1483
  case "TD":
1478
1484
  processTimeOfDeparture(decodeResult, data2.split(","));
1479
1485
  break;
1486
+ case "TR":
1487
+ processTR(decodeResult, data2.split(","));
1488
+ break;
1480
1489
  case "TS":
1481
1490
  _Arinc702Helper.processTimeStamp(decodeResult, data2.split(","));
1482
1491
  break;
@@ -1657,6 +1666,21 @@ function processLandingReport(decodeResult, data) {
1657
1666
  ResultFormatter.unknown(decodeResult, data.join(","));
1658
1667
  }
1659
1668
  }
1669
+ function processTR(decodeResult, data) {
1670
+ if (data.length !== 21) {
1671
+ ResultFormatter.unknownArr(decodeResult, data, ",");
1672
+ return;
1673
+ }
1674
+ ResultFormatter.unknownArr(decodeResult, data.slice(0, 5), ",");
1675
+ ResultFormatter.off(decodeResult, DateTimeUtils.convertHHMMSSToTod(data[5]));
1676
+ ResultFormatter.unknownArr(decodeResult, data.slice(6, 11), ",");
1677
+ ResultFormatter.departureAirport(decodeResult, data[11]);
1678
+ ResultFormatter.arrivalAirport(decodeResult, data[12]);
1679
+ ResultFormatter.departureRunway(decodeResult, data[13]);
1680
+ ResultFormatter.unknownArr(decodeResult, data.slice(14, 16), ",");
1681
+ ResultFormatter.flightNumber(decodeResult, data[16]);
1682
+ ResultFormatter.unknownArr(decodeResult, data.slice(17), ",");
1683
+ }
1660
1684
  function processCenterOfGravity(decodeResult, data) {
1661
1685
  if (data.length === 1) {
1662
1686
  if (data[0] !== void 0 && data[0] !== "") {
@@ -1717,6 +1741,8 @@ function processIMI(decodeResult, type) {
1717
1741
  decodeResult.formatted.description = "Load Distribution Information";
1718
1742
  } else if (type === "PER") {
1719
1743
  decodeResult.formatted.description = "Performance Report";
1744
+ } else if (type === "PRF") {
1745
+ decodeResult.formatted.description = "Profile Report";
1720
1746
  } else if (type === "POS") {
1721
1747
  decodeResult.formatted.description = "Position Report";
1722
1748
  } else if (type === "PRG") {
@@ -4742,91 +4768,60 @@ var Label_ColonComma = class extends DecoderPlugin {
4742
4768
  }
4743
4769
  };
4744
4770
 
4745
- // lib/plugins/Label_H2_02E.ts
4746
- var Label_H2_02E = class extends DecoderPlugin {
4747
- name = "label-h2-02e";
4771
+ // lib/plugins/Label_H1_76401.ts
4772
+ var Label_H1_76401 = class extends DecoderPlugin {
4773
+ name = "label-h1-76401";
4748
4774
  qualifiers() {
4749
4775
  return {
4750
- labels: ["H2"],
4751
- preambles: ["02E"]
4776
+ labels: ["H1"],
4777
+ preambles: ["76401\r\n"]
4752
4778
  };
4753
4779
  }
4754
4780
  decode(message, options = {}) {
4755
- let decodeResult = this.defaultResult();
4756
- decodeResult.decoder.name = this.name;
4757
- decodeResult.formatted.description = "Weather Report";
4758
- decodeResult.message = message;
4759
- const parts = message.text.split(" ");
4760
- if (parts[parts.length - 1] !== "Q") {
4761
- decodeResult.remaining.text = message.text;
4762
- decodeResult.decoded = false;
4763
- decodeResult.decoder.decodeLevel = "none";
4781
+ const decodeResult = this.initResult(message, "Position Report");
4782
+ const lines = message.text.split("\r\n");
4783
+ if (lines.length < 3) {
4764
4784
  return decodeResult;
4765
4785
  }
4766
- const windData = [];
4767
- decodeResult.remaining.text = "";
4768
- const header = parts[0];
4769
- if (header.length === 45) {
4770
- ResultFormatter.day(decodeResult, parseInt(header.substring(3, 5), 10));
4771
- ResultFormatter.departureAirport(decodeResult, header.substring(5, 9));
4772
- ResultFormatter.arrivalAirport(decodeResult, header.substring(9, 13));
4773
- const firstWind = this.parseWeatherReport(header.substring(13));
4774
- if (firstWind) {
4775
- windData.push(firstWind);
4786
+ ResultFormatter.unknown(decodeResult, lines[0], "\r\n");
4787
+ ResultFormatter.unknown(decodeResult, lines[1].substring(0, 5), "\r\n");
4788
+ ResultFormatter.departureAirport(decodeResult, lines[1].substring(5, 9));
4789
+ ResultFormatter.arrivalAirport(decodeResult, lines[1].substring(9, 13));
4790
+ ResultFormatter.unknown(decodeResult, lines[1].substring(13), "");
4791
+ const waypoints = [];
4792
+ for (const line of lines.slice(2)) {
4793
+ const position = CoordinateUtils.decodeStringCoordinates(
4794
+ line.substring(0, 13)
4795
+ );
4796
+ if (position) {
4797
+ waypoints.push({
4798
+ name: CoordinateUtils.coordinateString(position),
4799
+ latitude: position.latitude,
4800
+ longitude: position.longitude,
4801
+ time: DateTimeUtils.convertHHMMSSToTod(line.substring(13, 19))
4802
+ });
4776
4803
  } else {
4777
- decodeResult.remaining.text += (decodeResult.remaining.text ? " " : "") + header.substring(13);
4804
+ ResultFormatter.unknown(decodeResult, line.substring(0, 19), "");
4778
4805
  }
4806
+ ResultFormatter.unknown(decodeResult, line.substring(19), "\r\n");
4779
4807
  }
4780
- for (let i = 1; i < parts.length - 1; i++) {
4781
- const part = parts[i];
4782
- if (part[0] !== "Q") {
4783
- decodeResult.remaining.text += (decodeResult.remaining.text ? " " : "") + part;
4784
- continue;
4808
+ ResultFormatter.route(decodeResult, { waypoints });
4809
+ if (waypoints.length > 0) {
4810
+ const lastWaypoint = waypoints[waypoints.length - 1];
4811
+ if (lastWaypoint.latitude !== void 0 && lastWaypoint.longitude !== void 0) {
4812
+ ResultFormatter.position(decodeResult, {
4813
+ latitude: lastWaypoint.latitude,
4814
+ longitude: lastWaypoint.longitude
4815
+ });
4785
4816
  }
4786
- const wind = this.parseWeatherReport(part.substring(1));
4787
- if (wind) {
4788
- windData.push(wind);
4789
- } else {
4790
- decodeResult.remaining.text += (decodeResult.remaining.text ? " " : "") + part;
4817
+ if (lastWaypoint.time !== void 0) {
4818
+ ResultFormatter.timestamp(decodeResult, lastWaypoint.time);
4791
4819
  }
4792
4820
  }
4793
- ResultFormatter.windData(decodeResult, windData);
4794
4821
  decodeResult.decoded = true;
4795
- decodeResult.decoder.decodeLevel = decodeResult.remaining.text.length === 0 ? "full" : "partial";
4822
+ decodeResult.decoder.decodeLevel = "partial";
4796
4823
  return decodeResult;
4797
4824
  }
4798
- parseWeatherReport(text) {
4799
- const posString = text.substring(0, 13);
4800
- const pos = CoordinateUtils.decodeStringCoordinatesDecimalMinutes(posString);
4801
- if (text.length !== 32 || !pos) {
4802
- return null;
4803
- }
4804
- const tod = DateTimeUtils.convertHHMMSSToTod(text.substring(13, 17));
4805
- const flightLevel = parseInt(text.substring(17, 20), 10);
4806
- const tempSign = text[21] === "M" ? -1 : 1;
4807
- const tempDegreesRaw = parseInt(text.substring(22, 25), 10);
4808
- const tempDegrees = tempSign * (tempDegreesRaw / 10);
4809
- const windDirection = parseInt(text.substring(25, 28), 10);
4810
- const windSpeed = parseInt(text.substring(28, 31), 10);
4811
- if (text[31] !== "G") {
4812
- return null;
4813
- }
4814
- return {
4815
- waypoint: {
4816
- name: posString,
4817
- latitude: pos.latitude,
4818
- longitude: pos.longitude,
4819
- time: tod
4820
- },
4821
- flightLevel,
4822
- windDirection,
4823
- windSpeed,
4824
- temperature: {
4825
- flightLevel,
4826
- degreesC: tempDegrees
4827
- }
4828
- };
4829
- }
4830
4825
  };
4831
4826
 
4832
4827
  // lib/plugins/Label_H1_ATIS.ts
@@ -5484,6 +5479,93 @@ var Label_H1_WRN = class extends DecoderPlugin {
5484
5479
  }
5485
5480
  };
5486
5481
 
5482
+ // lib/plugins/Label_H2_02E.ts
5483
+ var Label_H2_02E = class extends DecoderPlugin {
5484
+ name = "label-h2-02e";
5485
+ qualifiers() {
5486
+ return {
5487
+ labels: ["H2"],
5488
+ preambles: ["02E"]
5489
+ };
5490
+ }
5491
+ decode(message, options = {}) {
5492
+ let decodeResult = this.defaultResult();
5493
+ decodeResult.decoder.name = this.name;
5494
+ decodeResult.formatted.description = "Weather Report";
5495
+ decodeResult.message = message;
5496
+ const parts = message.text.split(" ");
5497
+ if (parts[parts.length - 1] !== "Q") {
5498
+ decodeResult.remaining.text = message.text;
5499
+ decodeResult.decoded = false;
5500
+ decodeResult.decoder.decodeLevel = "none";
5501
+ return decodeResult;
5502
+ }
5503
+ const windData = [];
5504
+ decodeResult.remaining.text = "";
5505
+ const header = parts[0];
5506
+ if (header.length === 45) {
5507
+ ResultFormatter.day(decodeResult, parseInt(header.substring(3, 5), 10));
5508
+ ResultFormatter.departureAirport(decodeResult, header.substring(5, 9));
5509
+ ResultFormatter.arrivalAirport(decodeResult, header.substring(9, 13));
5510
+ const firstWind = this.parseWeatherReport(header.substring(13));
5511
+ if (firstWind) {
5512
+ windData.push(firstWind);
5513
+ } else {
5514
+ decodeResult.remaining.text += (decodeResult.remaining.text ? " " : "") + header.substring(13);
5515
+ }
5516
+ }
5517
+ for (let i = 1; i < parts.length - 1; i++) {
5518
+ const part = parts[i];
5519
+ if (part[0] !== "Q") {
5520
+ decodeResult.remaining.text += (decodeResult.remaining.text ? " " : "") + part;
5521
+ continue;
5522
+ }
5523
+ const wind = this.parseWeatherReport(part.substring(1));
5524
+ if (wind) {
5525
+ windData.push(wind);
5526
+ } else {
5527
+ decodeResult.remaining.text += (decodeResult.remaining.text ? " " : "") + part;
5528
+ }
5529
+ }
5530
+ ResultFormatter.windData(decodeResult, windData);
5531
+ decodeResult.decoded = true;
5532
+ decodeResult.decoder.decodeLevel = decodeResult.remaining.text.length === 0 ? "full" : "partial";
5533
+ return decodeResult;
5534
+ }
5535
+ parseWeatherReport(text) {
5536
+ const posString = text.substring(0, 13);
5537
+ const pos = CoordinateUtils.decodeStringCoordinatesDecimalMinutes(posString);
5538
+ if (text.length !== 32 || !pos) {
5539
+ return null;
5540
+ }
5541
+ const tod = DateTimeUtils.convertHHMMSSToTod(text.substring(13, 17));
5542
+ const flightLevel = parseInt(text.substring(17, 20), 10);
5543
+ const tempSign = text[21] === "M" ? -1 : 1;
5544
+ const tempDegreesRaw = parseInt(text.substring(22, 25), 10);
5545
+ const tempDegrees = tempSign * (tempDegreesRaw / 10);
5546
+ const windDirection = parseInt(text.substring(25, 28), 10);
5547
+ const windSpeed = parseInt(text.substring(28, 31), 10);
5548
+ if (text[31] !== "G") {
5549
+ return null;
5550
+ }
5551
+ return {
5552
+ waypoint: {
5553
+ name: posString,
5554
+ latitude: pos.latitude,
5555
+ longitude: pos.longitude,
5556
+ time: tod
5557
+ },
5558
+ flightLevel,
5559
+ windDirection,
5560
+ windSpeed,
5561
+ temperature: {
5562
+ flightLevel,
5563
+ degreesC: tempDegrees
5564
+ }
5565
+ };
5566
+ }
5567
+ };
5568
+
5487
5569
  // lib/plugins/Label_HX.ts
5488
5570
  var Label_HX = class extends DecoderPlugin {
5489
5571
  name = "label-hx";
@@ -5556,8 +5638,8 @@ function ascii85Decode(input) {
5556
5638
  if (digit < 0 || digit > 84) return null;
5557
5639
  value = value * 85 + digit;
5558
5640
  }
5559
- if (chunkLen === 5 && value > 4294967295) return null;
5560
- const v = value >>> 0;
5641
+ if (value > 4294967295) return null;
5642
+ const v = value;
5561
5643
  const numBytes = chunkLen === 5 ? 4 : chunkLen - 1;
5562
5644
  if (numBytes >= 1) output.push(v >>> 24 & 255);
5563
5645
  if (numBytes >= 2) output.push(v >>> 16 & 255);
@@ -6819,7 +6901,7 @@ var pluginClasses = [
6819
6901
  Label_4T_AGFSR,
6820
6902
  Label_4T_ETA,
6821
6903
  Label_B6_Forwardslash,
6822
- Label_H2_02E,
6904
+ Label_H1_76401,
6823
6905
  Label_H1_ATIS,
6824
6906
  Label_H1_EZF,
6825
6907
  Label_H1_FLR,
@@ -6829,6 +6911,7 @@ var pluginClasses = [
6829
6911
  Label_H1_Paren,
6830
6912
  Label_H1_WRN,
6831
6913
  Label_H1_StarPOS,
6914
+ Label_H2_02E,
6832
6915
  Label_HX,
6833
6916
  Label_58,
6834
6917
  Label_80,
@@ -6874,6 +6957,9 @@ var MessageDecoder = class {
6874
6957
  this.wildcardSet.add(plugin);
6875
6958
  const wildcardInsertIndex = this.wildcardEntries.length - 1;
6876
6959
  for (const bucket of this.candidatesByLabel.values()) {
6960
+ if (bucket.some((e) => e.plugin === plugin)) {
6961
+ continue;
6962
+ }
6877
6963
  bucket.splice(wildcardInsertIndex, 0, entry);
6878
6964
  }
6879
6965
  }