opcua-webapi-ts 1.0.27 → 1.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/client/UaClientConfigure.js +3 -3
- package/dist/cjs/client/UaWebClient.js +191 -11
- package/dist/cjs/common/types/UaRequestPatameters.js +1 -1
- package/dist/client/UaClientConfigure.js +3 -3
- package/dist/client/UaWebClient.d.ts +1 -0
- package/dist/client/UaWebClient.js +191 -11
- package/dist/common/types/UaRequestPatameters.js +1 -1
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ exports.UaClientConfiguration = void 0;
|
|
|
4
4
|
class UaClientConfiguration {
|
|
5
5
|
constructor(apiConfig) {
|
|
6
6
|
this._apiConfig = apiConfig;
|
|
7
|
-
this._defaultTimeout =
|
|
7
|
+
this._defaultTimeout = 0;
|
|
8
8
|
}
|
|
9
9
|
get apiConfig() {
|
|
10
10
|
return this._apiConfig;
|
|
@@ -13,8 +13,8 @@ class UaClientConfiguration {
|
|
|
13
13
|
return this._defaultTimeout;
|
|
14
14
|
}
|
|
15
15
|
set defaultTimeout(timeout) {
|
|
16
|
-
if (timeout <
|
|
17
|
-
this._defaultTimeout =
|
|
16
|
+
if (timeout < 1000) {
|
|
17
|
+
this._defaultTimeout = 0;
|
|
18
18
|
}
|
|
19
19
|
else {
|
|
20
20
|
this._defaultTimeout = timeout;
|
|
@@ -365,7 +365,29 @@ class UaWebClient {
|
|
|
365
365
|
RequestedMaxReferencesPerNode: (maxReferencesPerNode && maxReferencesPerNode > 0) ? maxReferencesPerNode : undefined,
|
|
366
366
|
View: view
|
|
367
367
|
});
|
|
368
|
-
let
|
|
368
|
+
let timeout = this.requestTimeout(this.clientConfig, additionalParameters);
|
|
369
|
+
let response;
|
|
370
|
+
if (timeout > 0 && typeof AbortController !== "undefined") {
|
|
371
|
+
let controller = new AbortController();
|
|
372
|
+
let timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
373
|
+
try {
|
|
374
|
+
response = yield this.api.browse({ browseRequest: request }, { signal: controller.signal });
|
|
375
|
+
}
|
|
376
|
+
catch (error) {
|
|
377
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
378
|
+
}
|
|
379
|
+
finally {
|
|
380
|
+
clearTimeout(timeoutId);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
try {
|
|
385
|
+
response = yield this.api.browse({ browseRequest: request });
|
|
386
|
+
}
|
|
387
|
+
catch (error) {
|
|
388
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
389
|
+
}
|
|
390
|
+
}
|
|
369
391
|
if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
|
|
370
392
|
throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
|
|
371
393
|
if (!response.Results || nodesToBrowse.length != response.Results.length)
|
|
@@ -392,7 +414,29 @@ class UaWebClient {
|
|
|
392
414
|
ContinuationPoints: continuationPoints,
|
|
393
415
|
ReleaseContinuationPoints: releaseContinuationPoints
|
|
394
416
|
});
|
|
395
|
-
let
|
|
417
|
+
let timeout = this.requestTimeout(this.clientConfig, additionalParameters);
|
|
418
|
+
let response;
|
|
419
|
+
if (timeout > 0 && typeof AbortController !== "undefined") {
|
|
420
|
+
let controller = new AbortController();
|
|
421
|
+
let timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
422
|
+
try {
|
|
423
|
+
response = yield this.api.browseNext({ browseNextRequest: request }, { signal: controller.signal });
|
|
424
|
+
}
|
|
425
|
+
catch (error) {
|
|
426
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
427
|
+
}
|
|
428
|
+
finally {
|
|
429
|
+
clearTimeout(timeoutId);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
else {
|
|
433
|
+
try {
|
|
434
|
+
response = yield this.api.browseNext({ browseNextRequest: request });
|
|
435
|
+
}
|
|
436
|
+
catch (error) {
|
|
437
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
438
|
+
}
|
|
439
|
+
}
|
|
396
440
|
if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
|
|
397
441
|
throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
|
|
398
442
|
if (!response.Results || continuationPoints.length != response.Results.length)
|
|
@@ -424,7 +468,29 @@ class UaWebClient {
|
|
|
424
468
|
timestampsToReturn >= opcua_webapi_1.TimestampsToReturn.Source &&
|
|
425
469
|
timestampsToReturn < opcua_webapi_1.TimestampsToReturn.Invalid) ? timestampsToReturn : opcua_webapi_1.TimestampsToReturn.Neither
|
|
426
470
|
});
|
|
427
|
-
let
|
|
471
|
+
let timeout = this.requestTimeout(this.clientConfig, additionalParameters);
|
|
472
|
+
let response;
|
|
473
|
+
if (timeout > 0 && typeof AbortController !== "undefined") {
|
|
474
|
+
let controller = new AbortController();
|
|
475
|
+
let timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
476
|
+
try {
|
|
477
|
+
response = yield this.api.read({ readRequest: request }, { signal: controller.signal });
|
|
478
|
+
}
|
|
479
|
+
catch (error) {
|
|
480
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
481
|
+
}
|
|
482
|
+
finally {
|
|
483
|
+
clearTimeout(timeoutId);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
else {
|
|
487
|
+
try {
|
|
488
|
+
response = yield this.api.read({ readRequest: request });
|
|
489
|
+
}
|
|
490
|
+
catch (error) {
|
|
491
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
492
|
+
}
|
|
493
|
+
}
|
|
428
494
|
if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
|
|
429
495
|
throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
|
|
430
496
|
if (!response.Results || nodesToRead.length != response.Results.length)
|
|
@@ -450,7 +516,29 @@ class UaWebClient {
|
|
|
450
516
|
RequestHeader: this.requestHeader(this.clientConfig, additionalParameters),
|
|
451
517
|
NodesToWrite: NodesToWrite
|
|
452
518
|
});
|
|
453
|
-
let
|
|
519
|
+
let timeout = this.requestTimeout(this.clientConfig, additionalParameters);
|
|
520
|
+
let response;
|
|
521
|
+
if (timeout > 0 && typeof AbortController !== "undefined") {
|
|
522
|
+
let controller = new AbortController();
|
|
523
|
+
let timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
524
|
+
try {
|
|
525
|
+
response = yield this.api.write({ writeRequest: request }, { signal: controller.signal });
|
|
526
|
+
}
|
|
527
|
+
catch (error) {
|
|
528
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
529
|
+
}
|
|
530
|
+
finally {
|
|
531
|
+
clearTimeout(timeoutId);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
else {
|
|
535
|
+
try {
|
|
536
|
+
response = yield this.api.write({ writeRequest: request });
|
|
537
|
+
}
|
|
538
|
+
catch (error) {
|
|
539
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
540
|
+
}
|
|
541
|
+
}
|
|
454
542
|
if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
|
|
455
543
|
throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
|
|
456
544
|
if (!response.Results || nodesToWrite.length != response.Results.length)
|
|
@@ -476,7 +564,29 @@ class UaWebClient {
|
|
|
476
564
|
RequestHeader: this.requestHeader(this.clientConfig, additionalParameters),
|
|
477
565
|
MethodsToCall: MethodsToCall
|
|
478
566
|
});
|
|
479
|
-
let
|
|
567
|
+
let timeout = this.requestTimeout(this.clientConfig, additionalParameters);
|
|
568
|
+
let response;
|
|
569
|
+
if (timeout > 0 && typeof AbortController !== "undefined") {
|
|
570
|
+
let controller = new AbortController();
|
|
571
|
+
let timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
572
|
+
try {
|
|
573
|
+
response = yield this.api.call({ callRequest: request }, { signal: controller.signal });
|
|
574
|
+
}
|
|
575
|
+
catch (error) {
|
|
576
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
577
|
+
}
|
|
578
|
+
finally {
|
|
579
|
+
clearTimeout(timeoutId);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
else {
|
|
583
|
+
try {
|
|
584
|
+
response = yield this.api.call({ callRequest: request });
|
|
585
|
+
}
|
|
586
|
+
catch (error) {
|
|
587
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
588
|
+
}
|
|
589
|
+
}
|
|
480
590
|
if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
|
|
481
591
|
throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
|
|
482
592
|
if (!response.Results || methodsToCall.length != response.Results.length)
|
|
@@ -509,7 +619,29 @@ class UaWebClient {
|
|
|
509
619
|
ReleaseContinuationPoints: releaseContinuationPoints,
|
|
510
620
|
NodesToRead: NodesToRead
|
|
511
621
|
});
|
|
512
|
-
let
|
|
622
|
+
let timeout = this.requestTimeout(this.clientConfig, additionalParameters);
|
|
623
|
+
let response;
|
|
624
|
+
if (timeout > 0 && typeof AbortController !== "undefined") {
|
|
625
|
+
let controller = new AbortController();
|
|
626
|
+
let timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
627
|
+
try {
|
|
628
|
+
response = yield this.api.historyRead({ historyReadRequest: request }, { signal: controller.signal });
|
|
629
|
+
}
|
|
630
|
+
catch (error) {
|
|
631
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
632
|
+
}
|
|
633
|
+
finally {
|
|
634
|
+
clearTimeout(timeoutId);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
else {
|
|
638
|
+
try {
|
|
639
|
+
response = yield this.api.historyRead({ historyReadRequest: request });
|
|
640
|
+
}
|
|
641
|
+
catch (error) {
|
|
642
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
643
|
+
}
|
|
644
|
+
}
|
|
513
645
|
if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
|
|
514
646
|
throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
|
|
515
647
|
if (!response.Results || nodesToRead.length != response.Results.length)
|
|
@@ -533,7 +665,29 @@ class UaWebClient {
|
|
|
533
665
|
EndpointUrl: endpointUrl,
|
|
534
666
|
LocaleIds: localeIds
|
|
535
667
|
});
|
|
536
|
-
let
|
|
668
|
+
let timeout = this.requestTimeout(this.clientConfig, additionalParameters);
|
|
669
|
+
let response;
|
|
670
|
+
if (timeout > 0 && typeof AbortController !== "undefined") {
|
|
671
|
+
let controller = new AbortController();
|
|
672
|
+
let timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
673
|
+
try {
|
|
674
|
+
response = yield this.api.findServers({ findServersRequest: request }, { signal: controller.signal });
|
|
675
|
+
}
|
|
676
|
+
catch (error) {
|
|
677
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
678
|
+
}
|
|
679
|
+
finally {
|
|
680
|
+
clearTimeout(timeoutId);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
else {
|
|
684
|
+
try {
|
|
685
|
+
response = yield this.api.findServers({ findServersRequest: request });
|
|
686
|
+
}
|
|
687
|
+
catch (error) {
|
|
688
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
689
|
+
}
|
|
690
|
+
}
|
|
537
691
|
if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
|
|
538
692
|
throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
|
|
539
693
|
if (!response.Servers)
|
|
@@ -550,7 +704,29 @@ class UaWebClient {
|
|
|
550
704
|
LocaleIds: localeIds,
|
|
551
705
|
ProfileUris: profileUris
|
|
552
706
|
});
|
|
553
|
-
let
|
|
707
|
+
let timeout = this.requestTimeout(this.clientConfig, additionalParameters);
|
|
708
|
+
let response;
|
|
709
|
+
if (timeout > 0 && typeof AbortController !== "undefined") {
|
|
710
|
+
let controller = new AbortController();
|
|
711
|
+
let timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
712
|
+
try {
|
|
713
|
+
response = yield this.api.getEndpoints({ getEndpointsRequest: request }, { signal: controller.signal });
|
|
714
|
+
}
|
|
715
|
+
catch (error) {
|
|
716
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
717
|
+
}
|
|
718
|
+
finally {
|
|
719
|
+
clearTimeout(timeoutId);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
else {
|
|
723
|
+
try {
|
|
724
|
+
response = yield this.api.getEndpoints({ getEndpointsRequest: request });
|
|
725
|
+
}
|
|
726
|
+
catch (error) {
|
|
727
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
728
|
+
}
|
|
729
|
+
}
|
|
554
730
|
if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
|
|
555
731
|
throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
|
|
556
732
|
if (!response.Endpoints)
|
|
@@ -559,9 +735,7 @@ class UaWebClient {
|
|
|
559
735
|
});
|
|
560
736
|
}
|
|
561
737
|
requestHeader(clientConfig, additionalParameters) {
|
|
562
|
-
let timeout = clientConfig
|
|
563
|
-
if (additionalParameters && additionalParameters.timeout)
|
|
564
|
-
timeout = additionalParameters.timeout;
|
|
738
|
+
let timeout = this.requestTimeout(clientConfig, additionalParameters);
|
|
565
739
|
let ret = {
|
|
566
740
|
RequestHandle: this.requestHandle,
|
|
567
741
|
TimeoutHint: timeout,
|
|
@@ -575,5 +749,11 @@ class UaWebClient {
|
|
|
575
749
|
this.requestHandle = 1;
|
|
576
750
|
return ret;
|
|
577
751
|
}
|
|
752
|
+
requestTimeout(clientConfig, additionalParameters) {
|
|
753
|
+
let timeout = clientConfig.defaultTimeout;
|
|
754
|
+
if (additionalParameters && additionalParameters.timeout > 1000)
|
|
755
|
+
timeout = additionalParameters.timeout;
|
|
756
|
+
return timeout;
|
|
757
|
+
}
|
|
578
758
|
}
|
|
579
759
|
exports.UaWebClient = UaWebClient;
|
|
@@ -4,7 +4,7 @@ exports.UaClientConfiguration = void 0;
|
|
|
4
4
|
class UaClientConfiguration {
|
|
5
5
|
constructor(apiConfig) {
|
|
6
6
|
this._apiConfig = apiConfig;
|
|
7
|
-
this._defaultTimeout =
|
|
7
|
+
this._defaultTimeout = 0;
|
|
8
8
|
}
|
|
9
9
|
get apiConfig() {
|
|
10
10
|
return this._apiConfig;
|
|
@@ -13,8 +13,8 @@ class UaClientConfiguration {
|
|
|
13
13
|
return this._defaultTimeout;
|
|
14
14
|
}
|
|
15
15
|
set defaultTimeout(timeout) {
|
|
16
|
-
if (timeout <
|
|
17
|
-
this._defaultTimeout =
|
|
16
|
+
if (timeout < 1000) {
|
|
17
|
+
this._defaultTimeout = 0;
|
|
18
18
|
}
|
|
19
19
|
else {
|
|
20
20
|
this._defaultTimeout = timeout;
|
|
@@ -34,4 +34,5 @@ export declare class UaWebClient {
|
|
|
34
34
|
findServer(endpointUrl: string, serverUris: Array<string>, localeIds?: Array<string>, additionalParameters?: UaClientParameters): Promise<Array<ApplicationDescription>>;
|
|
35
35
|
getEndpoints(endpointUrl?: string, localeIds?: Array<string>, profileUris?: Array<string>, additionalParameters?: UaClientParameters): Promise<Array<EndpointDescription>>;
|
|
36
36
|
private requestHeader;
|
|
37
|
+
private requestTimeout;
|
|
37
38
|
}
|
|
@@ -365,7 +365,29 @@ class UaWebClient {
|
|
|
365
365
|
RequestedMaxReferencesPerNode: (maxReferencesPerNode && maxReferencesPerNode > 0) ? maxReferencesPerNode : undefined,
|
|
366
366
|
View: view
|
|
367
367
|
});
|
|
368
|
-
let
|
|
368
|
+
let timeout = this.requestTimeout(this.clientConfig, additionalParameters);
|
|
369
|
+
let response;
|
|
370
|
+
if (timeout > 0 && typeof AbortController !== "undefined") {
|
|
371
|
+
let controller = new AbortController();
|
|
372
|
+
let timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
373
|
+
try {
|
|
374
|
+
response = yield this.api.browse({ browseRequest: request }, { signal: controller.signal });
|
|
375
|
+
}
|
|
376
|
+
catch (error) {
|
|
377
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
378
|
+
}
|
|
379
|
+
finally {
|
|
380
|
+
clearTimeout(timeoutId);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
try {
|
|
385
|
+
response = yield this.api.browse({ browseRequest: request });
|
|
386
|
+
}
|
|
387
|
+
catch (error) {
|
|
388
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
389
|
+
}
|
|
390
|
+
}
|
|
369
391
|
if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
|
|
370
392
|
throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
|
|
371
393
|
if (!response.Results || nodesToBrowse.length != response.Results.length)
|
|
@@ -392,7 +414,29 @@ class UaWebClient {
|
|
|
392
414
|
ContinuationPoints: continuationPoints,
|
|
393
415
|
ReleaseContinuationPoints: releaseContinuationPoints
|
|
394
416
|
});
|
|
395
|
-
let
|
|
417
|
+
let timeout = this.requestTimeout(this.clientConfig, additionalParameters);
|
|
418
|
+
let response;
|
|
419
|
+
if (timeout > 0 && typeof AbortController !== "undefined") {
|
|
420
|
+
let controller = new AbortController();
|
|
421
|
+
let timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
422
|
+
try {
|
|
423
|
+
response = yield this.api.browseNext({ browseNextRequest: request }, { signal: controller.signal });
|
|
424
|
+
}
|
|
425
|
+
catch (error) {
|
|
426
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
427
|
+
}
|
|
428
|
+
finally {
|
|
429
|
+
clearTimeout(timeoutId);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
else {
|
|
433
|
+
try {
|
|
434
|
+
response = yield this.api.browseNext({ browseNextRequest: request });
|
|
435
|
+
}
|
|
436
|
+
catch (error) {
|
|
437
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
438
|
+
}
|
|
439
|
+
}
|
|
396
440
|
if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
|
|
397
441
|
throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
|
|
398
442
|
if (!response.Results || continuationPoints.length != response.Results.length)
|
|
@@ -424,7 +468,29 @@ class UaWebClient {
|
|
|
424
468
|
timestampsToReturn >= opcua_webapi_1.TimestampsToReturn.Source &&
|
|
425
469
|
timestampsToReturn < opcua_webapi_1.TimestampsToReturn.Invalid) ? timestampsToReturn : opcua_webapi_1.TimestampsToReturn.Neither
|
|
426
470
|
});
|
|
427
|
-
let
|
|
471
|
+
let timeout = this.requestTimeout(this.clientConfig, additionalParameters);
|
|
472
|
+
let response;
|
|
473
|
+
if (timeout > 0 && typeof AbortController !== "undefined") {
|
|
474
|
+
let controller = new AbortController();
|
|
475
|
+
let timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
476
|
+
try {
|
|
477
|
+
response = yield this.api.read({ readRequest: request }, { signal: controller.signal });
|
|
478
|
+
}
|
|
479
|
+
catch (error) {
|
|
480
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
481
|
+
}
|
|
482
|
+
finally {
|
|
483
|
+
clearTimeout(timeoutId);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
else {
|
|
487
|
+
try {
|
|
488
|
+
response = yield this.api.read({ readRequest: request });
|
|
489
|
+
}
|
|
490
|
+
catch (error) {
|
|
491
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
492
|
+
}
|
|
493
|
+
}
|
|
428
494
|
if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
|
|
429
495
|
throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
|
|
430
496
|
if (!response.Results || nodesToRead.length != response.Results.length)
|
|
@@ -450,7 +516,29 @@ class UaWebClient {
|
|
|
450
516
|
RequestHeader: this.requestHeader(this.clientConfig, additionalParameters),
|
|
451
517
|
NodesToWrite: NodesToWrite
|
|
452
518
|
});
|
|
453
|
-
let
|
|
519
|
+
let timeout = this.requestTimeout(this.clientConfig, additionalParameters);
|
|
520
|
+
let response;
|
|
521
|
+
if (timeout > 0 && typeof AbortController !== "undefined") {
|
|
522
|
+
let controller = new AbortController();
|
|
523
|
+
let timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
524
|
+
try {
|
|
525
|
+
response = yield this.api.write({ writeRequest: request }, { signal: controller.signal });
|
|
526
|
+
}
|
|
527
|
+
catch (error) {
|
|
528
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
529
|
+
}
|
|
530
|
+
finally {
|
|
531
|
+
clearTimeout(timeoutId);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
else {
|
|
535
|
+
try {
|
|
536
|
+
response = yield this.api.write({ writeRequest: request });
|
|
537
|
+
}
|
|
538
|
+
catch (error) {
|
|
539
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
540
|
+
}
|
|
541
|
+
}
|
|
454
542
|
if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
|
|
455
543
|
throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
|
|
456
544
|
if (!response.Results || nodesToWrite.length != response.Results.length)
|
|
@@ -476,7 +564,29 @@ class UaWebClient {
|
|
|
476
564
|
RequestHeader: this.requestHeader(this.clientConfig, additionalParameters),
|
|
477
565
|
MethodsToCall: MethodsToCall
|
|
478
566
|
});
|
|
479
|
-
let
|
|
567
|
+
let timeout = this.requestTimeout(this.clientConfig, additionalParameters);
|
|
568
|
+
let response;
|
|
569
|
+
if (timeout > 0 && typeof AbortController !== "undefined") {
|
|
570
|
+
let controller = new AbortController();
|
|
571
|
+
let timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
572
|
+
try {
|
|
573
|
+
response = yield this.api.call({ callRequest: request }, { signal: controller.signal });
|
|
574
|
+
}
|
|
575
|
+
catch (error) {
|
|
576
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
577
|
+
}
|
|
578
|
+
finally {
|
|
579
|
+
clearTimeout(timeoutId);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
else {
|
|
583
|
+
try {
|
|
584
|
+
response = yield this.api.call({ callRequest: request });
|
|
585
|
+
}
|
|
586
|
+
catch (error) {
|
|
587
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
588
|
+
}
|
|
589
|
+
}
|
|
480
590
|
if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
|
|
481
591
|
throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
|
|
482
592
|
if (!response.Results || methodsToCall.length != response.Results.length)
|
|
@@ -509,7 +619,29 @@ class UaWebClient {
|
|
|
509
619
|
ReleaseContinuationPoints: releaseContinuationPoints,
|
|
510
620
|
NodesToRead: NodesToRead
|
|
511
621
|
});
|
|
512
|
-
let
|
|
622
|
+
let timeout = this.requestTimeout(this.clientConfig, additionalParameters);
|
|
623
|
+
let response;
|
|
624
|
+
if (timeout > 0 && typeof AbortController !== "undefined") {
|
|
625
|
+
let controller = new AbortController();
|
|
626
|
+
let timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
627
|
+
try {
|
|
628
|
+
response = yield this.api.historyRead({ historyReadRequest: request }, { signal: controller.signal });
|
|
629
|
+
}
|
|
630
|
+
catch (error) {
|
|
631
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
632
|
+
}
|
|
633
|
+
finally {
|
|
634
|
+
clearTimeout(timeoutId);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
else {
|
|
638
|
+
try {
|
|
639
|
+
response = yield this.api.historyRead({ historyReadRequest: request });
|
|
640
|
+
}
|
|
641
|
+
catch (error) {
|
|
642
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
643
|
+
}
|
|
644
|
+
}
|
|
513
645
|
if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
|
|
514
646
|
throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
|
|
515
647
|
if (!response.Results || nodesToRead.length != response.Results.length)
|
|
@@ -533,7 +665,29 @@ class UaWebClient {
|
|
|
533
665
|
EndpointUrl: endpointUrl,
|
|
534
666
|
LocaleIds: localeIds
|
|
535
667
|
});
|
|
536
|
-
let
|
|
668
|
+
let timeout = this.requestTimeout(this.clientConfig, additionalParameters);
|
|
669
|
+
let response;
|
|
670
|
+
if (timeout > 0 && typeof AbortController !== "undefined") {
|
|
671
|
+
let controller = new AbortController();
|
|
672
|
+
let timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
673
|
+
try {
|
|
674
|
+
response = yield this.api.findServers({ findServersRequest: request }, { signal: controller.signal });
|
|
675
|
+
}
|
|
676
|
+
catch (error) {
|
|
677
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
678
|
+
}
|
|
679
|
+
finally {
|
|
680
|
+
clearTimeout(timeoutId);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
else {
|
|
684
|
+
try {
|
|
685
|
+
response = yield this.api.findServers({ findServersRequest: request });
|
|
686
|
+
}
|
|
687
|
+
catch (error) {
|
|
688
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
689
|
+
}
|
|
690
|
+
}
|
|
537
691
|
if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
|
|
538
692
|
throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
|
|
539
693
|
if (!response.Servers)
|
|
@@ -550,7 +704,29 @@ class UaWebClient {
|
|
|
550
704
|
LocaleIds: localeIds,
|
|
551
705
|
ProfileUris: profileUris
|
|
552
706
|
});
|
|
553
|
-
let
|
|
707
|
+
let timeout = this.requestTimeout(this.clientConfig, additionalParameters);
|
|
708
|
+
let response;
|
|
709
|
+
if (timeout > 0 && typeof AbortController !== "undefined") {
|
|
710
|
+
let controller = new AbortController();
|
|
711
|
+
let timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
712
|
+
try {
|
|
713
|
+
response = yield this.api.getEndpoints({ getEndpointsRequest: request }, { signal: controller.signal });
|
|
714
|
+
}
|
|
715
|
+
catch (error) {
|
|
716
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
717
|
+
}
|
|
718
|
+
finally {
|
|
719
|
+
clearTimeout(timeoutId);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
else {
|
|
723
|
+
try {
|
|
724
|
+
response = yield this.api.getEndpoints({ getEndpointsRequest: request });
|
|
725
|
+
}
|
|
726
|
+
catch (error) {
|
|
727
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadCommunicationError));
|
|
728
|
+
}
|
|
729
|
+
}
|
|
554
730
|
if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
|
|
555
731
|
throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
|
|
556
732
|
if (!response.Endpoints)
|
|
@@ -559,9 +735,7 @@ class UaWebClient {
|
|
|
559
735
|
});
|
|
560
736
|
}
|
|
561
737
|
requestHeader(clientConfig, additionalParameters) {
|
|
562
|
-
let timeout = clientConfig
|
|
563
|
-
if (additionalParameters && additionalParameters.timeout)
|
|
564
|
-
timeout = additionalParameters.timeout;
|
|
738
|
+
let timeout = this.requestTimeout(clientConfig, additionalParameters);
|
|
565
739
|
let ret = {
|
|
566
740
|
RequestHandle: this.requestHandle,
|
|
567
741
|
TimeoutHint: timeout,
|
|
@@ -575,5 +749,11 @@ class UaWebClient {
|
|
|
575
749
|
this.requestHandle = 1;
|
|
576
750
|
return ret;
|
|
577
751
|
}
|
|
752
|
+
requestTimeout(clientConfig, additionalParameters) {
|
|
753
|
+
let timeout = clientConfig.defaultTimeout;
|
|
754
|
+
if (additionalParameters && additionalParameters.timeout > 1000)
|
|
755
|
+
timeout = additionalParameters.timeout;
|
|
756
|
+
return timeout;
|
|
757
|
+
}
|
|
578
758
|
}
|
|
579
759
|
exports.UaWebClient = UaWebClient;
|