@airframes/acars-decoder 1.6.1 → 1.6.3

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.d.mts CHANGED
@@ -1,2 +1,64 @@
1
+ declare class IcaoDecoder {
2
+ name: string;
3
+ icao: string;
4
+ constructor(icao: string);
5
+ isMilitary(): true | RegExpMatchArray | null;
6
+ }
1
7
 
2
- export { }
8
+ /**
9
+ * Representation of a Message
10
+ */
11
+ interface Message {
12
+ label?: string;
13
+ sublabel?: string;
14
+ text: string;
15
+ }
16
+ /**
17
+ * Decoder Options
18
+ */
19
+ interface Options {
20
+ debug?: boolean;
21
+ }
22
+ /**
23
+ * Results from decoding a message
24
+ */
25
+ interface DecodeResult {
26
+ decoded: boolean;
27
+ decoder: {
28
+ name: string;
29
+ type: 'pattern-match' | 'none';
30
+ decodeLevel: 'none' | 'partial' | 'full';
31
+ };
32
+ error?: string;
33
+ formatted: {
34
+ description: string;
35
+ items: {
36
+ type: string;
37
+ code: string;
38
+ label: string;
39
+ value: string;
40
+ }[];
41
+ };
42
+ message?: any;
43
+ raw: any;
44
+ remaining: {
45
+ text?: string;
46
+ };
47
+ }
48
+ interface DecoderPluginInterface {
49
+ decode(message: Message): DecodeResult;
50
+ meetsStateRequirements(): boolean;
51
+ qualifiers(): any;
52
+ }
53
+
54
+ declare class MessageDecoder {
55
+ name: string;
56
+ plugins: Array<DecoderPluginInterface>;
57
+ debug: boolean;
58
+ constructor();
59
+ registerPlugin(plugin: DecoderPluginInterface): boolean;
60
+ decode(message: Message, options?: Options): DecodeResult;
61
+ lookupAirportByIata(iata: string): any;
62
+ }
63
+
64
+ export { IcaoDecoder, MessageDecoder };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,64 @@
1
+ declare class IcaoDecoder {
2
+ name: string;
3
+ icao: string;
4
+ constructor(icao: string);
5
+ isMilitary(): true | RegExpMatchArray | null;
6
+ }
1
7
 
2
- export { }
8
+ /**
9
+ * Representation of a Message
10
+ */
11
+ interface Message {
12
+ label?: string;
13
+ sublabel?: string;
14
+ text: string;
15
+ }
16
+ /**
17
+ * Decoder Options
18
+ */
19
+ interface Options {
20
+ debug?: boolean;
21
+ }
22
+ /**
23
+ * Results from decoding a message
24
+ */
25
+ interface DecodeResult {
26
+ decoded: boolean;
27
+ decoder: {
28
+ name: string;
29
+ type: 'pattern-match' | 'none';
30
+ decodeLevel: 'none' | 'partial' | 'full';
31
+ };
32
+ error?: string;
33
+ formatted: {
34
+ description: string;
35
+ items: {
36
+ type: string;
37
+ code: string;
38
+ label: string;
39
+ value: string;
40
+ }[];
41
+ };
42
+ message?: any;
43
+ raw: any;
44
+ remaining: {
45
+ text?: string;
46
+ };
47
+ }
48
+ interface DecoderPluginInterface {
49
+ decode(message: Message): DecodeResult;
50
+ meetsStateRequirements(): boolean;
51
+ qualifiers(): any;
52
+ }
53
+
54
+ declare class MessageDecoder {
55
+ name: string;
56
+ plugins: Array<DecoderPluginInterface>;
57
+ debug: boolean;
58
+ constructor();
59
+ registerPlugin(plugin: DecoderPluginInterface): boolean;
60
+ decode(message: Message, options?: Options): DecodeResult;
61
+ lookupAirportByIata(iata: string): any;
62
+ }
63
+
64
+ export { IcaoDecoder, MessageDecoder };
package/dist/index.js CHANGED
@@ -204,6 +204,32 @@ var Label_5Z = class extends DecoderPlugin {
204
204
  }
205
205
  };
206
206
 
207
+ // lib/utils/coordinate_utils.ts
208
+ var CoordinateUtils = class {
209
+ static decodeStringCoordinates(stringCoords) {
210
+ var results = {};
211
+ const firstChar = stringCoords.substring(0, 1);
212
+ let middleChar = stringCoords.substring(6, 7);
213
+ let longitudeChars = stringCoords.substring(7, 13);
214
+ if (middleChar == " ") {
215
+ middleChar = stringCoords.substring(7, 8);
216
+ longitudeChars = stringCoords.substring(8, 14);
217
+ }
218
+ if ((firstChar === "N" || firstChar === "S") && (middleChar === "W" || middleChar === "E")) {
219
+ results.latitude = Number(stringCoords.substring(1, 6)) / 1e3 * (firstChar === "S" ? -1 : 1);
220
+ results.longitude = Number(longitudeChars) / 1e3 * (middleChar === "W" ? -1 : 1);
221
+ } else {
222
+ return;
223
+ }
224
+ return results;
225
+ }
226
+ static coordinateString(coords) {
227
+ const latDir = coords.latitude > 0 ? "N" : "S";
228
+ const lonDir = coords.longitude > 0 ? "E" : "W";
229
+ return `${Math.abs(coords.latitude).toFixed(3)} ${latDir}, ${Math.abs(coords.longitude).toFixed(3)} ${lonDir}`;
230
+ }
231
+ };
232
+
207
233
  // lib/plugins/Label_12_N_Space.ts
208
234
  var Label_12_N_Space = class extends DecoderPlugin {
209
235
  name = "label-12-n-space";
@@ -225,16 +251,16 @@ var Label_12_N_Space = class extends DecoderPlugin {
225
251
  console.log(`Label 12 N : results`);
226
252
  console.log(results);
227
253
  }
228
- decodeResult.raw.latitude_direction = results.groups.lat;
229
- decodeResult.raw.latitude = Number(results.groups.lat_coord);
230
- decodeResult.raw.longitude_direction = results.groups.long;
231
- decodeResult.raw.longitude = Number(results.groups.long_coord);
254
+ decodeResult.raw.position = {
255
+ latitude: Number(results.groups.lat_coord) * (results.groups.lat == "N" ? 1 : -1),
256
+ longitude: Number(results.groups.long_coord) * (results.groups.long == "E" ? 1 : -1)
257
+ };
232
258
  decodeResult.raw.flight_level = results.groups.alt == "GRD" || results.groups.alt == "***" ? "0" : Number(results.groups.alt);
233
259
  decodeResult.formatted.items.push({
234
260
  type: "aircraft_position",
235
261
  code: "POS",
236
262
  label: "Aircraft Position",
237
- value: `${results.groups.lat_coord} ${decodeResult.raw.latitude_direction}, ${results.groups.long_coord} ${decodeResult.raw.longitude_direction}`
263
+ value: CoordinateUtils.coordinateString(decodeResult.raw.position)
238
264
  });
239
265
  decodeResult.formatted.items.push({
240
266
  type: "flight_level",
@@ -257,37 +283,6 @@ var Label_12_N_Space = class extends DecoderPlugin {
257
283
  }
258
284
  };
259
285
 
260
- // lib/utils/coordinate_utils.ts
261
- var CoordinateUtils = class {
262
- static decodeStringCoordinates(stringCoords) {
263
- var results = {};
264
- const firstChar = stringCoords.substring(0, 1);
265
- let middleChar = stringCoords.substring(6, 7);
266
- let longitudeChars = stringCoords.substring(7, 13);
267
- if (middleChar == " ") {
268
- middleChar = stringCoords.substring(7, 8);
269
- longitudeChars = stringCoords.substring(8, 14);
270
- }
271
- if ((firstChar === "N" || firstChar === "S") && (middleChar === "W" || middleChar === "E")) {
272
- results.latitudeDirection = firstChar;
273
- results.latitude = Number(stringCoords.substring(1, 6)) / 1e3 * (firstChar === "S" ? -1 : 1);
274
- results.longitudeDirection = middleChar;
275
- results.longitude = Number(longitudeChars) / 1e3 * (middleChar === "W" ? -1 : 1);
276
- } else {
277
- return;
278
- }
279
- return results;
280
- }
281
- static coordinateString(coords) {
282
- return `${Math.abs(coords.latitude)} ${coords.latitudeDirection}, ${Math.abs(coords.longitude)} ${coords.longitudeDirection}`;
283
- }
284
- static latLonToCoordinateString(lat, lon) {
285
- const latDir = lat > 0 ? "N" : "S";
286
- const lonDir = lon > 0 ? "E" : "W";
287
- return `${Math.abs(lat)} ${latDir}, ${Math.abs(lon)} ${lonDir}`;
288
- }
289
- };
290
-
291
286
  // lib/plugins/Label_15.ts
292
287
  var Label_15 = class extends DecoderPlugin {
293
288
  name = "label-5z";
@@ -341,9 +336,7 @@ var Label_15_FST = class extends DecoderPlugin {
341
336
  const middleChar = stringCoords.substring(7, 8);
342
337
  decodeResult.raw.position = {};
343
338
  if ((firstChar === "N" || firstChar === "S") && (middleChar === "W" || middleChar === "E")) {
344
- decodeResult.raw.position.latitudeDirection = firstChar;
345
339
  decodeResult.raw.position.latitude = Number(stringCoords.substring(1, 7)) / 1e4 * (firstChar === "S" ? -1 : 1);
346
- decodeResult.raw.position.longitudeDirection = middleChar;
347
340
  decodeResult.raw.position.longitude = Number(stringCoords.substring(8, 26)) / 1e5 * (middleChar === "W" ? -1 : 1);
348
341
  } else {
349
342
  decodeResult.decoded = false;
@@ -395,16 +388,16 @@ var Label_16_N_Space = class extends DecoderPlugin {
395
388
  console.log(`Label 16 N : results`);
396
389
  console.log(results);
397
390
  }
398
- decodeResult.raw.latitude_direction = results.groups.lat;
399
- decodeResult.raw.latitude = Number(results.groups.lat_coord);
400
- decodeResult.raw.longitude_direction = results.groups.long;
401
- decodeResult.raw.longitude = Number(results.groups.long_coord);
391
+ decodeResult.raw.position = {
392
+ latitude: Number(results.groups.lat_coord) * (results.groups.lat == "N" ? 1 : -1),
393
+ longitude: Number(results.groups.long_coord) * (results.groups.long == "E" ? 1 : -1)
394
+ };
402
395
  decodeResult.raw.flight_level = results.groups.alt == "GRD" || results.groups.alt == "***" ? "0" : Number(results.groups.alt);
403
396
  decodeResult.formatted.items.push({
404
397
  type: "aircraft_position",
405
398
  code: "POS",
406
399
  label: "Aircraft Position",
407
- value: `${decodeResult.raw.latitude} ${decodeResult.raw.latitude_direction}, ${decodeResult.raw.longitude} ${decodeResult.raw.longitude_direction}`
400
+ value: CoordinateUtils.coordinateString(decodeResult.raw.position)
408
401
  });
409
402
  decodeResult.formatted.items.push({
410
403
  type: "flight_level",
@@ -420,15 +413,15 @@ var Label_16_N_Space = class extends DecoderPlugin {
420
413
  console.log(`Label 16 N : results`);
421
414
  console.log(results);
422
415
  }
423
- decodeResult.raw.latitude_direction = results.groups.lat;
424
- decodeResult.raw.latitude = Number(results.groups.lat_coord);
425
- decodeResult.raw.longitude_direction = results.groups.long;
426
- decodeResult.raw.longitude = Number(results.groups.long_coord);
416
+ decodeResult.raw.position = {
417
+ latitude: Number(results.groups.lat_coord) * (results.groups.lat == "N" ? 1 : -1),
418
+ longitude: Number(results.groups.long_coord) * (results.groups.long == "E" ? 1 : -1)
419
+ };
427
420
  decodeResult.formatted.items.push({
428
421
  type: "aircraft_position",
429
422
  code: "POS",
430
423
  label: "Aircraft Position",
431
- value: `${results.groups.lat_coord} ${decodeResult.raw.latitude_direction}, ${results.groups.long_coord} ${decodeResult.raw.longitude_direction}`
424
+ value: CoordinateUtils.coordinateString(decodeResult.raw.position)
432
425
  });
433
426
  decodeResult.decoded = true;
434
427
  decodeResult.decoder.decodeLevel = "full";
@@ -483,11 +476,14 @@ var DateTimeUtils = class {
483
476
  /**
484
477
  *
485
478
  * @param time HHMMSS
486
- * @param date MMDDYY
479
+ * @param date MMDDYY or MMDDYYYY
487
480
  * @returns seconds since epoch
488
481
  */
489
482
  static convertDateTimeToEpoch(time, date) {
490
- const timestamp = `20${date.substring(4, 6)}-${date.substring(0, 2)}-${date.substring(2, 4)}T${time.substring(0, 2)}:${time.substring(2, 4)}:${time.substring(4, 6)}.000Z`;
483
+ if (date.length === 6) {
484
+ date = date.substring(0, 4) + `20${date.substring(4, 6)}`;
485
+ }
486
+ 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`;
491
487
  const millis = Date.parse(timestamp);
492
488
  return millis / 1e3;
493
489
  }
@@ -579,11 +575,13 @@ var Label_20_POS = class extends DecoderPlugin {
579
575
  console.log(`DEBUG: ${this.name}: Variation 2 detected`);
580
576
  const rawCoords = fields[0];
581
577
  decodeResult.raw.position = CoordinateUtils.decodeStringCoordinates(rawCoords);
582
- decodeResult.formatted.items.push({
583
- type: "position",
584
- label: "Position",
585
- value: CoordinateUtils.coordinateString(decodeResult.raw.position)
586
- });
578
+ if (decodeResult.raw.position) {
579
+ decodeResult.formatted.items.push({
580
+ type: "position",
581
+ label: "Position",
582
+ value: CoordinateUtils.coordinateString(decodeResult.raw.position)
583
+ });
584
+ }
587
585
  decodeResult.decoded = true;
588
586
  decodeResult.decoder.decodeLevel = "full";
589
587
  } else {
@@ -1089,7 +1087,7 @@ var Label_80 = class extends DecoderPlugin {
1089
1087
  const lon = Number(posResult.groups.lng) * (posResult.groups.lngd === "W" ? -1 : 1);
1090
1088
  const latitude = Number.isInteger(lat) ? lat / 1e3 : lat / 100;
1091
1089
  const longitude = Number.isInteger(lon) ? lon / 1e3 : lon / 100;
1092
- decodeResult.raw.aircraft_position = {
1090
+ decodeResult.raw.position = {
1093
1091
  latitude,
1094
1092
  longitude
1095
1093
  };
@@ -1097,7 +1095,7 @@ var Label_80 = class extends DecoderPlugin {
1097
1095
  type: "position",
1098
1096
  code: "POS",
1099
1097
  label: "Position",
1100
- value: `${Math.abs(latitude).toPrecision(5)} ${posResult.groups.latd}, ${Math.abs(longitude).toPrecision(5)} ${posResult.groups.lngd}`
1098
+ value: CoordinateUtils.coordinateString(decodeResult.raw.position)
1101
1099
  });
1102
1100
  break;
1103
1101
  }
@@ -1240,7 +1238,7 @@ var RouteUtils = class _RouteUtils {
1240
1238
  static waypointToString(waypoint) {
1241
1239
  let s = waypoint.name;
1242
1240
  if (waypoint.latitude && waypoint.longitude) {
1243
- s += `(${CoordinateUtils.latLonToCoordinateString(waypoint.latitude, waypoint.longitude)})`;
1241
+ s += `(${CoordinateUtils.coordinateString({ latitude: waypoint.latitude, longitude: waypoint.longitude })})`;
1244
1242
  }
1245
1243
  if (waypoint.time && waypoint.timeFormat) {
1246
1244
  s += `@${_RouteUtils.timestampToString(waypoint.time, waypoint.timeFormat)}`;
@@ -1251,11 +1249,15 @@ var RouteUtils = class _RouteUtils {
1251
1249
  const waypoint = leg.split(",");
1252
1250
  if (waypoint.length == 2) {
1253
1251
  const position = CoordinateUtils.decodeStringCoordinates(waypoint[1]);
1254
- return { name: waypoint[0], latitude: position.latitude, longitude: position.longitude };
1252
+ if (position) {
1253
+ return { name: waypoint[0], latitude: position.latitude, longitude: position.longitude };
1254
+ }
1255
1255
  }
1256
1256
  if (leg.length == 14) {
1257
1257
  const position = CoordinateUtils.decodeStringCoordinates(leg);
1258
- return { name: waypoint[0], latitude: position.latitude, longitude: position.longitude };
1258
+ if (position) {
1259
+ return { name: waypoint[0], latitude: position.latitude, longitude: position.longitude };
1260
+ }
1259
1261
  }
1260
1262
  return { name: leg };
1261
1263
  }
@@ -1508,7 +1510,6 @@ var Label_H1_POS = class extends DecoderPlugin {
1508
1510
  decodeResult.message = message;
1509
1511
  const checksum = message.text.slice(-4);
1510
1512
  const parts = message.text.replace("#M1B", "").replace("POS", "").slice(0, -4).split(",");
1511
- console.log(parts);
1512
1513
  if (parts.length == 1 && parts[0].startsWith("/RF")) {
1513
1514
  decodeResult.raw.route_status == "RF";
1514
1515
  decodeResult.formatted.items.push({
@@ -1564,6 +1565,40 @@ var Label_H1_POS = class extends DecoderPlugin {
1564
1565
  processChecksum(decodeResult, checksum);
1565
1566
  decodeResult.decoded = true;
1566
1567
  decodeResult.decoder.decodeLevel = "partial";
1568
+ } else if (parts.length === 15) {
1569
+ decodeResult.remaining.text = "";
1570
+ processUnknown(decodeResult, parts[0]);
1571
+ processUnknown(decodeResult, parts[1]);
1572
+ let date = void 0;
1573
+ if (parts[2].startsWith("/DC")) {
1574
+ date = parts[2].substring(3);
1575
+ } else {
1576
+ processUnknown(decodeResult, parts[2]);
1577
+ }
1578
+ processUnknown(decodeResult, parts[3]);
1579
+ const fields = parts[4].split("/");
1580
+ for (let i = 0; i < fields.length; ++i) {
1581
+ const field = fields[i];
1582
+ if (field.startsWith("PS")) {
1583
+ processPosition(decodeResult, field.substring(2));
1584
+ } else {
1585
+ if (i === 0) {
1586
+ processUnknown(decodeResult, field);
1587
+ } else {
1588
+ processUnknown(decodeResult, "/" + field);
1589
+ }
1590
+ }
1591
+ }
1592
+ processRoute(decodeResult, parts[7], parts[5], parts[9], parts[8], void 0, date);
1593
+ processAlt(decodeResult, parts[6]);
1594
+ processTemp(decodeResult, parts[10]);
1595
+ processUnknown(decodeResult, parts[11]);
1596
+ processUnknown(decodeResult, parts[12]);
1597
+ processUnknown(decodeResult, parts[13]);
1598
+ processUnknown(decodeResult, parts[14]);
1599
+ processChecksum(decodeResult, checksum);
1600
+ decodeResult.decoded = true;
1601
+ decodeResult.decoder.decodeLevel = "partial";
1567
1602
  } else if (parts.length === 32) {
1568
1603
  decodeResult.remaining.text = "";
1569
1604
  processPosition(decodeResult, parts[0]);
@@ -1584,7 +1619,7 @@ var Label_H1_POS = class extends DecoderPlugin {
1584
1619
  processAlt(decodeResult, parts[22]);
1585
1620
  processUnknown(decodeResult, parts.slice(23, 31).join(","));
1586
1621
  const allProcessed = FlightPlanUtils.processFlightPlan(decodeResult, (parts[31] + checksum).split(":"));
1587
- processRoute(decodeResult, past, time, next, eta, "?");
1622
+ processRoute(decodeResult, past, time, next, eta);
1588
1623
  decodeResult.decoded = true;
1589
1624
  decodeResult.decoder.decodeLevel = "partial";
1590
1625
  } else {
@@ -1603,16 +1638,15 @@ function processUnknown(decodeResult, value) {
1603
1638
  }
1604
1639
  function processPosition(decodeResult, value) {
1605
1640
  const position = CoordinateUtils.decodeStringCoordinates(value);
1606
- decodeResult.raw.latitude_direction = position.latitudeDirection;
1607
- decodeResult.raw.latitude = Math.abs(position.latitude);
1608
- decodeResult.raw.longitude_direction = position.longitudeDirection;
1609
- decodeResult.raw.longitude = Math.abs(position.longitude);
1610
- decodeResult.formatted.items.push({
1611
- type: "aircraft_position",
1612
- code: "POS",
1613
- label: "Aircraft Position",
1614
- value: CoordinateUtils.coordinateString(position)
1615
- });
1641
+ if (position) {
1642
+ decodeResult.raw.position = position;
1643
+ decodeResult.formatted.items.push({
1644
+ type: "aircraft_position",
1645
+ code: "POS",
1646
+ label: "Aircraft Position",
1647
+ value: CoordinateUtils.coordinateString(position)
1648
+ });
1649
+ }
1616
1650
  }
1617
1651
  function processAlt(decodeResult, value) {
1618
1652
  decodeResult.raw.altitude = Number(value) * 100;
@@ -1650,16 +1684,14 @@ function processGndspd(decodeResult, value) {
1650
1684
  });
1651
1685
  }
1652
1686
  function processRoute(decodeResult, last, time, next, eta, then, date) {
1653
- let waypoints;
1654
- waypoints = date === void 0 ? [
1655
- { name: last || "?,", time: DateTimeUtils.convertHHMMSSToTod(time), timeFormat: "tod" },
1656
- { name: next || "?", time: DateTimeUtils.convertHHMMSSToTod(eta), timeFormat: "tod" },
1657
- { name: then || "?" }
1658
- ] : [
1659
- { name: last || "?,", time: DateTimeUtils.convertDateTimeToEpoch(time, date), timeFormat: "epoch" },
1660
- { name: next || "?", time: DateTimeUtils.convertDateTimeToEpoch(eta, date), timeFormat: "epoch" },
1661
- { name: then || "?" }
1662
- ];
1687
+ const lastCoords = CoordinateUtils.decodeStringCoordinates(last);
1688
+ const nextCoords = CoordinateUtils.decodeStringCoordinates(next);
1689
+ const lastTime = date ? DateTimeUtils.convertDateTimeToEpoch(time, date) : DateTimeUtils.convertHHMMSSToTod(time);
1690
+ const nextTime = date ? DateTimeUtils.convertDateTimeToEpoch(eta, date) : DateTimeUtils.convertHHMMSSToTod(eta);
1691
+ const timeFormat = date ? "epoch" : "tod";
1692
+ const lastWaypoint = lastCoords ? { name: "", latitude: lastCoords.latitude, longitude: lastCoords.longitude, time: lastTime, timeFormat } : { name: last, time: lastTime, timeFormat };
1693
+ const nextWaypoint = nextCoords ? { name: "", latitude: nextCoords.latitude, longitude: nextCoords.longitude, time: nextTime, timeFormat } : { name: next, time: nextTime, timeFormat };
1694
+ const waypoints = [lastWaypoint, nextWaypoint, { name: then || "?" }];
1663
1695
  decodeResult.raw.route = { waypoints };
1664
1696
  decodeResult.formatted.items.push({
1665
1697
  type: "aircraft_route",
@@ -1678,6 +1710,62 @@ function processChecksum(decodeResult, value) {
1678
1710
  });
1679
1711
  }
1680
1712
 
1713
+ // lib/plugins/Label_H1_WRN.ts
1714
+ var Label_H1_WRN = class extends DecoderPlugin {
1715
+ name = "label-h1-wrn";
1716
+ qualifiers() {
1717
+ return {
1718
+ labels: ["H1"],
1719
+ preambles: ["WRN", "#CFBWRN"]
1720
+ };
1721
+ }
1722
+ decode(message, options = {}) {
1723
+ let decodeResult = this.defaultResult;
1724
+ decodeResult.decoder.name = this.name;
1725
+ decodeResult.formatted.description = "Warning Message";
1726
+ decodeResult.message = message;
1727
+ const parts = message.text.split("/WN");
1728
+ if (parts.length > 1) {
1729
+ decodeResult.remaining.text = "";
1730
+ const fields = parts[0].split("/");
1731
+ for (let i = 1; i < fields.length; i++) {
1732
+ const field = fields[i];
1733
+ if (field.startsWith("PN")) {
1734
+ processUnknown2(decodeResult, "/" + field);
1735
+ } else {
1736
+ processUnknown2(decodeResult, "/" + field);
1737
+ }
1738
+ }
1739
+ const data = parts[1].substring(0, 20);
1740
+ const msg = parts[1].substring(20);
1741
+ const datetime = data.substring(0, 12);
1742
+ const date = datetime.substring(4, 6) + datetime.substring(2, 4) + datetime.substring(0, 2);
1743
+ processUnknown2(decodeResult, data.substring(12));
1744
+ decodeResult.raw.message_timestamp = DateTimeUtils.convertDateTimeToEpoch(datetime.substring(6), date);
1745
+ decodeResult.raw.warning_message = msg;
1746
+ decodeResult.formatted.items.push({
1747
+ type: "warning",
1748
+ code: "WRN",
1749
+ label: "Warning Message",
1750
+ value: decodeResult.raw.warning_message
1751
+ });
1752
+ decodeResult.decoded = true;
1753
+ decodeResult.decoder.decodeLevel = "partial";
1754
+ } else {
1755
+ if (options.debug) {
1756
+ console.log(`Decoder: Unknown H1 message: ${message.text}`);
1757
+ }
1758
+ decodeResult.remaining.text = message.text;
1759
+ decodeResult.decoded = false;
1760
+ decodeResult.decoder.decodeLevel = "none";
1761
+ }
1762
+ return decodeResult;
1763
+ }
1764
+ };
1765
+ function processUnknown2(decodeResult, value) {
1766
+ decodeResult.remaining.text += value;
1767
+ }
1768
+
1681
1769
  // lib/plugins/Label_SQ.ts
1682
1770
  var Label_SQ = class extends DecoderPlugin {
1683
1771
  name = "label-sq";
@@ -2781,6 +2869,7 @@ var MessageDecoder = class {
2781
2869
  this.registerPlugin(new Label_B6_Forwardslash(this));
2782
2870
  this.registerPlugin(new Label_H1_FPN(this));
2783
2871
  this.registerPlugin(new Label_H1_POS(this));
2872
+ this.registerPlugin(new Label_H1_WRN(this));
2784
2873
  this.registerPlugin(new Label_80(this));
2785
2874
  this.registerPlugin(new Label_8E(this));
2786
2875
  this.registerPlugin(new Label_1M_Slash(this));