@airframes/acars-decoder 1.8.8 → 1.8.9

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
@@ -253,14 +253,14 @@ var DateTimeUtils = class {
253
253
  /**
254
254
  *
255
255
  * @param time HHMMSS
256
- * @param date MMDDYY or MMDDYYYY
256
+ * @param date DDMMYY or DDMMYYYY
257
257
  * @returns seconds since epoch
258
258
  */
259
259
  static convertDateTimeToEpoch(time, date) {
260
260
  if (date.length === 6) {
261
261
  date = date.substring(0, 4) + `20${date.substring(4, 6)}`;
262
262
  }
263
- const timestamp = `${date.substring(4, 8)}-${date.substring(0, 2)}-${date.substring(2, 4)}T${time.substring(0, 2)}:${time.substring(2, 4)}:${time.substring(4, 6)}.000Z`;
263
+ const timestamp = `${date.substring(4, 8)}-${date.substring(2, 4)}-${date.substring(0, 2)}T${time.substring(0, 2)}:${time.substring(2, 4)}:${time.substring(4, 6)}.000Z`;
264
264
  const millis = Date.parse(timestamp);
265
265
  return millis / 1e3;
266
266
  }
@@ -643,6 +643,20 @@ var ResultFormatter = class {
643
643
  value: `${decodeResult.raw.outside_air_temperature} degrees`
644
644
  });
645
645
  }
646
+ static totalAirTemp(decodeResult, value) {
647
+ if (value.length === 0) {
648
+ return;
649
+ }
650
+ decodeResult.raw.total_air_temperature = Number(
651
+ value.replace("M", "-").replace("P", "+")
652
+ );
653
+ decodeResult.formatted.items.push({
654
+ type: "temperature",
655
+ code: "TATEMP",
656
+ label: "Total Air Temperature (C)",
657
+ value: `${decodeResult.raw.total_air_temperature} degrees`
658
+ });
659
+ }
646
660
  static heading(decodeResult, value) {
647
661
  decodeResult.raw.heading = value;
648
662
  decodeResult.formatted.items.push({
@@ -906,6 +920,15 @@ var ResultFormatter = class {
906
920
  value: `${decodeResult.raw.ground_address}`
907
921
  });
908
922
  }
923
+ static timestamp(decodeResult, value) {
924
+ decodeResult.raw.message_timestamp = value;
925
+ decodeResult.formatted.items.push({
926
+ type: "epoch",
927
+ code: "TIMESTAMP",
928
+ label: "Message Timestamp",
929
+ value: DateTimeUtils.timestampToString(value, "epoch")
930
+ });
931
+ }
909
932
  static unknown(decodeResult, value, sep = ",") {
910
933
  if (!decodeResult.remaining.text) decodeResult.remaining.text = value;
911
934
  else decodeResult.remaining.text += sep + value;
@@ -1508,10 +1531,9 @@ var Label_15 = class extends DecoderPlugin {
1508
1531
  const ddmmyy = between.substring(16, 22);
1509
1532
  const hhmm = between.substring(22, 26);
1510
1533
  if (ddmmyy != "------") {
1511
- const mmddyy = ddmmyy.substring(2, 4) + ddmmyy.substring(0, 2) + ddmmyy.substring(4);
1512
1534
  ResultFormatter.off(
1513
1535
  decodeResult,
1514
- DateTimeUtils.convertDateTimeToEpoch(hhmm + "00", mmddyy),
1536
+ DateTimeUtils.convertDateTimeToEpoch(hhmm + "00", ddmmyy),
1515
1537
  "epoch"
1516
1538
  );
1517
1539
  } else {
@@ -2305,6 +2327,8 @@ function processMessageType(decodeResult, type) {
2305
2327
  decodeResult.formatted.description = "Free Text";
2306
2328
  } else if (type === "INI") {
2307
2329
  decodeResult.formatted.description = "Initial Report";
2330
+ } else if (type === "INR") {
2331
+ decodeResult.formatted.description = "In-Range Report";
2308
2332
  } else if (type === "LDI") {
2309
2333
  decodeResult.formatted.description = "Load Distribution Information";
2310
2334
  } else if (type === "PER") {
@@ -2315,6 +2339,8 @@ function processMessageType(decodeResult, type) {
2315
2339
  decodeResult.formatted.description = "Progress Report";
2316
2340
  } else if (type === "PWI") {
2317
2341
  decodeResult.formatted.description = "Pilot Weather Information";
2342
+ } else if (type === "WXR") {
2343
+ decodeResult.formatted.description = "Weather Report";
2318
2344
  } else if (type === "REJ") {
2319
2345
  decodeResult.formatted.description = "Reject";
2320
2346
  } else if (type === "REQ") {
@@ -2328,7 +2354,6 @@ function processMessageType(decodeResult, type) {
2328
2354
  return true;
2329
2355
  }
2330
2356
  function processDateCode(decodeResult, data) {
2331
- decodeResult.raw.message_date = data[0];
2332
2357
  if (data.length === 1) {
2333
2358
  } else if (data.length === 2) {
2334
2359
  const date = data[0].substring(2, 4) + data[0].substring(0, 2) + data[0].substring(4, 6);
@@ -2522,7 +2547,7 @@ var Label_1M_Slash = class extends DecoderPlugin {
2522
2547
  decodeResult,
2523
2548
  DateTimeUtils.convertDateTimeToEpoch(
2524
2549
  results[7] + "00",
2525
- yymmdd.substring(2, 4) + yymmdd.substring(4, 6) + yymmdd.substring(0, 2)
2550
+ yymmdd.substring(4, 6) + yymmdd.substring(2, 4) + yymmdd.substring(0, 2)
2526
2551
  ),
2527
2552
  "epoch"
2528
2553
  );
@@ -3307,11 +3332,11 @@ var Label_24_Slash = class extends DecoderPlugin {
3307
3332
  decodeResult.message = message;
3308
3333
  const fields = message.text.split("/");
3309
3334
  if (fields.length == 10 && fields[0] == "" && fields[9] == "") {
3310
- const mmddyy = fields[1].substring(4, 6) + fields[1].substring(2, 4) + fields[1].substring(0, 2);
3335
+ const ddmmyy = fields[1].substring(2, 4) + fields[1].substring(4, 6) + fields[1].substring(0, 2);
3311
3336
  const hhmmss = fields[2] + "00";
3312
3337
  decodeResult.raw.message_timestamp = DateTimeUtils.convertDateTimeToEpoch(
3313
3338
  hhmmss,
3314
- mmddyy
3339
+ ddmmyy
3315
3340
  );
3316
3341
  ResultFormatter.flightNumber(decodeResult, fields[3]);
3317
3342
  ResultFormatter.altitude(decodeResult, Number(fields[4]));