secs4js 0.4.1 → 0.4.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.
Files changed (39) hide show
  1. package/LICENSE.md +20 -20
  2. package/lib/core/AbstractSecsCommunicator.d.ts.map +1 -1
  3. package/lib/core/AbstractSecsCommunicator.js +9 -6
  4. package/lib/core/AbstractSecsCommunicator.js.map +1 -1
  5. package/lib/core/AbstractSecsMessage.js.map +1 -1
  6. package/lib/core/enums/HsmsSsControlType.js.map +1 -1
  7. package/lib/core/enums/RejectReason.js.map +1 -1
  8. package/lib/core/enums/SecsItemType.js.map +1 -1
  9. package/lib/core/enums/SelectStatus.js.map +1 -1
  10. package/lib/core/secs2item/AbstractSecs2Item.js.map +1 -1
  11. package/lib/core/secs2item/Secs2ItemAscii.js.map +1 -1
  12. package/lib/core/secs2item/Secs2ItemBinary.js.map +1 -1
  13. package/lib/core/secs2item/Secs2ItemBoolean.js.map +1 -1
  14. package/lib/core/secs2item/Secs2ItemFactory.js.map +1 -1
  15. package/lib/core/secs2item/Secs2ItemList.js.map +1 -1
  16. package/lib/core/secs2item/Secs2ItemNumeric.js.map +1 -1
  17. package/lib/core/secs2item/Secs2ItemParser.js.map +1 -1
  18. package/lib/gem/Clock.js.map +1 -1
  19. package/lib/gem/Gem.js.map +1 -1
  20. package/lib/helper/Secs2ItemHelper.js.map +1 -1
  21. package/lib/hsms/HsmsCommunicator.d.ts.map +1 -1
  22. package/lib/hsms/HsmsCommunicator.js +1 -1
  23. package/lib/hsms/HsmsCommunicator.js.map +1 -1
  24. package/lib/hsms/HsmsMessage.js.map +1 -1
  25. package/lib/hsms/HsmsPassiveCommunicator.js.map +1 -1
  26. package/lib/hsms/enums/HsmsControlType.js.map +1 -1
  27. package/lib/hsms/enums/RejectReason.js.map +1 -1
  28. package/lib/hsms/enums/SelectStatus.js.map +1 -1
  29. package/lib/index.d.ts +2 -1
  30. package/lib/index.js +2 -1
  31. package/lib/logging/SecsLogger.d.ts +1 -1
  32. package/lib/logging/SecsLogger.d.ts.map +1 -1
  33. package/lib/logging/SecsLogger.js +20 -9
  34. package/lib/logging/SecsLogger.js.map +1 -1
  35. package/lib/secs1/Secs1Message.js.map +1 -1
  36. package/lib/secs1/Secs1MessageBlock.js.map +1 -1
  37. package/lib/secs1/Secs1SerialCommunicator.js.map +1 -1
  38. package/lib/sml/SmlParser.js.map +1 -1
  39. package/package.json +2 -2
package/LICENSE.md CHANGED
@@ -1,20 +1,20 @@
1
- # MIT License
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- 'Software'), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ # MIT License
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ 'Software'), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractSecsCommunicator.d.ts","names":[],"sources":["../../src/core/AbstractSecsCommunicator.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAWA;AAoBA;AAeA;;AACgB,UApCC,sBAAA,CAoCD;EAAkC,OAAA,EAAA,CAnCvC,WAmCuC,CAAA;EAChD,KAAA,EAAA,CAnCO,KAmCP,CAAA;EAK0B,SAAA,EAAA,EAAA;EAeV,YAAA,EAAA,EAAA;;;;;;;;;;;;;;;AAoEN,UAzGK,sBAAA,CAyGL;EAAR,QAAA,EAAA,MAAA;EAkEU,OAAA,EAAA,OAAA;EAGN,IAAA,CAAA,EAAA,MAAA;EACJ,GAAA,CAAA,EA3KG,gBA2KH;EAmC0B,SAAA,CAAA,EAAA,MAAA;EAhMpB,SAAA,CAAA,EAAA,MAAA;EAAY,SAAA,CAAA,EAAA,MAAA;;;;;;;uBAHA,wCACN,aAAa,qBAAqB,yBAChD,gCACQ,YAAA;;;;6BAIkB;;;;;;;;;;2BAYJ;mBAGN;kBACD;WACP,MAAA,CAAO;;sBAII;mBAoBH;oBACC;;wCAgBoB,SAAS;yFAKtC,eACD,0BACL;sFASI,gDAEJ;2DAMI,2BACJ,QAAQ;oBAkEE,kDAGN,2BACJ;;+BAmC0B"}
1
+ {"version":3,"file":"AbstractSecsCommunicator.d.ts","names":[],"sources":["../../src/core/AbstractSecsCommunicator.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAWA;AAoBA;AAeA;;AACgB,UApCC,sBAAA,CAoCD;EAAkC,OAAA,EAAA,CAnCvC,WAmCuC,CAAA;EAChD,KAAA,EAAA,CAnCO,KAmCP,CAAA;EAK0B,SAAA,EAAA,EAAA;EAeV,YAAA,EAAA,EAAA;;;;;;;;;;;;;;;AAoEN,UAzGK,sBAAA,CAyGL;EAAR,QAAA,EAAA,MAAA;EAmEU,OAAA,EAAA,OAAA;EAGN,IAAA,CAAA,EAAA,MAAA;EACJ,GAAA,CAAA,EA5KG,gBA4KH;EA0C0B,SAAA,CAAA,EAAA,MAAA;EAxMpB,SAAA,CAAA,EAAA,MAAA;EAAY,SAAA,CAAA,EAAA,MAAA;;;;;;;uBAHA,wCACN,aAAa,qBAAqB,yBAChD,gCACQ,YAAA;;;;6BAIkB;;;;;;;;;;2BAYJ;mBAGN;kBACD;WACP,MAAA,CAAO;;sBAII;mBAoBH;oBACC;;wCAgBoB,SAAS;yFAKtC,eACD,0BACL;sFASI,gDAEJ;2DAMI,2BACJ,QAAQ;oBAmEE,kDAGN,2BACJ;;+BA0C0B"}
@@ -47,7 +47,8 @@ var AbstractSecsCommunicator = class extends EventEmitter {
47
47
  const systemBytes = this.getNextSystemBytes();
48
48
  const msg = this.createMessage(stream, func, wBit, body, systemBytes);
49
49
  const sml = msg.toSml();
50
- this.logger.logSecs2("Sent", sml);
50
+ const buffer = msg.toBuffer();
51
+ this.logger.logSecs2("Sent", sml, this.deviceId, systemBytes, buffer);
51
52
  this.logger.detail.debug({
52
53
  protocol: "SECS",
53
54
  dir: "Sent",
@@ -69,7 +70,7 @@ var AbstractSecsCommunicator = class extends EventEmitter {
69
70
  reject,
70
71
  timer
71
72
  });
72
- this.sendBufferWithLogs("Sent", "SECS", msg.toBuffer(), {
73
+ this.sendBufferWithLogs("Sent", "SECS", buffer, {
73
74
  stream,
74
75
  func,
75
76
  wBit,
@@ -88,7 +89,7 @@ var AbstractSecsCommunicator = class extends EventEmitter {
88
89
  });
89
90
  });
90
91
  else {
91
- await this.sendBufferWithLogs("Sent", "SECS", msg.toBuffer(), {
92
+ await this.sendBufferWithLogs("Sent", "SECS", buffer, {
92
93
  stream,
93
94
  func,
94
95
  wBit,
@@ -100,7 +101,8 @@ var AbstractSecsCommunicator = class extends EventEmitter {
100
101
  async reply(primaryMsg, stream, func, body = null) {
101
102
  const msg = this.createMessage(stream, func, false, body, primaryMsg.systemBytes);
102
103
  const sml = msg.toSml();
103
- this.logger.logSecs2("Sent", sml);
104
+ const buffer = msg.toBuffer();
105
+ this.logger.logSecs2("Sent", sml, this.deviceId, primaryMsg.systemBytes, buffer);
104
106
  this.logger.detail.debug({
105
107
  protocol: "SECS",
106
108
  dir: "Sent",
@@ -110,7 +112,7 @@ var AbstractSecsCommunicator = class extends EventEmitter {
110
112
  systemBytes: primaryMsg.systemBytes,
111
113
  sml
112
114
  }, "sml");
113
- await this.sendBufferWithLogs("Sent", "SECS", msg.toBuffer(), {
115
+ await this.sendBufferWithLogs("Sent", "SECS", buffer, {
114
116
  stream,
115
117
  func,
116
118
  wBit: false,
@@ -123,7 +125,8 @@ var AbstractSecsCommunicator = class extends EventEmitter {
123
125
  }
124
126
  handleMessage(msg) {
125
127
  const sml = msg.toSml();
126
- this.logger.logSecs2("Received", sml);
128
+ const buffer = msg.toBuffer();
129
+ this.logger.logSecs2("Received", sml, this.deviceId, msg.systemBytes, buffer);
127
130
  this.logger.detail.debug({
128
131
  protocol: "SECS",
129
132
  dir: "Received",
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractSecsCommunicator.js","names":[],"sources":["../../src/core/AbstractSecsCommunicator.ts"],"sourcesContent":["import { EventEmitter } from \"events\";\nimport { SecsMessage } from \"./AbstractSecsMessage.js\";\nimport { AbstractSecs2Item } from \"./secs2item/AbstractSecs2Item.js\";\nimport { SecsLogger, type SecsLoggerConfig } from \"../logging/SecsLogger.js\";\n\n/**\n * @param message The message received.\n * @param error The error occurred.\n * @param connected The connection is established.\n * @param disconnected The connection is closed.\n */\nexport interface SecsCommunicatorEvents {\n\tmessage: [SecsMessage];\n\terror: [Error];\n\tconnected: [];\n\tdisconnected: [];\n}\n\n/**\n * @param deviceId The device ID.\n * @param isEquip Whether the device is an equip.\n * @param name The name of the connection.\n * @param timeoutT1 Only SECS-I supports this parameter, ENQ retransmission interval.\n * @param timeoutT2 Only SECS-I supports this parameter, ENQ wait-for-response timeout.\n * @param timeoutT3 Support SECS-I and SECS-II, W-Bit timeout.\n * @param timeoutT4 Only SECS-I supports this parameter, data block retransmission interval.\n * @param timeoutT5 Support SECS-I and SECS-II, establishment of communication session timeout.\n * @param timeoutT6 Only HSMS supports this parameter, reply control message timeout.\n * @param timeoutT7 Only HSMS supports this parameter, create connection timeout.\n * @param timeoutT8 Only HSMS supports this parameter, the maximum time interval between message bytes when receiving a message\n */\nexport interface SecsCommunicatorConfig {\n\tdeviceId: number;\n\tisEquip: boolean;\n\tname?: string;\n\tlog?: SecsLoggerConfig;\n\ttimeoutT1?: number;\n\ttimeoutT2?: number;\n\ttimeoutT3?: number;\n\ttimeoutT4?: number;\n\ttimeoutT5?: number;\n\ttimeoutT6?: number;\n\ttimeoutT7?: number;\n\ttimeoutT8?: number;\n}\n\nexport abstract class AbstractSecsCommunicator<\n\tEvents extends Record<keyof Events, unknown[]> & SecsCommunicatorEvents =\n\t\tSecsCommunicatorEvents,\n> extends EventEmitter {\n\tpublic readonly deviceId: number;\n\tpublic readonly isEquip: boolean;\n\tpublic readonly name: string;\n\tprotected readonly logger: SecsLogger;\n\n\tpublic timeoutT1 = 1;\n\tpublic timeoutT2 = 15;\n\tpublic timeoutT3 = 45;\n\tpublic timeoutT4 = 45;\n\tpublic timeoutT5 = 10;\n\tpublic timeoutT6 = 5;\n\tpublic timeoutT7 = 10;\n\tpublic timeoutT8 = 5;\n\n\tprotected _systemBytesCounter = 0;\n\tprotected _transactions = new Map<\n\t\tnumber,\n\t\t{\n\t\t\tresolve: (msg: SecsMessage) => void;\n\t\t\treject: (err: Error) => void;\n\t\t\ttimer: NodeJS.Timeout;\n\t\t}\n\t>();\n\n\tconstructor(config: SecsCommunicatorConfig) {\n\t\tsuper();\n\t\tthis.deviceId = config.deviceId;\n\t\tthis.isEquip = config.isEquip;\n\t\tthis.name = config.name ?? \"SecsCommunicator\";\n\t\tif (config.timeoutT1 !== undefined) this.timeoutT1 = config.timeoutT1;\n\t\tif (config.timeoutT2 !== undefined) this.timeoutT2 = config.timeoutT2;\n\t\tif (config.timeoutT3 !== undefined) this.timeoutT3 = config.timeoutT3;\n\t\tif (config.timeoutT4 !== undefined) this.timeoutT4 = config.timeoutT4;\n\t\tif (config.timeoutT5 !== undefined) this.timeoutT5 = config.timeoutT5;\n\t\tif (config.timeoutT6 !== undefined) this.timeoutT6 = config.timeoutT6;\n\t\tif (config.timeoutT7 !== undefined) this.timeoutT7 = config.timeoutT7;\n\t\tif (config.timeoutT8 !== undefined) this.timeoutT8 = config.timeoutT8;\n\t\tthis.logger = SecsLogger.create(config.log, {\n\t\t\tname: this.name,\n\t\t\tdeviceId: this.deviceId,\n\t\t\tisEquip: this.isEquip,\n\t\t});\n\t}\n\n\tabstract open(): Promise<void>;\n\tabstract close(): Promise<void>;\n\n\tprotected emitInternal(\n\t\teventName: string | symbol,\n\t\t...args: unknown[]\n\t): boolean {\n\t\treturn (\n\t\t\tsuper.emit as (\n\t\t\t\tthis: AbstractSecsCommunicator<Events>,\n\t\t\t\teventName: string | symbol,\n\t\t\t\t...args: unknown[]\n\t\t\t) => boolean\n\t\t).call(this, eventName, ...args);\n\t}\n\n\t// This method sends the message bytes. To be implemented by subclasses.\n\tprotected abstract sendBuffer(buffer: Buffer): Promise<void>;\n\n\tprotected async sendBufferWithLogs(\n\t\tdirection: \"Sent\" | \"Received\",\n\t\tprotocol: string,\n\t\tbuffer: Buffer,\n\t\tmeta?: Record<string, unknown>,\n\t): Promise<void> {\n\t\tthis.logger.logBytes(direction, protocol, buffer, meta);\n\t\tawait this.sendBuffer(buffer);\n\t}\n\n\tprotected abstract createMessage(\n\t\tstream: number,\n\t\tfunc: number,\n\t\twBit: boolean,\n\t\tbody: AbstractSecs2Item | null,\n\t\tsystemBytes: number,\n\t): SecsMessage;\n\n\tasync send(\n\t\tstream: number,\n\t\tfunc: number,\n\t\twBit: boolean,\n\t\tbody: AbstractSecs2Item | null = null,\n\t): Promise<SecsMessage | null> {\n\t\tconst systemBytes = this.getNextSystemBytes();\n\t\tconst msg = this.createMessage(stream, func, wBit, body, systemBytes);\n\t\tconst sml = msg.toSml();\n\t\tthis.logger.logSecs2(\"Sent\", sml);\n\t\tthis.logger.detail.debug(\n\t\t\t{\n\t\t\t\tprotocol: \"SECS\",\n\t\t\t\tdir: \"Sent\",\n\t\t\t\tstream,\n\t\t\t\tfunc,\n\t\t\t\twBit,\n\t\t\t\tsystemBytes,\n\t\t\t\tsml,\n\t\t\t},\n\t\t\t\"sml\",\n\t\t);\n\n\t\tif (wBit) {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tconst timer = setTimeout(() => {\n\t\t\t\t\tif (this._transactions.has(systemBytes)) {\n\t\t\t\t\t\tthis._transactions.delete(systemBytes);\n\t\t\t\t\t\treject(\n\t\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t\t`T3 Timeout waiting for reply to S${String(stream)}F${String(func)} [SysBytes=${String(systemBytes)}]`,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}, this.timeoutT3 * 1000);\n\n\t\t\t\tthis._transactions.set(systemBytes, { resolve, reject, timer });\n\n\t\t\t\tthis.sendBufferWithLogs(\"Sent\", \"SECS\", msg.toBuffer(), {\n\t\t\t\t\tstream,\n\t\t\t\t\tfunc,\n\t\t\t\t\twBit,\n\t\t\t\t\tsystemBytes,\n\t\t\t\t}).catch((err: unknown) => {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tthis._transactions.delete(systemBytes);\n\t\t\t\t\tthis.logger.detail.error(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\terr: err instanceof Error ? err : new Error(String(err)),\n\t\t\t\t\t\t\tstream,\n\t\t\t\t\t\t\tfunc,\n\t\t\t\t\t\t\twBit,\n\t\t\t\t\t\t\tsystemBytes,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"send failed\",\n\t\t\t\t\t);\n\t\t\t\t\treject(err instanceof Error ? err : new Error(String(err)));\n\t\t\t\t});\n\t\t\t});\n\t\t} else {\n\t\t\tawait this.sendBufferWithLogs(\"Sent\", \"SECS\", msg.toBuffer(), {\n\t\t\t\tstream,\n\t\t\t\tfunc,\n\t\t\t\twBit,\n\t\t\t\tsystemBytes,\n\t\t\t});\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tasync reply(\n\t\tprimaryMsg: SecsMessage,\n\t\tstream: number,\n\t\tfunc: number,\n\t\tbody: AbstractSecs2Item | null = null,\n\t): Promise<void> {\n\t\tconst msg = this.createMessage(\n\t\t\tstream,\n\t\t\tfunc,\n\t\t\tfalse,\n\t\t\tbody,\n\t\t\tprimaryMsg.systemBytes,\n\t\t);\n\t\tconst sml = msg.toSml();\n\t\tthis.logger.logSecs2(\"Sent\", sml);\n\t\tthis.logger.detail.debug(\n\t\t\t{\n\t\t\t\tprotocol: \"SECS\",\n\t\t\t\tdir: \"Sent\",\n\t\t\t\tstream,\n\t\t\t\tfunc,\n\t\t\t\twBit: false,\n\t\t\t\tsystemBytes: primaryMsg.systemBytes,\n\t\t\t\tsml,\n\t\t\t},\n\t\t\t\"sml\",\n\t\t);\n\t\tawait this.sendBufferWithLogs(\"Sent\", \"SECS\", msg.toBuffer(), {\n\t\t\tstream,\n\t\t\tfunc,\n\t\t\twBit: false,\n\t\t\tsystemBytes: primaryMsg.systemBytes,\n\t\t});\n\t}\n\n\tprotected getNextSystemBytes(): number {\n\t\tthis._systemBytesCounter = (this._systemBytesCounter + 1) >>> 0; // Ensure 32-bit unsigned\n\t\treturn this._systemBytesCounter;\n\t}\n\n\tprotected handleMessage(msg: SecsMessage) {\n\t\tconst sml = msg.toSml();\n\t\tthis.logger.logSecs2(\"Received\", sml);\n\t\tthis.logger.detail.debug(\n\t\t\t{\n\t\t\t\tprotocol: \"SECS\",\n\t\t\t\tdir: \"Received\",\n\t\t\t\tstream: msg.stream,\n\t\t\t\tfunc: msg.func,\n\t\t\t\twBit: msg.wBit,\n\t\t\t\tsystemBytes: msg.systemBytes,\n\t\t\t\tdeviceId: msg.deviceId,\n\t\t\t\tsml,\n\t\t\t},\n\t\t\t\"message\",\n\t\t);\n\t\t// Check if it's a reply\n\t\t// Usually, if we have a transaction waiting for this SystemBytes, we treat it as a reply.\n\t\t// However, Stream 0 (HSMS Control) messages are never replies to SECS-II messages.\n\t\t// SECS-II replies usually have the same SystemBytes as the primary.\n\n\t\tconst tx = this._transactions.get(msg.systemBytes);\n\t\tif (tx) {\n\t\t\tclearTimeout(tx.timer);\n\t\t\tthis._transactions.delete(msg.systemBytes);\n\t\t\ttx.resolve(msg);\n\t\t\treturn;\n\t\t}\n\n\t\t// If not a reply, emit event\n\t\tthis.emitInternal(\"message\", msg);\n\t}\n}\n"],"mappings":";;;;AA8CA,IAAsB,2BAAtB,cAGU,aAAa;CACtB,AAAgB;CAChB,AAAgB;CAChB,AAAgB;CAChB,AAAmB;CAEnB,AAAO,YAAY;CACnB,AAAO,YAAY;CACnB,AAAO,YAAY;CACnB,AAAO,YAAY;CACnB,AAAO,YAAY;CACnB,AAAO,YAAY;CACnB,AAAO,YAAY;CACnB,AAAO,YAAY;CAEnB,AAAU,sBAAsB;CAChC,AAAU,gCAAgB,IAAI,KAO3B;CAEH,YAAY,QAAgC;AAC3C,SAAO;AACP,OAAK,WAAW,OAAO;AACvB,OAAK,UAAU,OAAO;AACtB,OAAK,OAAO,OAAO,QAAQ;AAC3B,MAAI,OAAO,cAAc,OAAW,MAA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AAI;GACjB,UAAU,IAAI;GACd;GACA,EACD,UACA;EAMD,MAAM,KAAK,KAAK,cAAc,IAAI,IAAI,YAAY;AAClD,MAAI,IAAI;AACP,gBAAa,GAAG,MAAM;AACtB,QAAK,cAAc,OAAO,IAAI,YAAY;AAC1C,MAAG,QAAQ,IAAI;AACf;;AAID,OAAK,aAAa,WAAW,IAAI"}
1
+ {"version":3,"file":"AbstractSecsCommunicator.js","names":[],"sources":["../../src/core/AbstractSecsCommunicator.ts"],"sourcesContent":["import { EventEmitter } from \"events\";\nimport { SecsMessage } from \"./AbstractSecsMessage.js\";\nimport { AbstractSecs2Item } from \"./secs2item/AbstractSecs2Item.js\";\nimport { SecsLogger, type SecsLoggerConfig } from \"../logging/SecsLogger.js\";\n\n/**\n * @param message The message received.\n * @param error The error occurred.\n * @param connected The connection is established.\n * @param disconnected The connection is closed.\n */\nexport interface SecsCommunicatorEvents {\n\tmessage: [SecsMessage];\n\terror: [Error];\n\tconnected: [];\n\tdisconnected: [];\n}\n\n/**\n * @param deviceId The device ID.\n * @param isEquip Whether the device is an equip.\n * @param name The name of the connection.\n * @param timeoutT1 Only SECS-I supports this parameter, ENQ retransmission interval.\n * @param timeoutT2 Only SECS-I supports this parameter, ENQ wait-for-response timeout.\n * @param timeoutT3 Support SECS-I and SECS-II, W-Bit timeout.\n * @param timeoutT4 Only SECS-I supports this parameter, data block retransmission interval.\n * @param timeoutT5 Support SECS-I and SECS-II, establishment of communication session timeout.\n * @param timeoutT6 Only HSMS supports this parameter, reply control message timeout.\n * @param timeoutT7 Only HSMS supports this parameter, create connection timeout.\n * @param timeoutT8 Only HSMS supports this parameter, the maximum time interval between message bytes when receiving a message\n */\nexport interface SecsCommunicatorConfig {\n\tdeviceId: number;\n\tisEquip: boolean;\n\tname?: string;\n\tlog?: SecsLoggerConfig;\n\ttimeoutT1?: number;\n\ttimeoutT2?: number;\n\ttimeoutT3?: number;\n\ttimeoutT4?: number;\n\ttimeoutT5?: number;\n\ttimeoutT6?: number;\n\ttimeoutT7?: number;\n\ttimeoutT8?: number;\n}\n\nexport abstract class AbstractSecsCommunicator<\n\tEvents extends Record<keyof Events, unknown[]> & SecsCommunicatorEvents =\n\t\tSecsCommunicatorEvents,\n> extends EventEmitter {\n\tpublic readonly deviceId: number;\n\tpublic readonly isEquip: boolean;\n\tpublic readonly name: string;\n\tprotected readonly logger: SecsLogger;\n\n\tpublic timeoutT1 = 1;\n\tpublic timeoutT2 = 15;\n\tpublic timeoutT3 = 45;\n\tpublic timeoutT4 = 45;\n\tpublic timeoutT5 = 10;\n\tpublic timeoutT6 = 5;\n\tpublic timeoutT7 = 10;\n\tpublic timeoutT8 = 5;\n\n\tprotected _systemBytesCounter = 0;\n\tprotected _transactions = new Map<\n\t\tnumber,\n\t\t{\n\t\t\tresolve: (msg: SecsMessage) => void;\n\t\t\treject: (err: Error) => void;\n\t\t\ttimer: NodeJS.Timeout;\n\t\t}\n\t>();\n\n\tconstructor(config: SecsCommunicatorConfig) {\n\t\tsuper();\n\t\tthis.deviceId = config.deviceId;\n\t\tthis.isEquip = config.isEquip;\n\t\tthis.name = config.name ?? \"SecsCommunicator\";\n\t\tif (config.timeoutT1 !== undefined) this.timeoutT1 = config.timeoutT1;\n\t\tif (config.timeoutT2 !== undefined) this.timeoutT2 = config.timeoutT2;\n\t\tif (config.timeoutT3 !== undefined) this.timeoutT3 = config.timeoutT3;\n\t\tif (config.timeoutT4 !== undefined) this.timeoutT4 = config.timeoutT4;\n\t\tif (config.timeoutT5 !== undefined) this.timeoutT5 = config.timeoutT5;\n\t\tif (config.timeoutT6 !== undefined) this.timeoutT6 = config.timeoutT6;\n\t\tif (config.timeoutT7 !== undefined) this.timeoutT7 = config.timeoutT7;\n\t\tif (config.timeoutT8 !== undefined) this.timeoutT8 = config.timeoutT8;\n\t\tthis.logger = SecsLogger.create(config.log, {\n\t\t\tname: this.name,\n\t\t\tdeviceId: this.deviceId,\n\t\t\tisEquip: this.isEquip,\n\t\t});\n\t}\n\n\tabstract open(): Promise<void>;\n\tabstract close(): Promise<void>;\n\n\tprotected emitInternal(\n\t\teventName: string | symbol,\n\t\t...args: unknown[]\n\t): boolean {\n\t\treturn (\n\t\t\tsuper.emit as (\n\t\t\t\tthis: AbstractSecsCommunicator<Events>,\n\t\t\t\teventName: string | symbol,\n\t\t\t\t...args: unknown[]\n\t\t\t) => boolean\n\t\t).call(this, eventName, ...args);\n\t}\n\n\t// This method sends the message bytes. To be implemented by subclasses.\n\tprotected abstract sendBuffer(buffer: Buffer): Promise<void>;\n\n\tprotected async sendBufferWithLogs(\n\t\tdirection: \"Sent\" | \"Received\",\n\t\tprotocol: string,\n\t\tbuffer: Buffer,\n\t\tmeta?: Record<string, unknown>,\n\t): Promise<void> {\n\t\tthis.logger.logBytes(direction, protocol, buffer, meta);\n\t\tawait this.sendBuffer(buffer);\n\t}\n\n\tprotected abstract createMessage(\n\t\tstream: number,\n\t\tfunc: number,\n\t\twBit: boolean,\n\t\tbody: AbstractSecs2Item | null,\n\t\tsystemBytes: number,\n\t): SecsMessage;\n\n\tasync send(\n\t\tstream: number,\n\t\tfunc: number,\n\t\twBit: boolean,\n\t\tbody: AbstractSecs2Item | null = null,\n\t): Promise<SecsMessage | null> {\n\t\tconst systemBytes = this.getNextSystemBytes();\n\t\tconst msg = this.createMessage(stream, func, wBit, body, systemBytes);\n\t\tconst sml = msg.toSml();\n\t\tconst buffer = msg.toBuffer();\n\t\tthis.logger.logSecs2(\"Sent\", sml, this.deviceId, systemBytes, buffer);\n\t\tthis.logger.detail.debug(\n\t\t\t{\n\t\t\t\tprotocol: \"SECS\",\n\t\t\t\tdir: \"Sent\",\n\t\t\t\tstream,\n\t\t\t\tfunc,\n\t\t\t\twBit,\n\t\t\t\tsystemBytes,\n\t\t\t\tsml,\n\t\t\t},\n\t\t\t\"sml\",\n\t\t);\n\n\t\tif (wBit) {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tconst timer = setTimeout(() => {\n\t\t\t\t\tif (this._transactions.has(systemBytes)) {\n\t\t\t\t\t\tthis._transactions.delete(systemBytes);\n\t\t\t\t\t\treject(\n\t\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t\t`T3 Timeout waiting for reply to S${String(stream)}F${String(func)} [SysBytes=${String(systemBytes)}]`,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}, this.timeoutT3 * 1000);\n\n\t\t\t\tthis._transactions.set(systemBytes, { resolve, reject, timer });\n\n\t\t\t\tthis.sendBufferWithLogs(\"Sent\", \"SECS\", buffer, {\n\t\t\t\t\tstream,\n\t\t\t\t\tfunc,\n\t\t\t\t\twBit,\n\t\t\t\t\tsystemBytes,\n\t\t\t\t}).catch((err: unknown) => {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tthis._transactions.delete(systemBytes);\n\t\t\t\t\tthis.logger.detail.error(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\terr: err instanceof Error ? err : new Error(String(err)),\n\t\t\t\t\t\t\tstream,\n\t\t\t\t\t\t\tfunc,\n\t\t\t\t\t\t\twBit,\n\t\t\t\t\t\t\tsystemBytes,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"send failed\",\n\t\t\t\t\t);\n\t\t\t\t\treject(err instanceof Error ? err : new Error(String(err)));\n\t\t\t\t});\n\t\t\t});\n\t\t} else {\n\t\t\tawait this.sendBufferWithLogs(\"Sent\", \"SECS\", buffer, {\n\t\t\t\tstream,\n\t\t\t\tfunc,\n\t\t\t\twBit,\n\t\t\t\tsystemBytes,\n\t\t\t});\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tasync reply(\n\t\tprimaryMsg: SecsMessage,\n\t\tstream: number,\n\t\tfunc: number,\n\t\tbody: AbstractSecs2Item | null = null,\n\t): Promise<void> {\n\t\tconst msg = this.createMessage(\n\t\t\tstream,\n\t\t\tfunc,\n\t\t\tfalse,\n\t\t\tbody,\n\t\t\tprimaryMsg.systemBytes,\n\t\t);\n\t\tconst sml = msg.toSml();\n\t\tconst buffer = msg.toBuffer();\n\t\tthis.logger.logSecs2(\n\t\t\t\"Sent\",\n\t\t\tsml,\n\t\t\tthis.deviceId,\n\t\t\tprimaryMsg.systemBytes,\n\t\t\tbuffer,\n\t\t);\n\t\tthis.logger.detail.debug(\n\t\t\t{\n\t\t\t\tprotocol: \"SECS\",\n\t\t\t\tdir: \"Sent\",\n\t\t\t\tstream,\n\t\t\t\tfunc,\n\t\t\t\twBit: false,\n\t\t\t\tsystemBytes: primaryMsg.systemBytes,\n\t\t\t\tsml,\n\t\t\t},\n\t\t\t\"sml\",\n\t\t);\n\t\tawait this.sendBufferWithLogs(\"Sent\", \"SECS\", buffer, {\n\t\t\tstream,\n\t\t\tfunc,\n\t\t\twBit: false,\n\t\t\tsystemBytes: primaryMsg.systemBytes,\n\t\t});\n\t}\n\n\tprotected getNextSystemBytes(): number {\n\t\tthis._systemBytesCounter = (this._systemBytesCounter + 1) >>> 0; // Ensure 32-bit unsigned\n\t\treturn this._systemBytesCounter;\n\t}\n\n\tprotected handleMessage(msg: SecsMessage) {\n\t\tconst sml = msg.toSml();\n\t\tconst buffer = msg.toBuffer();\n\t\tthis.logger.logSecs2(\n\t\t\t\"Received\",\n\t\t\tsml,\n\t\t\tthis.deviceId,\n\t\t\tmsg.systemBytes,\n\t\t\tbuffer,\n\t\t);\n\n\t\tthis.logger.detail.debug(\n\t\t\t{\n\t\t\t\tprotocol: \"SECS\",\n\t\t\t\tdir: \"Received\",\n\t\t\t\tstream: msg.stream,\n\t\t\t\tfunc: msg.func,\n\t\t\t\twBit: msg.wBit,\n\t\t\t\tsystemBytes: msg.systemBytes,\n\t\t\t\tdeviceId: msg.deviceId,\n\t\t\t\tsml,\n\t\t\t},\n\t\t\t\"message\",\n\t\t);\n\t\t// Check if it's a reply\n\t\t// Usually, if we have a transaction waiting for this SystemBytes, we treat it as a reply.\n\t\t// However, Stream 0 (HSMS Control) messages are never replies to SECS-II messages.\n\t\t// SECS-II replies usually have the same SystemBytes as the primary.\n\n\t\tconst tx = this._transactions.get(msg.systemBytes);\n\t\tif (tx) {\n\t\t\tclearTimeout(tx.timer);\n\t\t\tthis._transactions.delete(msg.systemBytes);\n\t\t\ttx.resolve(msg);\n\t\t\treturn;\n\t\t}\n\n\t\t// If not a reply, emit event\n\t\tthis.emitInternal(\"message\", msg);\n\t}\n}\n"],"mappings":";;;;AA8CA,IAAsB,2BAAtB,cAGU,aAAa;CACtB,AAAgB;CAChB,AAAgB;CAChB,AAAgB;CAChB,AAAmB;CAEnB,AAAO,YAAY;CACnB,AAAO,YAAY;CACnB,AAAO,YAAY;CACnB,AAAO,YAAY;CACnB,AAAO,YAAY;CACnB,AAAO,YAAY;CACnB,AAAO,YAAY;CACnB,AAAO,YAAY;CAEnB,AAAU,sBAAsB;CAChC,AAAU,gCAAgB,IAAI,KAO3B;CAEH,YAAY,QAAgC;AAC3C,SAAO;AACP,OAAK,WAAW,OAAO;AACvB,OAAK,UAAU,OAAO;AACtB,OAAK,OAAO,OAAO,QAAQ;AAC3B,MAAI,OAAO,cAAc,OAAW,MAAK,YAAY,OAAO;AAC5D,MAAI,OAAO,cAAc,OAAW,MAAK,YAAY,OAAO;AAC5D,MAAI,OAAO,cAAc,OAAW,MAAK,YAAY,OAAO;AAC5D,MAAI,OAAO,cAAc,OAAW,MAAK,YAAY,OAAO;AAC5D,MAAI,OAAO,cAAc,OAAW,MAAK,YAAY,OAAO;AAC5D,MAAI,OAAO,cAAc,OAAW,MAAK,YAAY,OAAO;AAC5D,MAAI,OAAO,cAAc,OAAW,MAAK,YAAY,OAAO;AAC5D,MAAI,OAAO,cAAc,OAAW,MAAK,YAAY,OAAO;AAC5D,OAAK,SAAS,WAAW,OAAO,OAAO,KAAK;GAC3C,MAAM,KAAK;GACX,UAAU,KAAK;GACf,SAAS,KAAK;GACd,CAAC;;CAMH,AAAU,aACT,WACA,GAAG,MACO;AACV,SACC,MAAM,KAKL,KAAK,MAAM,WAAW,GAAG,KAA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;IACA;IACA;IACA,CAAC;AACF,UAAO;;;CAIT,MAAM,MACL,YACA,QACA,MACA,OAAiC,MACjB;EAChB,MAAM,MAAM,KAAK,cAChB,QACA,MACA,OACA,MACA,WAAW,YACX;EACD,MAAM,MAAM,IAAI,OAAO;EACvB,MAAM,SAAS,IAAI,UAAU;AAC7B,OAAK,OAAO,SACX,QACA,KACA,KAAK,UACL,WAAW,aACX,OACA;AACD,OAAK,OAAO,OAAO,MAClB;GACC,UAAU;GACV,KAAK;GACL;GACA;GACA,MAAM;GACN,aAAa,WAAW;GACxB;GACA,EACD,MACA;AACD,QAAM,KAAK,mBAAmB,QAAQ,QAAQ,QAAQ;GACrD;GACA;GACA,MAAM;GACN,aAAa,WAAW;GACxB,CAAC;;CAGH,AAAU,qBAA6B;AACtC,OAAK,sBAAuB,KAAK,sBAAsB,MAAO;AAC9D,SAAO,KAAK;;CAGb,AAAU,cAAc,KAAkB;EACzC,MAAM,MAAM,IAAI,OAAO;EACvB,MAAM,SAAS,IAAI,UAAU;AAC7B,OAAK,OAAO,SACX,YACA,KACA,KAAK,UACL,IAAI,aACJ,OACA;AAED,OAAK,OAAO,OAAO,MAClB;GACC,UAAU;GACV,KAAK;GACL,QAAQ,IAAI;GACZ,MAAM,IAAI;GACV,MAAM,IAAI;GACV,aAAa,IAAI;GACjB,UAAU,IAAI;GACd;GACA,EACD,UACA;EAMD,MAAM,KAAK,KAAK,cAAc,IAAI,IAAI,YAAY;AAClD,MAAI,IAAI;AACP,gBAAa,GAAG,MAAM;AACtB,QAAK,cAAc,OAAO,IAAI,YAAY;AAC1C,MAAG,QAAQ,IAAI;AACf;;AAID,OAAK,aAAa,WAAW,IAAI"}
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractSecsMessage.js","names":["stream: number","func: number","wBit: boolean","body: AbstractSecs2Item | null"],"sources":["../../src/core/AbstractSecsMessage.ts"],"sourcesContent":["import { AbstractSecs2Item } from \"./secs2item/AbstractSecs2Item.js\";\r\n\r\n/**\r\n * @param stream The stream number.\r\n * @param func The function number.\r\n * @param wBit Whether the message is a request.\r\n * @param body The body of the message.\r\n * @param systemBytes The system bytes.\r\n * @param deviceId The device ID.\r\n */\r\nexport class SecsMessage {\r\n\tconstructor(\r\n\t\tpublic readonly stream: number,\r\n\t\tpublic readonly func: number,\r\n\t\tpublic readonly wBit: boolean,\r\n\t\tpublic readonly body: AbstractSecs2Item | null = null,\r\n\t\tpublic readonly systemBytes = 0, // Typically 4 bytes, treated as integer for convenience if it fits, or Buffer\r\n\t\tpublic readonly deviceId = 0,\r\n\t) {\r\n\t\tif (stream < 0 || stream > 127) throw new Error(\"Stream must be 0-127\");\r\n\t\tif (func < 0 || func > 255) throw new Error(\"Function must be 0-255\");\r\n\t}\r\n\r\n\t/**\r\n\t * @description Returns the SML representation of the message.\r\n\t * @returns The SML representation.\r\n\t */\r\n\ttoSml(): string {\r\n\t\tconst wBitStr = this.wBit ? \"W\" : \"\";\r\n\t\tconst header = `S${this.stream.toString()}F${this.func.toString()} ${wBitStr}`;\r\n\t\tif (this.body) {\r\n\t\t\treturn `${header}\\n${this.body.toSml()}.`;\r\n\t\t}\r\n\t\treturn `${header}.`;\r\n\t}\r\n\r\n\t/**\r\n\t * @description Returns the binary representation of the message.\r\n\t * @returns The binary representation.\r\n\t */\r\n\ttoBuffer(): Buffer {\r\n\t\tconst header = Buffer.from([\r\n\t\t\t0x02, // SML header\r\n\t\t\tthis.stream,\r\n\t\t\tthis.func,\r\n\t\t\tthis.wBit ? 0x80 : 0x00,\r\n\t\t]);\r\n\t\tconst body = this.body?.toBuffer() ?? Buffer.alloc(0);\r\n\t\tconst systemBytes =\r\n\t\t\ttypeof this.systemBytes === \"number\"\r\n\t\t\t\t? Buffer.from([\r\n\t\t\t\t\t\tthis.systemBytes >>> 24,\r\n\t\t\t\t\t\t(this.systemBytes >>> 16) & 0xff,\r\n\t\t\t\t\t\t(this.systemBytes >>> 8) & 0xff,\r\n\t\t\t\t\t\tthis.systemBytes & 0xff,\r\n\t\t\t\t\t])\r\n\t\t\t\t: this.systemBytes;\r\n\t\tconst deviceId = Buffer.from([\r\n\t\t\tthis.deviceId >>> 24,\r\n\t\t\t(this.deviceId >>> 16) & 0xff,\r\n\t\t\t(this.deviceId >>> 8) & 0xff,\r\n\t\t\tthis.deviceId & 0xff,\r\n\t\t]);\r\n\t\treturn Buffer.concat([header, systemBytes, deviceId, body]);\r\n\t}\r\n}\r\n"],"mappings":";;;;;;;;;AAUA,IAAa,cAAb,MAAyB;CACxB,YACC,AAAgBA,QAChB,AAAgBC,MAChB,AAAgBC,MAChB,AAAgBC,OAAiC,MACjD,AAAgB,cAAc,GAC9B,AAAgB,WAAW,GAC1B;EANe;EACA;EACA;EACA;EACA;EACA;AAEhB,MAAI,SAAS,KAAK,SAAS,IAAK,OAAM,IAAI,MAAM,uBAAuB;AACvE,MAAI,OAAO,KAAK,OAAO,IAAK,OAAM,IAAI,MAAM,yBAAyB;;;;;;CAOtE,QAAgB;EACf,MAAM,UAAU,KAAK,OAAO,MAAM;EAClC,MAAM,SAAS,IAAI,KAAK,OAAO,UAAU,CAAC,GAAG,KAAK,KAAK,UAAU,CAAC,GAAG;AACrE,MAAI,KAAK,KACR,QAAO,GAAG,OAAO,IAAI,KAAK,KAAK,OAAO,CAAC;AAExC,SAAO,GAAG,OAAO;;;;;;CAOlB,WAAmB;EAClB,MAAM,SAAS,OAAO,KAAK;GAC1B;GACA,KAAK;GACL,KAAK;GACL,KAAK,OAAO,MAAO;GACnB,CAAC;EACF,MAAM,OAAO,KAAK,MAAM,UAAU,IAAI,OAAO,MAAM,EAAE;EACrD,MAAM,cACL,OAAO,KAAK,gBAAgB,WACzB,OAAO,KAAK;GACZ,KAAK,gBAAgB;GACpB,KAAK,gBAAgB,KAAM;GAC3B,KAAK,gBAAgB,IAAK;GAC3B,KAAK,cAAc;GACnB,CAAC,GACD,KAAK;EACT,MAAM,WAAW,OAAO,KAAK;GAC5B,KAAK,aAAa;GACjB,KAAK,aAAa,KAAM;GACxB,KAAK,aAAa,IAAK;GACxB,KAAK,WAAW;GAChB,CAAC;AACF,SAAO,OAAO,OAAO;GAAC;GAAQ;GAAa;GAAU;GAAK,CAAC"}
1
+ {"version":3,"file":"AbstractSecsMessage.js","names":["stream: number","func: number","wBit: boolean","body: AbstractSecs2Item | null"],"sources":["../../src/core/AbstractSecsMessage.ts"],"sourcesContent":["import { AbstractSecs2Item } from \"./secs2item/AbstractSecs2Item.js\";\n\n/**\n * @param stream The stream number.\n * @param func The function number.\n * @param wBit Whether the message is a request.\n * @param body The body of the message.\n * @param systemBytes The system bytes.\n * @param deviceId The device ID.\n */\nexport class SecsMessage {\n\tconstructor(\n\t\tpublic readonly stream: number,\n\t\tpublic readonly func: number,\n\t\tpublic readonly wBit: boolean,\n\t\tpublic readonly body: AbstractSecs2Item | null = null,\n\t\tpublic readonly systemBytes = 0, // Typically 4 bytes, treated as integer for convenience if it fits, or Buffer\n\t\tpublic readonly deviceId = 0,\n\t) {\n\t\tif (stream < 0 || stream > 127) throw new Error(\"Stream must be 0-127\");\n\t\tif (func < 0 || func > 255) throw new Error(\"Function must be 0-255\");\n\t}\n\n\t/**\n\t * @description Returns the SML representation of the message.\n\t * @returns The SML representation.\n\t */\n\ttoSml(): string {\n\t\tconst wBitStr = this.wBit ? \"W\" : \"\";\n\t\tconst header = `S${this.stream.toString()}F${this.func.toString()} ${wBitStr}`;\n\t\tif (this.body) {\n\t\t\treturn `${header}\\n${this.body.toSml()}.`;\n\t\t}\n\t\treturn `${header}.`;\n\t}\n\n\t/**\n\t * @description Returns the binary representation of the message.\n\t * @returns The binary representation.\n\t */\n\ttoBuffer(): Buffer {\n\t\tconst header = Buffer.from([\n\t\t\t0x02, // SML header\n\t\t\tthis.stream,\n\t\t\tthis.func,\n\t\t\tthis.wBit ? 0x80 : 0x00,\n\t\t]);\n\t\tconst body = this.body?.toBuffer() ?? Buffer.alloc(0);\n\t\tconst systemBytes =\n\t\t\ttypeof this.systemBytes === \"number\"\n\t\t\t\t? Buffer.from([\n\t\t\t\t\t\tthis.systemBytes >>> 24,\n\t\t\t\t\t\t(this.systemBytes >>> 16) & 0xff,\n\t\t\t\t\t\t(this.systemBytes >>> 8) & 0xff,\n\t\t\t\t\t\tthis.systemBytes & 0xff,\n\t\t\t\t\t])\n\t\t\t\t: this.systemBytes;\n\t\tconst deviceId = Buffer.from([\n\t\t\tthis.deviceId >>> 24,\n\t\t\t(this.deviceId >>> 16) & 0xff,\n\t\t\t(this.deviceId >>> 8) & 0xff,\n\t\t\tthis.deviceId & 0xff,\n\t\t]);\n\t\treturn Buffer.concat([header, systemBytes, deviceId, body]);\n\t}\n}\n"],"mappings":";;;;;;;;;AAUA,IAAa,cAAb,MAAyB;CACxB,YACC,AAAgBA,QAChB,AAAgBC,MAChB,AAAgBC,MAChB,AAAgBC,OAAiC,MACjD,AAAgB,cAAc,GAC9B,AAAgB,WAAW,GAC1B;EANe;EACA;EACA;EACA;EACA;EACA;AAEhB,MAAI,SAAS,KAAK,SAAS,IAAK,OAAM,IAAI,MAAM,uBAAuB;AACvE,MAAI,OAAO,KAAK,OAAO,IAAK,OAAM,IAAI,MAAM,yBAAyB;;;;;;CAOtE,QAAgB;EACf,MAAM,UAAU,KAAK,OAAO,MAAM;EAClC,MAAM,SAAS,IAAI,KAAK,OAAO,UAAU,CAAC,GAAG,KAAK,KAAK,UAAU,CAAC,GAAG;AACrE,MAAI,KAAK,KACR,QAAO,GAAG,OAAO,IAAI,KAAK,KAAK,OAAO,CAAC;AAExC,SAAO,GAAG,OAAO;;;;;;CAOlB,WAAmB;EAClB,MAAM,SAAS,OAAO,KAAK;GAC1B;GACA,KAAK;GACL,KAAK;GACL,KAAK,OAAO,MAAO;GACnB,CAAC;EACF,MAAM,OAAO,KAAK,MAAM,UAAU,IAAI,OAAO,MAAM,EAAE;EACrD,MAAM,cACL,OAAO,KAAK,gBAAgB,WACzB,OAAO,KAAK;GACZ,KAAK,gBAAgB;GACpB,KAAK,gBAAgB,KAAM;GAC3B,KAAK,gBAAgB,IAAK;GAC3B,KAAK,cAAc;GACnB,CAAC,GACD,KAAK;EACT,MAAM,WAAW,OAAO,KAAK;GAC5B,KAAK,aAAa;GACjB,KAAK,aAAa,KAAM;GACxB,KAAK,aAAa,IAAK;GACxB,KAAK,WAAW;GAChB,CAAC;AACF,SAAO,OAAO,OAAO;GAAC;GAAQ;GAAa;GAAU;GAAK,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"HsmsSsControlType.js","names":[],"sources":["../../../src/core/enums/HsmsSsControlType.ts"],"sourcesContent":["/**\r\n * HSMS-SS 控制类型(PType + SType 组合)\r\n * 存储在 Header 的 Byte 4-5\r\n */\r\nexport class HsmsSsControlType {\r\n\t// 只读实例属性\r\n\treadonly PType: number;\r\n\treadonly SType: number;\r\n\r\n\t// 私有构造函数,防止外部直接实例化\r\n\tprivate constructor(pType: number, sType: number) {\r\n\t\tthis.PType = pType;\r\n\t\tthis.SType = sType;\r\n\t}\r\n\r\n\t// ========== 静态只读实例 ==========\r\n\r\n\t// 未定义类型\r\n\tstatic readonly Undefined = new HsmsSsControlType(0xff, 0xff);\r\n\r\n\t// 数据消息(携带 SECS-II 数据)\r\n\tstatic readonly Data = new HsmsSsControlType(0x00, 0x00);\r\n\r\n\t// 连接控制消息\r\n\tstatic readonly SelectReq = new HsmsSsControlType(0x00, 0x01);\r\n\tstatic readonly SelectRsp = new HsmsSsControlType(0x00, 0x02);\r\n\tstatic readonly DeselectReq = new HsmsSsControlType(0x00, 0x03);\r\n\tstatic readonly DeselectRsp = new HsmsSsControlType(0x00, 0x04);\r\n\r\n\t// 链路测试消息\r\n\tstatic readonly LinktestReq = new HsmsSsControlType(0x00, 0x05);\r\n\tstatic readonly LinktestRsp = new HsmsSsControlType(0x00, 0x06);\r\n\r\n\t// 拒绝消息\r\n\tstatic readonly RejectReq = new HsmsSsControlType(0x00, 0x07);\r\n\r\n\t// 分离请求\r\n\tstatic readonly SeparateReq = new HsmsSsControlType(0x00, 0x09);\r\n\r\n\t// 私有已知类型数组\r\n\tprivate static readonly KnownTypes: HsmsSsControlType[] = [\r\n\t\tHsmsSsControlType.Data,\r\n\t\tHsmsSsControlType.SelectReq,\r\n\t\tHsmsSsControlType.SelectRsp,\r\n\t\tHsmsSsControlType.DeselectReq,\r\n\t\tHsmsSsControlType.DeselectRsp,\r\n\t\tHsmsSsControlType.LinktestReq,\r\n\t\tHsmsSsControlType.LinktestRsp,\r\n\t\tHsmsSsControlType.RejectReq,\r\n\t\tHsmsSsControlType.SeparateReq,\r\n\t];\r\n\r\n\t// ========== 静态工厂方法 ==========\r\n\r\n\t/**\r\n\t * 从字节解析控制类型\r\n\t */\r\n\tstatic fromBytes(pType: number, sType: number): HsmsSsControlType {\r\n\t\tfor (const known of HsmsSsControlType.KnownTypes) {\r\n\t\t\tif (known.PType === pType && known.SType === sType) {\r\n\t\t\t\treturn known;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn HsmsSsControlType.Undefined;\r\n\t}\r\n\r\n\t/**\r\n\t * 从 Header Bytes 4-5 解析\r\n\t */\r\n\tstatic fromHeaderBytes(\r\n\t\theaderBytes: Uint8Array | number[],\r\n\t): HsmsSsControlType {\r\n\t\treturn HsmsSsControlType.fromBytes(headerBytes[4], headerBytes[5]);\r\n\t}\r\n\r\n\t// ========== 实例方法 ==========\r\n\r\n\t/**\r\n\t * 判断是否为数据消息\r\n\t */\r\n\tget isDataMessage(): boolean {\r\n\t\treturn this === HsmsSsControlType.Data;\r\n\t}\r\n\r\n\t/**\r\n\t * 判断是否为控制消息\r\n\t */\r\n\tget isControlMessage(): boolean {\r\n\t\treturn !this.isDataMessage && this !== HsmsSsControlType.Undefined;\r\n\t}\r\n\r\n\tget isSelectRequest(): boolean {\r\n\t\treturn this === HsmsSsControlType.SelectReq;\r\n\t}\r\n\r\n\tget isSelectResponse(): boolean {\r\n\t\treturn this === HsmsSsControlType.SelectRsp;\r\n\t}\r\n\r\n\tget isLinktestRequest(): boolean {\r\n\t\treturn this === HsmsSsControlType.LinktestReq;\r\n\t}\r\n\r\n\tget isRejectRequest(): boolean {\r\n\t\treturn this === HsmsSsControlType.RejectReq;\r\n\t}\r\n\r\n\t/**\r\n\t * 字符串表示\r\n\t */\r\n\ttoString(): string {\r\n\t\tif (this === HsmsSsControlType.Data) return \"DATA\";\r\n\t\tif (this === HsmsSsControlType.SelectReq) return \"SELECT.req\";\r\n\t\tif (this === HsmsSsControlType.SelectRsp) return \"SELECT.rsp\";\r\n\t\tif (this === HsmsSsControlType.DeselectReq) return \"DESELECT.req\";\r\n\t\tif (this === HsmsSsControlType.DeselectRsp) return \"DESELECT.rsp\";\r\n\t\tif (this === HsmsSsControlType.LinktestReq) return \"LINKTEST.req\";\r\n\t\tif (this === HsmsSsControlType.LinktestRsp) return \"LINKTEST.rsp\";\r\n\t\tif (this === HsmsSsControlType.RejectReq) return \"REJECT.req\";\r\n\t\tif (this === HsmsSsControlType.SeparateReq) return \"SEPARATE.req\";\r\n\t\treturn `Unknown(${this.PType.toString(16).toUpperCase()},${this.SType.toString(16).toUpperCase()})`;\r\n\t}\r\n\r\n\t// ========== 值相等性比较 ==========\r\n\r\n\t/**\r\n\t * 比较两个控制类型是否相等(C# record struct 的值比较语义)\r\n\t */\r\n\tequals(other: HsmsSsControlType): boolean {\r\n\t\treturn this.PType === other.PType && this.SType === other.SType;\r\n\t}\r\n\r\n\t/**\r\n\t * 支持 === 运算符的比较\r\n\t */\r\n\tvalueOf(): { PType: number; SType: number } {\r\n\t\treturn { PType: this.PType, SType: this.SType };\r\n\t}\r\n}\r\n"],"mappings":";;;;;AAIA,IAAa,oBAAb,MAAa,kBAAkB;CAE9B,AAAS;CACT,AAAS;CAGT,AAAQ,YAAY,OAAe,OAAe;AACjD,OAAK,QAAQ;AACb,OAAK,QAAQ;;CAMd,OAAgB,YAAY,IAAI,kBAAkB,KAAM,IAAK;CAG7D,OAAgB,OAAO,IAAI,kBAAkB,GAAM,EAAK;CAGxD,OAAgB,YAAY,IAAI,kBA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ACnD,MAAI,SAAS,kBAAkB,YAAa,QAAO;AACnD,MAAI,SAAS,kBAAkB,YAAa,QAAO;AACnD,MAAI,SAAS,kBAAkB,YAAa,QAAO;AACnD,MAAI,SAAS,kBAAkB,UAAW,QAAO;AACjD,MAAI,SAAS,kBAAkB,YAAa,QAAO;AACnD,SAAO,WAAW,KAAK,MAAM,SAAS,GAAG,CAAC,aAAa,CAAC,GAAG,KAAK,MAAM,SAAS,GAAG,CAAC,aAAa,CAAC;;;;;CAQlG,OAAO,OAAmC;AACzC,SAAO,KAAK,UAAU,MAAM,SAAS,KAAK,UAAU,MAAM;;;;;CAM3D,UAA4C;AAC3C,SAAO;GAAE,OAAO,KAAK;GAAO,OAAO,KAAK;GAAO"}
1
+ {"version":3,"file":"HsmsSsControlType.js","names":[],"sources":["../../../src/core/enums/HsmsSsControlType.ts"],"sourcesContent":["/**\n * HSMS-SS 控制类型(PType + SType 组合)\n * 存储在 Header 的 Byte 4-5\n */\nexport class HsmsSsControlType {\n\t// 只读实例属性\n\treadonly PType: number;\n\treadonly SType: number;\n\n\t// 私有构造函数,防止外部直接实例化\n\tprivate constructor(pType: number, sType: number) {\n\t\tthis.PType = pType;\n\t\tthis.SType = sType;\n\t}\n\n\t// ========== 静态只读实例 ==========\n\n\t// 未定义类型\n\tstatic readonly Undefined = new HsmsSsControlType(0xff, 0xff);\n\n\t// 数据消息(携带 SECS-II 数据)\n\tstatic readonly Data = new HsmsSsControlType(0x00, 0x00);\n\n\t// 连接控制消息\n\tstatic readonly SelectReq = new HsmsSsControlType(0x00, 0x01);\n\tstatic readonly SelectRsp = new HsmsSsControlType(0x00, 0x02);\n\tstatic readonly DeselectReq = new HsmsSsControlType(0x00, 0x03);\n\tstatic readonly DeselectRsp = new HsmsSsControlType(0x00, 0x04);\n\n\t// 链路测试消息\n\tstatic readonly LinktestReq = new HsmsSsControlType(0x00, 0x05);\n\tstatic readonly LinktestRsp = new HsmsSsControlType(0x00, 0x06);\n\n\t// 拒绝消息\n\tstatic readonly RejectReq = new HsmsSsControlType(0x00, 0x07);\n\n\t// 分离请求\n\tstatic readonly SeparateReq = new HsmsSsControlType(0x00, 0x09);\n\n\t// 私有已知类型数组\n\tprivate static readonly KnownTypes: HsmsSsControlType[] = [\n\t\tHsmsSsControlType.Data,\n\t\tHsmsSsControlType.SelectReq,\n\t\tHsmsSsControlType.SelectRsp,\n\t\tHsmsSsControlType.DeselectReq,\n\t\tHsmsSsControlType.DeselectRsp,\n\t\tHsmsSsControlType.LinktestReq,\n\t\tHsmsSsControlType.LinktestRsp,\n\t\tHsmsSsControlType.RejectReq,\n\t\tHsmsSsControlType.SeparateReq,\n\t];\n\n\t// ========== 静态工厂方法 ==========\n\n\t/**\n\t * 从字节解析控制类型\n\t */\n\tstatic fromBytes(pType: number, sType: number): HsmsSsControlType {\n\t\tfor (const known of HsmsSsControlType.KnownTypes) {\n\t\t\tif (known.PType === pType && known.SType === sType) {\n\t\t\t\treturn known;\n\t\t\t}\n\t\t}\n\t\treturn HsmsSsControlType.Undefined;\n\t}\n\n\t/**\n\t * 从 Header Bytes 4-5 解析\n\t */\n\tstatic fromHeaderBytes(\n\t\theaderBytes: Uint8Array | number[],\n\t): HsmsSsControlType {\n\t\treturn HsmsSsControlType.fromBytes(headerBytes[4], headerBytes[5]);\n\t}\n\n\t// ========== 实例方法 ==========\n\n\t/**\n\t * 判断是否为数据消息\n\t */\n\tget isDataMessage(): boolean {\n\t\treturn this === HsmsSsControlType.Data;\n\t}\n\n\t/**\n\t * 判断是否为控制消息\n\t */\n\tget isControlMessage(): boolean {\n\t\treturn !this.isDataMessage && this !== HsmsSsControlType.Undefined;\n\t}\n\n\tget isSelectRequest(): boolean {\n\t\treturn this === HsmsSsControlType.SelectReq;\n\t}\n\n\tget isSelectResponse(): boolean {\n\t\treturn this === HsmsSsControlType.SelectRsp;\n\t}\n\n\tget isLinktestRequest(): boolean {\n\t\treturn this === HsmsSsControlType.LinktestReq;\n\t}\n\n\tget isRejectRequest(): boolean {\n\t\treturn this === HsmsSsControlType.RejectReq;\n\t}\n\n\t/**\n\t * 字符串表示\n\t */\n\ttoString(): string {\n\t\tif (this === HsmsSsControlType.Data) return \"DATA\";\n\t\tif (this === HsmsSsControlType.SelectReq) return \"SELECT.req\";\n\t\tif (this === HsmsSsControlType.SelectRsp) return \"SELECT.rsp\";\n\t\tif (this === HsmsSsControlType.DeselectReq) return \"DESELECT.req\";\n\t\tif (this === HsmsSsControlType.DeselectRsp) return \"DESELECT.rsp\";\n\t\tif (this === HsmsSsControlType.LinktestReq) return \"LINKTEST.req\";\n\t\tif (this === HsmsSsControlType.LinktestRsp) return \"LINKTEST.rsp\";\n\t\tif (this === HsmsSsControlType.RejectReq) return \"REJECT.req\";\n\t\tif (this === HsmsSsControlType.SeparateReq) return \"SEPARATE.req\";\n\t\treturn `Unknown(${this.PType.toString(16).toUpperCase()},${this.SType.toString(16).toUpperCase()})`;\n\t}\n\n\t// ========== 值相等性比较 ==========\n\n\t/**\n\t * 比较两个控制类型是否相等(C# record struct 的值比较语义)\n\t */\n\tequals(other: HsmsSsControlType): boolean {\n\t\treturn this.PType === other.PType && this.SType === other.SType;\n\t}\n\n\t/**\n\t * 支持 === 运算符的比较\n\t */\n\tvalueOf(): { PType: number; SType: number } {\n\t\treturn { PType: this.PType, SType: this.SType };\n\t}\n}\n"],"mappings":";;;;;AAIA,IAAa,oBAAb,MAAa,kBAAkB;CAE9B,AAAS;CACT,AAAS;CAGT,AAAQ,YAAY,OAAe,OAAe;AACjD,OAAK,QAAQ;AACb,OAAK,QAAQ;;CAMd,OAAgB,YAAY,IAAI,kBAAkB,KAAM,IAAK;CAG7D,OAAgB,OAAO,IAAI,kBAAkB,GAAM,EAAK;CAGxD,OAAgB,YAAY,IAAI,kBAAkB,GAAM,EAAK;CAC7D,OAAgB,YAAY,IAAI,kBAAkB,GAAM,EAAK;CAC7D,OAAgB,cAAc,IAAI,kBAAkB,GAAM,EAAK;CAC/D,OAAgB,cAAc,IAAI,kBAAkB,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,QAAO;AACjD,MAAI,SAAS,kBAAkB,YAAa,QAAO;AACnD,SAAO,WAAW,KAAK,MAAM,SAAS,GAAG,CAAC,aAAa,CAAC,GAAG,KAAK,MAAM,SAAS,GAAG,CAAC,aAAa,CAAC;;;;;CAQlG,OAAO,OAAmC;AACzC,SAAO,KAAK,UAAU,MAAM,SAAS,KAAK,UAAU,MAAM;;;;;CAM3D,UAA4C;AAC3C,SAAO;GAAE,OAAO,KAAK;GAAO,OAAO,KAAK;GAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"RejectReason.js","names":[],"sources":["../../../src/core/enums/RejectReason.ts"],"sourcesContent":["export enum RejectReason {\r\n\tUnknown = 0xff,\r\n\tNotSupportTypeS = 0x01,\r\n\tNotSupportTypeP = 0x02,\r\n\tTransactionNotOpen = 0x03,\r\n\tNotSelected = 0x04,\r\n}\r\n"],"mappings":";AAAA,IAAY,wDAAL;AACN;AACA;AACA;AACA;AACA"}
1
+ {"version":3,"file":"RejectReason.js","names":[],"sources":["../../../src/core/enums/RejectReason.ts"],"sourcesContent":["export enum RejectReason {\n\tUnknown = 0xff,\n\tNotSupportTypeS = 0x01,\n\tNotSupportTypeP = 0x02,\n\tTransactionNotOpen = 0x03,\n\tNotSelected = 0x04,\n}\n"],"mappings":";AAAA,IAAY,wDAAL;AACN;AACA;AACA;AACA;AACA"}
@@ -1 +1 @@
1
- {"version":3,"file":"SecsItemType.js","names":[],"sources":["../../../src/core/enums/SecsItemType.ts"],"sourcesContent":["export enum SecsItemType {\r\n L = 0x00, // List\r\n B = 0x20, // Binary\r\n BOOLEAN = 0x24, // Boolean\r\n A = 0x40, // ASCII\r\n I8 = 0x60, // Integer 8\r\n I1 = 0x64, // Integer 1\r\n I2 = 0x68, // Integer 2\r\n I4 = 0x70, // Integer 4\r\n F8 = 0x80, // Floating Point 8\r\n F4 = 0x90, // Floating Point 4\r\n U8 = 0xa0, // Unsigned Integer 8\r\n U1 = 0xa4, // Unsigned Integer 1\r\n U2 = 0xa8, // Unsigned Integer 2\r\n U4 = 0xb0, // Unsigned Integer 4\r\n}\r\n"],"mappings":";AAAA,IAAY,wDAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
1
+ {"version":3,"file":"SecsItemType.js","names":[],"sources":["../../../src/core/enums/SecsItemType.ts"],"sourcesContent":["export enum SecsItemType {\n L = 0x00, // List\n B = 0x20, // Binary\n BOOLEAN = 0x24, // Boolean\n A = 0x40, // ASCII\n I8 = 0x60, // Integer 8\n I1 = 0x64, // Integer 1\n I2 = 0x68, // Integer 2\n I4 = 0x70, // Integer 4\n F8 = 0x80, // Floating Point 8\n F4 = 0x90, // Floating Point 4\n U8 = 0xa0, // Unsigned Integer 8\n U1 = 0xa4, // Unsigned Integer 1\n U2 = 0xa8, // Unsigned Integer 2\n U4 = 0xb0, // Unsigned Integer 4\n}\n"],"mappings":";AAAA,IAAY,wDAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -1 +1 @@
1
- {"version":3,"file":"SelectStatus.js","names":[],"sources":["../../../src/core/enums/SelectStatus.ts"],"sourcesContent":["export enum SelectStatus {\r\n\tUnknown = 0xff,\r\n\tSuccess = 0x00,\r\n\tActivated = 0x01,\r\n\tNotReady = 0x02,\r\n\tAlreadyUsed = 0x03,\r\n}\r\n"],"mappings":";AAAA,IAAY,wDAAL;AACN;AACA;AACA;AACA;AACA"}
1
+ {"version":3,"file":"SelectStatus.js","names":[],"sources":["../../../src/core/enums/SelectStatus.ts"],"sourcesContent":["export enum SelectStatus {\n\tUnknown = 0xff,\n\tSuccess = 0x00,\n\tActivated = 0x01,\n\tNotReady = 0x02,\n\tAlreadyUsed = 0x03,\n}\n"],"mappings":";AAAA,IAAY,wDAAL;AACN;AACA;AACA;AACA;AACA"}
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractSecs2Item.js","names":["type: SecsItemType","_value: T","lengthBytes: Buffer"],"sources":["../../../src/core/secs2item/AbstractSecs2Item.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\r\n\r\nexport abstract class AbstractSecs2Item<T = unknown> {\r\n\t[index: number]: unknown;\r\n\r\n\tconstructor(\r\n\t\tpublic readonly type: SecsItemType,\r\n\t\tprotected readonly _value: T,\r\n\t) {\r\n\t\treturn new Proxy(this, {\r\n\t\t\tget: (target, prop, receiver) => {\r\n\t\t\t\tif (typeof prop === \"string\") {\r\n\t\t\t\t\tconst index = Number(prop);\r\n\t\t\t\t\tif (Number.isInteger(index) && index >= 0) {\r\n\t\t\t\t\t\treturn target.getByIndex(index);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\treturn Reflect.get(target, prop, receiver);\r\n\t\t\t},\r\n\t\t});\r\n\t}\r\n\r\n\t/**\r\n\t * @description Returns the value of the item.\r\n\t */\r\n\tget value(): T {\r\n\t\treturn this._value;\r\n\t}\r\n\r\n\t/**\r\n\t * @description Returns the value of the item at the given index.\r\n\t * @param index The index of the value to return.\r\n\t * @returns The value of the item at the given index.\r\n\t */\r\n\tprotected getByIndex(index: number): unknown {\r\n\t\tconst v = this._value;\r\n\t\tif (Array.isArray(v) || Buffer.isBuffer(v) || typeof v === \"string\") {\r\n\t\t\treturn v[index];\r\n\t\t}\r\n\t\t// Scalar value\r\n\t\tif (index === 0) {\r\n\t\t\treturn v;\r\n\t\t}\r\n\t\treturn undefined;\r\n\t}\r\n\r\n\t/**\r\n\t * @description Returns the SML representation of the item.\r\n\t */\r\n\tabstract toSml(): string;\r\n\r\n\t/**\r\n\t * @description Returns the SECS-II encoded buffer of the item.\r\n\t */\r\n\tabstract toBuffer(): Buffer;\r\n\r\n\t/**\r\n\t * @description Helper to create the header (Type + LengthBytes)\r\n\t */\r\n\tprotected createHeader(length: number): Buffer {\r\n\t\tlet headerByte = this.type;\r\n\t\tlet lengthBytes: Buffer;\r\n\r\n\t\tif (length > 0xffffff) {\r\n\t\t\tthrow new Error(`Length ${length.toString()} is too large for SECS item`);\r\n\t\t}\r\n\r\n\t\tif (length > 0xffff) {\r\n\t\t\t// 3 bytes length\r\n\t\t\theaderByte |= 0x03;\r\n\t\t\tlengthBytes = Buffer.alloc(4);\r\n\t\t\tlengthBytes.writeUInt8(headerByte, 0);\r\n\t\t\tlengthBytes.writeUIntBE(length, 1, 3);\r\n\t\t} else if (length > 0xff) {\r\n\t\t\t// 2 bytes length\r\n\t\t\theaderByte |= 0x02;\r\n\t\t\tlengthBytes = Buffer.alloc(3);\r\n\t\t\tlengthBytes.writeUInt8(headerByte, 0);\r\n\t\t\tlengthBytes.writeUInt16BE(length, 1);\r\n\t\t} else {\r\n\t\t\t// 1 byte length\r\n\t\t\theaderByte |= 0x01;\r\n\t\t\tlengthBytes = Buffer.alloc(2);\r\n\t\t\tlengthBytes.writeUInt8(headerByte, 0);\r\n\t\t\tlengthBytes.writeUInt8(length, 1);\r\n\t\t}\r\n\t\treturn lengthBytes;\r\n\t}\r\n}\r\n"],"mappings":";AAEA,IAAsB,oBAAtB,MAAqD;CAGpD,YACC,AAAgBA,MAChB,AAAmBC,QAClB;EAFe;EACG;AAEnB,SAAO,IAAI,MAAM,MAAM,EACtB,MAAM,QAAQ,MAAM,aAAa;AAChC,OAAI,OAAO,SAAS,UAAU;IAC7B,MAAM,QAAQ,OAAO,KAAK;AAC1B,QAAI,OAAO,UAAU,MAAM,IAAI,SAAS,EACvC,QAAO,OAAO,WAAW,MAAM;;AAGjC,UAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;KAE3C,CAAC;;;;;CAMH,IAAI,QAAW;AACd,SAAO,KAAK;;;;;;;CAQb,AAAU,WAAW,OAAwB;EAC5C,MAAM,IAAI,KAAK;AACf,MAAI,MAAM,QAAQ,EAAE,IAAI,OAAO,SAAS,EAAE,IAAI,OAAO,MAAM,SAC1D,QAAO,EAAE;AAGV,MAAI,UAAU,EACb,QAAO;;;;;CAkBT,AAAU,aAAa,QAAwB;EAC9C,IAAI,aAAa,KAAK;EACtB,IAAIC;AAEJ,MAAI,SAAS,SACZ,OAAM,IAAI,MAAM,UAAU,OAAO,UAAU,CAAC,6BAA6B;AAG1E,MAAI,SAAS,OAAQ;AAEpB,iBAAc;AACd,iBAAc,OAAO,MAAM,EAAE;AAC7B,eAAY,WAAW,YAAY,EAAE;AACrC,eAAY,YAAY,QAAQ,GAAG,EAAE;aAC3B,SAAS,KAAM;AAEzB,iBAAc;AACd,iBAAc,OAAO,MAAM,EAAE;AAC7B,eAAY,WAAW,YAAY,EAAE;AACrC,eAAY,cAAc,QAAQ,EAAE;SAC9B;AAEN,iBAAc;AACd,iBAAc,OAAO,MAAM,EAAE;AAC7B,eAAY,WAAW,YAAY,EAAE;AACrC,eAAY,WAAW,QAAQ,EAAE;;AAElC,SAAO"}
1
+ {"version":3,"file":"AbstractSecs2Item.js","names":["type: SecsItemType","_value: T","lengthBytes: Buffer"],"sources":["../../../src/core/secs2item/AbstractSecs2Item.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\n\nexport abstract class AbstractSecs2Item<T = unknown> {\n\t[index: number]: unknown;\n\n\tconstructor(\n\t\tpublic readonly type: SecsItemType,\n\t\tprotected readonly _value: T,\n\t) {\n\t\treturn new Proxy(this, {\n\t\t\tget: (target, prop, receiver) => {\n\t\t\t\tif (typeof prop === \"string\") {\n\t\t\t\t\tconst index = Number(prop);\n\t\t\t\t\tif (Number.isInteger(index) && index >= 0) {\n\t\t\t\t\t\treturn target.getByIndex(index);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn Reflect.get(target, prop, receiver);\n\t\t\t},\n\t\t});\n\t}\n\n\t/**\n\t * @description Returns the value of the item.\n\t */\n\tget value(): T {\n\t\treturn this._value;\n\t}\n\n\t/**\n\t * @description Returns the value of the item at the given index.\n\t * @param index The index of the value to return.\n\t * @returns The value of the item at the given index.\n\t */\n\tprotected getByIndex(index: number): unknown {\n\t\tconst v = this._value;\n\t\tif (Array.isArray(v) || Buffer.isBuffer(v) || typeof v === \"string\") {\n\t\t\treturn v[index];\n\t\t}\n\t\t// Scalar value\n\t\tif (index === 0) {\n\t\t\treturn v;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * @description Returns the SML representation of the item.\n\t */\n\tabstract toSml(): string;\n\n\t/**\n\t * @description Returns the SECS-II encoded buffer of the item.\n\t */\n\tabstract toBuffer(): Buffer;\n\n\t/**\n\t * @description Helper to create the header (Type + LengthBytes)\n\t */\n\tprotected createHeader(length: number): Buffer {\n\t\tlet headerByte = this.type;\n\t\tlet lengthBytes: Buffer;\n\n\t\tif (length > 0xffffff) {\n\t\t\tthrow new Error(`Length ${length.toString()} is too large for SECS item`);\n\t\t}\n\n\t\tif (length > 0xffff) {\n\t\t\t// 3 bytes length\n\t\t\theaderByte |= 0x03;\n\t\t\tlengthBytes = Buffer.alloc(4);\n\t\t\tlengthBytes.writeUInt8(headerByte, 0);\n\t\t\tlengthBytes.writeUIntBE(length, 1, 3);\n\t\t} else if (length > 0xff) {\n\t\t\t// 2 bytes length\n\t\t\theaderByte |= 0x02;\n\t\t\tlengthBytes = Buffer.alloc(3);\n\t\t\tlengthBytes.writeUInt8(headerByte, 0);\n\t\t\tlengthBytes.writeUInt16BE(length, 1);\n\t\t} else {\n\t\t\t// 1 byte length\n\t\t\theaderByte |= 0x01;\n\t\t\tlengthBytes = Buffer.alloc(2);\n\t\t\tlengthBytes.writeUInt8(headerByte, 0);\n\t\t\tlengthBytes.writeUInt8(length, 1);\n\t\t}\n\t\treturn lengthBytes;\n\t}\n}\n"],"mappings":";AAEA,IAAsB,oBAAtB,MAAqD;CAGpD,YACC,AAAgBA,MAChB,AAAmBC,QAClB;EAFe;EACG;AAEnB,SAAO,IAAI,MAAM,MAAM,EACtB,MAAM,QAAQ,MAAM,aAAa;AAChC,OAAI,OAAO,SAAS,UAAU;IAC7B,MAAM,QAAQ,OAAO,KAAK;AAC1B,QAAI,OAAO,UAAU,MAAM,IAAI,SAAS,EACvC,QAAO,OAAO,WAAW,MAAM;;AAGjC,UAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;KAE3C,CAAC;;;;;CAMH,IAAI,QAAW;AACd,SAAO,KAAK;;;;;;;CAQb,AAAU,WAAW,OAAwB;EAC5C,MAAM,IAAI,KAAK;AACf,MAAI,MAAM,QAAQ,EAAE,IAAI,OAAO,SAAS,EAAE,IAAI,OAAO,MAAM,SAC1D,QAAO,EAAE;AAGV,MAAI,UAAU,EACb,QAAO;;;;;CAkBT,AAAU,aAAa,QAAwB;EAC9C,IAAI,aAAa,KAAK;EACtB,IAAIC;AAEJ,MAAI,SAAS,SACZ,OAAM,IAAI,MAAM,UAAU,OAAO,UAAU,CAAC,6BAA6B;AAG1E,MAAI,SAAS,OAAQ;AAEpB,iBAAc;AACd,iBAAc,OAAO,MAAM,EAAE;AAC7B,eAAY,WAAW,YAAY,EAAE;AACrC,eAAY,YAAY,QAAQ,GAAG,EAAE;aAC3B,SAAS,KAAM;AAEzB,iBAAc;AACd,iBAAc,OAAO,MAAM,EAAE;AAC7B,eAAY,WAAW,YAAY,EAAE;AACrC,eAAY,cAAc,QAAQ,EAAE;SAC9B;AAEN,iBAAc;AACd,iBAAc,OAAO,MAAM,EAAE;AAC7B,eAAY,WAAW,YAAY,EAAE;AACrC,eAAY,WAAW,QAAQ,EAAE;;AAElC,SAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"Secs2ItemAscii.js","names":[],"sources":["../../../src/core/secs2item/Secs2ItemAscii.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\r\nimport { AbstractSecs2Item } from \"./AbstractSecs2Item.js\";\r\n\r\n/**\r\n * @description\r\n * ASCII string item is a string item that contains only ASCII characters.\r\n * @example\r\n * new Secs2ItemAscii(\"Hello World\");\r\n */\r\nexport class Secs2ItemAscii extends AbstractSecs2Item<string> {\r\n\tconstructor(value: string) {\r\n\t\tsuper(SecsItemType.A, value);\r\n\t}\r\n\r\n\toverride toSml(): string {\r\n\t\treturn `<A [${this._value.length}] \"${this._value}\">`;\r\n\t}\r\n\r\n\toverride toBuffer(): Buffer {\r\n\t\tconst valueBuffer = Buffer.from(this._value, \"ascii\");\r\n\t\tconst header = this.createHeader(valueBuffer.length);\r\n\t\treturn Buffer.concat([header, valueBuffer]);\r\n\t}\r\n}\r\n"],"mappings":";;;;;;;;;;AASA,IAAa,iBAAb,cAAoC,kBAA0B;CAC7D,YAAY,OAAe;AAC1B,QAAM,aAAa,GAAG,MAAM;;CAG7B,AAAS,QAAgB;AACxB,SAAO,OAAO,KAAK,OAAO,OAAO,KAAK,KAAK,OAAO;;CAGnD,AAAS,WAAmB;EAC3B,MAAM,cAAc,OAAO,KAAK,KAAK,QAAQ,QAAQ;EACrD,MAAM,SAAS,KAAK,aAAa,YAAY,OAAO;AACpD,SAAO,OAAO,OAAO,CAAC,QAAQ,YAAY,CAAC"}
1
+ {"version":3,"file":"Secs2ItemAscii.js","names":[],"sources":["../../../src/core/secs2item/Secs2ItemAscii.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\nimport { AbstractSecs2Item } from \"./AbstractSecs2Item.js\";\n\n/**\n * @description\n * ASCII string item is a string item that contains only ASCII characters.\n * @example\n * new Secs2ItemAscii(\"Hello World\");\n */\nexport class Secs2ItemAscii extends AbstractSecs2Item<string> {\n\tconstructor(value: string) {\n\t\tsuper(SecsItemType.A, value);\n\t}\n\n\toverride toSml(): string {\n\t\treturn `<A [${this._value.length}] \"${this._value}\">`;\n\t}\n\n\toverride toBuffer(): Buffer {\n\t\tconst valueBuffer = Buffer.from(this._value, \"ascii\");\n\t\tconst header = this.createHeader(valueBuffer.length);\n\t\treturn Buffer.concat([header, valueBuffer]);\n\t}\n}\n"],"mappings":";;;;;;;;;;AASA,IAAa,iBAAb,cAAoC,kBAA0B;CAC7D,YAAY,OAAe;AAC1B,QAAM,aAAa,GAAG,MAAM;;CAG7B,AAAS,QAAgB;AACxB,SAAO,OAAO,KAAK,OAAO,OAAO,KAAK,KAAK,OAAO;;CAGnD,AAAS,WAAmB;EAC3B,MAAM,cAAc,OAAO,KAAK,KAAK,QAAQ,QAAQ;EACrD,MAAM,SAAS,KAAK,aAAa,YAAY,OAAO;AACpD,SAAO,OAAO,OAAO,CAAC,QAAQ,YAAY,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Secs2ItemBinary.js","names":[],"sources":["../../../src/core/secs2item/Secs2ItemBinary.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\r\nimport { AbstractSecs2Item } from \"./AbstractSecs2Item.js\";\r\n\r\nexport class Secs2ItemBinary extends AbstractSecs2Item<Buffer> {\r\n\tconstructor(value: Buffer | number[]) {\r\n\t\tsuper(SecsItemType.B, Buffer.isBuffer(value) ? value : Buffer.from(value));\r\n\t}\r\n\r\n\toverride toSml(): string {\r\n\t\tconst hex = [];\r\n\t\tfor (const byte of this._value) {\r\n\t\t\thex.push(\"0x\" + byte.toString(16).toUpperCase().padStart(2, \"0\"));\r\n\t\t}\r\n\t\treturn `<B [${this._value.length}] ${hex.join(\" \")}>`;\r\n\t}\r\n\r\n\toverride toBuffer(): Buffer {\r\n\t\tconst header = this.createHeader(this._value.length);\r\n\t\treturn Buffer.concat([header, this._value]);\r\n\t}\r\n}\r\n"],"mappings":";;;;AAGA,IAAa,kBAAb,cAAqC,kBAA0B;CAC9D,YAAY,OAA0B;AACrC,QAAM,aAAa,GAAG,OAAO,SAAS,MAAM,GAAG,QAAQ,OAAO,KAAK,MAAM,CAAC;;CAG3E,AAAS,QAAgB;EACxB,MAAM,MAAM,EAAE;AACd,OAAK,MAAM,QAAQ,KAAK,OACvB,KAAI,KAAK,OAAO,KAAK,SAAS,GAAG,CAAC,aAAa,CAAC,SAAS,GAAG,IAAI,CAAC;AAElE,SAAO,OAAO,KAAK,OAAO,OAAO,IAAI,IAAI,KAAK,IAAI,CAAC;;CAGpD,AAAS,WAAmB;EAC3B,MAAM,SAAS,KAAK,aAAa,KAAK,OAAO,OAAO;AACpD,SAAO,OAAO,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC"}
1
+ {"version":3,"file":"Secs2ItemBinary.js","names":[],"sources":["../../../src/core/secs2item/Secs2ItemBinary.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\nimport { AbstractSecs2Item } from \"./AbstractSecs2Item.js\";\n\nexport class Secs2ItemBinary extends AbstractSecs2Item<Buffer> {\n\tconstructor(value: Buffer | number[]) {\n\t\tsuper(SecsItemType.B, Buffer.isBuffer(value) ? value : Buffer.from(value));\n\t}\n\n\toverride toSml(): string {\n\t\tconst hex = [];\n\t\tfor (const byte of this._value) {\n\t\t\thex.push(\"0x\" + byte.toString(16).toUpperCase().padStart(2, \"0\"));\n\t\t}\n\t\treturn `<B [${this._value.length}] ${hex.join(\" \")}>`;\n\t}\n\n\toverride toBuffer(): Buffer {\n\t\tconst header = this.createHeader(this._value.length);\n\t\treturn Buffer.concat([header, this._value]);\n\t}\n}\n"],"mappings":";;;;AAGA,IAAa,kBAAb,cAAqC,kBAA0B;CAC9D,YAAY,OAA0B;AACrC,QAAM,aAAa,GAAG,OAAO,SAAS,MAAM,GAAG,QAAQ,OAAO,KAAK,MAAM,CAAC;;CAG3E,AAAS,QAAgB;EACxB,MAAM,MAAM,EAAE;AACd,OAAK,MAAM,QAAQ,KAAK,OACvB,KAAI,KAAK,OAAO,KAAK,SAAS,GAAG,CAAC,aAAa,CAAC,SAAS,GAAG,IAAI,CAAC;AAElE,SAAO,OAAO,KAAK,OAAO,OAAO,IAAI,IAAI,KAAK,IAAI,CAAC;;CAGpD,AAAS,WAAmB;EAC3B,MAAM,SAAS,KAAK,aAAa,KAAK,OAAO,OAAO;AACpD,SAAO,OAAO,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Secs2ItemBoolean.js","names":[],"sources":["../../../src/core/secs2item/Secs2ItemBoolean.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\r\nimport { AbstractSecs2Item } from \"./AbstractSecs2Item.js\";\r\n\r\nexport class Secs2ItemBoolean extends AbstractSecs2Item<boolean | boolean[]> {\r\n\tconstructor(value: boolean | boolean[]) {\r\n\t\tsuper(SecsItemType.BOOLEAN, value);\r\n\t}\r\n\r\n\tget valueAsArray(): boolean[] {\r\n\t\treturn Array.isArray(this._value) ? this._value : [this._value];\r\n\t}\r\n\r\n\toverride toSml(): string {\r\n\t\tconst values = this.valueAsArray.map((v) => (v ? \"T\" : \"F\")); // Using T/F for brevity, standard might be TRUE/FALSE\r\n\t\treturn `<BOOLEAN ${values.join(\" \")}>`;\r\n\t}\r\n\r\n\toverride toBuffer(): Buffer {\r\n\t\tconst values = this.valueAsArray;\r\n\t\tconst buffer = Buffer.alloc(values.length);\r\n\t\tvalues.forEach((v, i) => buffer.writeUInt8(v ? 1 : 0, i)); // Or 0xFF? Python says 0xFF if v else 0x00?\r\n\t\t// Python code: 0xFF if v else 0x00.\r\n\t\t// Let's check pysemisecs again.\r\n\t\t// return bytes([(0xFF if v else 0x00) for v in self._value])\r\n\t\t// So 0xFF.\r\n\t\tvalues.forEach((v, i) => buffer.writeUInt8(v ? 0xff : 0x00, i));\r\n\t\tconst header = this.createHeader(buffer.length);\r\n\t\treturn Buffer.concat([header, buffer]);\r\n\t}\r\n}\r\n"],"mappings":";;;;AAGA,IAAa,mBAAb,cAAsC,kBAAuC;CAC5E,YAAY,OAA4B;AACvC,QAAM,aAAa,SAAS,MAAM;;CAGnC,IAAI,eAA0B;AAC7B,SAAO,MAAM,QAAQ,KAAK,OAAO,GAAG,KAAK,SAAS,CAAC,KAAK,OAAO;;CAGhE,AAAS,QAAgB;AAExB,SAAO,YADQ,KAAK,aAAa,KAAK,MAAO,IAAI,MAAM,IAAK,CAClC,KAAK,IAAI,CAAC;;CAGrC,AAAS,WAAmB;EAC3B,MAAM,SAAS,KAAK;EACpB,MAAM,SAAS,OAAO,MAAM,OAAO,OAAO;AAC1C,SAAO,SAAS,GAAG,MAAM,OAAO,WAAW,IAAI,IAAI,GAAG,EAAE,CAAC;AAKzD,SAAO,SAAS,GAAG,MAAM,OAAO,WAAW,IAAI,MAAO,GAAM,EAAE,CAAC;EAC/D,MAAM,SAAS,KAAK,aAAa,OAAO,OAAO;AAC/C,SAAO,OAAO,OAAO,CAAC,QAAQ,OAAO,CAAC"}
1
+ {"version":3,"file":"Secs2ItemBoolean.js","names":[],"sources":["../../../src/core/secs2item/Secs2ItemBoolean.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\nimport { AbstractSecs2Item } from \"./AbstractSecs2Item.js\";\n\nexport class Secs2ItemBoolean extends AbstractSecs2Item<boolean | boolean[]> {\n\tconstructor(value: boolean | boolean[]) {\n\t\tsuper(SecsItemType.BOOLEAN, value);\n\t}\n\n\tget valueAsArray(): boolean[] {\n\t\treturn Array.isArray(this._value) ? this._value : [this._value];\n\t}\n\n\toverride toSml(): string {\n\t\tconst values = this.valueAsArray.map((v) => (v ? \"T\" : \"F\")); // Using T/F for brevity, standard might be TRUE/FALSE\n\t\treturn `<BOOLEAN ${values.join(\" \")}>`;\n\t}\n\n\toverride toBuffer(): Buffer {\n\t\tconst values = this.valueAsArray;\n\t\tconst buffer = Buffer.alloc(values.length);\n\t\tvalues.forEach((v, i) => buffer.writeUInt8(v ? 1 : 0, i)); // Or 0xFF? Python says 0xFF if v else 0x00?\n\t\t// Python code: 0xFF if v else 0x00.\n\t\t// Let's check pysemisecs again.\n\t\t// return bytes([(0xFF if v else 0x00) for v in self._value])\n\t\t// So 0xFF.\n\t\tvalues.forEach((v, i) => buffer.writeUInt8(v ? 0xff : 0x00, i));\n\t\tconst header = this.createHeader(buffer.length);\n\t\treturn Buffer.concat([header, buffer]);\n\t}\n}\n"],"mappings":";;;;AAGA,IAAa,mBAAb,cAAsC,kBAAuC;CAC5E,YAAY,OAA4B;AACvC,QAAM,aAAa,SAAS,MAAM;;CAGnC,IAAI,eAA0B;AAC7B,SAAO,MAAM,QAAQ,KAAK,OAAO,GAAG,KAAK,SAAS,CAAC,KAAK,OAAO;;CAGhE,AAAS,QAAgB;AAExB,SAAO,YADQ,KAAK,aAAa,KAAK,MAAO,IAAI,MAAM,IAAK,CAClC,KAAK,IAAI,CAAC;;CAGrC,AAAS,WAAmB;EAC3B,MAAM,SAAS,KAAK;EACpB,MAAM,SAAS,OAAO,MAAM,OAAO,OAAO;AAC1C,SAAO,SAAS,GAAG,MAAM,OAAO,WAAW,IAAI,IAAI,GAAG,EAAE,CAAC;AAKzD,SAAO,SAAS,GAAG,MAAM,OAAO,WAAW,IAAI,MAAO,GAAM,EAAE,CAAC;EAC/D,MAAM,SAAS,KAAK,aAAa,OAAO,OAAO;AAC/C,SAAO,OAAO,OAAO,CAAC,QAAQ,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Secs2ItemFactory.js","names":[],"sources":["../../../src/core/secs2item/Secs2ItemFactory.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\r\nimport { AbstractSecs2Item } from \"./AbstractSecs2Item.js\";\r\nimport { Secs2ItemNumeric } from \"./Secs2ItemNumeric.js\";\r\nimport { Secs2ItemAscii } from \"./Secs2ItemAscii.js\";\r\nimport { Secs2ItemBinary } from \"./Secs2ItemBinary.js\";\r\nimport { Secs2ItemBoolean } from \"./Secs2ItemBoolean.js\";\r\nimport { Secs2ItemList } from \"./Secs2ItemList.js\";\r\n\r\nexport class Secs2ItemFactory {\r\n\tstatic createAsciiItem(value: string): Secs2ItemAscii {\r\n\t\treturn new Secs2ItemAscii(value);\r\n\t}\r\n\r\n\tstatic createBooleanItem(...value: boolean[]): Secs2ItemBoolean {\r\n\t\treturn new Secs2ItemBoolean(value);\r\n\t}\r\n\r\n\tstatic createBinaryItem(...value: Buffer[]): Secs2ItemBinary {\r\n\t\treturn new Secs2ItemBinary(Buffer.concat(value));\r\n\t}\r\n\r\n\tstatic createListItem(...items: AbstractSecs2Item[]): Secs2ItemList {\r\n\t\treturn new Secs2ItemList(items);\r\n\t}\r\n\r\n\tstatic createU1Item(...value: number[]): Secs2ItemNumeric {\r\n\t\treturn new Secs2ItemNumeric(SecsItemType.U1, value);\r\n\t}\r\n\r\n\tstatic createU2Item(...value: number[]): Secs2ItemNumeric {\r\n\t\treturn new Secs2ItemNumeric(SecsItemType.U2, value);\r\n\t}\r\n\r\n\tstatic createU4Item(...value: number[]): Secs2ItemNumeric {\r\n\t\treturn new Secs2ItemNumeric(SecsItemType.U4, value);\r\n\t}\r\n\r\n\tstatic createU8Item(...value: number[] | bigint[]): Secs2ItemNumeric {\r\n\t\treturn new Secs2ItemNumeric(SecsItemType.U8, value);\r\n\t}\r\n\r\n\tstatic createI1Item(...value: number[]): Secs2ItemNumeric {\r\n\t\treturn new Secs2ItemNumeric(SecsItemType.I1, value);\r\n\t}\r\n\r\n\tstatic createI2Item(...value: number[]): Secs2ItemNumeric {\r\n\t\treturn new Secs2ItemNumeric(SecsItemType.I2, value);\r\n\t}\r\n\r\n\tstatic createI4Item(...value: number[]): Secs2ItemNumeric {\r\n\t\treturn new Secs2ItemNumeric(SecsItemType.I4, value);\r\n\t}\r\n\r\n\tstatic createI8Item(...value: number[] | bigint[]): Secs2ItemNumeric {\r\n\t\treturn new Secs2ItemNumeric(SecsItemType.I8, value);\r\n\t}\r\n\r\n\tstatic createF4Item(...value: number[]): Secs2ItemNumeric {\r\n\t\treturn new Secs2ItemNumeric(SecsItemType.F4, value);\r\n\t}\r\n\r\n\tstatic createF8Item(...value: number[] | bigint[]): Secs2ItemNumeric {\r\n\t\treturn new Secs2ItemNumeric(SecsItemType.F8, value);\r\n\t}\r\n}\r\n"],"mappings":";;;;;;;;AAQA,IAAa,mBAAb,MAA8B;CAC7B,OAAO,gBAAgB,OAA+B;AACrD,SAAO,IAAI,eAAe,MAAM;;CAGjC,OAAO,kBAAkB,GAAG,OAAoC;AAC/D,SAAO,IAAI,iBAAiB,MAAM;;CAGnC,OAAO,iBAAiB,GAAG,OAAkC;AAC5D,SAAO,IAAI,gBAAgB,OAAO,OAAO,MAAM,CAAC;;CAGjD,OAAO,eAAe,GAAG,OAA2C;AACnE,SAAO,IAAI,cAAc,MAAM;;CAGhC,OAAO,aAAa,GAAG,OAAmC;AACzD,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM;;CAGpD,OAAO,aAAa,GAAG,OAAmC;AACzD,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM;;CAGpD,OAAO,aAAa,GAAG,OAAmC;AACzD,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM;;CAGpD,OAAO,aAAa,GAAG,OAA8C;AACpE,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM;;CAGpD,OAAO,aAAa,GAAG,OAAmC;AACzD,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM;;CAGpD,OAAO,aAAa,GAAG,OAAmC;AACzD,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM;;CAGpD,OAAO,aAAa,GAAG,OAAmC;AACzD,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM;;CAGpD,OAAO,aAAa,GAAG,OAA8C;AACpE,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM;;CAGpD,OAAO,aAAa,GAAG,OAAmC;AACzD,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM;;CAGpD,OAAO,aAAa,GAAG,OAA8C;AACpE,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM"}
1
+ {"version":3,"file":"Secs2ItemFactory.js","names":[],"sources":["../../../src/core/secs2item/Secs2ItemFactory.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\nimport { AbstractSecs2Item } from \"./AbstractSecs2Item.js\";\nimport { Secs2ItemNumeric } from \"./Secs2ItemNumeric.js\";\nimport { Secs2ItemAscii } from \"./Secs2ItemAscii.js\";\nimport { Secs2ItemBinary } from \"./Secs2ItemBinary.js\";\nimport { Secs2ItemBoolean } from \"./Secs2ItemBoolean.js\";\nimport { Secs2ItemList } from \"./Secs2ItemList.js\";\n\nexport class Secs2ItemFactory {\n\tstatic createAsciiItem(value: string): Secs2ItemAscii {\n\t\treturn new Secs2ItemAscii(value);\n\t}\n\n\tstatic createBooleanItem(...value: boolean[]): Secs2ItemBoolean {\n\t\treturn new Secs2ItemBoolean(value);\n\t}\n\n\tstatic createBinaryItem(...value: Buffer[]): Secs2ItemBinary {\n\t\treturn new Secs2ItemBinary(Buffer.concat(value));\n\t}\n\n\tstatic createListItem(...items: AbstractSecs2Item[]): Secs2ItemList {\n\t\treturn new Secs2ItemList(items);\n\t}\n\n\tstatic createU1Item(...value: number[]): Secs2ItemNumeric {\n\t\treturn new Secs2ItemNumeric(SecsItemType.U1, value);\n\t}\n\n\tstatic createU2Item(...value: number[]): Secs2ItemNumeric {\n\t\treturn new Secs2ItemNumeric(SecsItemType.U2, value);\n\t}\n\n\tstatic createU4Item(...value: number[]): Secs2ItemNumeric {\n\t\treturn new Secs2ItemNumeric(SecsItemType.U4, value);\n\t}\n\n\tstatic createU8Item(...value: number[] | bigint[]): Secs2ItemNumeric {\n\t\treturn new Secs2ItemNumeric(SecsItemType.U8, value);\n\t}\n\n\tstatic createI1Item(...value: number[]): Secs2ItemNumeric {\n\t\treturn new Secs2ItemNumeric(SecsItemType.I1, value);\n\t}\n\n\tstatic createI2Item(...value: number[]): Secs2ItemNumeric {\n\t\treturn new Secs2ItemNumeric(SecsItemType.I2, value);\n\t}\n\n\tstatic createI4Item(...value: number[]): Secs2ItemNumeric {\n\t\treturn new Secs2ItemNumeric(SecsItemType.I4, value);\n\t}\n\n\tstatic createI8Item(...value: number[] | bigint[]): Secs2ItemNumeric {\n\t\treturn new Secs2ItemNumeric(SecsItemType.I8, value);\n\t}\n\n\tstatic createF4Item(...value: number[]): Secs2ItemNumeric {\n\t\treturn new Secs2ItemNumeric(SecsItemType.F4, value);\n\t}\n\n\tstatic createF8Item(...value: number[] | bigint[]):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src/core/secs2item/Secs2ItemList.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\r\nimport { AbstractSecs2Item } from \"./AbstractSecs2Item.js\";\r\n\r\nexport class Secs2ItemList extends AbstractSecs2Item<AbstractSecs2Item[]> {\r\n\tconstructor(value: AbstractSecs2Item[]) {\r\n\t\tsuper(SecsItemType.L, value);\r\n\t}\r\n\r\n\toverride toSml(): string {\r\n\t\tif (this._value.length === 0) {\r\n\t\t\treturn \"<L [0] >\";\r\n\t\t}\r\n\t\tconst lines = [`<L [${this._value.length.toString()}] `];\r\n\t\tfor (const item of this._value) {\r\n\t\t\tlines.push(\" \" + item.toSml().replace(/\\n/g, \"\\n \"));\r\n\t\t}\r\n\t\tlines.push(\">\");\r\n\t\treturn lines.join(\"\\n\");\r\n\t}\r\n\r\n\toverride toBuffer(): Buffer {\r\n\t\tconst buffers = this._value.map((item) => item.toBuffer());\r\n\t\tconst valueBuffer = Buffer.concat(buffers);\r\n\t\t// For List, length is number of items, not byte length\r\n\t\tconst header = this.createHeader(this._value.length);\r\n\t\treturn Buffer.concat([header, valueBuffer]);\r\n\t}\r\n}\r\n"],"mappings":";;;;AAGA,IAAa,gBAAb,cAAmC,kBAAuC;CACzE,YAAY,OAA4B;AACvC,QAAM,aAAa,GAAG,MAAM;;CAG7B,AAAS,QAAgB;AACxB,MAAI,KAAK,OAAO,WAAW,EAC1B,QAAO;EAER,MAAM,QAAQ,CAAC,OAAO,KAAK,OAAO,OAAO,UAAU,CAAC,IAAI;AACxD,OAAK,MAAM,QAAQ,KAAK,OACvB,OAAM,KAAK,OAAO,KAAK,OAAO,CAAC,QAAQ,OAAO,OAAO,CAAC;AAEvD,QAAM,KAAK,IAAI;AACf,SAAO,MAAM,KAAK,KAAK;;CAGxB,AAAS,WAAmB;EAC3B,MAAM,UAAU,KAAK,OAAO,KAAK,SAAS,KAAK,UAAU,CAAC;EAC1D,MAAM,cAAc,OAAO,OAAO,QAAQ;EAE1C,MAAM,SAAS,KAAK,aAAa,KAAK,OAAO,OAAO;AACpD,SAAO,OAAO,OAAO,CAAC,QAAQ,YAAY,CAAC"}
1
+ {"version":3,"file":"Secs2ItemList.js","names":[],"sources":["../../../src/core/secs2item/Secs2ItemList.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\nimport { AbstractSecs2Item } from \"./AbstractSecs2Item.js\";\n\nexport class Secs2ItemList extends AbstractSecs2Item<AbstractSecs2Item[]> {\n\tconstructor(value: AbstractSecs2Item[]) {\n\t\tsuper(SecsItemType.L, value);\n\t}\n\n\toverride toSml(): string {\n\t\tif (this._value.length === 0) {\n\t\t\treturn \"<L [0] >\";\n\t\t}\n\t\tconst lines = [`<L [${this._value.length.toString()}] `];\n\t\tfor (const item of this._value) {\n\t\t\tlines.push(\" \" + item.toSml().replace(/\\n/g, \"\\n \"));\n\t\t}\n\t\tlines.push(\">\");\n\t\treturn lines.join(\"\\n\");\n\t}\n\n\toverride toBuffer(): Buffer {\n\t\tconst buffers = this._value.map((item) => item.toBuffer());\n\t\tconst valueBuffer = Buffer.concat(buffers);\n\t\t// For List, length is number of items, not byte length\n\t\tconst header = this.createHeader(this._value.length);\n\t\treturn Buffer.concat([header, valueBuffer]);\n\t}\n}\n"],"mappings":";;;;AAGA,IAAa,gBAAb,cAAmC,kBAAuC;CACzE,YAAY,OAA4B;AACvC,QAAM,aAAa,GAAG,MAAM;;CAG7B,AAAS,QAAgB;AACxB,MAAI,KAAK,OAAO,WAAW,EAC1B,QAAO;EAER,MAAM,QAAQ,CAAC,OAAO,KAAK,OAAO,OAAO,UAAU,CAAC,IAAI;AACxD,OAAK,MAAM,QAAQ,KAAK,OACvB,OAAM,KAAK,OAAO,KAAK,OAAO,CAAC,QAAQ,OAAO,OAAO,CAAC;AAEvD,QAAM,KAAK,IAAI;AACf,SAAO,MAAM,KAAK,KAAK;;CAGxB,AAAS,WAAmB;EAC3B,MAAM,UAAU,KAAK,OAAO,KAAK,SAAS,KAAK,UAAU,CAAC;EAC1D,MAAM,cAAc,OAAO,OAAO,QAAQ;EAE1C,MAAM,SAAS,KAAK,aAAa,KAAK,OAAO,OAAO;AACpD,SAAO,OAAO,OAAO,CAAC,QAAQ,YAAY,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Secs2ItemNumeric.js","names":["writeFunc: (val: number | bigint, buf: Buffer, offset: number) => void","readFunc: (buf: Buffer, offset: number) => number | bigint","values: (number | bigint)[]"],"sources":["../../../src/core/secs2item/Secs2ItemNumeric.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\r\nimport { AbstractSecs2Item } from \"./AbstractSecs2Item.js\";\r\n\r\nexport class Secs2ItemNumeric extends AbstractSecs2Item<\r\n\tnumber | number[] | bigint | bigint[]\r\n> {\r\n\tconstructor(\r\n\t\ttype: SecsItemType,\r\n\t\tvalue: number | number[] | bigint | bigint[],\r\n\t) {\r\n\t\tsuper(type, value);\r\n\t}\r\n\r\n\tget valueAsArray(): (number | bigint)[] {\r\n\t\treturn Array.isArray(this._value) ? this._value : [this._value];\r\n\t}\r\n\r\n\toverride toSml(): string {\r\n\t\tconst typeName = SecsItemType[this.type];\r\n\t\tconst values = this.valueAsArray.map((v) => v.toString());\r\n\t\treturn `<${typeName} [${values.length}] ${values.join(\" \")}>`;\r\n\t}\r\n\r\n\toverride toBuffer(): Buffer {\r\n\t\tconst values = this.valueAsArray;\r\n\t\tlet elementSize = 0;\r\n\t\tlet writeFunc: (val: number | bigint, buf: Buffer, offset: number) => void;\r\n\r\n\t\tswitch (this.type) {\r\n\t\t\tcase SecsItemType.I1:\r\n\t\t\t\telementSize = 1;\r\n\t\t\t\twriteFunc = (v, b, o) => b.writeInt8(Number(v), o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.I2:\r\n\t\t\t\telementSize = 2;\r\n\t\t\t\twriteFunc = (v, b, o) => b.writeInt16BE(Number(v), o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.I4:\r\n\t\t\t\telementSize = 4;\r\n\t\t\t\twriteFunc = (v, b, o) => b.writeInt32BE(Number(v), o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.I8:\r\n\t\t\t\telementSize = 8;\r\n\t\t\t\twriteFunc = (v, b, o) => b.writeBigInt64BE(BigInt(v), o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.U1:\r\n\t\t\t\telementSize = 1;\r\n\t\t\t\twriteFunc = (v, b, o) => b.writeUInt8(Number(v), o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.U2:\r\n\t\t\t\telementSize = 2;\r\n\t\t\t\twriteFunc = (v, b, o) => b.writeUInt16BE(Number(v), o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.U4:\r\n\t\t\t\telementSize = 4;\r\n\t\t\t\twriteFunc = (v, b, o) => b.writeUInt32BE(Number(v), o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.U8:\r\n\t\t\t\telementSize = 8;\r\n\t\t\t\twriteFunc = (v, b, o) => b.writeBigUInt64BE(BigInt(v), o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.F4:\r\n\t\t\t\telementSize = 4;\r\n\t\t\t\twriteFunc = (v, b, o) => b.writeFloatBE(Number(v), o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.F8:\r\n\t\t\t\telementSize = 8;\r\n\t\t\t\twriteFunc = (v, b, o) => b.writeDoubleBE(Number(v), o);\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\tthrow new Error(`Unsupported numeric type: ${this.type.toString()}`);\r\n\t\t}\r\n\r\n\t\tconst buffer = Buffer.alloc(values.length * elementSize);\r\n\t\tvalues.forEach((v, i) => {\r\n\t\t\twriteFunc(v, buffer, i * elementSize);\r\n\t\t});\r\n\t\tconst header = this.createHeader(buffer.length);\r\n\t\treturn Buffer.concat([header, buffer]);\r\n\t}\r\n\r\n\tstatic fromTypeBuffer(type: SecsItemType, buffer: Buffer): Secs2ItemNumeric {\r\n\t\tlet elementSize = 0;\r\n\t\tlet readFunc: (buf: Buffer, offset: number) => number | bigint;\r\n\r\n\t\tswitch (type) {\r\n\t\t\tcase SecsItemType.I1:\r\n\t\t\t\telementSize = 1;\r\n\t\t\t\treadFunc = (b, o) => b.readInt8(o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.I2:\r\n\t\t\t\telementSize = 2;\r\n\t\t\t\treadFunc = (b, o) => b.readInt16BE(o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.I4:\r\n\t\t\t\telementSize = 4;\r\n\t\t\t\treadFunc = (b, o) => b.readInt32BE(o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.I8:\r\n\t\t\t\telementSize = 8;\r\n\t\t\t\treadFunc = (b, o) => b.readBigInt64BE(o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.U1:\r\n\t\t\t\telementSize = 1;\r\n\t\t\t\treadFunc = (b, o) => b.readUInt8(o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.U2:\r\n\t\t\t\telementSize = 2;\r\n\t\t\t\treadFunc = (b, o) => b.readUInt16BE(o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.U4:\r\n\t\t\t\telementSize = 4;\r\n\t\t\t\treadFunc = (b, o) => b.readUInt32BE(o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.U8:\r\n\t\t\t\telementSize = 8;\r\n\t\t\t\treadFunc = (b, o) => b.readBigUInt64BE(o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.F4:\r\n\t\t\t\telementSize = 4;\r\n\t\t\t\treadFunc = (b, o) => b.readFloatBE(o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.F8:\r\n\t\t\t\telementSize = 8;\r\n\t\t\t\treadFunc = (b, o) => b.readDoubleBE(o);\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\tthrow new Error(`Unsupported numeric type: ${type.toString()}`);\r\n\t\t}\r\n\r\n\t\tconst count = buffer.length / elementSize;\r\n\t\tif (!Number.isInteger(count)) {\r\n\t\t\tthrow new Error(\r\n\t\t\t\t`Buffer length ${buffer.length.toString()} is not multiple of element size ${elementSize.toString()}`,\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\tconst values: (number | bigint)[] = [];\r\n\t\tfor (let i = 0; i < count; i++) {\r\n\t\t\tvalues.push(readFunc(buffer, i * elementSize));\r\n\t\t}\r\n\r\n\t\tif (type === SecsItemType.I8 || type === SecsItemType.U8) {\r\n\t\t\treturn new Secs2ItemNumeric(\r\n\t\t\t\ttype,\r\n\t\t\t\tvalues.length === 1\r\n\t\t\t\t\t? (values[0] as bigint)\r\n\t\t\t\t\t: (values as unknown as bigint[]),\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\treturn new Secs2ItemNumeric(\r\n\t\t\ttype,\r\n\t\t\tvalues.length === 1 ? (values[0] as number) : (values as number[]),\r\n\t\t);\r\n\t}\r\n}\r\n"],"mappings":";;;;AAGA,IAAa,mBAAb,MAAa,yBAAyB,kBAEpC;CACD,YACC,MACA,OACC;AACD,QAAM,MAAM,MAAM;;CAGnB,IAAI,eAAoC;AACvC,SAAO,MAAM,QAAQ,KAAK,OAAO,GAAG,KAAK,SAAS,CAAC,KAAK,OAAO;;CAGhE,AAAS,QAAgB;EACxB,MAAM,WAAW,aAAa,KAAK;EACnC,MAAM,SAAS,KAAK,aAAa,KAAK,MAAM,EAAE,UAAU,CAAC;AACzD,SAAO,IAAI,SAAS,IAAI,OAAO,OAAO,IAAI,OAAO,KAAK,IAAI,CAAC;;CAG5D,AAAS,WAAmB;EAC3B,MAAM,SAAS,KAAK;EACpB,IAAI,cAAc;EAClB,IAAIA;AAEJ,UAAQ,KAAK,MAAb;GACC,KAAK,aAAa;AACjB,kBAAc;AACd,iBAAa,GAAG,GAAG,MAAM,EAAE,UAAU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AAS,aAAa,GACrD,QAAO,IAAI,iBACV,MACA,OAAO,WAAW,IACd,OAAO,KACP,OACJ;AAGF,SAAO,IAAI,iBACV,MACA,OAAO,WAAW,IAAK,OAAO,KAAiB,OAC/C"}
1
+ {"version":3,"file":"Secs2ItemNumeric.js","names":["writeFunc: (val: number | bigint, buf: Buffer, offset: number) => void","readFunc: (buf: Buffer, offset: number) => number | bigint","values: (number | bigint)[]"],"sources":["../../../src/core/secs2item/Secs2ItemNumeric.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\nimport { AbstractSecs2Item } from \"./AbstractSecs2Item.js\";\n\nexport class Secs2ItemNumeric extends AbstractSecs2Item<\n\tnumber | number[] | bigint | bigint[]\n> {\n\tconstructor(\n\t\ttype: SecsItemType,\n\t\tvalue: number | number[] | bigint | bigint[],\n\t) {\n\t\tsuper(type, value);\n\t}\n\n\tget valueAsArray(): (number | bigint)[] {\n\t\treturn Array.isArray(this._value) ? this._value : [this._value];\n\t}\n\n\toverride toSml(): string {\n\t\tconst typeName = SecsItemType[this.type];\n\t\tconst values = this.valueAsArray.map((v) => v.toString());\n\t\treturn `<${typeName} [${values.length}] ${values.join(\" \")}>`;\n\t}\n\n\toverride toBuffer(): Buffer {\n\t\tconst values = this.valueAsArray;\n\t\tlet elementSize = 0;\n\t\tlet writeFunc: (val: number | bigint, buf: Buffer, offset: number) => void;\n\n\t\tswitch (this.type) {\n\t\t\tcase SecsItemType.I1:\n\t\t\t\telementSize = 1;\n\t\t\t\twriteFunc = (v, b, o) => b.writeInt8(Number(v), o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.I2:\n\t\t\t\telementSize = 2;\n\t\t\t\twriteFunc = (v, b, o) => b.writeInt16BE(Number(v), o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.I4:\n\t\t\t\telementSize = 4;\n\t\t\t\twriteFunc = (v, b, o) => b.writeInt32BE(Number(v), o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.I8:\n\t\t\t\telementSize = 8;\n\t\t\t\twriteFunc = (v, b, o) => b.writeBigInt64BE(BigInt(v), o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.U1:\n\t\t\t\telementSize = 1;\n\t\t\t\twriteFunc = (v, b, o) => b.writeUInt8(Number(v), o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.U2:\n\t\t\t\telementSize = 2;\n\t\t\t\twriteFunc = (v, b, o) => b.writeUInt16BE(Number(v), o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.U4:\n\t\t\t\telementSize = 4;\n\t\t\t\twriteFunc = (v, b, o) => b.writeUInt32BE(Number(v), o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.U8:\n\t\t\t\telementSize = 8;\n\t\t\t\twriteFunc = (v, b, o) => b.writeBigUInt64BE(BigInt(v), o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.F4:\n\t\t\t\telementSize = 4;\n\t\t\t\twriteFunc = (v, b, o) => b.writeFloatBE(Number(v), o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.F8:\n\t\t\t\telementSize = 8;\n\t\t\t\twriteFunc = (v, b, o) => b.writeDoubleBE(Number(v), o);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Unsupported numeric type: ${this.type.toString()}`);\n\t\t}\n\n\t\tconst buffer = Buffer.alloc(values.length * elementSize);\n\t\tvalues.forEach((v, i) => {\n\t\t\twriteFunc(v, buffer, i * elementSize);\n\t\t});\n\t\tconst header = this.createHeader(buffer.length);\n\t\treturn Buffer.concat([header, buffer]);\n\t}\n\n\tstatic fromTypeBuffer(type: SecsItemType, buffer: Buffer): Secs2ItemNumeric {\n\t\tlet elementSize = 0;\n\t\tlet readFunc: (buf: Buffer, offset: number) => number | bigint;\n\n\t\tswitch (type) {\n\t\t\tcase SecsItemType.I1:\n\t\t\t\telementSize = 1;\n\t\t\t\treadFunc = (b, o) => b.readInt8(o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.I2:\n\t\t\t\telementSize = 2;\n\t\t\t\treadFunc = (b, o) => b.readInt16BE(o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.I4:\n\t\t\t\telementSize = 4;\n\t\t\t\treadFunc = (b, o) => b.readInt32BE(o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.I8:\n\t\t\t\telementSize = 8;\n\t\t\t\treadFunc = (b, o) => b.readBigInt64BE(o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.U1:\n\t\t\t\telementSize = 1;\n\t\t\t\treadFunc = (b, o) => b.readUInt8(o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.U2:\n\t\t\t\telementSize = 2;\n\t\t\t\treadFunc = (b, o) => b.readUInt16BE(o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.U4:\n\t\t\t\telementSize = 4;\n\t\t\t\treadFunc = (b, o) => b.readUInt32BE(o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.U8:\n\t\t\t\telementSize = 8;\n\t\t\t\treadFunc = (b, o) => b.readBigUInt64BE(o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.F4:\n\t\t\t\telementSize = 4;\n\t\t\t\treadFunc = (b, o) => b.readFloatBE(o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.F8:\n\t\t\t\telementSize = 8;\n\t\t\t\treadFunc = (b, o) => b.readDoubleBE(o);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Unsupported numeric type: ${type.toString()}`);\n\t\t}\n\n\t\tconst count = buffer.length / elementSize;\n\t\tif (!Number.isInteger(count)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Buffer length ${buffer.length.toString()} is not multiple of element size ${elementSize.toString()}`,\n\t\t\t);\n\t\t}\n\n\t\tconst values: (number | bigint)[] = [];\n\t\tfor (let i = 0; i < count; i++) {\n\t\t\tvalues.push(readFunc(buffer, i * elementSize));\n\t\t}\n\n\t\tif (type === SecsItemType.I8 || type === SecsItemType.U8) {\n\t\t\treturn new Secs2ItemNumeric(\n\t\t\t\ttype,\n\t\t\t\tvalues.length === 1\n\t\t\t\t\t? (values[0] as bigint)\n\t\t\t\t\t: (values as unknown as bigint[]),\n\t\t\t);\n\t\t}\n\n\t\treturn new Secs2ItemNumeric(\n\t\t\ttype,\n\t\t\tvalues.length === 1 ? (values[0] as number) : (values as number[]),\n\t\t);\n\t}\n}\n"],"mappings":";;;;AAGA,IAAa,mBAAb,MAAa,yBAAyB,kBAEpC;CACD,YACC,MACA,OACC;AACD,QAAM,MAAM,MAAM;;CAGnB,IAAI,eAAoC;AACvC,SAAO,MAAM,QAAQ,KAAK,OAAO,GAAG,KAAK,SAAS,CAAC,KAAK,OAAO;;CAGhE,AAAS,QAAgB;EACxB,MAAM,WAAW,aAAa,KAAK;EACnC,MAAM,SAAS,KAAK,aAAa,KAAK,MAAM,EAAE,UAAU,CAAC;AACzD,SAAO,IAAI,SAAS,IAAI,OAAO,OAAO,IAAI,OAAO,KAAK,IAAI,CAAC;;CAG5D,AAAS,WAAmB;EAC3B,MAAM,SAAS,KAAK;EACpB,IAAI,cAAc;EAClB,IAAIA;AAEJ,UAAQ,KAAK,MAAb;GACC,KAAK,aAAa;AACjB,kBAAc;AACd,iBAAa,GAAG,GAAG,MAAM,EAAE,UAAU,OAAO,EAAE,EAAE,EAAE;AAClD;GACD,KAAK,aAAa;AACjB,kBAAc;AACd,iBAAa,GAAG,GAAG,MAAM,EAAE,aAAa,OAAO,EAAE,EAAE,EAAE;AACrD;GACD,KAAK,aAAa;AACjB,kBAAc;AACd,iBAAa,GAAG,GAAG,MAAM,EAAE,aAAa,OAAO,EAAE,EAAE,EAAE;AACrD;GACD,KAAK,aAAa;AACjB,kBAAc;AACd,iBAAa,GAAG,GAAG,MAAM,EAAE,gBAAgB,OAAO,EAAE,EAAE,EAAE;AACxD;GACD,KAAK,aAAa;AACjB,kBAAc;AACd,iBAAa,GAAG,GA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AE;AACxC;GACD,KAAK,aAAa;AACjB,kBAAc;AACd,gBAAY,GAAG,MAAM,EAAE,UAAU,EAAE;AACnC;GACD,KAAK,aAAa;AACjB,kBAAc;AACd,gBAAY,GAAG,MAAM,EAAE,aAAa,EAAE;AACtC;GACD,KAAK,aAAa;AACjB,kBAAc;AACd,gBAAY,GAAG,MAAM,EAAE,aAAa,EAAE;AACtC;GACD,KAAK,aAAa;AACjB,kBAAc;AACd,gBAAY,GAAG,MAAM,EAAE,gBAAgB,EAAE;AACzC;GACD,KAAK,aAAa;AACjB,kBAAc;AACd,gBAAY,GAAG,MAAM,EAAE,YAAY,EAAE;AACrC;GACD,KAAK,aAAa;AACjB,kBAAc;AACd,gBAAY,GAAG,MAAM,EAAE,aAAa,EAAE;AACtC;GACD,QACC,OAAM,IAAI,MAAM,6BAA6B,KAAK,UAAU,GAAG;;EAGjE,MAAM,QAAQ,OAAO,SAAS;AAC9B,MAAI,CAAC,OAAO,UAAU,MAAM,CAC3B,OAAM,IAAI,MACT,iBAAiB,OAAO,OAAO,UAAU,CAAC,mCAAmC,YAAY,UAAU,GACnG;EAGF,MAAMC,SAA8B,EAAE;AACtC,OAAK,IAAI,IAAI,GAAG,IAAI,OAAO,IAC1B,QAAO,KAAK,SAAS,QAAQ,IAAI,YAAY,CAAC;AAG/C,MAAI,SAAS,aAAa,MAAM,SAAS,aAAa,GACrD,QAAO,IAAI,iBACV,MACA,OAAO,WAAW,IACd,OAAO,KACP,OACJ;AAGF,SAAO,IAAI,iBACV,MACA,OAAO,WAAW,IAAK,OAAO,KAAiB,OAC/C"}
@@ -1 +1 @@
1
- {"version":3,"file":"Secs2ItemParser.js","names":["items: AbstractSecs2Item[]","item: AbstractSecs2Item"],"sources":["../../../src/core/secs2item/Secs2ItemParser.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\r\nimport { AbstractSecs2Item } from \"./AbstractSecs2Item.js\";\r\nimport { Secs2ItemFactory } from \"./Secs2ItemFactory.js\";\r\nimport { Secs2ItemNumeric } from \"./Secs2ItemNumeric.js\";\r\n\r\nexport class Secs2ItemParser {\r\n\tstatic fromBuffer(buffer: Buffer): {\r\n\t\titem: AbstractSecs2Item;\r\n\t\tconsumed: number;\r\n\t} {\r\n\t\tif (buffer.length === 0) {\r\n\t\t\tthrow new Error(\"Empty buffer\");\r\n\t\t}\r\n\r\n\t\tconst headerByte = buffer.readUInt8(0);\r\n\t\tconst itemType = (headerByte & 0xfc) as SecsItemType; // Clear last 2 bits\r\n\t\tconst lengthBytes = headerByte & 0x03;\r\n\r\n\t\tlet length = 0;\r\n\t\tif (lengthBytes === 1) {\r\n\t\t\tlength = buffer.readUInt8(1);\r\n\t\t} else if (lengthBytes === 2) {\r\n\t\t\tlength = buffer.readUInt16BE(1);\r\n\t\t} else if (lengthBytes === 3) {\r\n\t\t\tlength = buffer.readUIntBE(1, 3);\r\n\t\t} else {\r\n\t\t\tthrow new Error(`Invalid length bytes count: ${lengthBytes.toString()}`);\r\n\t\t}\r\n\r\n\t\tconst valueStart = 1 + lengthBytes;\r\n\r\n\t\t// Handle List items differently: length is number of items, not byte length\r\n\t\tif (itemType === SecsItemType.L) {\r\n\t\t\tconst items: AbstractSecs2Item[] = [];\r\n\t\t\tlet offset = valueStart;\r\n\t\t\tconst numItems = length;\r\n\r\n\t\t\tfor (let i = 0; i < numItems; i++) {\r\n\t\t\t\tif (offset >= buffer.length) {\r\n\t\t\t\t\tthrow new Error(\r\n\t\t\t\t\t\t`Insufficient buffer for List items. Expected ${numItems} items, got incomplete data.`,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\tconst result = Secs2ItemParser.fromBuffer(buffer.subarray(offset));\r\n\t\t\t\titems.push(result.item);\r\n\t\t\t\toffset += result.consumed;\r\n\t\t\t}\r\n\r\n\t\t\tconst item = Secs2ItemFactory.createListItem(...items);\r\n\t\t\treturn { item, consumed: offset };\r\n\t\t}\r\n\r\n\t\t// For other types, length is byte length\r\n\t\tconst valueEnd = valueStart + length;\r\n\r\n\t\tif (buffer.length < valueEnd) {\r\n\t\t\tthrow new Error(\r\n\t\t\t\t`Insufficient buffer length. Expected ${valueEnd.toString()}, got ${buffer.length.toString()}`,\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\tconst valueBuffer = buffer.subarray(valueStart, valueEnd);\r\n\t\tconst consumed = valueEnd;\r\n\r\n\t\tlet item: AbstractSecs2Item;\r\n\r\n\t\tswitch (itemType) {\r\n\t\t\tcase SecsItemType.A:\r\n\t\t\t\titem = Secs2ItemFactory.createAsciiItem(valueBuffer.toString(\"ascii\"));\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.B:\r\n\t\t\t\titem = Secs2ItemFactory.createBinaryItem(valueBuffer);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.BOOLEAN: {\r\n\t\t\t\t// Parse boolean array\r\n\t\t\t\tconst bools = [];\r\n\t\t\t\tfor (const byte of valueBuffer) {\r\n\t\t\t\t\tbools.push(byte !== 0);\r\n\t\t\t\t}\r\n\t\t\t\titem = Secs2ItemFactory.createBooleanItem(...bools);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tcase SecsItemType.I1:\r\n\t\t\tcase SecsItemType.I2:\r\n\t\t\tcase SecsItemType.I4:\r\n\t\t\tcase SecsItemType.I8:\r\n\t\t\tcase SecsItemType.U1:\r\n\t\t\tcase SecsItemType.U2:\r\n\t\t\tcase SecsItemType.U4:\r\n\t\t\tcase SecsItemType.U8:\r\n\t\t\tcase SecsItemType.F4:\r\n\t\t\tcase SecsItemType.F8:\r\n\t\t\t\titem = Secs2ItemNumeric.fromTypeBuffer(itemType, valueBuffer);\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\tthrow new Error(\r\n\t\t\t\t\t`Unknown item type: 0x${(itemType as number).toString(16)}`,\r\n\t\t\t\t);\r\n\t\t}\r\n\r\n\t\treturn { item, consumed };\r\n\t}\r\n}\r\n"],"mappings":";;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QAAQ,EAAE;AAChB,SAAK,MAAM,QAAQ,YAClB,OAAM,KAAK,SAAS,EAAE;AAEvB,WAAO,iBAAiB,kBAAkB,GAAG,MAAM;AACnD;;GAED,KAAK,aAAa;GAClB,KAAK,aAAa;GAClB,KAAK,aAAa;GAClB,KAAK,aAAa;GAClB,KAAK,aAAa;GAClB,KAAK,aAAa;GAClB,KAAK,aAAa;GAClB,KAAK,aAAa;GAClB,KAAK,aAAa;GAClB,KAAK,aAAa;AACjB,WAAO,iBAAiB,eAAe,UAAU,YAAY;AAC7D;GACD,QACC,OAAM,IAAI,MACT,wBAAyB,SAAoB,SAAS,GAAG,GACzD;;AAGH,SAAO;GAAE;GAAM;GAAU"}
1
+ {"version":3,"file":"Secs2ItemParser.js","names":["items: AbstractSecs2Item[]","item: AbstractSecs2Item"],"sources":["../../../src/core/secs2item/Secs2ItemParser.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\nimport { AbstractSecs2Item } from \"./AbstractSecs2Item.js\";\nimport { Secs2ItemFactory } from \"./Secs2ItemFactory.js\";\nimport { Secs2ItemNumeric } from \"./Secs2ItemNumeric.js\";\n\nexport class Secs2ItemParser {\n\tstatic fromBuffer(buffer: Buffer): {\n\t\titem: AbstractSecs2Item;\n\t\tconsumed: number;\n\t} {\n\t\tif (buffer.length === 0) {\n\t\t\tthrow new Error(\"Empty buffer\");\n\t\t}\n\n\t\tconst headerByte = buffer.readUInt8(0);\n\t\tconst itemType = (headerByte & 0xfc) as SecsItemType; // Clear last 2 bits\n\t\tconst lengthBytes = headerByte & 0x03;\n\n\t\tlet length = 0;\n\t\tif (lengthBytes === 1) {\n\t\t\tlength = buffer.readUInt8(1);\n\t\t} else if (lengthBytes === 2) {\n\t\t\tlength = buffer.readUInt16BE(1);\n\t\t} else if (lengthBytes === 3) {\n\t\t\tlength = buffer.readUIntBE(1, 3);\n\t\t} else {\n\t\t\tthrow new Error(`Invalid length bytes count: ${lengthBytes.toString()}`);\n\t\t}\n\n\t\tconst valueStart = 1 + lengthBytes;\n\n\t\t// Handle List items differently: length is number of items, not byte length\n\t\tif (itemType === SecsItemType.L) {\n\t\t\tconst items: AbstractSecs2Item[] = [];\n\t\t\tlet offset = valueStart;\n\t\t\tconst numItems = length;\n\n\t\t\tfor (let i = 0; i < numItems; i++) {\n\t\t\t\tif (offset >= buffer.length) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Insufficient buffer for List items. Expected ${numItems} items, got incomplete data.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst result = Secs2ItemParser.fromBuffer(buffer.subarray(offset));\n\t\t\t\titems.push(result.item);\n\t\t\t\toffset += result.consumed;\n\t\t\t}\n\n\t\t\tconst item = Secs2ItemFactory.createListItem(...items);\n\t\t\treturn { item, consumed: offset };\n\t\t}\n\n\t\t// For other types, length is byte length\n\t\tconst valueEnd = valueStart + length;\n\n\t\tif (buffer.length < valueEnd) {\n\t\t\tthrow new Error(\n\t\t\t\t`Insufficient buffer length. Expected ${valueEnd.toString()}, got ${buffer.length.toString()}`,\n\t\t\t);\n\t\t}\n\n\t\tconst valueBuffer = buffer.subarray(valueStart, valueEnd);\n\t\tconst consumed = valueEnd;\n\n\t\tlet item: AbstractSecs2Item;\n\n\t\tswitch (itemType) {\n\t\t\tcase SecsItemType.A:\n\t\t\t\titem = Secs2ItemFactory.createAsciiItem(valueBuffer.toString(\"ascii\"));\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.B:\n\t\t\t\titem = Secs2ItemFactory.createBinaryItem(valueBuffer);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.BOOLEAN: {\n\t\t\t\t// Parse boolean array\n\t\t\t\tconst bools = [];\n\t\t\t\tfor (const byte of valueBuffer) {\n\t\t\t\t\tbools.push(byte !== 0);\n\t\t\t\t}\n\t\t\t\titem = Secs2ItemFactory.createBooleanItem(...bools);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SecsItemType.I1:\n\t\t\tcase SecsItemType.I2:\n\t\t\tcase SecsItemType.I4:\n\t\t\tcase SecsItemType.I8:\n\t\t\tcase SecsItemType.U1:\n\t\t\tcase SecsItemType.U2:\n\t\t\tcase SecsItemType.U4:\n\t\t\tcase SecsItemType.U8:\n\t\t\tcase SecsItemType.F4:\n\t\t\tcase SecsItemType.F8:\n\t\t\t\titem = Secs2ItemNumeric.fromTypeBuffer(itemType, valueBuffer);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Unknown item type: 0x${(itemType as number).toString(16)}`,\n\t\t\t\t);\n\t\t}\n\n\t\treturn { item, consumed };\n\t}\n}\n"],"mappings":";;;;;AAKA,IAAa,kBAAb,MAAa,gBAAgB;CAC5B,OAAO,WAAW,QAGhB;AACD,MAAI,OAAO,WAAW,EACrB,OAAM,IAAI,MAAM,eAAe;EAGhC,MAAM,aAAa,OAAO,UAAU,EAAE;EACtC,MAAM,WAAY,aAAa;EAC/B,MAAM,cAAc,aAAa;EAEjC,IAAI,SAAS;AACb,MAAI,gBAAgB,EACnB,UAAS,OAAO,UAAU,EAAE;WAClB,gBAAgB,EAC1B,UAAS,OAAO,aAAa,EAAE;WACrB,gBAAgB,EAC1B,UAAS,OAAO,WAAW,GAAG,EAAE;MAEhC,OAAM,IAAI,MAAM,+BAA+B,YAAY,UAAU,GAAG;EAGzE,MAAM,aAAa,IAAI;AAGvB,MAAI,aAAa,aAAa,GAAG;GAChC,MAAMA,QAA6B,EAAE;GACrC,IAAI,SAAS;GACb,MAAM,WAAW;AAEjB,QAAK,IAAI,IAAI,GAAG,IAAI,UAAU,KAAK;AAClC,QAAI,UAAU,OAAO,OACpB,OAAM,IAAI,MACT,gDAAgD,SAAS,8BACzD;IAEF,MAAM,SAAS,gBAAgB,WAAW,OAAO,SAAS,OAAO,CAAC;AAClE,UAAM,KAAK,OAAO,KAAK;AACvB,cAAU,OAAO;;AAIlB,UAAO;IAAE,MADI,iBAAiB,eAAe,GAAG,MAAM;IACvC,UAAU;IAAQ;;EAIlC,MAAM,WAAW,aAAa;AAE9B,MAAI,OAAO,SAAS,SACnB,OAAM,IAAI,MACT,wCAAwC,SAAS,UAAU,CAAC,QAAQ,OAAO,OAAO,UAAU,GAC5F;EAGF,MAAM,cAAc,OAAO,SAAS,YAAY,SAAS;EACzD,MAAM,WAAW;EAEjB,IAAIC;AAEJ,UAAQ,UAAR;GACC,KAAK,aAAa;AACjB,WAAO,iBAAiB,gBAAgB,YAAY,SAAS,QAAQ,CAAC;AACtE;GACD,KAAK,aAAa;AACjB,WAAO,iBAAiB,iBAAiB,YAAY;AACrD;GACD,KAAK,aAAa,SAAS;IAE1B,MAAM,QAAQ,EAAE;AAChB,SAAK,MAAM,QAAQ,YAClB,OAAM,KAAK,SAAS,EAAE;AAEvB,WAAO,iBAAiB,kBAAkB,GAAG,MAAM;AACnD;;GAED,KAAK,aAAa;GAClB,KAAK,aAAa;GAClB,KAAK,aAAa;GAClB,KAAK,aAAa;GAClB,KAAK,aAAa;GAClB,KAAK,aAAa;GAClB,KAAK,aAAa;GAClB,KAAK,aAAa;GAClB,KAAK,aAAa;GAClB,KAAK,aAAa;AACjB,WAAO,iBAAiB,eAAe,UAAU,YAAY;AAC7D;GACD,QACC,OAAM,IAAI,MACT,wBAAyB,SAAoB,SAAS,GAAG,GACzD;;AAGH,SAAO;GAAE;GAAM;GAAU"}
@@ -1 +1 @@
1
- {"version":3,"file":"Clock.js","names":["datetime: Date"],"sources":["../../src/gem/Clock.ts"],"sourcesContent":["import { AbstractSecs2Item } from \"../core/secs2item/AbstractSecs2Item.js\";\r\nimport { Secs2ItemAscii } from \"../core/secs2item/Secs2ItemAscii.js\";\r\n\r\nexport enum ClockType {\r\n\tA12 = \"A12\",\r\n\tA16 = \"A16\",\r\n}\r\n\r\nexport class Clock {\r\n\tconstructor(private datetime: Date) {}\r\n\r\n\ttoA16(): Secs2ItemAscii {\r\n\t\tconst year = this.datetime.getFullYear();\r\n\t\tconst month = (this.datetime.getMonth() + 1).toString().padStart(2, \"0\");\r\n\t\tconst day = this.datetime.getDate().toString().padStart(2, \"0\");\r\n\t\tconst hour = this.datetime.getHours().toString().padStart(2, \"0\");\r\n\t\tconst minute = this.datetime.getMinutes().toString().padStart(2, \"0\");\r\n\t\tconst second = this.datetime.getSeconds().toString().padStart(2, \"0\");\r\n\t\tconst cc = Math.floor(this.datetime.getMilliseconds() / 10)\r\n\t\t\t.toString()\r\n\t\t\t.padStart(2, \"0\");\r\n\r\n\t\treturn new Secs2ItemAscii(\r\n\t\t\t`${year}${month}${day}${hour}${minute}${second}${cc}`,\r\n\t\t);\r\n\t}\r\n\r\n\ttoA12(): Secs2ItemAscii {\r\n\t\tconst year = this.datetime.getFullYear().toString().slice(-2);\r\n\t\tconst month = (this.datetime.getMonth() + 1).toString().padStart(2, \"0\");\r\n\t\tconst day = this.datetime.getDate().toString().padStart(2, \"0\");\r\n\t\tconst hour = this.datetime.getHours().toString().padStart(2, \"0\");\r\n\t\tconst minute = this.datetime.getMinutes().toString().padStart(2, \"0\");\r\n\t\tconst second = this.datetime.getSeconds().toString().padStart(2, \"0\");\r\n\r\n\t\treturn new Secs2ItemAscii(`${year}${month}${day}${hour}${minute}${second}`);\r\n\t}\r\n\r\n\ttoDatetime(): Date {\r\n\t\treturn this.datetime;\r\n\t}\r\n\r\n\tstatic now(): Clock {\r\n\t\treturn new Clock(new Date());\r\n\t}\r\n\r\n\tstatic fromAscii(item: AbstractSecs2Item): Clock {\r\n\t\tif (!(item instanceof Secs2ItemAscii)) {\r\n\t\t\tthrow new Error(\"Clock can only be parsed from ASCII item\");\r\n\t\t}\r\n\t\tconst val = item.value;\r\n\t\tconst len = val.length;\r\n\r\n\t\tif (len === 12) {\r\n\t\t\t// YYMMDDHHMMSS\r\n\t\t\tconst yy = parseInt(val.substring(0, 2), 10);\r\n\t\t\tconst mm = parseInt(val.substring(2, 4), 10);\r\n\t\t\tconst dd = parseInt(val.substring(4, 6), 10);\r\n\t\t\tconst hh = parseInt(val.substring(6, 8), 10);\r\n\t\t\tconst min = parseInt(val.substring(8, 10), 10);\r\n\t\t\tconst ss = parseInt(val.substring(10, 12), 10);\r\n\r\n\t\t\tconst year = Clock.getYear(yy);\r\n\t\t\treturn new Clock(new Date(year, mm - 1, dd, hh, min, ss));\r\n\t\t} else if (len === 16) {\r\n\t\t\t// YYYYMMDDHHMMSSCC\r\n\t\t\tconst year = parseInt(val.substring(0, 4), 10);\r\n\t\t\tconst mm = parseInt(val.substring(4, 6), 10);\r\n\t\t\tconst dd = parseInt(val.substring(6, 8), 10);\r\n\t\t\tconst hh = parseInt(val.substring(8, 10), 10);\r\n\t\t\tconst min = parseInt(val.substring(10, 12), 10);\r\n\t\t\tconst ss = parseInt(val.substring(12, 14), 10);\r\n\t\t\tconst cc = parseInt(val.substring(14, 16), 10);\r\n\r\n\t\t\treturn new Clock(new Date(year, mm - 1, dd, hh, min, ss, cc * 10));\r\n\t\t}\r\n\r\n\t\tthrow new Error(\"Unknown ClockType format\");\r\n\t}\r\n\r\n\tprivate static getYear(yy: number): number {\r\n\t\tconst nowYear = new Date().getFullYear();\r\n\t\tconst century = Math.floor(nowYear / 100) * 100;\r\n\t\tconst flacYear = nowYear % 100;\r\n\r\n\t\tif (flacYear < 25) {\r\n\t\t\tif (yy >= 75) return century - 100 + yy;\r\n\t\t} else if (flacYear >= 75) {\r\n\t\t\tif (yy < 25) return century + 100 + yy;\r\n\t\t}\r\n\t\treturn century + yy;\r\n\t}\r\n}\r\n"],"mappings":";;;AAGA,IAAY,kDAAL;AACN;AACA;;;AAGD,IAAa,QAAb,MAAa,MAAM;CAClB,YAAY,AAAQA,UAAgB;EAAhB;;CAEpB,QAAwB;AAWvB,SAAO,IAAI,eACV,GAXY,KAAK,SAAS,aAAa,IACzB,KAAK,SAAS,UAAU,GAAG,GAAG,UAAU,CAAC,SAAS,GAAG,IAAI,GAC5D,KAAK,SAAS,SAAS,CAAC,UAAU,CAAC,SAAS,GAAG,IAAI,GAClD,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AAE,GAAG;GAC9C,MAAM,KAAK,SAAS,IAAI,UAAU,IAAI,GAAG,EAAE,GAAG;GAE9C,MAAM,OAAO,MAAM,QAAQ,GAAG;AAC9B,UAAO,IAAI,MAAM,IAAI,KAAK,MAAM,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,CAAC;aAC/C,QAAQ,IAAI;GAEtB,MAAM,OAAO,SAAS,IAAI,UAAU,GAAG,EAAE,EAAE,GAAG;GAC9C,MAAM,KAAK,SAAS,IAAI,UAAU,GAAG,EAAE,EAAE,GAAG;GAC5C,MAAM,KAAK,SAAS,IAAI,UAAU,GAAG,EAAE,EAAE,GAAG;GAC5C,MAAM,KAAK,SAAS,IAAI,UAAU,GAAG,GAAG,EAAE,GAAG;GAC7C,MAAM,MAAM,SAAS,IAAI,UAAU,IAAI,GAAG,EAAE,GAAG;GAC/C,MAAM,KAAK,SAAS,IAAI,UAAU,IAAI,GAAG,EAAE,GAAG;GAC9C,MAAM,KAAK,SAAS,IAAI,UAAU,IAAI,GAAG,EAAE,GAAG;AAE9C,UAAO,IAAI,MAAM,IAAI,KAAK,MAAM,KAAK,GAAG,IAAI,IAAI,KAAK,IAAI,KAAK,GAAG,CAAC;;AAGnE,QAAM,IAAI,MAAM,2BAA2B;;CAG5C,OAAe,QAAQ,IAAoB;EAC1C,MAAM,2BAAU,IAAI,MAAM,EAAC,aAAa;EACxC,MAAM,UAAU,KAAK,MAAM,UAAU,IAAI,GAAG;EAC5C,MAAM,WAAW,UAAU;AAE3B,MAAI,WAAW,IACd;OAAI,MAAM,GAAI,QAAO,UAAU,MAAM;aAC3B,YAAY,IACtB;OAAI,KAAK,GAAI,QAAO,UAAU,MAAM;;AAErC,SAAO,UAAU"}
1
+ {"version":3,"file":"Clock.js","names":["datetime: Date"],"sources":["../../src/gem/Clock.ts"],"sourcesContent":["import { AbstractSecs2Item } from \"../core/secs2item/AbstractSecs2Item.js\";\nimport { Secs2ItemAscii } from \"../core/secs2item/Secs2ItemAscii.js\";\n\nexport enum ClockType {\n\tA12 = \"A12\",\n\tA16 = \"A16\",\n}\n\nexport class Clock {\n\tconstructor(private datetime: Date) {}\n\n\ttoA16(): Secs2ItemAscii {\n\t\tconst year = this.datetime.getFullYear();\n\t\tconst month = (this.datetime.getMonth() + 1).toString().padStart(2, \"0\");\n\t\tconst day = this.datetime.getDate().toString().padStart(2, \"0\");\n\t\tconst hour = this.datetime.getHours().toString().padStart(2, \"0\");\n\t\tconst minute = this.datetime.getMinutes().toString().padStart(2, \"0\");\n\t\tconst second = this.datetime.getSeconds().toString().padStart(2, \"0\");\n\t\tconst cc = Math.floor(this.datetime.getMilliseconds() / 10)\n\t\t\t.toString()\n\t\t\t.padStart(2, \"0\");\n\n\t\treturn new Secs2ItemAscii(\n\t\t\t`${year}${month}${day}${hour}${minute}${second}${cc}`,\n\t\t);\n\t}\n\n\ttoA12(): Secs2ItemAscii {\n\t\tconst year = this.datetime.getFullYear().toString().slice(-2);\n\t\tconst month = (this.datetime.getMonth() + 1).toString().padStart(2, \"0\");\n\t\tconst day = this.datetime.getDate().toString().padStart(2, \"0\");\n\t\tconst hour = this.datetime.getHours().toString().padStart(2, \"0\");\n\t\tconst minute = this.datetime.getMinutes().toString().padStart(2, \"0\");\n\t\tconst second = this.datetime.getSeconds().toString().padStart(2, \"0\");\n\n\t\treturn new Secs2ItemAscii(`${year}${month}${day}${hour}${minute}${second}`);\n\t}\n\n\ttoDatetime(): Date {\n\t\treturn this.datetime;\n\t}\n\n\tstatic now(): Clock {\n\t\treturn new Clock(new Date());\n\t}\n\n\tstatic fromAscii(item: AbstractSecs2Item): Clock {\n\t\tif (!(item instanceof Secs2ItemAscii)) {\n\t\t\tthrow new Error(\"Clock can only be parsed from ASCII item\");\n\t\t}\n\t\tconst val = item.value;\n\t\tconst len = val.length;\n\n\t\tif (len === 12) {\n\t\t\t// YYMMDDHHMMSS\n\t\t\tconst yy = parseInt(val.substring(0, 2), 10);\n\t\t\tconst mm = parseInt(val.substring(2, 4), 10);\n\t\t\tconst dd = parseInt(val.substring(4, 6), 10);\n\t\t\tconst hh = parseInt(val.substring(6, 8), 10);\n\t\t\tconst min = parseInt(val.substring(8, 10), 10);\n\t\t\tconst ss = parseInt(val.substring(10, 12), 10);\n\n\t\t\tconst year = Clock.getYear(yy);\n\t\t\treturn new Clock(new Date(year, mm - 1, dd, hh, min, ss));\n\t\t} else if (len === 16) {\n\t\t\t// YYYYMMDDHHMMSSCC\n\t\t\tconst year = parseInt(val.substring(0, 4), 10);\n\t\t\tconst mm = parseInt(val.substring(4, 6), 10);\n\t\t\tconst dd = parseInt(val.substring(6, 8), 10);\n\t\t\tconst hh = parseInt(val.substring(8, 10), 10);\n\t\t\tconst min = parseInt(val.substring(10, 12), 10);\n\t\t\tconst ss = parseInt(val.substring(12, 14), 10);\n\t\t\tconst cc = parseInt(val.substring(14, 16), 10);\n\n\t\t\treturn new Clock(new Date(year, mm - 1, dd, hh, min, ss, cc * 10));\n\t\t}\n\n\t\tthrow new Error(\"Unknown ClockType format\");\n\t}\n\n\tprivate static getYear(yy: number): number {\n\t\tconst nowYear = new Date().getFullYear();\n\t\tconst century = Math.floor(nowYear / 100) * 100;\n\t\tconst flacYear = nowYear % 100;\n\n\t\tif (flacYear < 25) {\n\t\t\tif (yy >= 75) return century - 100 + yy;\n\t\t} else if (flacYear >= 75) {\n\t\t\tif (yy < 25) return century + 100 + yy;\n\t\t}\n\t\treturn century + yy;\n\t}\n}\n"],"mappings":";;;AAGA,IAAY,kDAAL;AACN;AACA;;;AAGD,IAAa,QAAb,MAAa,MAAM;CAClB,YAAY,AAAQA,UAAgB;EAAhB;;CAEpB,QAAwB;AAWvB,SAAO,IAAI,eACV,GAXY,KAAK,SAAS,aAAa,IACzB,KAAK,SAAS,UAAU,GAAG,GAAG,UAAU,CAAC,SAAS,GAAG,IAAI,GAC5D,KAAK,SAAS,SAAS,CAAC,UAAU,CAAC,SAAS,GAAG,IAAI,GAClD,KAAK,SAAS,UAAU,CAAC,UAAU,CAAC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,IAAI,UAAU,IAAI,GAAG,EAAE,GAAG;GAE9C,MAAM,OAAO,MAAM,QAAQ,GAAG;AAC9B,UAAO,IAAI,MAAM,IAAI,KAAK,MAAM,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,CAAC;aAC/C,QAAQ,IAAI;GAEtB,MAAM,OAAO,SAAS,IAAI,UAAU,GAAG,EAAE,EAAE,GAAG;GAC9C,MAAM,KAAK,SAAS,IAAI,UAAU,GAAG,EAAE,EAAE,GAAG;GAC5C,MAAM,KAAK,SAAS,IAAI,UAAU,GAAG,EAAE,EAAE,GAAG;GAC5C,MAAM,KAAK,SAAS,IAAI,UAAU,GAAG,GAAG,EAAE,GAAG;GAC7C,MAAM,MAAM,SAAS,IAAI,UAAU,IAAI,GAAG,EAAE,GAAG;GAC/C,MAAM,KAAK,SAAS,IAAI,UAAU,IAAI,GAAG,EAAE,GAAG;GAC9C,MAAM,KAAK,SAAS,IAAI,UAAU,IAAI,GAAG,EAAE,GAAG;AAE9C,UAAO,IAAI,MAAM,IAAI,KAAK,MAAM,KAAK,GAAG,IAAI,IAAI,KAAK,IAAI,KAAK,GAAG,CAAC;;AAGnE,QAAM,IAAI,MAAM,2BAA2B;;CAG5C,OAAe,QAAQ,IAAoB;EAC1C,MAAM,2BAAU,IAAI,MAAM,EAAC,aAAa;EACxC,MAAM,UAAU,KAAK,MAAM,UAAU,IAAI,GAAG;EAC5C,MAAM,WAAW,UAAU;AAE3B,MAAI,WAAW,IACd;OAAI,MAAM,GAAI,QAAO,UAAU,MAAM;aAC3B,YAAY,IACtB;OAAI,KAAK,GAAI,QAAO,UAAU,MAAM;;AAErC,SAAO,UAAU"}
@@ -1 +1 @@
1
- {"version":3,"file":"Gem.js","names":["comm: AbstractSecsCommunicator","body: Secs2ItemList"],"sources":["../../src/gem/Gem.ts"],"sourcesContent":["import { AbstractSecsCommunicator } from \"../core/AbstractSecsCommunicator.js\";\r\nimport { SecsMessage } from \"../core/AbstractSecsMessage.js\";\r\nimport { Secs2ItemAscii } from \"../core/secs2item/Secs2ItemAscii.js\";\r\nimport { Secs2ItemBinary } from \"../core/secs2item/Secs2ItemBinary.js\";\r\nimport { Secs2ItemList } from \"../core/secs2item/Secs2ItemList.js\";\r\nimport { A, B, L } from \"../helper/Secs2ItemHelper.js\";\r\nimport { Clock, ClockType } from \"./Clock.js\";\r\n\r\nexport enum CommAck {\r\n\tOK = 0x0,\r\n\tDENIED = 0x1,\r\n}\r\n\r\nexport enum OflAck {\r\n\tOK = 0x0,\r\n}\r\n\r\nexport enum OnlAck {\r\n\tOK = 0x0,\r\n\tREFUSE = 0x1,\r\n\tALREADY_ONLINE = 0x2,\r\n}\r\n\r\nexport enum TiAck {\r\n\tOK = 0x0,\r\n\tNOT_DONE = 0x1,\r\n}\r\n\r\nexport class Gem {\r\n\tprivate static readonly DEFAULT_MDLN = \" \";\r\n\tprivate static readonly DEFAULT_SOFTREV = \" \";\r\n\tprivate static readonly DEFAULT_CLOCK_TYPE = ClockType.A16;\r\n\r\n\tpublic mdln: string = Gem.DEFAULT_MDLN;\r\n\tpublic softrev: string = Gem.DEFAULT_SOFTREV;\r\n\tpublic clockType: ClockType = Gem.DEFAULT_CLOCK_TYPE;\r\n\r\n\tconstructor(public comm: AbstractSecsCommunicator) {}\r\n\r\n\t// S1F2 - Are You There?\r\n\tasync s1f2(primaryMsg: SecsMessage): Promise<void> {\r\n\t\tawait this.comm.reply(primaryMsg, 1, 2, L());\r\n\t}\r\n\r\n\t// S1F13 - Establish Communications Request\r\n\tasync s1f13(): Promise<number> {\r\n\t\tlet body: Secs2ItemList;\r\n\t\tif (this.comm.isEquip) {\r\n\t\t\tbody = L(A(this.mdln), A(this.softrev));\r\n\t\t} else {\r\n\t\t\tbody = L();\r\n\t\t}\r\n\r\n\t\tconst reply = await this.comm.send(1, 13, true, body);\r\n\t\tif (reply && reply.body instanceof Secs2ItemList) {\r\n\t\t\tconst list = reply.body;\r\n\t\t\tif (list.value.length > 0 && list.value[0] instanceof Secs2ItemBinary) {\r\n\t\t\t\tconst bin = list.value[0];\r\n\t\t\t\treturn bin.value[0];\r\n\t\t\t}\r\n\t\t}\r\n\t\tthrow new Error(\"S1F14 invalid response or not COMMACK\");\r\n\t}\r\n\r\n\t// S1F14 - Establish Communications Acknowledge\r\n\tasync s1f14(primaryMsg: SecsMessage, commAck: CommAck): Promise<void> {\r\n\t\tlet body: Secs2ItemList;\r\n\t\tif (this.comm.isEquip) {\r\n\t\t\tbody = L(B(Buffer.from([commAck])), L(A(this.mdln), A(this.softrev)));\r\n\t\t} else {\r\n\t\t\tbody = L(B(Buffer.from([commAck])), L());\r\n\t\t}\r\n\t\tawait this.comm.reply(primaryMsg, 1, 14, body);\r\n\t}\r\n\r\n\t// S1F15 - Request OFF-LINE\r\n\tasync s1f15(): Promise<number> {\r\n\t\tconst reply = await this.comm.send(1, 15, true);\r\n\t\tif (reply && reply.body instanceof Secs2ItemBinary) {\r\n\t\t\treturn reply.body.value[0];\r\n\t\t}\r\n\t\tthrow new Error(\"S1F16 invalid response or not OFLACK\");\r\n\t}\r\n\r\n\t// S1F16 - OFF-LINE Acknowledge\r\n\tasync s1f16(primaryMsg: SecsMessage): Promise<void> {\r\n\t\tawait this.comm.reply(primaryMsg, 1, 16, B(Buffer.from([OflAck.OK])));\r\n\t}\r\n\r\n\t// S1F17 - Request ON-LINE\r\n\tasync s1f17(): Promise<number> {\r\n\t\tconst reply = await this.comm.send(1, 17, true);\r\n\t\tif (reply && reply.body instanceof Secs2ItemBinary) {\r\n\t\t\treturn reply.body.value[0];\r\n\t\t}\r\n\t\tthrow new Error(\"S1F18 invalid response or not ONLACK\");\r\n\t}\r\n\r\n\t// S1F18 - ON-LINE Acknowledge\r\n\tasync s1f18(primaryMsg: SecsMessage, onlAck: OnlAck): Promise<void> {\r\n\t\tawait this.comm.reply(primaryMsg, 1, 18, B(Buffer.from([onlAck])));\r\n\t}\r\n\r\n\t// S2F17 - Date and Time Request\r\n\tasync s2f17(): Promise<Clock> {\r\n\t\tconst reply = await this.comm.send(2, 17, true);\r\n\t\tif (reply?.body instanceof Secs2ItemAscii) {\r\n\t\t\treturn Clock.fromAscii(reply.body);\r\n\t\t}\r\n\t\tthrow new Error(\"S2F18 invalid response or not time\");\r\n\t}\r\n\r\n\t// S2F18 - Date and Time Data\r\n\tasync s2f18(\r\n\t\tprimaryMsg: SecsMessage,\r\n\t\tclock: Clock = Clock.now(),\r\n\t): Promise<void> {\r\n\t\tconst body =\r\n\t\t\tthis.clockType === ClockType.A12 ? clock.toA12() : clock.toA16();\r\n\t\tawait this.comm.reply(primaryMsg, 2, 18, body);\r\n\t}\r\n\r\n\tasync s2f18Now(primaryMsg: SecsMessage): Promise<void> {\r\n\t\treturn this.s2f18(primaryMsg, Clock.now());\r\n\t}\r\n\r\n\t// S2F31 - Date and Time Set Request\r\n\tasync s2f31(clock: Clock): Promise<number> {\r\n\t\tconst body =\r\n\t\t\tthis.clockType === ClockType.A12 ? clock.toA12() : clock.toA16();\r\n\t\tconst reply = await this.comm.send(2, 31, true, body);\r\n\t\tif (reply && reply.body instanceof Secs2ItemBinary) {\r\n\t\t\treturn reply.body.value[0];\r\n\t\t}\r\n\t\tthrow new Error(\"S2F32 invalid response or not TIACK\");\r\n\t}\r\n\r\n\tasync s2f31Now(): Promise<number> {\r\n\t\treturn this.s2f31(Clock.now());\r\n\t}\r\n\r\n\t// S2F32 - Date and Time Set Acknowledge\r\n\tasync s2f32(primaryMsg: SecsMessage, tiAck: TiAck): Promise<void> {\r\n\t\tawait this.comm.reply(primaryMsg, 2, 32, B(Buffer.from([tiAck])));\r\n\t}\r\n\r\n\t// S9Fx Helpers\r\n\tasync s9f1(refMsg: SecsMessage): Promise<void> {\r\n\t\tawait this.s9fy(refMsg, 1);\r\n\t}\r\n\tasync s9f3(refMsg: SecsMessage): Promise<void> {\r\n\t\tawait this.s9fy(refMsg, 3);\r\n\t}\r\n\tasync s9f5(refMsg: SecsMessage): Promise<void> {\r\n\t\tawait this.s9fy(refMsg, 5);\r\n\t}\r\n\tasync s9f7(refMsg: SecsMessage): Promise<void> {\r\n\t\tawait this.s9fy(refMsg, 7);\r\n\t}\r\n\tasync s9f9(refMsg: SecsMessage): Promise<void> {\r\n\t\tawait this.s9fy(refMsg, 9);\r\n\t}\r\n\tasync s9f11(refMsg: SecsMessage): Promise<void> {\r\n\t\tawait this.s9fy(refMsg, 11);\r\n\t}\r\n\r\n\tprivate async s9fy(refMsg: SecsMessage, func: number): Promise<void> {\r\n\t\tconst header = this.getHeader10Bytes(refMsg);\r\n\t\tawait this.comm.send(9, func, false, B(header));\r\n\t}\r\n\r\n\tprivate getHeader10Bytes(msg: SecsMessage): Buffer {\r\n\t\tconst buffer = Buffer.alloc(10);\r\n\t\t// Session ID (Device ID)\r\n\t\tbuffer.writeUInt16BE(msg.deviceId & 0x7fff, 0);\r\n\r\n\t\t// Stream + W-bit\r\n\t\tlet streamByte = msg.stream & 0x7f;\r\n\t\tif (msg.wBit) {\r\n\t\t\tstreamByte |= 0x80;\r\n\t\t}\r\n\t\tbuffer.writeUInt8(streamByte, 2);\r\n\r\n\t\t// Function\r\n\t\tbuffer.writeUInt8(msg.func, 3);\r\n\r\n\t\t// P-Type, S-Type (Assuming 0 for now)\r\n\t\tbuffer.writeUInt8(0, 4);\r\n\t\tbuffer.writeUInt8(0, 5);\r\n\r\n\t\t// System Bytes\r\n\t\tif (typeof msg.systemBytes === \"number\") {\r\n\t\t\tbuffer.writeUInt32BE(msg.systemBytes, 6);\r\n\t\t} else {\r\n\t\t\t// Assuming Buffer\r\n\t\t\tconst sysBuf = msg.systemBytes as Buffer;\r\n\t\t\tsysBuf.copy(buffer, 6, 0, 4);\r\n\t\t}\r\n\r\n\t\treturn buffer;\r\n\t}\r\n}\r\n"],"mappings":";;;;;;;AAQA,IAAY,8CAAL;AACN;AACA;;;AAGD,IAAY,4CAAL;AACN;;;AAGD,IAAY,4CAAL;AACN;AACA;AACA;;;AAGD,IAAY,0CAAL;AACN;AACA;;;AAGD,IAAa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,MAAM,YAAY,GAAG,IAAI,EAAE,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;;CAIlE,MAAM,KAAK,QAAoC;AAC9C,QAAM,KAAK,KAAK,QAAQ,EAAE;;CAE3B,MAAM,KAAK,QAAoC;AAC9C,QAAM,KAAK,KAAK,QAAQ,EAAE;;CAE3B,MAAM,KAAK,QAAoC;AAC9C,QAAM,KAAK,KAAK,QAAQ,EAAE;;CAE3B,MAAM,KAAK,QAAoC;AAC9C,QAAM,KAAK,KAAK,QAAQ,EAAE;;CAE3B,MAAM,KAAK,QAAoC;AAC9C,QAAM,KAAK,KAAK,QAAQ,EAAE;;CAE3B,MAAM,MAAM,QAAoC;AAC/C,QAAM,KAAK,KAAK,QAAQ,GAAG;;CAG5B,MAAc,KAAK,QAAqB,MAA6B;EACpE,MAAM,SAAS,KAAK,iBAAiB,OAAO;AAC5C,QAAM,KAAK,KAAK,KAAK,GAAG,MAAM,OAAO,EAAE,OAAO,CAAC;;CAGhD,AAAQ,iBAAiB,KAA0B;EAClD,MAAM,SAAS,OAAO,MAAM,GAAG;AAE/B,SAAO,cAAc,IAAI,WAAW,OAAQ,EAAE;EAG9C,IAAI,aAAa,IAAI,SAAS;AAC9B,MAAI,IAAI,KACP,eAAc;AAEf,SAAO,WAAW,YAAY,EAAE;AAGhC,SAAO,WAAW,IAAI,MAAM,EAAE;AAG9B,SAAO,WAAW,GAAG,EAAE;AACvB,SAAO,WAAW,GAAG,EAAE;AAGvB,MAAI,OAAO,IAAI,gBAAgB,SAC9B,QAAO,cAAc,IAAI,aAAa,EAAE;MAIxC,CADe,IAAI,YACZ,KAAK,QAAQ,GAAG,GAAG,EAAE;AAG7B,SAAO"}
1
+ {"version":3,"file":"Gem.js","names":["comm: AbstractSecsCommunicator","body: Secs2ItemList"],"sources":["../../src/gem/Gem.ts"],"sourcesContent":["import { AbstractSecsCommunicator } from \"../core/AbstractSecsCommunicator.js\";\nimport { SecsMessage } from \"../core/AbstractSecsMessage.js\";\nimport { Secs2ItemAscii } from \"../core/secs2item/Secs2ItemAscii.js\";\nimport { Secs2ItemBinary } from \"../core/secs2item/Secs2ItemBinary.js\";\nimport { Secs2ItemList } from \"../core/secs2item/Secs2ItemList.js\";\nimport { A, B, L } from \"../helper/Secs2ItemHelper.js\";\nimport { Clock, ClockType } from \"./Clock.js\";\n\nexport enum CommAck {\n\tOK = 0x0,\n\tDENIED = 0x1,\n}\n\nexport enum OflAck {\n\tOK = 0x0,\n}\n\nexport enum OnlAck {\n\tOK = 0x0,\n\tREFUSE = 0x1,\n\tALREADY_ONLINE = 0x2,\n}\n\nexport enum TiAck {\n\tOK = 0x0,\n\tNOT_DONE = 0x1,\n}\n\nexport class Gem {\n\tprivate static readonly DEFAULT_MDLN = \" \";\n\tprivate static readonly DEFAULT_SOFTREV = \" \";\n\tprivate static readonly DEFAULT_CLOCK_TYPE = ClockType.A16;\n\n\tpublic mdln: string = Gem.DEFAULT_MDLN;\n\tpublic softrev: string = Gem.DEFAULT_SOFTREV;\n\tpublic clockType: ClockType = Gem.DEFAULT_CLOCK_TYPE;\n\n\tconstructor(public comm: AbstractSecsCommunicator) {}\n\n\t// S1F2 - Are You There?\n\tasync s1f2(primaryMsg: SecsMessage): Promise<void> {\n\t\tawait this.comm.reply(primaryMsg, 1, 2, L());\n\t}\n\n\t// S1F13 - Establish Communications Request\n\tasync s1f13(): Promise<number> {\n\t\tlet body: Secs2ItemList;\n\t\tif (this.comm.isEquip) {\n\t\t\tbody = L(A(this.mdln), A(this.softrev));\n\t\t} else {\n\t\t\tbody = L();\n\t\t}\n\n\t\tconst reply = await this.comm.send(1, 13, true, body);\n\t\tif (reply && reply.body instanceof Secs2ItemList) {\n\t\t\tconst list = reply.body;\n\t\t\tif (list.value.length > 0 && list.value[0] instanceof Secs2ItemBinary) {\n\t\t\t\tconst bin = list.value[0];\n\t\t\t\treturn bin.value[0];\n\t\t\t}\n\t\t}\n\t\tthrow new Error(\"S1F14 invalid response or not COMMACK\");\n\t}\n\n\t// S1F14 - Establish Communications Acknowledge\n\tasync s1f14(primaryMsg: SecsMessage, commAck: CommAck): Promise<void> {\n\t\tlet body: Secs2ItemList;\n\t\tif (this.comm.isEquip) {\n\t\t\tbody = L(B(Buffer.from([commAck])), L(A(this.mdln), A(this.softrev)));\n\t\t} else {\n\t\t\tbody = L(B(Buffer.from([commAck])), L());\n\t\t}\n\t\tawait this.comm.reply(primaryMsg, 1, 14, body);\n\t}\n\n\t// S1F15 - Request OFF-LINE\n\tasync s1f15(): Promise<number> {\n\t\tconst reply = await this.comm.send(1, 15, true);\n\t\tif (reply && reply.body instanceof Secs2ItemBinary) {\n\t\t\treturn reply.body.value[0];\n\t\t}\n\t\tthrow new Error(\"S1F16 invalid response or not OFLACK\");\n\t}\n\n\t// S1F16 - OFF-LINE Acknowledge\n\tasync s1f16(primaryMsg: SecsMessage): Promise<void> {\n\t\tawait this.comm.reply(primaryMsg, 1, 16, B(Buffer.from([OflAck.OK])));\n\t}\n\n\t// S1F17 - Request ON-LINE\n\tasync s1f17(): Promise<number> {\n\t\tconst reply = await this.comm.send(1, 17, true);\n\t\tif (reply && reply.body instanceof Secs2ItemBinary) {\n\t\t\treturn reply.body.value[0];\n\t\t}\n\t\tthrow new Error(\"S1F18 invalid response or not ONLACK\");\n\t}\n\n\t// S1F18 - ON-LINE Acknowledge\n\tasync s1f18(primaryMsg: SecsMessage, onlAck: OnlAck): Promise<void> {\n\t\tawait this.comm.reply(primaryMsg, 1, 18, B(Buffer.from([onlAck])));\n\t}\n\n\t// S2F17 - Date and Time Request\n\tasync s2f17(): Promise<Clock> {\n\t\tconst reply = await this.comm.send(2, 17, true);\n\t\tif (reply?.body instanceof Secs2ItemAscii) {\n\t\t\treturn Clock.fromAscii(reply.body);\n\t\t}\n\t\tthrow new Error(\"S2F18 invalid response or not time\");\n\t}\n\n\t// S2F18 - Date and Time Data\n\tasync s2f18(\n\t\tprimaryMsg: SecsMessage,\n\t\tclock: Clock = Clock.now(),\n\t): Promise<void> {\n\t\tconst body =\n\t\t\tthis.clockType === ClockType.A12 ? clock.toA12() : clock.toA16();\n\t\tawait this.comm.reply(primaryMsg, 2, 18, body);\n\t}\n\n\tasync s2f18Now(primaryMsg: SecsMessage): Promise<void> {\n\t\treturn this.s2f18(primaryMsg, Clock.now());\n\t}\n\n\t// S2F31 - Date and Time Set Request\n\tasync s2f31(clock: Clock): Promise<number> {\n\t\tconst body =\n\t\t\tthis.clockType === ClockType.A12 ? clock.toA12() : clock.toA16();\n\t\tconst reply = await this.comm.send(2, 31, true, body);\n\t\tif (reply && reply.body instanceof Secs2ItemBinary) {\n\t\t\treturn reply.body.value[0];\n\t\t}\n\t\tthrow new Error(\"S2F32 invalid response or not TIACK\");\n\t}\n\n\tasync s2f31Now(): Promise<number> {\n\t\treturn this.s2f31(Clock.now());\n\t}\n\n\t// S2F32 - Date and Time Set Acknowledge\n\tasync s2f32(primaryMsg: SecsMessage, tiAck: TiAck): Promise<void> {\n\t\tawait this.comm.reply(primaryMsg, 2, 32, B(Buffer.from([tiAck])));\n\t}\n\n\t// S9Fx Helpers\n\tasync s9f1(refMsg: SecsMessage): Promise<void> {\n\t\tawait this.s9fy(refMsg, 1);\n\t}\n\tasync s9f3(refMsg: SecsMessage): Promise<void> {\n\t\tawait this.s9fy(refMsg, 3);\n\t}\n\tasync s9f5(refMsg: SecsMessage): Promise<void> {\n\t\tawait this.s9fy(refMsg, 5);\n\t}\n\tasync s9f7(refMsg: SecsMessage): Promise<void> {\n\t\tawait this.s9fy(refMsg, 7);\n\t}\n\tasync s9f9(refMsg: SecsMessage): Promise<void> {\n\t\tawait this.s9fy(refMsg, 9);\n\t}\n\tasync s9f11(refMsg: SecsMessage): Promise<void> {\n\t\tawait this.s9fy(refMsg, 11);\n\t}\n\n\tprivate async s9fy(refMsg: SecsMessage, func: number): Promise<void> {\n\t\tconst header = this.getHeader10Bytes(refMsg);\n\t\tawait this.comm.send(9, func, false, B(header));\n\t}\n\n\tprivate getHeader10Bytes(msg: SecsMessage): Buffer {\n\t\tconst buffer = Buffer.alloc(10);\n\t\t// Session ID (Device ID)\n\t\tbuffer.writeUInt16BE(msg.deviceId & 0x7fff, 0);\n\n\t\t// Stream + W-bit\n\t\tlet streamByte = msg.stream & 0x7f;\n\t\tif (msg.wBit) {\n\t\t\tstreamByte |= 0x80;\n\t\t}\n\t\tbuffer.writeUInt8(streamByte, 2);\n\n\t\t// Function\n\t\tbuffer.writeUInt8(msg.func, 3);\n\n\t\t// P-Type, S-Type (Assuming 0 for now)\n\t\tbuffer.writeUInt8(0, 4);\n\t\tbuffer.writeUInt8(0, 5);\n\n\t\t// System Bytes\n\t\tif (typeof msg.systemBytes === \"number\") {\n\t\t\tbuffer.writeUInt32BE(msg.systemBytes, 6);\n\t\t} else {\n\t\t\t// Assuming Buffer\n\t\t\tconst sysBuf = msg.systemBytes as Buffer;\n\t\t\tsysBuf.copy(buffer, 6, 0, 4);\n\t\t}\n\n\t\treturn buffer;\n\t}\n}\n"],"mappings":";;;;;;;AAQA,IAAY,8CAAL;AACN;AACA;;;AAGD,IAAY,4CAAL;AACN;;;AAGD,IAAY,4CAAL;AACN;AACA;AACA;;;AAGD,IAAY,0CAAL;AACN;AACA;;;AAGD,IAAa,MAAb,MAAa,IAAI;CAChB,OAAwB,eAAe;CACvC,OAAwB,kBAAkB;CAC1C,OAAwB,qBAAqB,UAAU;CAEvD,AAAO,OAAe,IAAI;CAC1B,AAAO,UAAkB,IAAI;CAC7B,AAAO,YAAuB,IAAI;CAElC,YAAY,AAAOA,MAAgC;EAAhC;;CAGnB,MAAM,KAAK,YAAwC;AAClD,QAAM,KAAK,KAAK,MAAM,YAAY,GAAG,GAAG,GAAG,CAAC;;CAI7C,MAAM,QAAyB;EAC9B,IAAIC;AACJ,MAAI,KAAK,KAAK,QACb,QAAO,EAAE,EAAE,KAAK,KAAK,EAAE,EAAE,KAAK,QAAQ,CAAC;MAEvC,QAAO,GAAG;EAGX,MAAM,QAAQ,MAAM,KAAK,KAAK,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CAG5B,MAAc,KAAK,QAAqB,MAA6B;EACpE,MAAM,SAAS,KAAK,iBAAiB,OAAO;AAC5C,QAAM,KAAK,KAAK,KAAK,GAAG,MAAM,OAAO,EAAE,OAAO,CAAC;;CAGhD,AAAQ,iBAAiB,KAA0B;EAClD,MAAM,SAAS,OAAO,MAAM,GAAG;AAE/B,SAAO,cAAc,IAAI,WAAW,OAAQ,EAAE;EAG9C,IAAI,aAAa,IAAI,SAAS;AAC9B,MAAI,IAAI,KACP,eAAc;AAEf,SAAO,WAAW,YAAY,EAAE;AAGhC,SAAO,WAAW,IAAI,MAAM,EAAE;AAG9B,SAAO,WAAW,GAAG,EAAE;AACvB,SAAO,WAAW,GAAG,EAAE;AAGvB,MAAI,OAAO,IAAI,gBAAgB,SAC9B,QAAO,cAAc,IAAI,aAAa,EAAE;MAIxC,CADe,IAAI,YACZ,KAAK,QAAQ,GAAG,GAAG,EAAE;AAG7B,SAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"Secs2ItemHelper.js","names":["booleanValues: boolean[]","binaryValues: number[]"],"sources":["../../src/helper/Secs2ItemHelper.ts"],"sourcesContent":["import { AbstractSecs2Item } from \"../core/secs2item/AbstractSecs2Item.js\";\r\nimport { Secs2ItemAscii } from \"../core/secs2item/Secs2ItemAscii.js\";\r\nimport { Secs2ItemBinary } from \"../core/secs2item/Secs2ItemBinary.js\";\r\nimport { Secs2ItemBoolean } from \"../core/secs2item/Secs2ItemBoolean.js\";\r\nimport { Secs2ItemFactory } from \"../core/secs2item/Secs2ItemFactory.js\";\r\nimport { Secs2ItemList } from \"../core/secs2item/Secs2ItemList.js\";\r\nimport { Secs2ItemNumeric } from \"../core/secs2item/Secs2ItemNumeric.js\";\r\n\r\n/**\r\n * @description Creates a SECS-II list item.\r\n * @param items The items in the list.\r\n * @returns The SECS-II list item.\r\n */\r\nexport function L(...items: AbstractSecs2Item[]): Secs2ItemList {\r\n\treturn Secs2ItemFactory.createListItem(...items);\r\n}\r\n\r\n/**\r\n * @description Creates a SECS-II ASCII item.\r\n * @param value The value of the item.\r\n * @returns The SECS-II ASCII item.\r\n */\r\nexport function A(value: string): Secs2ItemAscii {\r\n\treturn Secs2ItemFactory.createAsciiItem(value);\r\n}\r\n\r\n/**\r\n * @description Creates a SECS-II boolean item.\r\n * @param value The value of the item.\r\n * @returns The SECS-II boolean item.\r\n */\r\nexport function BOOLEAN(value: string): Secs2ItemBoolean {\r\n\tconst booleanValues: boolean[] = [];\r\n\tconst values = value.split(\"\");\r\n\tvalues.map((v) => {\r\n\t\tif (v !== \"TRUE\" && v !== \"FALSE\") {\r\n\t\t\tthrow new Error(\"BOOLEAN value must be TRUE or FALSE\");\r\n\t\t}\r\n\t\tif (v === \"TRUE\") {\r\n\t\t\tbooleanValues.push(true);\r\n\t\t} else {\r\n\t\t\tbooleanValues.push(false);\r\n\t\t}\r\n\t});\r\n\treturn Secs2ItemFactory.createBooleanItem(...booleanValues);\r\n}\r\n\r\n/**\r\n * @description Creates a SECS-II binary item.\r\n * @param value The value of the item.\r\n * @returns The SECS-II binary item.\r\n */\r\nexport function B(value: string | Buffer): Secs2ItemBinary {\r\n\tconst valueType = typeof value;\r\n\tif (valueType === \"string\") {\r\n\t\tconst stringToBytes = (s: string) =>\r\n\t\t\ts\r\n\t\t\t\t.split(/\\s+/)\r\n\t\t\t\t.map((v) =>\r\n\t\t\t\t\tv.trim().startsWith(\"0x\") ? parseInt(v, 16) : parseInt(v, 10),\r\n\t\t\t\t);\r\n\r\n\t\tconst binaryValues: number[] = stringToBytes(value as string);\r\n\t\treturn Secs2ItemFactory.createBinaryItem(Buffer.from(binaryValues));\r\n\t}\r\n\r\n\treturn Secs2ItemFactory.createBinaryItem(value as Buffer);\r\n}\r\n\r\n/**\r\n * @description Creates a SECS-II unsigned 8-bit integer item.\r\n * @param value The value of the item.\r\n * @returns The SECS-II unsigned 8-bit integer item.\r\n */\r\nexport function U1(...value: number[]): Secs2ItemNumeric {\r\n\tif (value.some((v) => v < 0)) {\r\n\t\tthrow new Error(\"U1 value must be unsigned 8-bit integer\");\r\n\t}\r\n\treturn Secs2ItemFactory.createU1Item(...value);\r\n}\r\n\r\n/**\r\n * @description Creates a SECS-II unsigned 16-bit integer item.\r\n * @param value The value of the item.\r\n * @returns The SECS-II unsigned 16-bit integer item.\r\n */\r\nexport function U2(...value: number[]): Secs2ItemNumeric {\r\n\tif (value.some((v) => v < 0)) {\r\n\t\tthrow new Error(\"U2 value must be unsigned 16-bit integer\");\r\n\t}\r\n\treturn Secs2ItemFactory.createU2Item(...value);\r\n}\r\n\r\n/**\r\n * @description Creates a SECS-II unsigned 32-bit integer item.\r\n * @param value The value of the item.\r\n * @returns The SECS-II unsigned 32-bit integer item.\r\n */\r\nexport function U4(...value: number[]): Secs2ItemNumeric {\r\n\tif (value.some((v) => v < 0)) {\r\n\t\tthrow new Error(\"U4 value must be unsigned 32-bit integer\");\r\n\t}\r\n\treturn Secs2ItemFactory.createU4Item(...value);\r\n}\r\n\r\n/**\r\n * @description Creates a SECS-II unsigned 64-bit integer item.\r\n * @param value The value of the item.\r\n * @returns The SECS-II unsigned 64-bit integer item.\r\n */\r\nexport function U8(...value: number[] | bigint[]): Secs2ItemNumeric {\r\n\tif (value.some((v) => v < 0)) {\r\n\t\tthrow new Error(\"U8 value must be unsigned 64-bit integer\");\r\n\t}\r\n\treturn Secs2ItemFactory.createU8Item(...value);\r\n}\r\n\r\n/**\r\n * @description Creates a SECS-II signed 8-bit integer item.\r\n * @param value The value of the item.\r\n * @returns The SECS-II signed 8-bit integer item.\r\n */\r\nexport function I1(...value: number[]): Secs2ItemNumeric {\r\n\treturn Secs2ItemFactory.createI1Item(...value);\r\n}\r\n\r\n/**\r\n * @description Creates a SECS-II signed 16-bit integer item.\r\n * @param value The value of the item.\r\n * @returns The SECS-II signed 16-bit integer item.\r\n */\r\nexport function I2(...value: number[]): Secs2ItemNumeric {\r\n\treturn Secs2ItemFactory.createI2Item(...value);\r\n}\r\n\r\n/**\r\n * @description Creates a SECS-II signed 32-bit integer item.\r\n * @param value The value of the item.\r\n * @returns The SECS-II signed 32-bit integer item.\r\n */\r\nexport function I4(...value: number[]): Secs2ItemNumeric {\r\n\treturn Secs2ItemFactory.createI4Item(...value);\r\n}\r\n\r\n/**\r\n * @description Creates a SECS-II signed 64-bit integer item.\r\n * @param value The value of the item.\r\n * @returns The SECS-II signed 64-bit integer item.\r\n */\r\nexport function I8(...value: number[] | bigint[]): Secs2ItemNumeric {\r\n\treturn Secs2ItemFactory.createI8Item(...value);\r\n}\r\n\r\n/**\r\n * @description Creates a SECS-II float 32-bit number item.\r\n * @param value The value of the item.\r\n * @returns The SECS-II float 32-bit number item.\r\n */\r\nexport function F4(...value: number[]): Secs2ItemNumeric {\r\n\tif (value.some((v) => v % 1 !== 0)) {\r\n\t\tthrow new Error(\"F4 value must be float 32-bit number\");\r\n\t}\r\n\treturn Secs2ItemFactory.createF4Item(...value);\r\n}\r\n\r\n/**\r\n * @description Creates a SECS-II float 64-bit number item.\r\n * @param value The value of the item.\r\n * @returns The SECS-II float 64-bit number item.\r\n */\r\nexport function F8(...value: number[]): Secs2ItemNumeric {\r\n\treturn Secs2ItemFactory.createF8Item(...value);\r\n}\r\n"],"mappings":";;;;;;;;AAaA,SAAgB,EAAE,GAAG,OAA2C;AAC/D,QAAO,iBAAiB,eAAe,GAAG,MAAM;;;;;;;AAQjD,SAAgB,EAAE,OAA+B;AAChD,QAAO,iBAAiB,gBAAgB,MAAM;;;;;;;AAQ/C,SAAgB,QAAQ,OAAiC;CACxD,MAAMA,gBAA2B,EAAE;AAEnC,CADe,MAAM,MAAM,GAAG,CACvB,KAAK,MAAM;AACjB,MAAI,MAAM,UAAU,MAAM,QACzB,OAAM,IAAI,MAAM,sCAAsC;AAEvD,MAAI,MAAM,OACT,eAAc,KAAK,KAAK;MAExB,eAAc,KAAK,MAAM;GAEzB;AACF,QAAO,iBAAiB,kBAAkB,GAAG,cAAc;;;;;;;AAQ5D,SAAgB,EAAE,OAAyC;AAE1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,aAAa,GAAG,MAAM;;;;;;;AAQ/C,SAAgB,GAAG,GAAG,OAAmC;AACxD,KAAI,MAAM,MAAM,MAAM,IAAI,MAAM,EAAE,CACjC,OAAM,IAAI,MAAM,uCAAuC;AAExD,QAAO,iBAAiB,aAAa,GAAG,MAAM;;;;;;;AAQ/C,SAAgB,GAAG,GAAG,OAAmC;AACxD,QAAO,iBAAiB,aAAa,GAAG,MAAM"}
1
+ {"version":3,"file":"Secs2ItemHelper.js","names":["booleanValues: boolean[]","binaryValues: number[]"],"sources":["../../src/helper/Secs2ItemHelper.ts"],"sourcesContent":["import { AbstractSecs2Item } from \"../core/secs2item/AbstractSecs2Item.js\";\nimport { Secs2ItemAscii } from \"../core/secs2item/Secs2ItemAscii.js\";\nimport { Secs2ItemBinary } from \"../core/secs2item/Secs2ItemBinary.js\";\nimport { Secs2ItemBoolean } from \"../core/secs2item/Secs2ItemBoolean.js\";\nimport { Secs2ItemFactory } from \"../core/secs2item/Secs2ItemFactory.js\";\nimport { Secs2ItemList } from \"../core/secs2item/Secs2ItemList.js\";\nimport { Secs2ItemNumeric } from \"../core/secs2item/Secs2ItemNumeric.js\";\n\n/**\n * @description Creates a SECS-II list item.\n * @param items The items in the list.\n * @returns The SECS-II list item.\n */\nexport function L(...items: AbstractSecs2Item[]): Secs2ItemList {\n\treturn Secs2ItemFactory.createListItem(...items);\n}\n\n/**\n * @description Creates a SECS-II ASCII item.\n * @param value The value of the item.\n * @returns The SECS-II ASCII item.\n */\nexport function A(value: string): Secs2ItemAscii {\n\treturn Secs2ItemFactory.createAsciiItem(value);\n}\n\n/**\n * @description Creates a SECS-II boolean item.\n * @param value The value of the item.\n * @returns The SECS-II boolean item.\n */\nexport function BOOLEAN(value: string): Secs2ItemBoolean {\n\tconst booleanValues: boolean[] = [];\n\tconst values = value.split(\"\");\n\tvalues.map((v) => {\n\t\tif (v !== \"TRUE\" && v !== \"FALSE\") {\n\t\t\tthrow new Error(\"BOOLEAN value must be TRUE or FALSE\");\n\t\t}\n\t\tif (v === \"TRUE\") {\n\t\t\tbooleanValues.push(true);\n\t\t} else {\n\t\t\tbooleanValues.push(false);\n\t\t}\n\t});\n\treturn Secs2ItemFactory.createBooleanItem(...booleanValues);\n}\n\n/**\n * @description Creates a SECS-II binary item.\n * @param value The value of the item.\n * @returns The SECS-II binary item.\n */\nexport function B(value: string | Buffer): Secs2ItemBinary {\n\tconst valueType = typeof value;\n\tif (valueType === \"string\") {\n\t\tconst stringToBytes = (s: string) =>\n\t\t\ts\n\t\t\t\t.split(/\\s+/)\n\t\t\t\t.map((v) =>\n\t\t\t\t\tv.trim().startsWith(\"0x\") ? parseInt(v, 16) : parseInt(v, 10),\n\t\t\t\t);\n\n\t\tconst binaryValues: number[] = stringToBytes(value as string);\n\t\treturn Secs2ItemFactory.createBinaryItem(Buffer.from(binaryValues));\n\t}\n\n\treturn Secs2ItemFactory.createBinaryItem(value as Buffer);\n}\n\n/**\n * @description Creates a SECS-II unsigned 8-bit integer item.\n * @param value The value of the item.\n * @returns The SECS-II unsigned 8-bit integer item.\n */\nexport function U1(...value: number[]): Secs2ItemNumeric {\n\tif (value.some((v) => v < 0)) {\n\t\tthrow new Error(\"U1 value must be unsigned 8-bit integer\");\n\t}\n\treturn Secs2ItemFactory.createU1Item(...value);\n}\n\n/**\n * @description Creates a SECS-II unsigned 16-bit integer item.\n * @param value The value of the item.\n * @returns The SECS-II unsigned 16-bit integer item.\n */\nexport function U2(...value: number[]): Secs2ItemNumeric {\n\tif (value.some((v) => v < 0)) {\n\t\tthrow new Error(\"U2 value must be unsigned 16-bit integer\");\n\t}\n\treturn Secs2ItemFactory.createU2Item(...value);\n}\n\n/**\n * @description Creates a SECS-II unsigned 32-bit integer item.\n * @param value The value of the item.\n * @returns The SECS-II unsigned 32-bit integer item.\n */\nexport function U4(...value: number[]): Secs2ItemNumeric {\n\tif (value.some((v) => v < 0)) {\n\t\tthrow new Error(\"U4 value must be unsigned 32-bit integer\");\n\t}\n\treturn Secs2ItemFactory.createU4Item(...value);\n}\n\n/**\n * @description Creates a SECS-II unsigned 64-bit integer item.\n * @param value The value of the item.\n * @returns The SECS-II unsigned 64-bit integer item.\n */\nexport function U8(...value: number[] | bigint[]): Secs2ItemNumeric {\n\tif (value.some((v) => v < 0)) {\n\t\tthrow new Error(\"U8 value must be unsigned 64-bit integer\");\n\t}\n\treturn Secs2ItemFactory.createU8Item(...value);\n}\n\n/**\n * @description Creates a SECS-II signed 8-bit integer item.\n * @param value The value of the item.\n * @returns The SECS-II signed 8-bit integer item.\n */\nexport function I1(...value: number[]): Secs2ItemNumeric {\n\treturn Secs2ItemFactory.createI1Item(...value);\n}\n\n/**\n * @description Creates a SECS-II signed 16-bit integer item.\n * @param value The value of the item.\n * @returns The SECS-II signed 16-bit integer item.\n */\nexport function I2(...value: number[]): Secs2ItemNumeric {\n\treturn Secs2ItemFactory.createI2Item(...value);\n}\n\n/**\n * @description Creates a SECS-II signed 32-bit integer item.\n * @param value The value of the item.\n * @returns The SECS-II signed 32-bit integer item.\n */\nexport function I4(...value: number[]): Secs2ItemNumeric {\n\treturn Secs2ItemFactory.createI4Item(...value);\n}\n\n/**\n * @description Creates a SECS-II signed 64-bit integer item.\n * @param value The value of the item.\n * @returns The SECS-II signed 64-bit integer item.\n */\nexport function I8(...value: number[] | bigint[]): Secs2ItemNumeric {\n\treturn Secs2ItemFactory.createI8Item(...value);\n}\n\n/**\n * @description Creates a SECS-II float 32-bit number item.\n * @param value The value of the item.\n * @returns The SECS-II float 32-bit number item.\n */\nexport function F4(...value: number[]): Secs2ItemNumeric {\n\tif (value.some((v) => v % 1 !== 0)) {\n\t\tthrow new Error(\"F4 value must be float 32-bit number\");\n\t}\n\treturn Secs2ItemFactory.createF4Item(...value);\n}\n\n/**\n * @description Creates a SECS-II float 64-bit number item.\n * @param value The value of the item.\n * @returns The SECS-II float 64-bit number item.\n */\nexport function F8(...value: number[]): Secs2ItemNumeric {\n\treturn Secs2ItemFactory.createF8Item(...value);\n}\n"],"mappings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,iBAiWyB,GAAA,IAAA,EAAA,WAAA,EAAA,MAAA,CAAA,EA/V7B,WA+V6B;EAAqB,UAAA,kBAAA,CAAA,MAAA,EAjVhB,MAiVgB,CAAA,EAAA,IAAA;EAAY,QAAA,YAAA;EAa1D,QAAA,YAAA;EACI,QAAA,YAAA;EAAR,QAAA,YAAA;EAQmC,QAAA,aAAA;EAAR,QAAA,kBAAA;EA+BE,QAAA,oBAAA;EA+BA,UAAA,eAAA,CAAA,GAAA,EAxND,WAwNC,CAAA,EAAA,IAAA;EA9ec,UAAA,eAAA,CAAA,GAAA,EAySf,WAzSe,CAAA,EAAA,IAAA;EAAwB,UAAA,iBAAA,CAAA,GAAA,EAmUrC,WAnUqC,CAAA,EAAA,IAAA;mCAuUrC;mCAWA;mCAcA;oCAoBC;+BAYC,8BAA2B;iCASzB,8BAA2B;iCAS3B,cAAW;4BAQhB,qBAAqB,eAAY;2DAa1D,2BACJ,QAAQ;mBAQmB,QAAQ;qBA+BN;qBA+BA"}
@@ -163,7 +163,7 @@ var HsmsCommunicator = class extends AbstractSecsCommunicator {
163
163
  return;
164
164
  }
165
165
  if (this.state !== HsmsState.Selected) {
166
- this.logger.logSecs2("Received", msg.toSml());
166
+ this.logger.logSecs2("Received", msg.toSml(), this.deviceId, msg.systemBytes, msg.toBuffer());
167
167
  this.sendReject(msg, RejectReason.NotSelected);
168
168
  return;
169
169
  }