@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.
@@ -782,6 +782,9 @@ var ResultFormatter = class {
782
782
  }
783
783
  }
784
784
  static version(decodeResult, value) {
785
+ if (isNaN(value)) {
786
+ return;
787
+ }
785
788
  decodeResult.raw.version = value;
786
789
  decodeResult.formatted.items.push({
787
790
  type: "version",
@@ -818,6 +821,9 @@ var ResultFormatter = class {
818
821
  });
819
822
  }
820
823
  static desiredAltitude(decodeResult, value) {
824
+ if (isNaN(value)) {
825
+ return;
826
+ }
821
827
  decodeResult.raw.desired_alt = value;
822
828
  decodeResult.formatted.items.push({
823
829
  type: "desired_altitude",
@@ -1392,6 +1398,9 @@ var Arinc702Helper = class _Arinc702Helper {
1392
1398
  case "TD":
1393
1399
  processTimeOfDeparture(decodeResult, data2.split(","));
1394
1400
  break;
1401
+ case "TR":
1402
+ processTR(decodeResult, data2.split(","));
1403
+ break;
1395
1404
  case "TS":
1396
1405
  _Arinc702Helper.processTimeStamp(decodeResult, data2.split(","));
1397
1406
  break;
@@ -1572,6 +1581,21 @@ function processLandingReport(decodeResult, data) {
1572
1581
  ResultFormatter.unknown(decodeResult, data.join(","));
1573
1582
  }
1574
1583
  }
1584
+ function processTR(decodeResult, data) {
1585
+ if (data.length !== 21) {
1586
+ ResultFormatter.unknownArr(decodeResult, data, ",");
1587
+ return;
1588
+ }
1589
+ ResultFormatter.unknownArr(decodeResult, data.slice(0, 5), ",");
1590
+ ResultFormatter.off(decodeResult, DateTimeUtils.convertHHMMSSToTod(data[5]));
1591
+ ResultFormatter.unknownArr(decodeResult, data.slice(6, 11), ",");
1592
+ ResultFormatter.departureAirport(decodeResult, data[11]);
1593
+ ResultFormatter.arrivalAirport(decodeResult, data[12]);
1594
+ ResultFormatter.departureRunway(decodeResult, data[13]);
1595
+ ResultFormatter.unknownArr(decodeResult, data.slice(14, 16), ",");
1596
+ ResultFormatter.flightNumber(decodeResult, data[16]);
1597
+ ResultFormatter.unknownArr(decodeResult, data.slice(17), ",");
1598
+ }
1575
1599
  function processCenterOfGravity(decodeResult, data) {
1576
1600
  if (data.length === 1) {
1577
1601
  if (data[0] !== void 0 && data[0] !== "") {
@@ -1632,6 +1656,8 @@ function processIMI(decodeResult, type) {
1632
1656
  decodeResult.formatted.description = "Load Distribution Information";
1633
1657
  } else if (type === "PER") {
1634
1658
  decodeResult.formatted.description = "Performance Report";
1659
+ } else if (type === "PRF") {
1660
+ decodeResult.formatted.description = "Profile Report";
1635
1661
  } else if (type === "POS") {
1636
1662
  decodeResult.formatted.description = "Position Report";
1637
1663
  } else if (type === "PRG") {
@@ -4657,91 +4683,60 @@ var Label_ColonComma = class extends DecoderPlugin {
4657
4683
  }
4658
4684
  };
4659
4685
 
4660
- // lib/plugins/Label_H2_02E.ts
4661
- var Label_H2_02E = class extends DecoderPlugin {
4662
- name = "label-h2-02e";
4686
+ // lib/plugins/Label_H1_76401.ts
4687
+ var Label_H1_76401 = class extends DecoderPlugin {
4688
+ name = "label-h1-76401";
4663
4689
  qualifiers() {
4664
4690
  return {
4665
- labels: ["H2"],
4666
- preambles: ["02E"]
4691
+ labels: ["H1"],
4692
+ preambles: ["76401\r\n"]
4667
4693
  };
4668
4694
  }
4669
4695
  decode(message2, options = {}) {
4670
- let decodeResult = this.defaultResult();
4671
- decodeResult.decoder.name = this.name;
4672
- decodeResult.formatted.description = "Weather Report";
4673
- decodeResult.message = message2;
4674
- const parts = message2.text.split(" ");
4675
- if (parts[parts.length - 1] !== "Q") {
4676
- decodeResult.remaining.text = message2.text;
4677
- decodeResult.decoded = false;
4678
- decodeResult.decoder.decodeLevel = "none";
4696
+ const decodeResult = this.initResult(message2, "Position Report");
4697
+ const lines = message2.text.split("\r\n");
4698
+ if (lines.length < 3) {
4679
4699
  return decodeResult;
4680
4700
  }
4681
- const windData = [];
4682
- decodeResult.remaining.text = "";
4683
- const header = parts[0];
4684
- if (header.length === 45) {
4685
- ResultFormatter.day(decodeResult, parseInt(header.substring(3, 5), 10));
4686
- ResultFormatter.departureAirport(decodeResult, header.substring(5, 9));
4687
- ResultFormatter.arrivalAirport(decodeResult, header.substring(9, 13));
4688
- const firstWind = this.parseWeatherReport(header.substring(13));
4689
- if (firstWind) {
4690
- windData.push(firstWind);
4701
+ ResultFormatter.unknown(decodeResult, lines[0], "\r\n");
4702
+ ResultFormatter.unknown(decodeResult, lines[1].substring(0, 5), "\r\n");
4703
+ ResultFormatter.departureAirport(decodeResult, lines[1].substring(5, 9));
4704
+ ResultFormatter.arrivalAirport(decodeResult, lines[1].substring(9, 13));
4705
+ ResultFormatter.unknown(decodeResult, lines[1].substring(13), "");
4706
+ const waypoints = [];
4707
+ for (const line of lines.slice(2)) {
4708
+ const position = CoordinateUtils.decodeStringCoordinates(
4709
+ line.substring(0, 13)
4710
+ );
4711
+ if (position) {
4712
+ waypoints.push({
4713
+ name: CoordinateUtils.coordinateString(position),
4714
+ latitude: position.latitude,
4715
+ longitude: position.longitude,
4716
+ time: DateTimeUtils.convertHHMMSSToTod(line.substring(13, 19))
4717
+ });
4691
4718
  } else {
4692
- decodeResult.remaining.text += (decodeResult.remaining.text ? " " : "") + header.substring(13);
4719
+ ResultFormatter.unknown(decodeResult, line.substring(0, 19), "");
4693
4720
  }
4721
+ ResultFormatter.unknown(decodeResult, line.substring(19), "\r\n");
4694
4722
  }
4695
- for (let i = 1; i < parts.length - 1; i++) {
4696
- const part = parts[i];
4697
- if (part[0] !== "Q") {
4698
- decodeResult.remaining.text += (decodeResult.remaining.text ? " " : "") + part;
4699
- continue;
4723
+ ResultFormatter.route(decodeResult, { waypoints });
4724
+ if (waypoints.length > 0) {
4725
+ const lastWaypoint = waypoints[waypoints.length - 1];
4726
+ if (lastWaypoint.latitude !== void 0 && lastWaypoint.longitude !== void 0) {
4727
+ ResultFormatter.position(decodeResult, {
4728
+ latitude: lastWaypoint.latitude,
4729
+ longitude: lastWaypoint.longitude
4730
+ });
4700
4731
  }
4701
- const wind = this.parseWeatherReport(part.substring(1));
4702
- if (wind) {
4703
- windData.push(wind);
4704
- } else {
4705
- decodeResult.remaining.text += (decodeResult.remaining.text ? " " : "") + part;
4732
+ if (lastWaypoint.time !== void 0) {
4733
+ ResultFormatter.timestamp(decodeResult, lastWaypoint.time);
4706
4734
  }
4707
4735
  }
4708
- ResultFormatter.windData(decodeResult, windData);
4709
4736
  decodeResult.decoded = true;
4710
- decodeResult.decoder.decodeLevel = decodeResult.remaining.text.length === 0 ? "full" : "partial";
4737
+ decodeResult.decoder.decodeLevel = "partial";
4711
4738
  return decodeResult;
4712
4739
  }
4713
- parseWeatherReport(text) {
4714
- const posString = text.substring(0, 13);
4715
- const pos = CoordinateUtils.decodeStringCoordinatesDecimalMinutes(posString);
4716
- if (text.length !== 32 || !pos) {
4717
- return null;
4718
- }
4719
- const tod = DateTimeUtils.convertHHMMSSToTod(text.substring(13, 17));
4720
- const flightLevel = parseInt(text.substring(17, 20), 10);
4721
- const tempSign = text[21] === "M" ? -1 : 1;
4722
- const tempDegreesRaw = parseInt(text.substring(22, 25), 10);
4723
- const tempDegrees = tempSign * (tempDegreesRaw / 10);
4724
- const windDirection = parseInt(text.substring(25, 28), 10);
4725
- const windSpeed = parseInt(text.substring(28, 31), 10);
4726
- if (text[31] !== "G") {
4727
- return null;
4728
- }
4729
- return {
4730
- waypoint: {
4731
- name: posString,
4732
- latitude: pos.latitude,
4733
- longitude: pos.longitude,
4734
- time: tod
4735
- },
4736
- flightLevel,
4737
- windDirection,
4738
- windSpeed,
4739
- temperature: {
4740
- flightLevel,
4741
- degreesC: tempDegrees
4742
- }
4743
- };
4744
- }
4745
4740
  };
4746
4741
 
4747
4742
  // lib/plugins/Label_H1_ATIS.ts
@@ -5399,6 +5394,93 @@ var Label_H1_WRN = class extends DecoderPlugin {
5399
5394
  }
5400
5395
  };
5401
5396
 
5397
+ // lib/plugins/Label_H2_02E.ts
5398
+ var Label_H2_02E = class extends DecoderPlugin {
5399
+ name = "label-h2-02e";
5400
+ qualifiers() {
5401
+ return {
5402
+ labels: ["H2"],
5403
+ preambles: ["02E"]
5404
+ };
5405
+ }
5406
+ decode(message2, options = {}) {
5407
+ let decodeResult = this.defaultResult();
5408
+ decodeResult.decoder.name = this.name;
5409
+ decodeResult.formatted.description = "Weather Report";
5410
+ decodeResult.message = message2;
5411
+ const parts = message2.text.split(" ");
5412
+ if (parts[parts.length - 1] !== "Q") {
5413
+ decodeResult.remaining.text = message2.text;
5414
+ decodeResult.decoded = false;
5415
+ decodeResult.decoder.decodeLevel = "none";
5416
+ return decodeResult;
5417
+ }
5418
+ const windData = [];
5419
+ decodeResult.remaining.text = "";
5420
+ const header = parts[0];
5421
+ if (header.length === 45) {
5422
+ ResultFormatter.day(decodeResult, parseInt(header.substring(3, 5), 10));
5423
+ ResultFormatter.departureAirport(decodeResult, header.substring(5, 9));
5424
+ ResultFormatter.arrivalAirport(decodeResult, header.substring(9, 13));
5425
+ const firstWind = this.parseWeatherReport(header.substring(13));
5426
+ if (firstWind) {
5427
+ windData.push(firstWind);
5428
+ } else {
5429
+ decodeResult.remaining.text += (decodeResult.remaining.text ? " " : "") + header.substring(13);
5430
+ }
5431
+ }
5432
+ for (let i = 1; i < parts.length - 1; i++) {
5433
+ const part = parts[i];
5434
+ if (part[0] !== "Q") {
5435
+ decodeResult.remaining.text += (decodeResult.remaining.text ? " " : "") + part;
5436
+ continue;
5437
+ }
5438
+ const wind = this.parseWeatherReport(part.substring(1));
5439
+ if (wind) {
5440
+ windData.push(wind);
5441
+ } else {
5442
+ decodeResult.remaining.text += (decodeResult.remaining.text ? " " : "") + part;
5443
+ }
5444
+ }
5445
+ ResultFormatter.windData(decodeResult, windData);
5446
+ decodeResult.decoded = true;
5447
+ decodeResult.decoder.decodeLevel = decodeResult.remaining.text.length === 0 ? "full" : "partial";
5448
+ return decodeResult;
5449
+ }
5450
+ parseWeatherReport(text) {
5451
+ const posString = text.substring(0, 13);
5452
+ const pos = CoordinateUtils.decodeStringCoordinatesDecimalMinutes(posString);
5453
+ if (text.length !== 32 || !pos) {
5454
+ return null;
5455
+ }
5456
+ const tod = DateTimeUtils.convertHHMMSSToTod(text.substring(13, 17));
5457
+ const flightLevel = parseInt(text.substring(17, 20), 10);
5458
+ const tempSign = text[21] === "M" ? -1 : 1;
5459
+ const tempDegreesRaw = parseInt(text.substring(22, 25), 10);
5460
+ const tempDegrees = tempSign * (tempDegreesRaw / 10);
5461
+ const windDirection = parseInt(text.substring(25, 28), 10);
5462
+ const windSpeed = parseInt(text.substring(28, 31), 10);
5463
+ if (text[31] !== "G") {
5464
+ return null;
5465
+ }
5466
+ return {
5467
+ waypoint: {
5468
+ name: posString,
5469
+ latitude: pos.latitude,
5470
+ longitude: pos.longitude,
5471
+ time: tod
5472
+ },
5473
+ flightLevel,
5474
+ windDirection,
5475
+ windSpeed,
5476
+ temperature: {
5477
+ flightLevel,
5478
+ degreesC: tempDegrees
5479
+ }
5480
+ };
5481
+ }
5482
+ };
5483
+
5402
5484
  // lib/plugins/Label_HX.ts
5403
5485
  var Label_HX = class extends DecoderPlugin {
5404
5486
  name = "label-hx";
@@ -5471,8 +5553,8 @@ function ascii85Decode(input) {
5471
5553
  if (digit < 0 || digit > 84) return null;
5472
5554
  value = value * 85 + digit;
5473
5555
  }
5474
- if (chunkLen === 5 && value > 4294967295) return null;
5475
- const v = value >>> 0;
5556
+ if (value > 4294967295) return null;
5557
+ const v = value;
5476
5558
  const numBytes = chunkLen === 5 ? 4 : chunkLen - 1;
5477
5559
  if (numBytes >= 1) output.push(v >>> 24 & 255);
5478
5560
  if (numBytes >= 2) output.push(v >>> 16 & 255);
@@ -6734,7 +6816,7 @@ var pluginClasses = [
6734
6816
  Label_4T_AGFSR,
6735
6817
  Label_4T_ETA,
6736
6818
  Label_B6_Forwardslash,
6737
- Label_H2_02E,
6819
+ Label_H1_76401,
6738
6820
  Label_H1_ATIS,
6739
6821
  Label_H1_EZF,
6740
6822
  Label_H1_FLR,
@@ -6744,6 +6826,7 @@ var pluginClasses = [
6744
6826
  Label_H1_Paren,
6745
6827
  Label_H1_WRN,
6746
6828
  Label_H1_StarPOS,
6829
+ Label_H2_02E,
6747
6830
  Label_HX,
6748
6831
  Label_58,
6749
6832
  Label_80,
@@ -6789,6 +6872,9 @@ var MessageDecoder = class {
6789
6872
  this.wildcardSet.add(plugin);
6790
6873
  const wildcardInsertIndex = this.wildcardEntries.length - 1;
6791
6874
  for (const bucket of this.candidatesByLabel.values()) {
6875
+ if (bucket.some((e) => e.plugin === plugin)) {
6876
+ continue;
6877
+ }
6792
6878
  bucket.splice(wildcardInsertIndex, 0, entry);
6793
6879
  }
6794
6880
  }