node-opcua-convert-nodeset-to-javascript 2.64.0 → 2.64.1
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/cache.d.ts +62 -0
- package/dist/cache.js +273 -0
- package/dist/cache.js.map +1 -0
- package/dist/convert_namespace_to_typescript.d.ts +3 -3
- package/dist/convert_namespace_to_typescript.js +172 -172
- package/dist/convert_to_typescript.d.ts +109 -109
- package/dist/convert_to_typescript.js +884 -884
- package/dist/index.d.ts +3 -3
- package/dist/index.js +15 -15
- package/dist/main.d.ts +1 -1
- package/dist/main.js +74 -74
- package/dist/official_namespaces.d.ts +23 -23
- package/dist/official_namespaces.js +35 -35
- package/dist/options.d.ts +5 -5
- package/dist/options.js +2 -2
- package/dist/private/cache.d.ts +58 -58
- package/dist/private/cache.js +212 -212
- package/dist/private/to_filename.d.ts +1 -1
- package/dist/private/to_filename.js +9 -9
- package/dist/private/utils.d.ts +24 -24
- package/dist/private/utils.js +260 -260
- package/dist/private-stuff.d.ts +4 -4
- package/dist/private-stuff.js +16 -16
- package/dist/utils.d.ts +20 -0
- package/dist/utils.js +221 -0
- package/dist/utils.js.map +1 -0
- package/dist/walk_through.d.ts +13 -13
- package/dist/walk_through.js +86 -86
- package/package.json +57 -57
package/dist/private/utils.js
CHANGED
|
@@ -1,261 +1,261 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getValueRank = exports.getChildrenOrFolderElements = exports.convertNodeIdToDataTypeAsync = exports.getTypeDefinition = exports.getTypeDefOrBaseType = exports.getSubtypeNodeId = exports.getSubtypeNodeIdIfAny = exports.extractBasicDataType = exports.isExtensionObject = exports.getModellingRule = exports.getFolderElements = exports.getChildren = exports.getNodeClass = exports.getDescription = exports.getIsAbstract = exports.getDataTypeNodeId = exports.getBrowseName = exports.getDefinition = void 0;
|
|
13
|
-
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
14
|
-
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
15
|
-
const node_opcua_types_1 = require("node-opcua-types");
|
|
16
|
-
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
17
|
-
const node_opcua_status_code_1 = require("node-opcua-status-code");
|
|
18
|
-
function getDefinition(session, nodeId) {
|
|
19
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
const dataValue = yield session.read({ nodeId, attributeId: node_opcua_data_model_1.AttributeIds.DataTypeDefinition });
|
|
21
|
-
return dataValue.value.value || null;
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
exports.getDefinition = getDefinition;
|
|
25
|
-
function getBrowseName(session, nodeId) {
|
|
26
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
const dataValue = yield session.read({ nodeId, attributeId: node_opcua_data_model_1.AttributeIds.BrowseName });
|
|
28
|
-
return dataValue.value.value;
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
exports.getBrowseName = getBrowseName;
|
|
32
|
-
function getDataTypeNodeId(session, nodeId) {
|
|
33
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
const dataValue = yield session.read({ nodeId, attributeId: node_opcua_data_model_1.AttributeIds.DataType });
|
|
35
|
-
return dataValue.value.value || null;
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
exports.getDataTypeNodeId = getDataTypeNodeId;
|
|
39
|
-
function getIsAbstract(session, nodeId) {
|
|
40
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
const dataValue = yield session.read({ nodeId, attributeId: node_opcua_data_model_1.AttributeIds.IsAbstract });
|
|
42
|
-
return dataValue.value.value;
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
exports.getIsAbstract = getIsAbstract;
|
|
46
|
-
function getDescription(session, nodeId) {
|
|
47
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
const dataValue = yield session.read({ nodeId, attributeId: node_opcua_data_model_1.AttributeIds.Description });
|
|
49
|
-
return dataValue.value.value;
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
exports.getDescription = getDescription;
|
|
53
|
-
function getNodeClass(session, nodeId) {
|
|
54
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
const dataValue = yield session.read({ nodeId, attributeId: node_opcua_data_model_1.AttributeIds.NodeClass });
|
|
56
|
-
return dataValue.value.value;
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
exports.getNodeClass = getNodeClass;
|
|
60
|
-
function getChildren(session, nodeId) {
|
|
61
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
const browseResult = yield session.browse({
|
|
63
|
-
browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
|
|
64
|
-
includeSubtypes: true,
|
|
65
|
-
nodeClassMask: node_opcua_data_model_1.NodeClassMask.Method | node_opcua_data_model_1.NodeClassMask.Object | node_opcua_data_model_1.NodeClass.Variable,
|
|
66
|
-
nodeId,
|
|
67
|
-
referenceTypeId: (0, node_opcua_nodeid_1.resolveNodeId)("HasChild"),
|
|
68
|
-
resultMask: 0xffff
|
|
69
|
-
});
|
|
70
|
-
return browseResult.references || [];
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
exports.getChildren = getChildren;
|
|
74
|
-
function getFolderElements(session, nodeId) {
|
|
75
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
const browseResult = yield session.browse({
|
|
77
|
-
browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
|
|
78
|
-
includeSubtypes: true,
|
|
79
|
-
nodeClassMask: node_opcua_data_model_1.NodeClassMask.Method | node_opcua_data_model_1.NodeClassMask.Object | node_opcua_data_model_1.NodeClass.Variable,
|
|
80
|
-
nodeId,
|
|
81
|
-
referenceTypeId: (0, node_opcua_nodeid_1.resolveNodeId)("Organizes"),
|
|
82
|
-
resultMask: 0xffff
|
|
83
|
-
});
|
|
84
|
-
return browseResult.references || [];
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
exports.getFolderElements = getFolderElements;
|
|
88
|
-
function getModellingRule(session, nodeId) {
|
|
89
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
-
const browseResult = yield session.browse({
|
|
91
|
-
browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
|
|
92
|
-
includeSubtypes: true,
|
|
93
|
-
nodeClassMask: node_opcua_data_model_1.NodeClassMask.Method | node_opcua_data_model_1.NodeClassMask.Object | node_opcua_data_model_1.NodeClass.Variable,
|
|
94
|
-
nodeId,
|
|
95
|
-
referenceTypeId: (0, node_opcua_nodeid_1.resolveNodeId)("HasModellingRule"),
|
|
96
|
-
resultMask: 0xffff
|
|
97
|
-
});
|
|
98
|
-
if (!browseResult.references || browseResult.references.length === 0) {
|
|
99
|
-
return null;
|
|
100
|
-
/*
|
|
101
|
-
console.log(nodeId.toString());
|
|
102
|
-
const browseName = await getBrowseName(session, nodeId);
|
|
103
|
-
throw new Error("No modelling rule for " + nodeId.toString() + " " + browseName.toString());
|
|
104
|
-
*/
|
|
105
|
-
}
|
|
106
|
-
return browseResult.references[0].browseName.name;
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
exports.getModellingRule = getModellingRule;
|
|
110
|
-
function isExtensionObject(session, nodeId) {
|
|
111
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
-
if (nodeId.namespace === 0 && nodeId.value === 22) {
|
|
113
|
-
return true;
|
|
114
|
-
}
|
|
115
|
-
if (nodeId.namespace === 0 && nodeId.value <= 25) {
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
const r = yield getSubtypeNodeIdIfAny(session, nodeId);
|
|
119
|
-
return yield isExtensionObject(session, r.nodeId);
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
exports.isExtensionObject = isExtensionObject;
|
|
123
|
-
function extractBasicDataType(session, dataTypeNodeId) {
|
|
124
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
-
if (dataTypeNodeId.namespace === 0 && dataTypeNodeId.value <= 25) {
|
|
126
|
-
return dataTypeNodeId.value;
|
|
127
|
-
}
|
|
128
|
-
const r = yield getSubtypeNodeIdIfAny(session, dataTypeNodeId);
|
|
129
|
-
return yield extractBasicDataType(session, r.nodeId);
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
exports.extractBasicDataType = extractBasicDataType;
|
|
133
|
-
function getSubtypeNodeIdIfAny(session, nodeId) {
|
|
134
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
135
|
-
if (nodeId.isEmpty()) {
|
|
136
|
-
return null;
|
|
137
|
-
}
|
|
138
|
-
const browseResult = yield session.browse({
|
|
139
|
-
browseDirection: node_opcua_data_model_1.BrowseDirection.Inverse,
|
|
140
|
-
includeSubtypes: true,
|
|
141
|
-
nodeClassMask: 0,
|
|
142
|
-
nodeId,
|
|
143
|
-
referenceTypeId: (0, node_opcua_nodeid_1.resolveNodeId)("HasSubtype"),
|
|
144
|
-
resultMask: 0xffff
|
|
145
|
-
});
|
|
146
|
-
if (!browseResult.references || browseResult.references.length === 0) {
|
|
147
|
-
return null;
|
|
148
|
-
}
|
|
149
|
-
return browseResult.references[0];
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
exports.getSubtypeNodeIdIfAny = getSubtypeNodeIdIfAny;
|
|
153
|
-
function getSubtypeNodeId(session, nodeId) {
|
|
154
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
155
|
-
const r = yield getSubtypeNodeIdIfAny(session, nodeId);
|
|
156
|
-
if (!r) {
|
|
157
|
-
throw new Error("No Subtype");
|
|
158
|
-
}
|
|
159
|
-
return r;
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
exports.getSubtypeNodeId = getSubtypeNodeId;
|
|
163
|
-
function getTypeDefOrBaseType(session, nodeId) {
|
|
164
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
165
|
-
let browseResult = yield session.browse({
|
|
166
|
-
browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
|
|
167
|
-
includeSubtypes: true,
|
|
168
|
-
nodeClassMask: 0,
|
|
169
|
-
nodeId,
|
|
170
|
-
referenceTypeId: (0, node_opcua_nodeid_1.resolveNodeId)("HasTypeDefinition"),
|
|
171
|
-
resultMask: 0xffff
|
|
172
|
-
});
|
|
173
|
-
if (!browseResult.references || browseResult.references.length === 0) {
|
|
174
|
-
browseResult = yield session.browse({
|
|
175
|
-
browseDirection: node_opcua_data_model_1.BrowseDirection.Inverse,
|
|
176
|
-
includeSubtypes: true,
|
|
177
|
-
nodeClassMask: 0,
|
|
178
|
-
nodeId,
|
|
179
|
-
referenceTypeId: (0, node_opcua_nodeid_1.resolveNodeId)("HasSubtype"),
|
|
180
|
-
resultMask: 0xffff
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
if (!browseResult.references || browseResult.references.length === 0) {
|
|
184
|
-
// console.log("cannot find type definition / subtype for " + nodeId.toString());
|
|
185
|
-
return new node_opcua_types_1.ReferenceDescription({});
|
|
186
|
-
}
|
|
187
|
-
return browseResult.references[0];
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
exports.getTypeDefOrBaseType = getTypeDefOrBaseType;
|
|
191
|
-
function getTypeDefinition(session, nodeId) {
|
|
192
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
193
|
-
const browseResult = yield session.browse({
|
|
194
|
-
browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
|
|
195
|
-
includeSubtypes: true,
|
|
196
|
-
nodeClassMask: 0,
|
|
197
|
-
nodeId,
|
|
198
|
-
referenceTypeId: (0, node_opcua_nodeid_1.resolveNodeId)("HasTypeDefinition"),
|
|
199
|
-
resultMask: 0xffff
|
|
200
|
-
});
|
|
201
|
-
if (!browseResult.references || browseResult.references.length === 0) {
|
|
202
|
-
console.log(nodeId.toString());
|
|
203
|
-
throw new Error("No subtype");
|
|
204
|
-
}
|
|
205
|
-
return browseResult.references[0];
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
exports.getTypeDefinition = getTypeDefinition;
|
|
209
|
-
// see also client-proxy
|
|
210
|
-
function convertNodeIdToDataTypeAsync(session, dataTypeId) {
|
|
211
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
212
|
-
const nodeToRead = {
|
|
213
|
-
attributeId: node_opcua_data_model_1.AttributeIds.BrowseName,
|
|
214
|
-
nodeId: dataTypeId
|
|
215
|
-
};
|
|
216
|
-
const dataValue = yield session.read(nodeToRead);
|
|
217
|
-
let dataType;
|
|
218
|
-
// istanbul ignore next
|
|
219
|
-
if (dataValue.statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
|
|
220
|
-
return (dataType = node_opcua_variant_1.DataType.Null);
|
|
221
|
-
}
|
|
222
|
-
const dataTypeName = dataValue.value.value;
|
|
223
|
-
if (dataTypeId.namespace === 0 && node_opcua_variant_1.DataType[dataTypeId.value]) {
|
|
224
|
-
dataType = dataTypeId.value;
|
|
225
|
-
return dataType;
|
|
226
|
-
}
|
|
227
|
-
/// example => Duration (i=290) => Double (i=11)
|
|
228
|
-
// read subTypeOf
|
|
229
|
-
const nodeToBrowse = {
|
|
230
|
-
browseDirection: node_opcua_data_model_1.BrowseDirection.Inverse,
|
|
231
|
-
nodeId: dataTypeId,
|
|
232
|
-
referenceTypeId: (0, node_opcua_nodeid_1.resolveNodeId)("HasSubtype"),
|
|
233
|
-
resultMask: 0xff
|
|
234
|
-
};
|
|
235
|
-
// tslint:disable:no-shadowed-variable
|
|
236
|
-
const browseResult = yield session.browse(nodeToBrowse);
|
|
237
|
-
const references = browseResult.references;
|
|
238
|
-
if (!references || references.length !== 1) {
|
|
239
|
-
throw new Error("cannot find SuperType of " + dataTypeName.toString());
|
|
240
|
-
}
|
|
241
|
-
const nodeId = references[0].nodeId;
|
|
242
|
-
return convertNodeIdToDataTypeAsync(session, nodeId);
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
exports.convertNodeIdToDataTypeAsync = convertNodeIdToDataTypeAsync;
|
|
246
|
-
function getChildrenOrFolderElements(session, nodeId) {
|
|
247
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
248
|
-
const c1 = yield getChildren(session, nodeId);
|
|
249
|
-
const c2 = yield getFolderElements(session, nodeId);
|
|
250
|
-
return [].concat(c1, c2);
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
exports.getChildrenOrFolderElements = getChildrenOrFolderElements;
|
|
254
|
-
function getValueRank(session, nodeId) {
|
|
255
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
256
|
-
const valueRankDataValue = yield session.read({ nodeId, attributeId: node_opcua_data_model_1.AttributeIds.ValueRank });
|
|
257
|
-
return valueRankDataValue.value.value;
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
exports.getValueRank = getValueRank;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getValueRank = exports.getChildrenOrFolderElements = exports.convertNodeIdToDataTypeAsync = exports.getTypeDefinition = exports.getTypeDefOrBaseType = exports.getSubtypeNodeId = exports.getSubtypeNodeIdIfAny = exports.extractBasicDataType = exports.isExtensionObject = exports.getModellingRule = exports.getFolderElements = exports.getChildren = exports.getNodeClass = exports.getDescription = exports.getIsAbstract = exports.getDataTypeNodeId = exports.getBrowseName = exports.getDefinition = void 0;
|
|
13
|
+
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
14
|
+
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
15
|
+
const node_opcua_types_1 = require("node-opcua-types");
|
|
16
|
+
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
17
|
+
const node_opcua_status_code_1 = require("node-opcua-status-code");
|
|
18
|
+
function getDefinition(session, nodeId) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const dataValue = yield session.read({ nodeId, attributeId: node_opcua_data_model_1.AttributeIds.DataTypeDefinition });
|
|
21
|
+
return dataValue.value.value || null;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
exports.getDefinition = getDefinition;
|
|
25
|
+
function getBrowseName(session, nodeId) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const dataValue = yield session.read({ nodeId, attributeId: node_opcua_data_model_1.AttributeIds.BrowseName });
|
|
28
|
+
return dataValue.value.value;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
exports.getBrowseName = getBrowseName;
|
|
32
|
+
function getDataTypeNodeId(session, nodeId) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const dataValue = yield session.read({ nodeId, attributeId: node_opcua_data_model_1.AttributeIds.DataType });
|
|
35
|
+
return dataValue.value.value || null;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
exports.getDataTypeNodeId = getDataTypeNodeId;
|
|
39
|
+
function getIsAbstract(session, nodeId) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const dataValue = yield session.read({ nodeId, attributeId: node_opcua_data_model_1.AttributeIds.IsAbstract });
|
|
42
|
+
return dataValue.value.value;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
exports.getIsAbstract = getIsAbstract;
|
|
46
|
+
function getDescription(session, nodeId) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const dataValue = yield session.read({ nodeId, attributeId: node_opcua_data_model_1.AttributeIds.Description });
|
|
49
|
+
return dataValue.value.value;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
exports.getDescription = getDescription;
|
|
53
|
+
function getNodeClass(session, nodeId) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
const dataValue = yield session.read({ nodeId, attributeId: node_opcua_data_model_1.AttributeIds.NodeClass });
|
|
56
|
+
return dataValue.value.value;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
exports.getNodeClass = getNodeClass;
|
|
60
|
+
function getChildren(session, nodeId) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
const browseResult = yield session.browse({
|
|
63
|
+
browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
|
|
64
|
+
includeSubtypes: true,
|
|
65
|
+
nodeClassMask: node_opcua_data_model_1.NodeClassMask.Method | node_opcua_data_model_1.NodeClassMask.Object | node_opcua_data_model_1.NodeClass.Variable,
|
|
66
|
+
nodeId,
|
|
67
|
+
referenceTypeId: (0, node_opcua_nodeid_1.resolveNodeId)("HasChild"),
|
|
68
|
+
resultMask: 0xffff
|
|
69
|
+
});
|
|
70
|
+
return browseResult.references || [];
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
exports.getChildren = getChildren;
|
|
74
|
+
function getFolderElements(session, nodeId) {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
const browseResult = yield session.browse({
|
|
77
|
+
browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
|
|
78
|
+
includeSubtypes: true,
|
|
79
|
+
nodeClassMask: node_opcua_data_model_1.NodeClassMask.Method | node_opcua_data_model_1.NodeClassMask.Object | node_opcua_data_model_1.NodeClass.Variable,
|
|
80
|
+
nodeId,
|
|
81
|
+
referenceTypeId: (0, node_opcua_nodeid_1.resolveNodeId)("Organizes"),
|
|
82
|
+
resultMask: 0xffff
|
|
83
|
+
});
|
|
84
|
+
return browseResult.references || [];
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
exports.getFolderElements = getFolderElements;
|
|
88
|
+
function getModellingRule(session, nodeId) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
const browseResult = yield session.browse({
|
|
91
|
+
browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
|
|
92
|
+
includeSubtypes: true,
|
|
93
|
+
nodeClassMask: node_opcua_data_model_1.NodeClassMask.Method | node_opcua_data_model_1.NodeClassMask.Object | node_opcua_data_model_1.NodeClass.Variable,
|
|
94
|
+
nodeId,
|
|
95
|
+
referenceTypeId: (0, node_opcua_nodeid_1.resolveNodeId)("HasModellingRule"),
|
|
96
|
+
resultMask: 0xffff
|
|
97
|
+
});
|
|
98
|
+
if (!browseResult.references || browseResult.references.length === 0) {
|
|
99
|
+
return null;
|
|
100
|
+
/*
|
|
101
|
+
console.log(nodeId.toString());
|
|
102
|
+
const browseName = await getBrowseName(session, nodeId);
|
|
103
|
+
throw new Error("No modelling rule for " + nodeId.toString() + " " + browseName.toString());
|
|
104
|
+
*/
|
|
105
|
+
}
|
|
106
|
+
return browseResult.references[0].browseName.name;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
exports.getModellingRule = getModellingRule;
|
|
110
|
+
function isExtensionObject(session, nodeId) {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
if (nodeId.namespace === 0 && nodeId.value === 22) {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
if (nodeId.namespace === 0 && nodeId.value <= 25) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
const r = yield getSubtypeNodeIdIfAny(session, nodeId);
|
|
119
|
+
return yield isExtensionObject(session, r.nodeId);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
exports.isExtensionObject = isExtensionObject;
|
|
123
|
+
function extractBasicDataType(session, dataTypeNodeId) {
|
|
124
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
if (dataTypeNodeId.namespace === 0 && dataTypeNodeId.value <= 25) {
|
|
126
|
+
return dataTypeNodeId.value;
|
|
127
|
+
}
|
|
128
|
+
const r = yield getSubtypeNodeIdIfAny(session, dataTypeNodeId);
|
|
129
|
+
return yield extractBasicDataType(session, r.nodeId);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
exports.extractBasicDataType = extractBasicDataType;
|
|
133
|
+
function getSubtypeNodeIdIfAny(session, nodeId) {
|
|
134
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
135
|
+
if (nodeId.isEmpty()) {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
const browseResult = yield session.browse({
|
|
139
|
+
browseDirection: node_opcua_data_model_1.BrowseDirection.Inverse,
|
|
140
|
+
includeSubtypes: true,
|
|
141
|
+
nodeClassMask: 0,
|
|
142
|
+
nodeId,
|
|
143
|
+
referenceTypeId: (0, node_opcua_nodeid_1.resolveNodeId)("HasSubtype"),
|
|
144
|
+
resultMask: 0xffff
|
|
145
|
+
});
|
|
146
|
+
if (!browseResult.references || browseResult.references.length === 0) {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
return browseResult.references[0];
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
exports.getSubtypeNodeIdIfAny = getSubtypeNodeIdIfAny;
|
|
153
|
+
function getSubtypeNodeId(session, nodeId) {
|
|
154
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
155
|
+
const r = yield getSubtypeNodeIdIfAny(session, nodeId);
|
|
156
|
+
if (!r) {
|
|
157
|
+
throw new Error("No Subtype");
|
|
158
|
+
}
|
|
159
|
+
return r;
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
exports.getSubtypeNodeId = getSubtypeNodeId;
|
|
163
|
+
function getTypeDefOrBaseType(session, nodeId) {
|
|
164
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
165
|
+
let browseResult = yield session.browse({
|
|
166
|
+
browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
|
|
167
|
+
includeSubtypes: true,
|
|
168
|
+
nodeClassMask: 0,
|
|
169
|
+
nodeId,
|
|
170
|
+
referenceTypeId: (0, node_opcua_nodeid_1.resolveNodeId)("HasTypeDefinition"),
|
|
171
|
+
resultMask: 0xffff
|
|
172
|
+
});
|
|
173
|
+
if (!browseResult.references || browseResult.references.length === 0) {
|
|
174
|
+
browseResult = yield session.browse({
|
|
175
|
+
browseDirection: node_opcua_data_model_1.BrowseDirection.Inverse,
|
|
176
|
+
includeSubtypes: true,
|
|
177
|
+
nodeClassMask: 0,
|
|
178
|
+
nodeId,
|
|
179
|
+
referenceTypeId: (0, node_opcua_nodeid_1.resolveNodeId)("HasSubtype"),
|
|
180
|
+
resultMask: 0xffff
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
if (!browseResult.references || browseResult.references.length === 0) {
|
|
184
|
+
// console.log("cannot find type definition / subtype for " + nodeId.toString());
|
|
185
|
+
return new node_opcua_types_1.ReferenceDescription({});
|
|
186
|
+
}
|
|
187
|
+
return browseResult.references[0];
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
exports.getTypeDefOrBaseType = getTypeDefOrBaseType;
|
|
191
|
+
function getTypeDefinition(session, nodeId) {
|
|
192
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
193
|
+
const browseResult = yield session.browse({
|
|
194
|
+
browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
|
|
195
|
+
includeSubtypes: true,
|
|
196
|
+
nodeClassMask: 0,
|
|
197
|
+
nodeId,
|
|
198
|
+
referenceTypeId: (0, node_opcua_nodeid_1.resolveNodeId)("HasTypeDefinition"),
|
|
199
|
+
resultMask: 0xffff
|
|
200
|
+
});
|
|
201
|
+
if (!browseResult.references || browseResult.references.length === 0) {
|
|
202
|
+
console.log(nodeId.toString());
|
|
203
|
+
throw new Error("No subtype");
|
|
204
|
+
}
|
|
205
|
+
return browseResult.references[0];
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
exports.getTypeDefinition = getTypeDefinition;
|
|
209
|
+
// see also client-proxy
|
|
210
|
+
function convertNodeIdToDataTypeAsync(session, dataTypeId) {
|
|
211
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
212
|
+
const nodeToRead = {
|
|
213
|
+
attributeId: node_opcua_data_model_1.AttributeIds.BrowseName,
|
|
214
|
+
nodeId: dataTypeId
|
|
215
|
+
};
|
|
216
|
+
const dataValue = yield session.read(nodeToRead);
|
|
217
|
+
let dataType;
|
|
218
|
+
// istanbul ignore next
|
|
219
|
+
if (dataValue.statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
|
|
220
|
+
return (dataType = node_opcua_variant_1.DataType.Null);
|
|
221
|
+
}
|
|
222
|
+
const dataTypeName = dataValue.value.value;
|
|
223
|
+
if (dataTypeId.namespace === 0 && node_opcua_variant_1.DataType[dataTypeId.value]) {
|
|
224
|
+
dataType = dataTypeId.value;
|
|
225
|
+
return dataType;
|
|
226
|
+
}
|
|
227
|
+
/// example => Duration (i=290) => Double (i=11)
|
|
228
|
+
// read subTypeOf
|
|
229
|
+
const nodeToBrowse = {
|
|
230
|
+
browseDirection: node_opcua_data_model_1.BrowseDirection.Inverse,
|
|
231
|
+
nodeId: dataTypeId,
|
|
232
|
+
referenceTypeId: (0, node_opcua_nodeid_1.resolveNodeId)("HasSubtype"),
|
|
233
|
+
resultMask: 0xff
|
|
234
|
+
};
|
|
235
|
+
// tslint:disable:no-shadowed-variable
|
|
236
|
+
const browseResult = yield session.browse(nodeToBrowse);
|
|
237
|
+
const references = browseResult.references;
|
|
238
|
+
if (!references || references.length !== 1) {
|
|
239
|
+
throw new Error("cannot find SuperType of " + dataTypeName.toString());
|
|
240
|
+
}
|
|
241
|
+
const nodeId = references[0].nodeId;
|
|
242
|
+
return convertNodeIdToDataTypeAsync(session, nodeId);
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
exports.convertNodeIdToDataTypeAsync = convertNodeIdToDataTypeAsync;
|
|
246
|
+
function getChildrenOrFolderElements(session, nodeId) {
|
|
247
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
248
|
+
const c1 = yield getChildren(session, nodeId);
|
|
249
|
+
const c2 = yield getFolderElements(session, nodeId);
|
|
250
|
+
return [].concat(c1, c2);
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
exports.getChildrenOrFolderElements = getChildrenOrFolderElements;
|
|
254
|
+
function getValueRank(session, nodeId) {
|
|
255
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
256
|
+
const valueRankDataValue = yield session.read({ nodeId, attributeId: node_opcua_data_model_1.AttributeIds.ValueRank });
|
|
257
|
+
return valueRankDataValue.value.value;
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
exports.getValueRank = getValueRank;
|
|
261
261
|
//# sourceMappingURL=utils.js.map
|
package/dist/private-stuff.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./index";
|
|
2
|
-
export * from "./options";
|
|
3
|
-
export * from "./private/cache";
|
|
4
|
-
export * from "./private/utils";
|
|
1
|
+
export * from "./index";
|
|
2
|
+
export * from "./options";
|
|
3
|
+
export * from "./private/cache";
|
|
4
|
+
export * from "./private/utils";
|
package/dist/private-stuff.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./index"), exports);
|
|
14
|
-
__exportStar(require("./options"), exports);
|
|
15
|
-
__exportStar(require("./private/cache"), exports);
|
|
16
|
-
__exportStar(require("./private/utils"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./index"), exports);
|
|
14
|
+
__exportStar(require("./options"), exports);
|
|
15
|
+
__exportStar(require("./private/cache"), exports);
|
|
16
|
+
__exportStar(require("./private/utils"), exports);
|
|
17
17
|
//# sourceMappingURL=private-stuff.js.map
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { LocalizedText, NodeClass, QualifiedName } from "node-opcua-data-model";
|
|
2
|
+
import { NodeId } from "node-opcua-nodeid";
|
|
3
|
+
import { IBasicSession } from "node-opcua-pseudo-session";
|
|
4
|
+
import { DataTypeDefinition, ReferenceDescription } from "node-opcua-types";
|
|
5
|
+
import { ModellingRuleType } from "node-opcua-address-space";
|
|
6
|
+
import { DataType } from "node-opcua-variant";
|
|
7
|
+
export declare function getDefinition(session: IBasicSession, nodeId: NodeId): Promise<DataTypeDefinition | null>;
|
|
8
|
+
export declare function getBrowseName(session: IBasicSession, nodeId: NodeId): Promise<QualifiedName>;
|
|
9
|
+
export declare function getIsAbstract(session: IBasicSession, nodeId: NodeId): Promise<boolean>;
|
|
10
|
+
export declare function getDescription(session: IBasicSession, nodeId: NodeId): Promise<LocalizedText>;
|
|
11
|
+
export declare function getNodeClass(session: IBasicSession, nodeId: NodeId): Promise<NodeClass>;
|
|
12
|
+
export declare function getChildren(session: IBasicSession, nodeId: NodeId): Promise<ReferenceDescription[]>;
|
|
13
|
+
export declare function getFolderElements(session: IBasicSession, nodeId: NodeId): Promise<ReferenceDescription[]>;
|
|
14
|
+
export declare function getModellingRule(session: IBasicSession, nodeId: NodeId): Promise<ModellingRuleType | null>;
|
|
15
|
+
export declare function getSubtypeNodeIdIfAny(session: IBasicSession, nodeId: NodeId): Promise<ReferenceDescription | null>;
|
|
16
|
+
export declare function getSubtypeNodeId(session: IBasicSession, nodeId: NodeId): Promise<ReferenceDescription>;
|
|
17
|
+
export declare function getTypeDefOrBaseType(session: IBasicSession, nodeId: NodeId): Promise<ReferenceDescription>;
|
|
18
|
+
export declare function getTypeDefinition(session: IBasicSession, nodeId: NodeId): Promise<ReferenceDescription>;
|
|
19
|
+
export declare function convertNodeIdToDataTypeAsync(session: IBasicSession, dataTypeId: NodeId): Promise<DataType>;
|
|
20
|
+
export declare function getChildrenOrFolderElements(session: IBasicSession, nodeId: NodeId): Promise<ReferenceDescription[]>;
|