@netkitty/codec 2.1.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +249 -0
- package/README.md +30 -1
- package/README.zh-CN.md +26 -1
- package/dist/Codec.d.ts +25 -7
- package/dist/Codec.js +151 -18
- package/dist/PacketHeaders.d.ts +2 -0
- package/dist/PacketHeaders.js +8 -4
- package/dist/abstracts/BaseHeader.d.ts +34 -0
- package/dist/abstracts/BaseHeader.js +43 -0
- package/dist/headers/ARP.d.ts +3 -1
- package/dist/headers/ARP.js +8 -1
- package/dist/headers/BACnetIP.js +2 -1
- package/dist/headers/BGP.js +3 -2
- package/dist/headers/Babel.js +1 -1
- package/dist/headers/Codesys.js +3 -2
- package/dist/headers/DHCP.js +2 -1
- package/dist/headers/DNP3.d.ts +12 -7
- package/dist/headers/DNP3.js +98 -18
- package/dist/headers/DTLS.js +5 -3
- package/dist/headers/Diameter.js +2 -1
- package/dist/headers/Elasticsearch.js +3 -2
- package/dist/headers/EthernetII.d.ts +1 -0
- package/dist/headers/EthernetII.js +3 -0
- package/dist/headers/Goose.d.ts +31 -7
- package/dist/headers/Goose.js +409 -168
- package/dist/headers/HARTIP.js +2 -2
- package/dist/headers/ICMP.d.ts +1 -0
- package/dist/headers/ICMP.js +9 -1
- package/dist/headers/ICMPv6.d.ts +1 -0
- package/dist/headers/ICMPv6.js +1 -0
- package/dist/headers/IEC104_I_Frame.d.ts +28 -0
- package/dist/headers/IEC104_I_Frame.js +246 -160
- package/dist/headers/IEC104_S_Frame.js +3 -3
- package/dist/headers/IEC104_U_Frame.js +5 -3
- package/dist/headers/IEC61850SampledValues.d.ts +1 -0
- package/dist/headers/IEC61850SampledValues.js +16 -1
- package/dist/headers/IPFIX.js +2 -1
- package/dist/headers/IPv4.d.ts +1 -0
- package/dist/headers/IPv4.js +6 -0
- package/dist/headers/IPv6.d.ts +1 -0
- package/dist/headers/IPv6.js +6 -0
- package/dist/headers/IPv6HopByHopOptions.d.ts +2 -0
- package/dist/headers/IPv6HopByHopOptions.js +11 -0
- package/dist/headers/KNXnetIP.js +3 -2
- package/dist/headers/LACP.js +2 -1
- package/dist/headers/LDP.js +2 -2
- package/dist/headers/MQTT.js +3 -1
- package/dist/headers/MarkerProtocol.js +2 -1
- package/dist/headers/NHRP.js +7 -15
- package/dist/headers/NetFlowV5.js +2 -1
- package/dist/headers/OPCUA.js +4 -0
- package/dist/headers/OSPF.d.ts +2 -2
- package/dist/headers/OSPF.js +32 -20
- package/dist/headers/OSPFv3.d.ts +38 -0
- package/dist/headers/OSPFv3.js +316 -0
- package/dist/headers/PPTP.js +2 -2
- package/dist/headers/QUIC.js +8 -3
- package/dist/headers/RGoose.js +2 -1
- package/dist/headers/RIP.js +3 -2
- package/dist/headers/RIPng.js +3 -2
- package/dist/headers/RTCP.js +3 -2
- package/dist/headers/RTP.js +3 -2
- package/dist/headers/SFlow.js +4 -2
- package/dist/headers/SLMP.js +2 -1
- package/dist/headers/SLP.js +2 -1
- package/dist/headers/SLPv1.js +2 -1
- package/dist/headers/SMB1.js +3 -2
- package/dist/headers/SMB2.js +3 -2
- package/dist/headers/STUN.js +2 -1
- package/dist/headers/TLS_Handshake.d.ts +6 -0
- package/dist/headers/TLS_Handshake.js +28 -3
- package/dist/headers/TacacsPlus.js +3 -1
- package/dist/headers/Trailer.d.ts +30 -0
- package/dist/headers/Trailer.js +63 -0
- package/dist/headers/VLAN_802dot1Q.d.ts +1 -0
- package/dist/headers/VLAN_802dot1Q.js +3 -0
- package/dist/headers/WakeOnLAN.js +2 -1
- package/dist/headers/WireGuard.js +3 -2
- package/dist/headers/Zabbix.js +2 -2
- package/dist/lib/BERElement.d.ts +51 -0
- package/dist/lib/BERElement.js +125 -0
- package/dist/types/LayerGraph.d.ts +10 -5
- package/package.json +2 -2
|
@@ -7,6 +7,26 @@ const HexToBuffer_1 = require("../helper/HexToBuffer");
|
|
|
7
7
|
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
8
8
|
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
9
9
|
const NumberToBuffer_1 = require("../helper/NumberToBuffer");
|
|
10
|
+
/** The schema of a CP56Time2a held as its own object (the two range times of F_SC_NB_1). */
|
|
11
|
+
function cp56Time2aSchema(label) {
|
|
12
|
+
return {
|
|
13
|
+
type: 'object',
|
|
14
|
+
label: label,
|
|
15
|
+
properties: {
|
|
16
|
+
Milliseconds: { type: 'integer', label: 'Milliseconds', minimum: 0, maximum: 65535 },
|
|
17
|
+
Minutes: { type: 'integer', label: 'Minute', minimum: 0, maximum: 63 },
|
|
18
|
+
GEN: { type: 'integer', label: 'Reserved', minimum: 0, maximum: 1 },
|
|
19
|
+
MIN_IV: { type: 'integer', label: 'Invalid Quality Flag', minimum: 0, maximum: 1 },
|
|
20
|
+
Hours: { type: 'integer', label: 'Hour', minimum: 0, maximum: 31 },
|
|
21
|
+
SU: { type: 'integer', label: 'Summer Time', minimum: 0, maximum: 1 },
|
|
22
|
+
Day: { type: 'integer', label: 'Day Of The Month', minimum: 0, maximum: 31 },
|
|
23
|
+
DOW: { type: 'integer', label: 'Day Of The Week', minimum: 0, maximum: 7 },
|
|
24
|
+
Month: { type: 'integer', label: 'Month', minimum: 0, maximum: 15 },
|
|
25
|
+
Year: { type: 'integer', label: 'Year', minimum: 0, maximum: 127 }
|
|
26
|
+
},
|
|
27
|
+
required: ['Milliseconds', 'Minutes', 'GEN', 'MIN_IV', 'Hours', 'SU', 'Day', 'DOW', 'Month', 'Year']
|
|
28
|
+
};
|
|
29
|
+
}
|
|
10
30
|
class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
11
31
|
constructor() {
|
|
12
32
|
super(...arguments);
|
|
@@ -88,8 +108,6 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
88
108
|
apciType: {
|
|
89
109
|
type: 'string',
|
|
90
110
|
label: 'APCI Type',
|
|
91
|
-
minimum: 0,
|
|
92
|
-
maximum: 3,
|
|
93
111
|
decode: () => {
|
|
94
112
|
const controlType = this.readBits(2, 1, 7, 1);
|
|
95
113
|
switch (controlType) {
|
|
@@ -155,8 +173,12 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
155
173
|
this.writeBits(7, 1, 0, 1, bit);
|
|
156
174
|
}
|
|
157
175
|
},
|
|
176
|
+
//The number of information objects (SQ=0) or elements (SQ=1). Written as given; left out, it
|
|
177
|
+
//is the number of IOA items, one per object or element in either structure. Encode writes
|
|
178
|
+
//every IOA item whatever this says, so a given count that differs is reported, not obeyed.
|
|
158
179
|
numberOfObject: {
|
|
159
180
|
type: 'integer',
|
|
181
|
+
autoCalculated: true,
|
|
160
182
|
label: 'Number Of Object',
|
|
161
183
|
minimum: 0,
|
|
162
184
|
maximum: 127,
|
|
@@ -168,7 +190,22 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
168
190
|
this.instance.numberOfObject.setValue(numberOfObject);
|
|
169
191
|
},
|
|
170
192
|
encode: () => {
|
|
171
|
-
const
|
|
193
|
+
const items = this.ioaItemCount();
|
|
194
|
+
if (!this.isLeftOut(this.instance.numberOfObject)) {
|
|
195
|
+
const numberOfObject = this.instance.numberOfObject.getValue(0);
|
|
196
|
+
//An unparsed ASDU (raw) rewrites this octet and carries no IOA items to count.
|
|
197
|
+
if (numberOfObject !== items && !this.asduRawFallbackActive()) {
|
|
198
|
+
this.recordError(this.instance.numberOfObject.getPath(), `Number of objects ${numberOfObject} differs from the ${items} IOA item(s), all of which are written`);
|
|
199
|
+
}
|
|
200
|
+
this.writeBits(7, 1, 1, 7, numberOfObject);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
let numberOfObject = items;
|
|
204
|
+
if (numberOfObject > 127) {
|
|
205
|
+
this.recordError(this.instance.numberOfObject.getPath(), 'Maximum value is 127');
|
|
206
|
+
numberOfObject = 127;
|
|
207
|
+
}
|
|
208
|
+
this.instance.numberOfObject.setValue(numberOfObject);
|
|
172
209
|
this.writeBits(7, 1, 1, 7, numberOfObject);
|
|
173
210
|
}
|
|
174
211
|
},
|
|
@@ -1851,7 +1888,7 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
1851
1888
|
},
|
|
1852
1889
|
required: ['address', 'GS', 'SL1', 'SL2', 'SL3', 'SIE', 'SIF', 'EI', 'BL', 'SB', 'NT', 'IV', 'Milliseconds_16', 'Milliseconds_56', 'Minutes', 'GEN', 'MIN_IV', 'Hours', 'SU', 'Day', 'DOW', 'Month', 'Year']
|
|
1853
1890
|
},
|
|
1854
|
-
//带时标CP56time2a的继电器保护装置成组输出电路信息 M_EP_TF_1 = OCI + CP16Time2a +CP56Time2a
|
|
1891
|
+
//带时标CP56time2a的继电器保护装置成组输出电路信息 M_EP_TF_1 = OCI + QDP + CP16Time2a + CP56Time2a
|
|
1855
1892
|
{
|
|
1856
1893
|
type: 'object',
|
|
1857
1894
|
label: 'Packed Output Circuit Information Of Protection Equipment With CP56Time2a Time Tag',
|
|
@@ -3046,7 +3083,7 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
3046
3083
|
type: 'integer',
|
|
3047
3084
|
label: 'Test Counter',
|
|
3048
3085
|
minimum: 0,
|
|
3049
|
-
maximum:
|
|
3086
|
+
maximum: 65535
|
|
3050
3087
|
},
|
|
3051
3088
|
Milliseconds: {
|
|
3052
3089
|
type: 'integer',
|
|
@@ -3264,7 +3301,7 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
3264
3301
|
type: 'integer',
|
|
3265
3302
|
label: 'Length Of File',
|
|
3266
3303
|
minimum: 0,
|
|
3267
|
-
maximum:
|
|
3304
|
+
maximum: 16777215
|
|
3268
3305
|
},
|
|
3269
3306
|
FRQ: {
|
|
3270
3307
|
type: 'integer',
|
|
@@ -3294,15 +3331,15 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
3294
3331
|
},
|
|
3295
3332
|
NOS: {
|
|
3296
3333
|
type: 'integer',
|
|
3297
|
-
label: 'Name Of
|
|
3334
|
+
label: 'Name Of Section',
|
|
3298
3335
|
minimum: 0,
|
|
3299
|
-
maximum:
|
|
3336
|
+
maximum: 255
|
|
3300
3337
|
},
|
|
3301
3338
|
LOF: {
|
|
3302
3339
|
type: 'integer',
|
|
3303
3340
|
label: 'Length Of File',
|
|
3304
3341
|
minimum: 0,
|
|
3305
|
-
maximum:
|
|
3342
|
+
maximum: 16777215
|
|
3306
3343
|
},
|
|
3307
3344
|
SRQ: {
|
|
3308
3345
|
type: 'integer',
|
|
@@ -3332,9 +3369,9 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
3332
3369
|
},
|
|
3333
3370
|
NOS: {
|
|
3334
3371
|
type: 'integer',
|
|
3335
|
-
label: 'Name Of
|
|
3372
|
+
label: 'Name Of Section',
|
|
3336
3373
|
minimum: 0,
|
|
3337
|
-
maximum:
|
|
3374
|
+
maximum: 255
|
|
3338
3375
|
},
|
|
3339
3376
|
SCQ: {
|
|
3340
3377
|
type: 'integer',
|
|
@@ -3364,9 +3401,9 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
3364
3401
|
},
|
|
3365
3402
|
NOS: {
|
|
3366
3403
|
type: 'integer',
|
|
3367
|
-
label: 'Name Of
|
|
3404
|
+
label: 'Name Of Section',
|
|
3368
3405
|
minimum: 0,
|
|
3369
|
-
maximum:
|
|
3406
|
+
maximum: 255
|
|
3370
3407
|
},
|
|
3371
3408
|
LSQ: {
|
|
3372
3409
|
type: 'integer',
|
|
@@ -3402,9 +3439,9 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
3402
3439
|
},
|
|
3403
3440
|
NOS: {
|
|
3404
3441
|
type: 'integer',
|
|
3405
|
-
label: 'Name Of
|
|
3442
|
+
label: 'Name Of Section',
|
|
3406
3443
|
minimum: 0,
|
|
3407
|
-
maximum:
|
|
3444
|
+
maximum: 255
|
|
3408
3445
|
},
|
|
3409
3446
|
AFQ: {
|
|
3410
3447
|
type: 'integer',
|
|
@@ -3434,9 +3471,9 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
3434
3471
|
},
|
|
3435
3472
|
NOS: {
|
|
3436
3473
|
type: 'integer',
|
|
3437
|
-
label: 'Name Of
|
|
3474
|
+
label: 'Name Of Section',
|
|
3438
3475
|
minimum: 0,
|
|
3439
|
-
maximum:
|
|
3476
|
+
maximum: 255
|
|
3440
3477
|
},
|
|
3441
3478
|
LOS: {
|
|
3442
3479
|
type: 'integer',
|
|
@@ -3472,11 +3509,11 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
3472
3509
|
type: 'integer',
|
|
3473
3510
|
label: 'Length Of File',
|
|
3474
3511
|
minimum: 0,
|
|
3475
|
-
maximum:
|
|
3512
|
+
maximum: 16777215
|
|
3476
3513
|
},
|
|
3477
|
-
|
|
3514
|
+
SOF: {
|
|
3478
3515
|
type: 'integer',
|
|
3479
|
-
label: '
|
|
3516
|
+
label: 'Status Of File',
|
|
3480
3517
|
minimum: 0,
|
|
3481
3518
|
maximum: 255
|
|
3482
3519
|
},
|
|
@@ -3541,12 +3578,12 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
3541
3578
|
maximum: 127
|
|
3542
3579
|
}
|
|
3543
3580
|
},
|
|
3544
|
-
required: ['address', 'NOF', 'LOF', '
|
|
3581
|
+
required: ['address', 'NOF', 'LOF', 'SOF', 'Milliseconds', 'Minutes', 'GEN', 'MIN_IV', 'Hours', 'SU', 'Day', 'DOW', 'Month', 'Year']
|
|
3545
3582
|
},
|
|
3546
|
-
//日志查询,请求存档文件 F_SC_NB_1 = NOF +
|
|
3583
|
+
//日志查询,请求存档文件 F_SC_NB_1 = NOF + CP56Time2a (range start) + CP56Time2a (range stop)
|
|
3547
3584
|
{
|
|
3548
3585
|
type: 'object',
|
|
3549
|
-
label: '
|
|
3586
|
+
label: 'Query Log, Request Archive File',
|
|
3550
3587
|
properties: {
|
|
3551
3588
|
address: {
|
|
3552
3589
|
type: 'integer',
|
|
@@ -3560,14 +3597,10 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
3560
3597
|
minimum: 0,
|
|
3561
3598
|
maximum: 65535
|
|
3562
3599
|
},
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
label: 'Select And Call Qualifier',
|
|
3566
|
-
minimum: 0,
|
|
3567
|
-
maximum: 255
|
|
3568
|
-
}
|
|
3600
|
+
RangeStartTime: cp56Time2aSchema('Range Start Time'),
|
|
3601
|
+
RangeStopTime: cp56Time2aSchema('Range Stop Time')
|
|
3569
3602
|
},
|
|
3570
|
-
required: ['address', 'NOF', '
|
|
3603
|
+
required: ['address', 'NOF', 'RangeStartTime', 'RangeStopTime']
|
|
3571
3604
|
}
|
|
3572
3605
|
]
|
|
3573
3606
|
},
|
|
@@ -4451,29 +4484,30 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
4451
4484
|
IOA_arr.push(M_EP_TE_1);
|
|
4452
4485
|
}
|
|
4453
4486
|
break;
|
|
4454
|
-
//带时标CP56time2a的继电器保护装置成组输出电路信息 M_EP_TF_1 = OCI + CP16Time2a +CP56Time2a
|
|
4487
|
+
//带时标CP56time2a的继电器保护装置成组输出电路信息 M_EP_TF_1 = OCI + QDP + CP16Time2a + CP56Time2a
|
|
4488
|
+
//(IEC 60870-5-101): OCI and QDP are separate octets, 11 octets in all.
|
|
4455
4489
|
case 40:
|
|
4456
4490
|
{
|
|
4457
4491
|
const GC = this.readBits(objectOffset + 3, 1, 7, 1);
|
|
4458
4492
|
const CL1 = this.readBits(objectOffset + 3, 1, 6, 1);
|
|
4459
4493
|
const CL2 = this.readBits(objectOffset + 3, 1, 5, 1);
|
|
4460
4494
|
const CL3 = this.readBits(objectOffset + 3, 1, 4, 1);
|
|
4461
|
-
const EI = this.readBits(objectOffset +
|
|
4462
|
-
const BL = this.readBits(objectOffset +
|
|
4463
|
-
const SB = this.readBits(objectOffset +
|
|
4464
|
-
const NT = this.readBits(objectOffset +
|
|
4465
|
-
const IV = this.readBits(objectOffset +
|
|
4466
|
-
const Milliseconds_16 = this.readBytes(objectOffset +
|
|
4467
|
-
const Milliseconds_56 = this.readBytes(objectOffset +
|
|
4468
|
-
const Minutes = this.readBits(objectOffset +
|
|
4469
|
-
const GEN = this.readBits(objectOffset +
|
|
4470
|
-
const MIN_IV = this.readBits(objectOffset +
|
|
4471
|
-
const Hours = this.readBits(objectOffset +
|
|
4472
|
-
const SU = this.readBits(objectOffset +
|
|
4473
|
-
const Day = this.readBits(objectOffset +
|
|
4474
|
-
const DOW = this.readBits(objectOffset +
|
|
4475
|
-
const Month = this.readBits(objectOffset +
|
|
4476
|
-
const Year = this.readBits(objectOffset +
|
|
4495
|
+
const EI = this.readBits(objectOffset + 4, 1, 4, 1);
|
|
4496
|
+
const BL = this.readBits(objectOffset + 4, 1, 3, 1);
|
|
4497
|
+
const SB = this.readBits(objectOffset + 4, 1, 2, 1);
|
|
4498
|
+
const NT = this.readBits(objectOffset + 4, 1, 1, 1);
|
|
4499
|
+
const IV = this.readBits(objectOffset + 4, 1, 0, 1);
|
|
4500
|
+
const Milliseconds_16 = this.readBytes(objectOffset + 5, 2).readUInt16LE();
|
|
4501
|
+
const Milliseconds_56 = this.readBytes(objectOffset + 7, 2).readUInt16LE();
|
|
4502
|
+
const Minutes = this.readBits(objectOffset + 9, 1, 2, 6);
|
|
4503
|
+
const GEN = this.readBits(objectOffset + 9, 1, 1, 1);
|
|
4504
|
+
const MIN_IV = this.readBits(objectOffset + 9, 1, 0, 1);
|
|
4505
|
+
const Hours = this.readBits(objectOffset + 10, 1, 3, 5);
|
|
4506
|
+
const SU = this.readBits(objectOffset + 10, 1, 0, 1);
|
|
4507
|
+
const Day = this.readBits(objectOffset + 11, 1, 3, 5);
|
|
4508
|
+
const DOW = this.readBits(objectOffset + 11, 1, 0, 3);
|
|
4509
|
+
const Month = this.readBits(objectOffset + 12, 1, 4, 4);
|
|
4510
|
+
const Year = this.readBits(objectOffset + 13, 1, 1, 7);
|
|
4477
4511
|
const M_EP_TF_1 = {
|
|
4478
4512
|
address: 0,
|
|
4479
4513
|
GC: 0,
|
|
@@ -5110,19 +5144,20 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
5110
5144
|
}
|
|
5111
5145
|
break;
|
|
5112
5146
|
//带时标CP56time2a的测试命令 C_TS_TA_1 = TSC + CP56time2a
|
|
5147
|
+
//TSC is a 16-bit test sequence counter (IEC 60870-5-104), so the element is 9 octets.
|
|
5113
5148
|
case 107:
|
|
5114
5149
|
{
|
|
5115
|
-
const TSC =
|
|
5116
|
-
const Milliseconds = this.readBytes(objectOffset +
|
|
5117
|
-
const Minutes = this.readBits(objectOffset +
|
|
5118
|
-
const GEN = this.readBits(objectOffset +
|
|
5119
|
-
const MIN_IV = this.readBits(objectOffset +
|
|
5120
|
-
const Hours = this.readBits(objectOffset +
|
|
5121
|
-
const SU = this.readBits(objectOffset +
|
|
5122
|
-
const Day = this.readBits(objectOffset +
|
|
5123
|
-
const DOW = this.readBits(objectOffset +
|
|
5124
|
-
const Month = this.readBits(objectOffset +
|
|
5125
|
-
const Year = this.readBits(objectOffset +
|
|
5150
|
+
const TSC = this.readBytes(objectOffset + 3, 2).readUInt16LE();
|
|
5151
|
+
const Milliseconds = this.readBytes(objectOffset + 5, 2).readUInt16LE();
|
|
5152
|
+
const Minutes = this.readBits(objectOffset + 7, 1, 2, 6);
|
|
5153
|
+
const GEN = this.readBits(objectOffset + 7, 1, 1, 1);
|
|
5154
|
+
const MIN_IV = this.readBits(objectOffset + 7, 1, 0, 1);
|
|
5155
|
+
const Hours = this.readBits(objectOffset + 8, 1, 3, 5);
|
|
5156
|
+
const SU = this.readBits(objectOffset + 8, 1, 0, 1);
|
|
5157
|
+
const Day = this.readBits(objectOffset + 9, 1, 3, 5);
|
|
5158
|
+
const DOW = this.readBits(objectOffset + 9, 1, 0, 3);
|
|
5159
|
+
const Month = this.readBits(objectOffset + 10, 1, 4, 4);
|
|
5160
|
+
const Year = this.readBits(objectOffset + 11, 1, 1, 7);
|
|
5126
5161
|
const C_TS_TA_1 = {
|
|
5127
5162
|
address: 0,
|
|
5128
5163
|
TSC: 0,
|
|
@@ -5232,11 +5267,12 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
5232
5267
|
}
|
|
5233
5268
|
break;
|
|
5234
5269
|
//文件已准备好 F_FR_NA_1 = NOF + LOF + FRQ
|
|
5270
|
+
//File transfer elements (IEC 60870-5-101): NOF is 2 octets, NOS 1 and LOF 3.
|
|
5235
5271
|
case 120:
|
|
5236
5272
|
{
|
|
5237
5273
|
const NOF = this.readBytes(objectOffset + 3, 2).readUInt16LE();
|
|
5238
|
-
const LOF =
|
|
5239
|
-
const FRQ = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(objectOffset +
|
|
5274
|
+
const LOF = this.readBytes(objectOffset + 5, 3).readUIntLE(0, 3);
|
|
5275
|
+
const FRQ = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(objectOffset + 8, 1));
|
|
5240
5276
|
const F_FR_NA_1 = {
|
|
5241
5277
|
address: 0,
|
|
5242
5278
|
NOF: 0,
|
|
@@ -5254,9 +5290,9 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
5254
5290
|
case 121:
|
|
5255
5291
|
{
|
|
5256
5292
|
const NOF = this.readBytes(objectOffset + 3, 2).readUint16LE();
|
|
5257
|
-
const NOS = this.readBytes(objectOffset + 5,
|
|
5258
|
-
const LOF =
|
|
5259
|
-
const SRQ = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(objectOffset +
|
|
5293
|
+
const NOS = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(objectOffset + 5, 1));
|
|
5294
|
+
const LOF = this.readBytes(objectOffset + 6, 3).readUIntLE(0, 3);
|
|
5295
|
+
const SRQ = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(objectOffset + 9, 1));
|
|
5260
5296
|
const F_SR_NA_1 = {
|
|
5261
5297
|
address: 0,
|
|
5262
5298
|
NOF: 0,
|
|
@@ -5276,8 +5312,8 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
5276
5312
|
case 122:
|
|
5277
5313
|
{
|
|
5278
5314
|
const NOF = this.readBytes(objectOffset + 3, 2).readUint16LE();
|
|
5279
|
-
const NOS = this.readBytes(objectOffset + 5,
|
|
5280
|
-
const SCQ = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(objectOffset +
|
|
5315
|
+
const NOS = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(objectOffset + 5, 1));
|
|
5316
|
+
const SCQ = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(objectOffset + 6, 1));
|
|
5281
5317
|
const F_SC_NA_1 = {
|
|
5282
5318
|
address: 0,
|
|
5283
5319
|
NOF: 0,
|
|
@@ -5295,9 +5331,9 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
5295
5331
|
case 123:
|
|
5296
5332
|
{
|
|
5297
5333
|
const NOF = this.readBytes(objectOffset + 3, 2).readUint16LE();
|
|
5298
|
-
const NOS = this.readBytes(objectOffset + 5,
|
|
5299
|
-
const LSQ = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(objectOffset +
|
|
5300
|
-
const CHS = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(objectOffset +
|
|
5334
|
+
const NOS = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(objectOffset + 5, 1));
|
|
5335
|
+
const LSQ = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(objectOffset + 6, 1));
|
|
5336
|
+
const CHS = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(objectOffset + 7, 1));
|
|
5301
5337
|
const F_LS_NA_1 = {
|
|
5302
5338
|
address: 0,
|
|
5303
5339
|
NOF: 0,
|
|
@@ -5317,8 +5353,8 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
5317
5353
|
case 124:
|
|
5318
5354
|
{
|
|
5319
5355
|
const NOF = this.readBytes(objectOffset + 3, 2).readUint16LE();
|
|
5320
|
-
const NOS = this.readBytes(objectOffset + 5,
|
|
5321
|
-
const AFQ = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(objectOffset +
|
|
5356
|
+
const NOS = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(objectOffset + 5, 1));
|
|
5357
|
+
const AFQ = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(objectOffset + 6, 1));
|
|
5322
5358
|
const F_FA_NA_1 = {
|
|
5323
5359
|
address: 0,
|
|
5324
5360
|
NOF: 0,
|
|
@@ -5336,9 +5372,9 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
5336
5372
|
case 125:
|
|
5337
5373
|
{
|
|
5338
5374
|
const NOF = this.readBytes(objectOffset + 3, 2).readUint16LE();
|
|
5339
|
-
const NOS = this.readBytes(objectOffset + 5,
|
|
5340
|
-
const LOS = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(objectOffset +
|
|
5341
|
-
const Segment = (0, BufferToHex_1.BufferToHex)(this.readBytes(objectOffset +
|
|
5375
|
+
const NOS = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(objectOffset + 5, 1));
|
|
5376
|
+
const LOS = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(objectOffset + 6, 1));
|
|
5377
|
+
const Segment = (0, BufferToHex_1.BufferToHex)(this.readBytes(objectOffset + 7, LOS));
|
|
5342
5378
|
const F_SG_NA_1 = {
|
|
5343
5379
|
address: 0,
|
|
5344
5380
|
NOF: 0,
|
|
@@ -5358,18 +5394,18 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
5358
5394
|
case 126:
|
|
5359
5395
|
{
|
|
5360
5396
|
const NOF = this.readBytes(objectOffset + 3, 2).readUint16LE();
|
|
5361
|
-
const LOF =
|
|
5362
|
-
const SOF = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(objectOffset +
|
|
5363
|
-
const Milliseconds = this.readBytes(objectOffset +
|
|
5364
|
-
const Minutes = this.readBits(objectOffset +
|
|
5365
|
-
const GEN = this.readBits(objectOffset +
|
|
5366
|
-
const MIN_IV = this.readBits(objectOffset +
|
|
5367
|
-
const Hours = this.readBits(objectOffset +
|
|
5368
|
-
const SU = this.readBits(objectOffset +
|
|
5369
|
-
const Day = this.readBits(objectOffset +
|
|
5370
|
-
const DOW = this.readBits(objectOffset +
|
|
5371
|
-
const Month = this.readBits(objectOffset +
|
|
5372
|
-
const Year = this.readBits(objectOffset +
|
|
5397
|
+
const LOF = this.readBytes(objectOffset + 5, 3).readUIntLE(0, 3);
|
|
5398
|
+
const SOF = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(objectOffset + 8, 1));
|
|
5399
|
+
const Milliseconds = this.readBytes(objectOffset + 9, 2).readUInt16LE();
|
|
5400
|
+
const Minutes = this.readBits(objectOffset + 11, 1, 2, 6);
|
|
5401
|
+
const GEN = this.readBits(objectOffset + 11, 1, 1, 1);
|
|
5402
|
+
const MIN_IV = this.readBits(objectOffset + 11, 1, 0, 1);
|
|
5403
|
+
const Hours = this.readBits(objectOffset + 12, 1, 3, 5);
|
|
5404
|
+
const SU = this.readBits(objectOffset + 12, 1, 0, 1);
|
|
5405
|
+
const Day = this.readBits(objectOffset + 13, 1, 3, 5);
|
|
5406
|
+
const DOW = this.readBits(objectOffset + 13, 1, 0, 3);
|
|
5407
|
+
const Month = this.readBits(objectOffset + 14, 1, 4, 4);
|
|
5408
|
+
const Year = this.readBits(objectOffset + 15, 1, 1, 7);
|
|
5373
5409
|
const F_DR_TA_1 = {
|
|
5374
5410
|
address: 0,
|
|
5375
5411
|
NOF: 0,
|
|
@@ -5403,19 +5439,15 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
5403
5439
|
IOA_arr.push(F_DR_TA_1);
|
|
5404
5440
|
}
|
|
5405
5441
|
break;
|
|
5406
|
-
//日志查询,请求存档文件 F_SC_NB_1 = NOF +
|
|
5442
|
+
//日志查询,请求存档文件 F_SC_NB_1 = NOF + CP56Time2a (range start) + CP56Time2a (range stop)
|
|
5407
5443
|
case 127:
|
|
5408
5444
|
{
|
|
5409
|
-
const NOF = this.readBytes(objectOffset + 3, 2).readUint16LE();
|
|
5410
|
-
const SCQ = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(objectOffset + 5, 1));
|
|
5411
5445
|
const F_SC_NB_1 = {
|
|
5412
|
-
address: 0,
|
|
5413
|
-
NOF:
|
|
5414
|
-
|
|
5446
|
+
address: buffer.readUintBE(0, 3),
|
|
5447
|
+
NOF: this.readBytes(objectOffset + 3, 2).readUint16LE(),
|
|
5448
|
+
RangeStartTime: this.readCP56Time2a(objectOffset + 5),
|
|
5449
|
+
RangeStopTime: this.readCP56Time2a(objectOffset + 12)
|
|
5415
5450
|
};
|
|
5416
|
-
F_SC_NB_1.address = buffer.readUintBE(0, 3);
|
|
5417
|
-
F_SC_NB_1.NOF = NOF;
|
|
5418
|
-
F_SC_NB_1.SCQ = SCQ;
|
|
5419
5451
|
IOA_arr.push(F_SC_NB_1);
|
|
5420
5452
|
}
|
|
5421
5453
|
break;
|
|
@@ -5439,7 +5471,8 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
5439
5471
|
this.writeBytes(6, (0, HexToBuffer_1.HexToBuffer)(this.instance.raw.getValue().toString()));
|
|
5440
5472
|
return;
|
|
5441
5473
|
}
|
|
5442
|
-
|
|
5474
|
+
//Every IOA item is written, whatever numberOfObject says (it is reported when it differs).
|
|
5475
|
+
const items = this.ioaItemCount();
|
|
5443
5476
|
const typeId = this.instance.messageTypeId.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
5444
5477
|
//A given APDU length spaces the objects (a crafted one misplaces them, as it would on the
|
|
5445
5478
|
//wire). A left-out one is only known once the APDU is written, so the objects are then
|
|
@@ -5448,10 +5481,10 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
5448
5481
|
const strideFromLength = !this.isLeftOut(this.instance.apduLength);
|
|
5449
5482
|
const apduLength = this.instance.apduLength.getValue(0);
|
|
5450
5483
|
const ioaTotalLength = apduLength - 10;
|
|
5451
|
-
const ioaLength = ioaTotalLength /
|
|
5484
|
+
const ioaLength = ioaTotalLength / items;
|
|
5452
5485
|
const sq = this.instance.sqBit.getValue(0);
|
|
5453
|
-
let objectStride = sq === 1 ? (ioaTotalLength - 3) /
|
|
5454
|
-
Loop: for (let i = 1; i <=
|
|
5486
|
+
let objectStride = sq === 1 ? (ioaTotalLength - 3) / items : ioaLength;
|
|
5487
|
+
Loop: for (let i = 1; i <= items; i++) {
|
|
5455
5488
|
const objectOffset = 12 + (i - 1) * objectStride;
|
|
5456
5489
|
switch (typeId) {
|
|
5457
5490
|
//单点信息 M_SP_NA_1 : SIQ
|
|
@@ -5681,7 +5714,7 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
5681
5714
|
this.writeBytes(objectOffset + 5, (0, NumberToBuffer_1.UInt16ToBuffer)(Milliseconds_buffer.readUInt16LE()));
|
|
5682
5715
|
this.writeBits(objectOffset + 7, 1, 2, 6, IOA_message[i - 1].Minutes);
|
|
5683
5716
|
this.writeBits(objectOffset + 7, 1, 1, 1, IOA_message[i - 1].GEN);
|
|
5684
|
-
this.writeBits(objectOffset +
|
|
5717
|
+
this.writeBits(objectOffset + 7, 1, 0, 1, IOA_message[i - 1].MIN_IV);
|
|
5685
5718
|
this.writeBits(objectOffset + 8, 1, 3, 5, IOA_message[i - 1].Hours);
|
|
5686
5719
|
this.writeBits(objectOffset + 8, 1, 0, 1, IOA_message[i - 1].SU);
|
|
5687
5720
|
this.writeBits(objectOffset + 9, 1, 3, 5, IOA_message[i - 1].Day);
|
|
@@ -5889,7 +5922,7 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
5889
5922
|
this.writeBits(objectOffset + 13, 1, 1, 7, IOA_message[i - 1].Year);
|
|
5890
5923
|
}
|
|
5891
5924
|
break;
|
|
5892
|
-
//带时标CP56time2a的继电器保护装置成组输出电路信息 M_EP_TF_1 = OCI + CP16Time2a +CP56Time2a
|
|
5925
|
+
//带时标CP56time2a的继电器保护装置成组输出电路信息 M_EP_TF_1 = OCI + QDP + CP16Time2a + CP56Time2a
|
|
5893
5926
|
case 40:
|
|
5894
5927
|
{
|
|
5895
5928
|
const IOA_message = this.instance.IOA.getValue([], (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
@@ -5901,24 +5934,24 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
5901
5934
|
this.writeBits(objectOffset + 3, 1, 6, 1, IOA_message[i - 1].CL1);
|
|
5902
5935
|
this.writeBits(objectOffset + 3, 1, 5, 1, IOA_message[i - 1].CL2);
|
|
5903
5936
|
this.writeBits(objectOffset + 3, 1, 4, 1, IOA_message[i - 1].CL3);
|
|
5904
|
-
this.writeBits(objectOffset +
|
|
5905
|
-
this.writeBits(objectOffset +
|
|
5906
|
-
this.writeBits(objectOffset +
|
|
5907
|
-
this.writeBits(objectOffset +
|
|
5908
|
-
this.writeBits(objectOffset +
|
|
5937
|
+
this.writeBits(objectOffset + 4, 1, 4, 1, IOA_message[i - 1].EI);
|
|
5938
|
+
this.writeBits(objectOffset + 4, 1, 3, 1, IOA_message[i - 1].BL);
|
|
5939
|
+
this.writeBits(objectOffset + 4, 1, 2, 1, IOA_message[i - 1].SB);
|
|
5940
|
+
this.writeBits(objectOffset + 4, 1, 1, 1, IOA_message[i - 1].NT);
|
|
5941
|
+
this.writeBits(objectOffset + 4, 1, 0, 1, IOA_message[i - 1].IV);
|
|
5909
5942
|
const Milliseconds_16_buffer = (0, NumberToBuffer_1.UInt16ToBuffer)(IOA_message[i - 1].Milliseconds_16);
|
|
5910
|
-
this.writeBytes(objectOffset +
|
|
5943
|
+
this.writeBytes(objectOffset + 5, (0, NumberToBuffer_1.UInt16ToBuffer)(Milliseconds_16_buffer.readUInt16LE()));
|
|
5911
5944
|
const Milliseconds_56_buffer = (0, NumberToBuffer_1.UInt16ToBuffer)(IOA_message[i - 1].Milliseconds_56);
|
|
5912
|
-
this.writeBytes(objectOffset +
|
|
5913
|
-
this.writeBits(objectOffset +
|
|
5914
|
-
this.writeBits(objectOffset +
|
|
5915
|
-
this.writeBits(objectOffset +
|
|
5916
|
-
this.writeBits(objectOffset +
|
|
5917
|
-
this.writeBits(objectOffset +
|
|
5918
|
-
this.writeBits(objectOffset +
|
|
5919
|
-
this.writeBits(objectOffset +
|
|
5920
|
-
this.writeBits(objectOffset +
|
|
5921
|
-
this.writeBits(objectOffset +
|
|
5945
|
+
this.writeBytes(objectOffset + 7, (0, NumberToBuffer_1.UInt16ToBuffer)(Milliseconds_56_buffer.readUInt16LE()));
|
|
5946
|
+
this.writeBits(objectOffset + 9, 1, 2, 6, IOA_message[i - 1].Minutes);
|
|
5947
|
+
this.writeBits(objectOffset + 9, 1, 1, 1, IOA_message[i - 1].GEN);
|
|
5948
|
+
this.writeBits(objectOffset + 9, 1, 0, 1, IOA_message[i - 1].MIN_IV);
|
|
5949
|
+
this.writeBits(objectOffset + 10, 1, 3, 5, IOA_message[i - 1].Hours);
|
|
5950
|
+
this.writeBits(objectOffset + 10, 1, 0, 1, IOA_message[i - 1].SU);
|
|
5951
|
+
this.writeBits(objectOffset + 11, 1, 3, 5, IOA_message[i - 1].Day);
|
|
5952
|
+
this.writeBits(objectOffset + 11, 1, 0, 3, IOA_message[i - 1].DOW);
|
|
5953
|
+
this.writeBits(objectOffset + 12, 1, 4, 4, IOA_message[i - 1].Month);
|
|
5954
|
+
this.writeBits(objectOffset + 13, 1, 1, 7, IOA_message[i - 1].Year);
|
|
5922
5955
|
}
|
|
5923
5956
|
break;
|
|
5924
5957
|
//单命令 C_SC_NA_1 = SCO
|
|
@@ -6277,18 +6310,19 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
6277
6310
|
const buf = Buffer.alloc(3);
|
|
6278
6311
|
buf.writeUIntLE(address_LE, 0, 3);
|
|
6279
6312
|
this.writeIOAAddress(objectOffset, buf, i);
|
|
6280
|
-
|
|
6313
|
+
const TSC_buffer = (0, NumberToBuffer_1.UInt16ToBuffer)(IOA_message[i - 1].TSC);
|
|
6314
|
+
this.writeBytes(objectOffset + 3, (0, NumberToBuffer_1.UInt16ToBuffer)(TSC_buffer.readUInt16LE()));
|
|
6281
6315
|
const Milliseconds_buffer = (0, NumberToBuffer_1.UInt16ToBuffer)(IOA_message[i - 1].Milliseconds);
|
|
6282
|
-
this.writeBytes(objectOffset +
|
|
6283
|
-
this.writeBits(objectOffset +
|
|
6284
|
-
this.writeBits(objectOffset +
|
|
6285
|
-
this.writeBits(objectOffset +
|
|
6286
|
-
this.writeBits(objectOffset +
|
|
6287
|
-
this.writeBits(objectOffset +
|
|
6288
|
-
this.writeBits(objectOffset +
|
|
6289
|
-
this.writeBits(objectOffset +
|
|
6290
|
-
this.writeBits(objectOffset +
|
|
6291
|
-
this.writeBits(objectOffset +
|
|
6316
|
+
this.writeBytes(objectOffset + 5, (0, NumberToBuffer_1.UInt16ToBuffer)(Milliseconds_buffer.readUInt16LE()));
|
|
6317
|
+
this.writeBits(objectOffset + 7, 1, 2, 6, IOA_message[i - 1].Minutes);
|
|
6318
|
+
this.writeBits(objectOffset + 7, 1, 1, 1, IOA_message[i - 1].GEN);
|
|
6319
|
+
this.writeBits(objectOffset + 7, 1, 0, 1, IOA_message[i - 1].MIN_IV);
|
|
6320
|
+
this.writeBits(objectOffset + 8, 1, 3, 5, IOA_message[i - 1].Hours);
|
|
6321
|
+
this.writeBits(objectOffset + 8, 1, 0, 1, IOA_message[i - 1].SU);
|
|
6322
|
+
this.writeBits(objectOffset + 9, 1, 3, 5, IOA_message[i - 1].Day);
|
|
6323
|
+
this.writeBits(objectOffset + 9, 1, 0, 3, IOA_message[i - 1].DOW);
|
|
6324
|
+
this.writeBits(objectOffset + 10, 1, 4, 4, IOA_message[i - 1].Month);
|
|
6325
|
+
this.writeBits(objectOffset + 11, 1, 1, 7, IOA_message[i - 1].Year);
|
|
6292
6326
|
}
|
|
6293
6327
|
break;
|
|
6294
6328
|
//归一化测量值 P_ME_NA_1 = NVA + QPM
|
|
@@ -6355,8 +6389,10 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
6355
6389
|
buf.writeUIntLE(address_LE, 0, 3);
|
|
6356
6390
|
this.writeIOAAddress(objectOffset, buf, i);
|
|
6357
6391
|
this.writeBytes(objectOffset + 3, (0, NumberToBuffer_1.UInt16ToBuffer)((0, NumberToBuffer_1.UInt16ToBuffer)(IOA_message[i - 1].NOF).readUInt16LE()));
|
|
6358
|
-
|
|
6359
|
-
|
|
6392
|
+
const LOF = Buffer.alloc(3);
|
|
6393
|
+
LOF.writeUIntLE(IOA_message[i - 1].LOF, 0, 3);
|
|
6394
|
+
this.writeBytes(objectOffset + 5, LOF);
|
|
6395
|
+
this.writeBytes(objectOffset + 8, (0, NumberToBuffer_1.UInt8ToBuffer)(IOA_message[i - 1].FRQ));
|
|
6360
6396
|
}
|
|
6361
6397
|
break;
|
|
6362
6398
|
//节点已准备好 F_SR_NA_1 = NOF + NOS + LOF + SRQ
|
|
@@ -6368,9 +6404,11 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
6368
6404
|
buf.writeUIntLE(address_LE, 0, 3);
|
|
6369
6405
|
this.writeIOAAddress(objectOffset, buf, i);
|
|
6370
6406
|
this.writeBytes(objectOffset + 3, (0, NumberToBuffer_1.UInt16ToBuffer)((0, NumberToBuffer_1.UInt16ToBuffer)(IOA_message[i - 1].NOF).readUInt16LE()));
|
|
6371
|
-
this.writeBytes(objectOffset + 5, (0, NumberToBuffer_1.
|
|
6372
|
-
|
|
6373
|
-
|
|
6407
|
+
this.writeBytes(objectOffset + 5, (0, NumberToBuffer_1.UInt8ToBuffer)(IOA_message[i - 1].NOS));
|
|
6408
|
+
const LOF = Buffer.alloc(3);
|
|
6409
|
+
LOF.writeUIntLE(IOA_message[i - 1].LOF, 0, 3);
|
|
6410
|
+
this.writeBytes(objectOffset + 6, LOF);
|
|
6411
|
+
this.writeBytes(objectOffset + 9, (0, NumberToBuffer_1.UInt8ToBuffer)(IOA_message[i - 1].SRQ));
|
|
6374
6412
|
}
|
|
6375
6413
|
break;
|
|
6376
6414
|
//召唤目录,选择文件,召唤文件,选择节 F_SC_NA_1 = NOF + NOS + SCQ
|
|
@@ -6381,9 +6419,9 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
6381
6419
|
const buf = Buffer.alloc(3);
|
|
6382
6420
|
buf.writeUIntLE(address_LE, 0, 3);
|
|
6383
6421
|
this.writeIOAAddress(objectOffset, buf, i);
|
|
6384
|
-
this.writeBytes(objectOffset + 3, (0, NumberToBuffer_1.UInt16ToBuffer)(IOA_message[i - 1].NOF));
|
|
6385
|
-
this.writeBytes(objectOffset + 5, (0, NumberToBuffer_1.
|
|
6386
|
-
this.writeBytes(objectOffset +
|
|
6422
|
+
this.writeBytes(objectOffset + 3, (0, NumberToBuffer_1.UInt16ToBuffer)((0, NumberToBuffer_1.UInt16ToBuffer)(IOA_message[i - 1].NOF).readUInt16LE()));
|
|
6423
|
+
this.writeBytes(objectOffset + 5, (0, NumberToBuffer_1.UInt8ToBuffer)(IOA_message[i - 1].NOS));
|
|
6424
|
+
this.writeBytes(objectOffset + 6, (0, NumberToBuffer_1.UInt8ToBuffer)(IOA_message[i - 1].SCQ));
|
|
6387
6425
|
}
|
|
6388
6426
|
break;
|
|
6389
6427
|
//最后的节,最后的段 F_LS_NA_1 = NOF + NOS + LSQ + CHS
|
|
@@ -6395,9 +6433,9 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
6395
6433
|
buf.writeUIntLE(address_LE, 0, 3);
|
|
6396
6434
|
this.writeIOAAddress(objectOffset, buf, i);
|
|
6397
6435
|
this.writeBytes(objectOffset + 3, (0, NumberToBuffer_1.UInt16ToBuffer)((0, NumberToBuffer_1.UInt16ToBuffer)(IOA_message[i - 1].NOF).readUInt16LE()));
|
|
6398
|
-
this.writeBytes(objectOffset + 5, (0, NumberToBuffer_1.
|
|
6399
|
-
this.writeBytes(objectOffset +
|
|
6400
|
-
this.writeBytes(objectOffset +
|
|
6436
|
+
this.writeBytes(objectOffset + 5, (0, NumberToBuffer_1.UInt8ToBuffer)(IOA_message[i - 1].NOS));
|
|
6437
|
+
this.writeBytes(objectOffset + 6, (0, NumberToBuffer_1.UInt8ToBuffer)(IOA_message[i - 1].LSQ));
|
|
6438
|
+
this.writeBytes(objectOffset + 7, (0, NumberToBuffer_1.UInt8ToBuffer)(IOA_message[i - 1].CHS));
|
|
6401
6439
|
}
|
|
6402
6440
|
break;
|
|
6403
6441
|
//确认文件,确认节 F_FA_NA_1 = NOF + NOS + AFQ
|
|
@@ -6409,8 +6447,8 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
6409
6447
|
buf.writeUIntLE(address_LE, 0, 3);
|
|
6410
6448
|
this.writeIOAAddress(objectOffset, buf, i);
|
|
6411
6449
|
this.writeBytes(objectOffset + 3, (0, NumberToBuffer_1.UInt16ToBuffer)((0, NumberToBuffer_1.UInt16ToBuffer)(IOA_message[i - 1].NOF).readUInt16LE()));
|
|
6412
|
-
this.writeBytes(objectOffset + 5, (0, NumberToBuffer_1.
|
|
6413
|
-
this.writeBytes(objectOffset +
|
|
6450
|
+
this.writeBytes(objectOffset + 5, (0, NumberToBuffer_1.UInt8ToBuffer)(IOA_message[i - 1].NOS));
|
|
6451
|
+
this.writeBytes(objectOffset + 6, (0, NumberToBuffer_1.UInt8ToBuffer)(IOA_message[i - 1].AFQ));
|
|
6414
6452
|
}
|
|
6415
6453
|
break;
|
|
6416
6454
|
//段 F_SG_NA_1 = NOF + NOS + LOS + Segment
|
|
@@ -6422,9 +6460,9 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
6422
6460
|
buf.writeUIntLE(address_LE, 0, 3);
|
|
6423
6461
|
this.writeIOAAddress(objectOffset, buf, i);
|
|
6424
6462
|
this.writeBytes(objectOffset + 3, (0, NumberToBuffer_1.UInt16ToBuffer)((0, NumberToBuffer_1.UInt16ToBuffer)(IOA_message[i - 1].NOF).readUInt16LE()));
|
|
6425
|
-
this.writeBytes(objectOffset + 5, (0, NumberToBuffer_1.
|
|
6426
|
-
this.writeBytes(objectOffset +
|
|
6427
|
-
this.writeBytes(objectOffset +
|
|
6463
|
+
this.writeBytes(objectOffset + 5, (0, NumberToBuffer_1.UInt8ToBuffer)(IOA_message[i - 1].NOS));
|
|
6464
|
+
this.writeBytes(objectOffset + 6, (0, NumberToBuffer_1.UInt8ToBuffer)(IOA_message[i - 1].LOS));
|
|
6465
|
+
this.writeBytes(objectOffset + 7, (0, HexToBuffer_1.HexToBuffer)(IOA_message[i - 1].Segment));
|
|
6428
6466
|
}
|
|
6429
6467
|
break;
|
|
6430
6468
|
//目录 F_DR_TA_1 = NOF + LOF + SOF + CP56Time2a
|
|
@@ -6436,22 +6474,24 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
6436
6474
|
buf.writeUIntLE(address_LE, 0, 3);
|
|
6437
6475
|
this.writeIOAAddress(objectOffset, buf, i);
|
|
6438
6476
|
this.writeBytes(objectOffset + 3, (0, NumberToBuffer_1.UInt16ToBuffer)((0, NumberToBuffer_1.UInt16ToBuffer)(IOA_message[i - 1].NOF).readUInt16LE()));
|
|
6439
|
-
|
|
6440
|
-
|
|
6477
|
+
const LOF = Buffer.alloc(3);
|
|
6478
|
+
LOF.writeUIntLE(IOA_message[i - 1].LOF, 0, 3);
|
|
6479
|
+
this.writeBytes(objectOffset + 5, LOF);
|
|
6480
|
+
this.writeBytes(objectOffset + 8, (0, NumberToBuffer_1.UInt8ToBuffer)(IOA_message[i - 1].SOF));
|
|
6441
6481
|
const Milliseconds_buffer = (0, NumberToBuffer_1.UInt16ToBuffer)(IOA_message[i - 1].Milliseconds);
|
|
6442
|
-
this.writeBytes(objectOffset +
|
|
6443
|
-
this.writeBits(objectOffset +
|
|
6444
|
-
this.writeBits(objectOffset +
|
|
6445
|
-
this.writeBits(objectOffset +
|
|
6446
|
-
this.writeBits(objectOffset +
|
|
6447
|
-
this.writeBits(objectOffset +
|
|
6448
|
-
this.writeBits(objectOffset +
|
|
6449
|
-
this.writeBits(objectOffset +
|
|
6450
|
-
this.writeBits(objectOffset +
|
|
6451
|
-
this.writeBits(objectOffset +
|
|
6482
|
+
this.writeBytes(objectOffset + 9, (0, NumberToBuffer_1.UInt16ToBuffer)(Milliseconds_buffer.readUInt16LE()));
|
|
6483
|
+
this.writeBits(objectOffset + 11, 1, 2, 6, IOA_message[i - 1].Minutes);
|
|
6484
|
+
this.writeBits(objectOffset + 11, 1, 1, 1, IOA_message[i - 1].GEN);
|
|
6485
|
+
this.writeBits(objectOffset + 11, 1, 0, 1, IOA_message[i - 1].MIN_IV);
|
|
6486
|
+
this.writeBits(objectOffset + 12, 1, 3, 5, IOA_message[i - 1].Hours);
|
|
6487
|
+
this.writeBits(objectOffset + 12, 1, 0, 1, IOA_message[i - 1].SU);
|
|
6488
|
+
this.writeBits(objectOffset + 13, 1, 3, 5, IOA_message[i - 1].Day);
|
|
6489
|
+
this.writeBits(objectOffset + 13, 1, 0, 3, IOA_message[i - 1].DOW);
|
|
6490
|
+
this.writeBits(objectOffset + 14, 1, 4, 4, IOA_message[i - 1].Month);
|
|
6491
|
+
this.writeBits(objectOffset + 15, 1, 1, 7, IOA_message[i - 1].Year);
|
|
6452
6492
|
}
|
|
6453
6493
|
break;
|
|
6454
|
-
//日志查询,请求存档文件 F_SC_NB_1 = NOF +
|
|
6494
|
+
//日志查询,请求存档文件 F_SC_NB_1 = NOF + CP56Time2a (range start) + CP56Time2a (range stop)
|
|
6455
6495
|
case 127:
|
|
6456
6496
|
{
|
|
6457
6497
|
const IOA_message = this.instance.IOA.getValue([], (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
@@ -6459,13 +6499,18 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
6459
6499
|
const buf = Buffer.alloc(3);
|
|
6460
6500
|
buf.writeUIntLE(address_LE, 0, 3);
|
|
6461
6501
|
this.writeIOAAddress(objectOffset, buf, i);
|
|
6462
|
-
this.writeBytes(objectOffset + 3, (0, NumberToBuffer_1.UInt16ToBuffer)((0, NumberToBuffer_1.UInt16ToBuffer)(IOA_message[i - 1].NOF).
|
|
6463
|
-
this.
|
|
6502
|
+
this.writeBytes(objectOffset + 3, (0, NumberToBuffer_1.UInt16ToBuffer)((0, NumberToBuffer_1.UInt16ToBuffer)(IOA_message[i - 1].NOF).readUInt16LE()));
|
|
6503
|
+
this.writeCP56Time2a(objectOffset + 5, IOA_message[i - 1].RangeStartTime);
|
|
6504
|
+
this.writeCP56Time2a(objectOffset + 12, IOA_message[i - 1].RangeStopTime);
|
|
6464
6505
|
}
|
|
6465
6506
|
break;
|
|
6466
6507
|
default: {
|
|
6467
|
-
|
|
6468
|
-
|
|
6508
|
+
//No element layout for this type id, so the IOA items cannot be written. The
|
|
6509
|
+
//unparsed ASDU (raw), when given, is written instead, as with no items.
|
|
6510
|
+
const raw = `${this.instance.raw.getValue('')}`;
|
|
6511
|
+
if (raw)
|
|
6512
|
+
this.writeBytes(6, (0, HexToBuffer_1.HexToBuffer)(raw));
|
|
6513
|
+
this.recordError(this.instance.IOA.getPath(), `Type id ${typeId} has no element layout: the IOA items are not written${raw ? ', the unparsed ASDU (raw) is' : ''}`, 'error');
|
|
6469
6514
|
break Loop;
|
|
6470
6515
|
}
|
|
6471
6516
|
}
|
|
@@ -6502,6 +6547,13 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
6502
6547
|
const ioa = this.instance.IOA.isUndefined() ? [] : this.instance.IOA.getValue([]);
|
|
6503
6548
|
return !Array.isArray(ioa) || ioa.length === 0;
|
|
6504
6549
|
}
|
|
6550
|
+
/**
|
|
6551
|
+
* The number of IOA items encode writes: one per information object (SQ=0) or element (SQ=1).
|
|
6552
|
+
*/
|
|
6553
|
+
ioaItemCount() {
|
|
6554
|
+
const ioa = this.instance.IOA.getValue([]);
|
|
6555
|
+
return Array.isArray(ioa) ? ioa.length : 0;
|
|
6556
|
+
}
|
|
6505
6557
|
/**
|
|
6506
6558
|
* Write an information object's 3-octet address. SQ=0 frames carry a per-object address; SQ=1
|
|
6507
6559
|
* frames carry a single base address (before the first element) with the rest implied by
|
|
@@ -6513,6 +6565,40 @@ class IEC104_I_Frame extends BaseHeader_1.BaseHeader {
|
|
|
6513
6565
|
return;
|
|
6514
6566
|
this.writeBytes(offset, buffer);
|
|
6515
6567
|
}
|
|
6568
|
+
/**
|
|
6569
|
+
* Read a 7-octet CP56Time2a (IEC 60870-5-4, IEC 60870-5-101 7.2.6.18) at `offset`: milliseconds (2
|
|
6570
|
+
* octets, little-endian), minutes with GEN and IV in bits 7 and 8, hours with SU in bit 8, day of month
|
|
6571
|
+
* with day of week in bits 6-8, month, year.
|
|
6572
|
+
*/
|
|
6573
|
+
readCP56Time2a(offset) {
|
|
6574
|
+
return {
|
|
6575
|
+
Milliseconds: this.readBytes(offset, 2).readUInt16LE(),
|
|
6576
|
+
Minutes: this.readBits(offset + 2, 1, 2, 6),
|
|
6577
|
+
GEN: this.readBits(offset + 2, 1, 1, 1),
|
|
6578
|
+
MIN_IV: this.readBits(offset + 2, 1, 0, 1),
|
|
6579
|
+
Hours: this.readBits(offset + 3, 1, 3, 5),
|
|
6580
|
+
SU: this.readBits(offset + 3, 1, 0, 1),
|
|
6581
|
+
Day: this.readBits(offset + 4, 1, 3, 5),
|
|
6582
|
+
DOW: this.readBits(offset + 4, 1, 0, 3),
|
|
6583
|
+
Month: this.readBits(offset + 5, 1, 4, 4),
|
|
6584
|
+
Year: this.readBits(offset + 6, 1, 1, 7)
|
|
6585
|
+
};
|
|
6586
|
+
}
|
|
6587
|
+
/**
|
|
6588
|
+
* Write a 7-octet CP56Time2a at `offset`, the inverse of readCP56Time2a.
|
|
6589
|
+
*/
|
|
6590
|
+
writeCP56Time2a(offset, time) {
|
|
6591
|
+
this.writeBytes(offset, (0, NumberToBuffer_1.UInt16ToBuffer)((0, NumberToBuffer_1.UInt16ToBuffer)(time.Milliseconds).readUInt16LE()));
|
|
6592
|
+
this.writeBits(offset + 2, 1, 2, 6, time.Minutes);
|
|
6593
|
+
this.writeBits(offset + 2, 1, 1, 1, time.GEN);
|
|
6594
|
+
this.writeBits(offset + 2, 1, 0, 1, time.MIN_IV);
|
|
6595
|
+
this.writeBits(offset + 3, 1, 3, 5, time.Hours);
|
|
6596
|
+
this.writeBits(offset + 3, 1, 0, 1, time.SU);
|
|
6597
|
+
this.writeBits(offset + 4, 1, 3, 5, time.Day);
|
|
6598
|
+
this.writeBits(offset + 4, 1, 0, 3, time.DOW);
|
|
6599
|
+
this.writeBits(offset + 5, 1, 4, 4, time.Month);
|
|
6600
|
+
this.writeBits(offset + 6, 1, 1, 7, time.Year);
|
|
6601
|
+
}
|
|
6516
6602
|
match() {
|
|
6517
6603
|
if (!this.prevCodecModules)
|
|
6518
6604
|
return false;
|