node-opcua-client 2.73.1 → 2.76.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/LICENSE +3 -1
- package/README.md +54 -0
- package/dist/alarms_and_conditions/client_alarm.d.ts +49 -45
- package/dist/alarms_and_conditions/client_alarm.js +109 -101
- package/dist/alarms_and_conditions/client_alarm.js.map +1 -1
- package/dist/alarms_and_conditions/client_alarm_list.d.ts +25 -25
- package/dist/alarms_and_conditions/client_alarm_list.js +97 -97
- package/dist/alarms_and_conditions/client_alarm_list.js.map +1 -1
- package/dist/alarms_and_conditions/client_alarm_tools.d.ts +4 -4
- package/dist/alarms_and_conditions/client_alarm_tools.js +156 -152
- package/dist/alarms_and_conditions/client_alarm_tools.js.map +1 -1
- package/dist/alarms_and_conditions/client_alarm_tools_acknowledge_all_conditions.d.ts +18 -18
- package/dist/alarms_and_conditions/client_alarm_tools_acknowledge_all_conditions.js +192 -190
- package/dist/alarms_and_conditions/client_alarm_tools_acknowledge_all_conditions.js.map +1 -1
- package/dist/alarms_and_conditions/client_alarm_tools_dump_event.d.ts +9 -9
- package/dist/alarms_and_conditions/client_alarm_tools_dump_event.js +73 -73
- package/dist/alarms_and_conditions/client_alarm_tools_extractConditionFields.d.ts +3 -8
- package/dist/alarms_and_conditions/client_alarm_tools_extractConditionFields.js +118 -120
- package/dist/alarms_and_conditions/client_alarm_tools_extractConditionFields.js.map +1 -1
- package/dist/alarms_and_conditions/client_tools.d.ts +7 -7
- package/dist/alarms_and_conditions/client_tools.js +180 -180
- package/dist/client_base.d.ts +277 -277
- package/dist/client_base.js +14 -14
- package/dist/client_monitored_item.d.ts +21 -21
- package/dist/client_monitored_item.js +11 -11
- package/dist/client_monitored_item_base.d.ts +39 -39
- package/dist/client_monitored_item_base.js +2 -2
- package/dist/client_monitored_item_group.d.ts +18 -18
- package/dist/client_monitored_item_group.js +13 -13
- package/dist/client_monitored_item_toolbox.d.ts +15 -15
- package/dist/client_monitored_item_toolbox.js +117 -117
- package/dist/client_session.d.ts +484 -484
- package/dist/client_session.js +10 -10
- package/dist/client_session_keepalive_manager.d.ts +34 -34
- package/dist/client_session_keepalive_manager.js +150 -150
- package/dist/client_subscription.d.ts +241 -241
- package/dist/client_subscription.js +14 -14
- package/dist/client_utils.d.ts +22 -22
- package/dist/client_utils.js +88 -88
- package/dist/common.d.ts +17 -17
- package/dist/common.js +5 -5
- package/dist/index.d.ts +55 -55
- package/dist/index.js +93 -93
- package/dist/opcua_client.d.ts +132 -132
- package/dist/opcua_client.js +33 -33
- package/dist/private/client_base_impl.d.ts +157 -157
- package/dist/private/client_base_impl.js +1337 -1337
- package/dist/private/client_monitored_item_base_impl.d.ts +3 -3
- package/dist/private/client_monitored_item_base_impl.js +4 -4
- package/dist/private/client_monitored_item_group_impl.d.ts +53 -53
- package/dist/private/client_monitored_item_group_impl.js +159 -159
- package/dist/private/client_monitored_item_impl.d.ts +93 -93
- package/dist/private/client_monitored_item_impl.js +305 -304
- package/dist/private/client_monitored_item_impl.js.map +1 -1
- package/dist/private/client_publish_engine.d.ts +62 -62
- package/dist/private/client_publish_engine.js +408 -408
- package/dist/private/client_session_impl.d.ts +621 -621
- package/dist/private/client_session_impl.js +1302 -1301
- package/dist/private/client_session_impl.js.map +1 -1
- package/dist/private/client_subscription_impl.d.ts +93 -93
- package/dist/private/client_subscription_impl.js +748 -743
- package/dist/private/client_subscription_impl.js.map +1 -1
- package/dist/private/i_private_client.d.ts +18 -18
- package/dist/private/i_private_client.js +2 -2
- package/dist/private/opcua_client_impl.d.ts +169 -169
- package/dist/private/opcua_client_impl.js +981 -981
- package/dist/reconnection.d.ts +9 -9
- package/dist/reconnection.js +408 -408
- package/dist/tools/findservers.d.ts +20 -20
- package/dist/tools/findservers.js +61 -61
- package/dist/tools/read_history_server_capabilities.d.ts +6 -6
- package/dist/tools/read_history_server_capabilities.js +99 -99
- package/dist/verify.d.ts +5 -5
- package/dist/verify.js +134 -134
- package/package.json +48 -48
- package/source/alarms_and_conditions/client_alarm.ts +28 -17
- package/source/alarms_and_conditions/client_alarm_list.ts +1 -0
- package/source/alarms_and_conditions/client_alarm_tools.ts +33 -23
- package/source/alarms_and_conditions/client_alarm_tools_acknowledge_all_conditions.ts +10 -4
- package/source/alarms_and_conditions/client_alarm_tools_extractConditionFields.ts +11 -11
- package/source/private/client_monitored_item_impl.ts +4 -3
- package/source/private/client_session_impl.ts +10 -2
- package/source/private/client_subscription_impl.ts +6 -2
|
@@ -5,7 +5,6 @@ import { CreateSubscriptionRequestOptions, MonitoringParametersOptions } from "n
|
|
|
5
5
|
import { StatusCode, StatusCodes } from "node-opcua-status-code";
|
|
6
6
|
import { DataType, Variant } from "node-opcua-variant";
|
|
7
7
|
import { checkDebugFlag, make_debugLog, make_errorLog } from "node-opcua-debug";
|
|
8
|
-
import { ClientMonitoredItem } from "../client_monitored_item";
|
|
9
8
|
import { ClientSession } from "../client_session";
|
|
10
9
|
import { EventStuff, fieldsToJson } from "./client_alarm";
|
|
11
10
|
import { extractConditionFields } from "./client_alarm_tools_extractConditionFields";
|
|
@@ -22,6 +21,7 @@ const errorLog = make_errorLog(__filename);
|
|
|
22
21
|
* @param comment
|
|
23
22
|
*/
|
|
24
23
|
export async function acknowledgeCondition(session: ClientSession, eventStuff: EventStuff, comment: string): Promise<StatusCode> {
|
|
24
|
+
|
|
25
25
|
try {
|
|
26
26
|
const conditionId = eventStuff.conditionId.value;
|
|
27
27
|
const eventId = eventStuff.eventId.value;
|
|
@@ -65,7 +65,9 @@ export async function findActiveConditions(session: ClientSession): Promise<Even
|
|
|
65
65
|
|
|
66
66
|
const fields = await extractConditionFields(session, "AcknowledgeableConditionType");
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
// note: we may want to have this select clause
|
|
69
|
+
// Or(OfType("AcknowledgeableConditionType"), OfType("RefreshStartEventType"), OfType("RefreshEndEventType"))
|
|
70
|
+
const eventFilter = constructEventFilter(fields);
|
|
69
71
|
|
|
70
72
|
const monitoringParameters: MonitoringParametersOptions = {
|
|
71
73
|
discardOldest: false,
|
|
@@ -88,13 +90,17 @@ export async function findActiveConditions(session: ClientSession): Promise<Even
|
|
|
88
90
|
// now create a event monitored Item
|
|
89
91
|
event_monitoringItem.on("changed", (_eventFields: any) => {
|
|
90
92
|
const eventFields = _eventFields as Variant[];
|
|
93
|
+
|
|
91
94
|
try {
|
|
92
95
|
if (RefreshEndEventHasBeenReceived) {
|
|
93
96
|
return;
|
|
94
97
|
}
|
|
98
|
+
|
|
99
|
+
|
|
95
100
|
// dumpEvent(session, fields, eventFields);
|
|
96
101
|
const pojo = fieldsToJson(fields, eventFields) as any;
|
|
97
|
-
|
|
102
|
+
|
|
103
|
+
// console.log(pojo.eventType.value.toString({ addressSpace}), RefreshEndEventType, RefreshStartEventType);
|
|
98
104
|
|
|
99
105
|
// make sure we only start recording event after the RefreshStartEvent has been received
|
|
100
106
|
if (!refreshStartEventHasBeenReceived) {
|
|
@@ -147,7 +153,7 @@ export async function acknwoledgeAllConditions(session: ClientSession, message:
|
|
|
147
153
|
// filter acknowledgable conditions (no acked yet)
|
|
148
154
|
conditions = conditions.filter((pojo) => pojo.ackedState.id.value === false);
|
|
149
155
|
|
|
150
|
-
const promises: Array<Promise<
|
|
156
|
+
const promises: Array<Promise<StatusCode>> = [];
|
|
151
157
|
for (const eventStuff of conditions) {
|
|
152
158
|
promises.push(acknowledgeCondition(session, eventStuff, message));
|
|
153
159
|
}
|
|
@@ -2,15 +2,11 @@ import { BrowseDirection, NodeClassMask, QualifiedName } from "node-opcua-data-m
|
|
|
2
2
|
import { NodeId, NodeIdLike, resolveNodeId } from "node-opcua-nodeid";
|
|
3
3
|
import { IBasicSession } from "node-opcua-pseudo-session";
|
|
4
4
|
import { BrowseDescriptionOptions } from "node-opcua-service-browse";
|
|
5
|
+
import { NodeClass } from "node-opcua-types";
|
|
5
6
|
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* @param session
|
|
9
|
-
* @param conditionNodeId
|
|
10
|
-
*/
|
|
11
7
|
export async function extractConditionFields(session: IBasicSession, conditionNodeId: NodeIdLike): Promise<string[]> {
|
|
12
8
|
// conditionNodeId could be a Object of type ConditionType
|
|
13
|
-
// or it could be directly a
|
|
9
|
+
// or it could be directly a ObjectType which is a subType of ConditionType
|
|
14
10
|
|
|
15
11
|
const _duplicateMap: any = {};
|
|
16
12
|
const fields1: string[] = [];
|
|
@@ -63,7 +59,9 @@ export async function extractConditionFields(session: IBasicSession, conditionNo
|
|
|
63
59
|
|
|
64
60
|
for (const ref of result.references) {
|
|
65
61
|
const n = name + "." + ref.browseName.toString();
|
|
66
|
-
|
|
62
|
+
if (ref.nodeClass === NodeClass.Variable) {
|
|
63
|
+
addField(n);
|
|
64
|
+
}
|
|
67
65
|
deferObjectOrVariableInvestigation(ref.nodeId, n);
|
|
68
66
|
}
|
|
69
67
|
}
|
|
@@ -83,8 +81,10 @@ export async function extractConditionFields(session: IBasicSession, conditionNo
|
|
|
83
81
|
const nodeToBrowse2: BrowseDescriptionOptions = {
|
|
84
82
|
browseDirection: BrowseDirection.Forward,
|
|
85
83
|
includeSubtypes: true,
|
|
84
|
+
|
|
86
85
|
// tslint:disable-next-line: no-bitwise
|
|
87
86
|
nodeClassMask: NodeClassMask.Object | NodeClassMask.Variable,
|
|
87
|
+
|
|
88
88
|
nodeId: conditionNodeId,
|
|
89
89
|
referenceTypeId: resolveNodeId("HasChild"),
|
|
90
90
|
resultMask: 63
|
|
@@ -92,12 +92,11 @@ export async function extractConditionFields(session: IBasicSession, conditionNo
|
|
|
92
92
|
const nodesToBrowse = [nodeToBrowse1, nodeToBrowse2];
|
|
93
93
|
const browseResults = await session.browse(nodesToBrowse);
|
|
94
94
|
|
|
95
|
-
// console.log(browseResults[0].toString());
|
|
96
|
-
// console.log(browseResults[1].toString());
|
|
97
|
-
|
|
98
95
|
if (browseResults[1] && browseResults[1].references) {
|
|
99
96
|
for (const ref of browseResults[1].references) {
|
|
100
|
-
|
|
97
|
+
if (ref.nodeClass === NodeClass.Variable) {
|
|
98
|
+
addField(ref.browseName.toString());
|
|
99
|
+
}
|
|
101
100
|
deferObjectOrVariableInvestigation(ref.nodeId, ref.browseName.toString());
|
|
102
101
|
}
|
|
103
102
|
}
|
|
@@ -115,5 +114,6 @@ export async function extractConditionFields(session: IBasicSession, conditionNo
|
|
|
115
114
|
|
|
116
115
|
// add this field which will always be added
|
|
117
116
|
addField("ConditionId");
|
|
117
|
+
|
|
118
118
|
return fields1;
|
|
119
119
|
}
|
|
@@ -8,7 +8,7 @@ import { assert } from "node-opcua-assert";
|
|
|
8
8
|
|
|
9
9
|
import { AttributeIds } from "node-opcua-data-model";
|
|
10
10
|
import { DataValue, coerceTimestampsToReturn } from "node-opcua-data-value";
|
|
11
|
-
import { checkDebugFlag, make_debugLog } from "node-opcua-debug";
|
|
11
|
+
import { checkDebugFlag, make_debugLog, make_warningLog } from "node-opcua-debug";
|
|
12
12
|
import { ExtensionObject } from "node-opcua-extension-object";
|
|
13
13
|
import { EventFilter } from "node-opcua-service-filter";
|
|
14
14
|
import { ReadValueId, ReadValueIdOptions, TimestampsToReturn } from "node-opcua-service-read";
|
|
@@ -29,6 +29,7 @@ import { ClientSubscription } from "../client_subscription";
|
|
|
29
29
|
import { ClientMonitoredItem_create, ClientSubscriptionImpl } from "./client_subscription_impl";
|
|
30
30
|
|
|
31
31
|
const debugLog = make_debugLog(__filename);
|
|
32
|
+
const warningLog = make_warningLog(__filename);
|
|
32
33
|
const doDebug = checkDebugFlag(__filename);
|
|
33
34
|
|
|
34
35
|
export type PrepareForMonitoringResult =
|
|
@@ -216,8 +217,8 @@ export class ClientMonitoredItemImpl extends EventEmitter implements ClientMonit
|
|
|
216
217
|
try {
|
|
217
218
|
this.emit("changed", eventFields);
|
|
218
219
|
} catch (err) {
|
|
219
|
-
|
|
220
|
-
|
|
220
|
+
warningLog("Exception raised inside the event handler called by ClientMonitoredItem.on('change')", err);
|
|
221
|
+
warningLog("Please verify the application using this node-opcua client");
|
|
221
222
|
}
|
|
222
223
|
}
|
|
223
224
|
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
ExtraDataTypeManager,
|
|
11
11
|
getExtensionObjectConstructor,
|
|
12
12
|
getExtraDataTypeManager,
|
|
13
|
-
promoteOpaqueStructure
|
|
13
|
+
promoteOpaqueStructure
|
|
14
14
|
} from "node-opcua-client-dynamic-extension-object";
|
|
15
15
|
import { Certificate, Nonce } from "node-opcua-crypto";
|
|
16
16
|
import { attributeNameById, BrowseDirection, LocalizedTextLike } from "node-opcua-data-model";
|
|
@@ -82,7 +82,13 @@ import {
|
|
|
82
82
|
import { WriteRequest, WriteResponse, WriteValue } from "node-opcua-service-write";
|
|
83
83
|
import { StatusCode, StatusCodes, Callback, CallbackT } from "node-opcua-status-code";
|
|
84
84
|
import { ErrorCallback } from "node-opcua-status-code";
|
|
85
|
-
import {
|
|
85
|
+
import {
|
|
86
|
+
BrowseNextRequest,
|
|
87
|
+
BrowseNextResponse,
|
|
88
|
+
HistoryReadValueIdOptions,
|
|
89
|
+
ServiceFault,
|
|
90
|
+
WriteValueOptions
|
|
91
|
+
} from "node-opcua-types";
|
|
86
92
|
import { buffer_ellipsis, getFunctionParameterNames, isNullOrUndefined, lowerFirstLetter } from "node-opcua-utils";
|
|
87
93
|
import { DataType, Variant, VariantLike } from "node-opcua-variant";
|
|
88
94
|
|
|
@@ -1540,6 +1546,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession {
|
|
|
1540
1546
|
if (err && err.message.match(/BadSessionIdInvalid/) && request.constructor.name !== "ActivateSessionRequest") {
|
|
1541
1547
|
debugLog("Transaction on Invalid Session ", request.constructor.name);
|
|
1542
1548
|
request.requestHeader.requestHandle = requestHandleNotSetValue;
|
|
1549
|
+
warningLog("client is now attempting to recreate a session");
|
|
1543
1550
|
this.recreate_session_and_reperform_transaction(request, callback);
|
|
1544
1551
|
return;
|
|
1545
1552
|
}
|
|
@@ -1595,6 +1602,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession {
|
|
|
1595
1602
|
}
|
|
1596
1603
|
return callback(err);
|
|
1597
1604
|
}
|
|
1605
|
+
|
|
1598
1606
|
/* istanbul ignore next */
|
|
1599
1607
|
if (!response) {
|
|
1600
1608
|
return callback(new Error("internal Error"));
|
|
@@ -471,8 +471,12 @@ export class ClientSubscriptionImpl extends EventEmitter implements ClientSubscr
|
|
|
471
471
|
});
|
|
472
472
|
session.setTriggering(setTriggeringRequest, (err: Error | null, response?: SetTriggeringResponse) => {
|
|
473
473
|
if (err) {
|
|
474
|
-
|
|
475
|
-
|
|
474
|
+
if (response) {
|
|
475
|
+
// use soft error, no exceptions
|
|
476
|
+
return callback(null, response);
|
|
477
|
+
} else {
|
|
478
|
+
return callback(err);
|
|
479
|
+
}
|
|
476
480
|
}
|
|
477
481
|
// istanbul ignore next
|
|
478
482
|
if (!response) {
|