node-opcua-client-dynamic-extension-object 2.107.0 → 2.109.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.
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import { IBasicSession } from "node-opcua-pseudo-session";
|
|
2
2
|
import { ExtraDataTypeManager } from "./extra_data_type_manager";
|
|
3
|
+
/**
|
|
4
|
+
* @private
|
|
5
|
+
*/
|
|
6
|
+
export declare function serverImplementsDataTypeDefinition(session: IBasicSession): Promise<boolean>;
|
|
3
7
|
export declare function populateDataTypeManager(session: IBasicSession, dataTypeManager: ExtraDataTypeManager): Promise<void>;
|
|
@@ -9,17 +9,58 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.populateDataTypeManager = void 0;
|
|
12
|
+
exports.populateDataTypeManager = exports.serverImplementsDataTypeDefinition = void 0;
|
|
13
13
|
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
14
14
|
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
15
15
|
const node_opcua_pseudo_session_1 = require("node-opcua-pseudo-session");
|
|
16
16
|
const node_opcua_constants_1 = require("node-opcua-constants");
|
|
17
17
|
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
18
|
+
const node_opcua_service_translate_browse_path_1 = require("node-opcua-service-translate-browse-path");
|
|
18
19
|
const populate_data_type_manager_103_1 = require("./private/populate_data_type_manager_103");
|
|
19
20
|
const populate_data_type_manager_104_1 = require("./private/populate_data_type_manager_104");
|
|
21
|
+
/**
|
|
22
|
+
* @private
|
|
23
|
+
*/
|
|
20
24
|
function serverImplementsDataTypeDefinition(session) {
|
|
21
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
//
|
|
26
|
+
// One way to figure out is to check if the server provides DataTypeDefinition node
|
|
27
|
+
// ( see OPCUA 1.04 part 6 -)
|
|
28
|
+
// This is the preferred route, as we go along, more and more servers will implement this.
|
|
29
|
+
const browseResult1 = yield (0, node_opcua_pseudo_session_1.browseAll)(session, {
|
|
30
|
+
browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
|
|
31
|
+
includeSubtypes: true,
|
|
32
|
+
nodeClassMask: node_opcua_data_model_1.NodeClassMask.Variable,
|
|
33
|
+
nodeId: (0, node_opcua_nodeid_1.resolveNodeId)(node_opcua_constants_1.ObjectIds.OPCBinarySchema_TypeSystem),
|
|
34
|
+
resultMask: node_opcua_data_model_1.ResultMask.TypeDefinition
|
|
35
|
+
});
|
|
36
|
+
let count103DataType = 0;
|
|
37
|
+
for (const ref of browseResult1.references || []) {
|
|
38
|
+
const td = ref.typeDefinition;
|
|
39
|
+
if (!(td.namespace === 0 && td.value === node_opcua_constants_1.VariableTypeIds.DataTypeDictionaryType))
|
|
40
|
+
continue;
|
|
41
|
+
// we have a type definition,
|
|
42
|
+
// let check if there is a deprecated property
|
|
43
|
+
const p = yield session.translateBrowsePath((0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(ref.nodeId, "/Deprecated"));
|
|
44
|
+
if (!p.statusCode.isGood() || !p.targets || p.targets.length === 0) {
|
|
45
|
+
// the dataTypeDictionaryType is not exposing a Deprecated property
|
|
46
|
+
count103DataType++;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const deprecatedNodeId = p.targets[0].targetId;
|
|
50
|
+
// we have a deprecated property => this is a 1.03 server or 1.04
|
|
51
|
+
// => we need to check if the server provides DataTypeDefinition
|
|
52
|
+
const dataValue = yield session.read({ nodeId: deprecatedNodeId, attributeId: node_opcua_data_model_1.AttributeIds.Value });
|
|
53
|
+
if (dataValue.statusCode.isGood() && dataValue.value.value === false) {
|
|
54
|
+
// this is a 1.03 server
|
|
55
|
+
count103DataType++;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (count103DataType >= 1) {
|
|
60
|
+
// some namespace are old , we cannot assume that all namespace are 1.04
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
// check if server provides DataTypeDefinition => in this case this is the preferred route,
|
|
23
64
|
// as we go along, more and more servers will implement this.
|
|
24
65
|
const browseResult = yield (0, node_opcua_pseudo_session_1.browseAll)(session, {
|
|
25
66
|
browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
|
|
@@ -69,6 +110,7 @@ function serverImplementsDataTypeDefinition(session) {
|
|
|
69
110
|
return false;
|
|
70
111
|
});
|
|
71
112
|
}
|
|
113
|
+
exports.serverImplementsDataTypeDefinition = serverImplementsDataTypeDefinition;
|
|
72
114
|
function populateDataTypeManager(session, dataTypeManager) {
|
|
73
115
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
116
|
const force104 = yield serverImplementsDataTypeDefinition(session);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"populate_data_type_manager.js","sourceRoot":"","sources":["../source/populate_data_type_manager.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"populate_data_type_manager.js","sourceRoot":"","sources":["../source/populate_data_type_manager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iEAAiG;AACjG,yDAAkD;AAClD,yEAAqE;AACrE,+DAA8F;AAC9F,2DAA8C;AAE9C,uGAA0E;AAG1E,6FAAsF;AACtF,6FAAsF;AAEtF;;GAEG;AACH,SAAsB,kCAAkC,CAAC,OAAsB;;QAC3E,mFAAmF;QACnF,6BAA6B;QAC7B,0FAA0F;QAC1F,MAAM,aAAa,GAAG,MAAM,IAAA,qCAAS,EAAC,OAAO,EAAE;YAC3C,eAAe,EAAE,uCAAe,CAAC,OAAO;YACxC,eAAe,EAAE,IAAI;YACrB,aAAa,EAAE,qCAAa,CAAC,QAAQ;YACrC,MAAM,EAAE,IAAA,iCAAa,EAAC,gCAAS,CAAC,0BAA0B,CAAC;YAC3D,UAAU,EAAE,kCAAU,C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ACV,MAAM,IAAA,2DAA0B,EAAC,OAAO,EAAE,eAAe,CAAC,CAAC;YAC3D,OAAO;SACV;QACD,4CAA4C;QAC5C,MAAM,IAAA,2DAA0B,EAAC,OAAO,EAAE,eAAe,CAAC,CAAC;QAC3D,MAAM,IAAA,2DAA0B,EAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IAC/D,CAAC;CAAA;AATD,0DASC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-client-dynamic-extension-object",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.109.0",
|
|
4
4
|
"description": "pure nodejs OPCUA SDK - module client-dynamic-extension-object",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -12,21 +12,21 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"chalk": "4.1.2",
|
|
14
14
|
"node-opcua-assert": "2.105.0",
|
|
15
|
-
"node-opcua-binary-stream": "2.
|
|
15
|
+
"node-opcua-binary-stream": "2.109.0",
|
|
16
16
|
"node-opcua-constants": "2.98.1",
|
|
17
|
-
"node-opcua-data-model": "2.
|
|
18
|
-
"node-opcua-data-value": "2.
|
|
19
|
-
"node-opcua-debug": "2.
|
|
20
|
-
"node-opcua-extension-object": "2.
|
|
21
|
-
"node-opcua-factory": "2.
|
|
22
|
-
"node-opcua-nodeid": "2.
|
|
23
|
-
"node-opcua-pseudo-session": "2.
|
|
24
|
-
"node-opcua-schemas": "2.
|
|
25
|
-
"node-opcua-service-browse": "2.
|
|
26
|
-
"node-opcua-service-translate-browse-path": "2.
|
|
27
|
-
"node-opcua-status-code": "2.
|
|
28
|
-
"node-opcua-types": "2.
|
|
29
|
-
"node-opcua-variant": "2.
|
|
17
|
+
"node-opcua-data-model": "2.109.0",
|
|
18
|
+
"node-opcua-data-value": "2.109.0",
|
|
19
|
+
"node-opcua-debug": "2.109.0",
|
|
20
|
+
"node-opcua-extension-object": "2.109.0",
|
|
21
|
+
"node-opcua-factory": "2.109.0",
|
|
22
|
+
"node-opcua-nodeid": "2.109.0",
|
|
23
|
+
"node-opcua-pseudo-session": "2.109.0",
|
|
24
|
+
"node-opcua-schemas": "2.109.0",
|
|
25
|
+
"node-opcua-service-browse": "2.109.0",
|
|
26
|
+
"node-opcua-service-translate-browse-path": "2.109.0",
|
|
27
|
+
"node-opcua-status-code": "2.109.0",
|
|
28
|
+
"node-opcua-types": "2.109.0",
|
|
29
|
+
"node-opcua-variant": "2.109.0"
|
|
30
30
|
},
|
|
31
31
|
"author": "Etienne Rossignon",
|
|
32
32
|
"license": "MIT",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"internet of things"
|
|
44
44
|
],
|
|
45
45
|
"homepage": "http://node-opcua.github.io/",
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "50cfa07779d4c07b299176ac9c27527fcd97d079",
|
|
47
47
|
"files": [
|
|
48
48
|
"dist",
|
|
49
49
|
"source"
|
|
@@ -1,19 +1,58 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { coerceNodeId, resolveNodeId } from "node-opcua-nodeid";
|
|
1
|
+
import { AttributeIds, BrowseDirection, NodeClassMask, ResultMask } from "node-opcua-data-model";
|
|
2
|
+
import { resolveNodeId } from "node-opcua-nodeid";
|
|
4
3
|
import { IBasicSession, browseAll } from "node-opcua-pseudo-session";
|
|
5
|
-
import { DataTypeIds } from "node-opcua-constants";
|
|
6
|
-
|
|
7
|
-
import { StatusCodes } from "node-opcua-status-code";
|
|
4
|
+
import { DataTypeIds, ObjectIds, ObjectTypeIds, VariableTypeIds } from "node-opcua-constants";
|
|
8
5
|
import { DataType } from "node-opcua-variant";
|
|
9
6
|
import { ReferenceDescription } from "node-opcua-types";
|
|
7
|
+
import { makeBrowsePath } from "node-opcua-service-translate-browse-path";
|
|
10
8
|
//
|
|
11
9
|
import { ExtraDataTypeManager } from "./extra_data_type_manager";
|
|
12
10
|
import { populateDataTypeManager103 } from "./private/populate_data_type_manager_103";
|
|
13
11
|
import { populateDataTypeManager104 } from "./private/populate_data_type_manager_104";
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
/**
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
16
|
+
export async function serverImplementsDataTypeDefinition(session: IBasicSession): Promise<boolean> {
|
|
17
|
+
// One way to figure out is to check if the server provides DataTypeDefinition node
|
|
18
|
+
// ( see OPCUA 1.04 part 6 -)
|
|
19
|
+
// This is the preferred route, as we go along, more and more servers will implement this.
|
|
20
|
+
const browseResult1 = await browseAll(session, {
|
|
21
|
+
browseDirection: BrowseDirection.Forward,
|
|
22
|
+
includeSubtypes: true,
|
|
23
|
+
nodeClassMask: NodeClassMask.Variable,
|
|
24
|
+
nodeId: resolveNodeId(ObjectIds.OPCBinarySchema_TypeSystem),
|
|
25
|
+
resultMask: ResultMask.TypeDefinition
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
let count103DataType = 0;
|
|
29
|
+
for (const ref of browseResult1.references || []) {
|
|
30
|
+
const td = ref.typeDefinition;
|
|
31
|
+
if (!(td.namespace === 0 && td.value === VariableTypeIds.DataTypeDictionaryType)) continue;
|
|
32
|
+
// we have a type definition,
|
|
33
|
+
// let check if there is a deprecated property
|
|
34
|
+
const p = await session.translateBrowsePath(makeBrowsePath(ref.nodeId, "/Deprecated"));
|
|
35
|
+
if (!p.statusCode.isGood() || !p.targets || p.targets.length === 0) {
|
|
36
|
+
// the dataTypeDictionaryType is not exposing a Deprecated property
|
|
37
|
+
count103DataType++;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const deprecatedNodeId = p.targets[0].targetId;
|
|
41
|
+
// we have a deprecated property => this is a 1.03 server or 1.04
|
|
42
|
+
// => we need to check if the server provides DataTypeDefinition
|
|
43
|
+
const dataValue = await session.read({ nodeId: deprecatedNodeId, attributeId: AttributeIds.Value });
|
|
44
|
+
if (dataValue.statusCode.isGood() && dataValue.value.value === false) {
|
|
45
|
+
// this is a 1.03 server
|
|
46
|
+
count103DataType++;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (count103DataType >= 1) {
|
|
51
|
+
// some namespace are old , we cannot assume that all namespace are 1.04
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// check if server provides DataTypeDefinition => in this case this is the preferred route,
|
|
17
56
|
// as we go along, more and more servers will implement this.
|
|
18
57
|
const browseResult = await browseAll(session, {
|
|
19
58
|
browseDirection: BrowseDirection.Forward,
|