node-opcua-address-space 2.177.0 → 2.179.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/dist/source/address_space_ts.d.ts +16 -6
- package/dist/source/address_space_ts.js +1 -1
- package/dist/source/address_space_ts.js.map +1 -1
- package/dist/source/helpers/argument_list.js +2 -2
- package/dist/source/helpers/argument_list.js.map +1 -1
- package/dist/source/helpers/call_helpers.js +3 -0
- package/dist/source/helpers/call_helpers.js.map +1 -1
- package/dist/source/helpers/dump_tools.js +6 -2
- package/dist/source/helpers/dump_tools.js.map +1 -1
- package/dist/source/helpers/make_optionals_map.d.ts +3 -1
- package/dist/source/helpers/make_optionals_map.js.map +1 -1
- package/dist/source/interfaces/extension_object_constructor.d.ts +1 -1
- package/dist/source/interfaces/state_machine/ua_state_machine_type.js +0 -1
- package/dist/source/interfaces/state_machine/ua_state_machine_type.js.map +1 -1
- package/dist/source/loader/decode_xml_extension_object.js.map +1 -1
- package/dist/source/loader/ensure_datatype_extracted.js.map +1 -1
- package/dist/source/loader/generateAddressSpaceRaw.js +2 -1
- package/dist/source/loader/generateAddressSpaceRaw.js.map +1 -1
- package/dist/source/loader/load_nodeset2.js +39 -17
- package/dist/source/loader/load_nodeset2.js.map +1 -1
- package/dist/source/loader/make_xml_extension_object_parser.js +26 -7
- package/dist/source/loader/make_xml_extension_object_parser.js.map +1 -1
- package/dist/source/loader/namespace_post_step.js.map +1 -1
- package/dist/source/loader/parsers/extension_object_parser.d.ts +6 -4
- package/dist/source/loader/parsers/extension_object_parser.js +12 -6
- package/dist/source/loader/parsers/extension_object_parser.js.map +1 -1
- package/dist/source/loader/parsers/localized_text_parser.d.ts +1 -1
- package/dist/source/loader/parsers/nodeid_parser.d.ts +10 -2
- package/dist/source/loader/parsers/nodeid_parser.js.map +1 -1
- package/dist/source/loader/parsers/qualified_name_parser.d.ts +1 -2
- package/dist/source/loader/parsers/variant_parser.d.ts +8 -2
- package/dist/source/loader/parsers/variant_parser.js +11 -8
- package/dist/source/loader/parsers/variant_parser.js.map +1 -1
- package/dist/source/pseudo_session.js +70 -24
- package/dist/source/pseudo_session.js.map +1 -1
- package/dist/source/session_context.js.map +1 -1
- package/dist/source/xml_writer.d.ts +1 -1
- package/dist/src/_instantiate_helpers.js +0 -3
- package/dist/src/_instantiate_helpers.js.map +1 -1
- package/dist/src/_mandatory_child_or_requested_optional_filter.d.ts +3 -2
- package/dist/src/_mandatory_child_or_requested_optional_filter.js +0 -2
- package/dist/src/_mandatory_child_or_requested_optional_filter.js.map +1 -1
- package/dist/src/address_space.d.ts +7 -2
- package/dist/src/address_space.js +39 -25
- package/dist/src/address_space.js.map +1 -1
- package/dist/src/address_space_private.d.ts +1 -0
- package/dist/src/alarms_and_conditions/condition_snapshot_impl.js +6 -9
- package/dist/src/alarms_and_conditions/condition_snapshot_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js +6 -6
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js +8 -4
- package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_condition_impl.js +6 -5
- package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.js +3 -0
- package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.js +0 -1
- package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.js.map +1 -1
- package/dist/src/base_node_impl.js +17 -8
- package/dist/src/base_node_impl.js.map +1 -1
- package/dist/src/base_node_private.js +0 -6
- package/dist/src/base_node_private.js.map +1 -1
- package/dist/src/extension_object_array_node.d.ts +9 -1
- package/dist/src/extension_object_array_node.js +20 -3
- package/dist/src/extension_object_array_node.js.map +1 -1
- package/dist/src/get_basic_datatype.js +3 -1
- package/dist/src/get_basic_datatype.js.map +1 -1
- package/dist/src/historical_access/address_space_historical_data_node.js +2 -4
- package/dist/src/historical_access/address_space_historical_data_node.js.map +1 -1
- package/dist/src/namespace_impl.js +6 -5
- package/dist/src/namespace_impl.js.map +1 -1
- package/dist/src/nodeid_manager.js +4 -5
- package/dist/src/nodeid_manager.js.map +1 -1
- package/dist/src/nodeset_tools/construct_namespace_dependency.js +10 -11
- package/dist/src/nodeset_tools/construct_namespace_dependency.js.map +1 -1
- package/dist/src/nodeset_tools/dump_to_bsd.js +2 -4
- package/dist/src/nodeset_tools/dump_to_bsd.js.map +1 -1
- package/dist/src/nodeset_tools/nodeset_to_xml.d.ts +1 -1
- package/dist/src/nodeset_tools/nodeset_to_xml.js +71 -43
- package/dist/src/nodeset_tools/nodeset_to_xml.js.map +1 -1
- package/dist/src/private_namespace.js.map +1 -1
- package/dist/src/reference_impl.d.ts +2 -2
- package/dist/src/reference_impl.js +5 -4
- package/dist/src/reference_impl.js.map +1 -1
- package/dist/src/state_machine/finite_state_machine.js +1 -1
- package/dist/src/state_machine/finite_state_machine.js.map +1 -1
- package/dist/src/state_machine/ua_shelving_state_machine_ex.js.map +1 -1
- package/dist/src/state_machine/ua_two_state_variable.js +9 -7
- package/dist/src/state_machine/ua_two_state_variable.js.map +1 -1
- package/dist/src/tool_isSubtypeOf.js.map +1 -1
- package/dist/src/ua_data_type_impl.js +4 -4
- package/dist/src/ua_data_type_impl.js.map +1 -1
- package/dist/src/ua_method_impl.js +21 -11
- package/dist/src/ua_method_impl.js.map +1 -1
- package/dist/src/ua_object_type_impl.d.ts +5 -2
- package/dist/src/ua_object_type_impl.js +4 -3
- package/dist/src/ua_object_type_impl.js.map +1 -1
- package/dist/src/ua_reference_type_impl.js +1 -2
- package/dist/src/ua_reference_type_impl.js.map +1 -1
- package/dist/src/ua_variable_impl.d.ts +9 -11
- package/dist/src/ua_variable_impl.js +103 -65
- package/dist/src/ua_variable_impl.js.map +1 -1
- package/dist/src/ua_variable_impl_ext_obj.d.ts +6 -6
- package/dist/src/ua_variable_impl_ext_obj.js +33 -22
- package/dist/src/ua_variable_impl_ext_obj.js.map +1 -1
- package/dist/src/ua_variable_type_impl.js +6 -2
- package/dist/src/ua_variable_type_impl.js.map +1 -1
- package/dist/tsconfig_base.tsbuildinfo +1 -1
- package/distHelpers/add_event_generator_object.js +3 -0
- package/distHelpers/add_event_generator_object.js.map +1 -1
- package/distHelpers/boiler_system.js +27 -6
- package/distHelpers/boiler_system.js.map +1 -1
- package/distHelpers/create_minimalist_address_space_nodeset.js +3 -3
- package/distHelpers/create_minimalist_address_space_nodeset.js.map +1 -1
- package/distHelpers/date_utils.js.map +1 -1
- package/distHelpers/dump_statemachine.js +1 -1
- package/distHelpers/dump_statemachine.js.map +1 -1
- package/distHelpers/get_address_space_fixture.js +0 -1
- package/distHelpers/get_address_space_fixture.js.map +1 -1
- package/package.json +41 -41
- package/source/address_space_ts.ts +19 -9
- package/source/helpers/argument_list.ts +2 -2
- package/source/helpers/call_helpers.ts +4 -1
- package/source/helpers/dump_tools.ts +7 -3
- package/source/helpers/make_optionals_map.ts +4 -2
- package/source/interfaces/alarms_and_conditions/ua_acknowledgeable_condition_ex.ts +4 -3
- package/source/interfaces/alarms_and_conditions/ua_alarm_condition_ex.ts +10 -11
- package/source/interfaces/alarms_and_conditions/ua_condition_ex.ts +6 -7
- package/source/interfaces/extension_object_constructor.ts +1 -1
- package/source/interfaces/state_machine/ua_program_state_machine_type.ts +0 -1
- package/source/interfaces/state_machine/ua_state_machine_type.ts +0 -1
- package/source/loader/decode_xml_extension_object.ts +3 -3
- package/source/loader/ensure_datatype_extracted.ts +6 -2
- package/source/loader/generateAddressSpaceRaw.ts +5 -4
- package/source/loader/load_nodeset2.ts +45 -18
- package/source/loader/make_xml_extension_object_parser.ts +78 -45
- package/source/loader/namespace_post_step.ts +1 -1
- package/source/loader/parsers/extension_object_parser.ts +36 -27
- package/source/loader/parsers/localized_text_parser.ts +1 -1
- package/source/loader/parsers/nodeid_parser.ts +10 -2
- package/source/loader/parsers/qualified_name_parser.ts +1 -1
- package/source/loader/parsers/variant_parser.ts +53 -40
- package/source/pseudo_session.ts +81 -28
- package/source/session_context.ts +1 -0
- package/source/xml_writer.ts +1 -1
- package/src/_instantiate_helpers.ts +0 -3
- package/src/_mandatory_child_or_requested_optional_filter.ts +3 -4
- package/src/address_space.ts +64 -40
- package/src/address_space_private.ts +2 -0
- package/src/alarms_and_conditions/condition_snapshot_impl.ts +6 -10
- package/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.ts +5 -7
- package/src/alarms_and_conditions/ua_alarm_condition_impl.ts +20 -13
- package/src/alarms_and_conditions/ua_base_event_impl.ts +1 -1
- package/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.ts +1 -1
- package/src/alarms_and_conditions/ua_condition_impl.ts +12 -10
- package/src/alarms_and_conditions/ua_discrete_alarm_impl.ts +8 -5
- package/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.ts +0 -1
- package/src/alarms_and_conditions/ua_off_normal_alarm_impl.ts +0 -1
- package/src/apply_condition_refresh.ts +1 -1
- package/src/base_node_impl.ts +30 -35
- package/src/base_node_private.ts +0 -6
- package/src/extension_object_array_node.ts +44 -15
- package/src/get_basic_datatype.ts +4 -1
- package/src/historical_access/address_space_historical_data_node.ts +2 -5
- package/src/namespace_impl.ts +24 -17
- package/src/nodeid_manager.ts +8 -11
- package/src/nodeset_tools/construct_namespace_dependency.ts +18 -15
- package/src/nodeset_tools/dump_to_bsd.ts +6 -8
- package/src/nodeset_tools/nodeset_to_xml.ts +105 -75
- package/src/private_namespace.ts +7 -2
- package/src/reference_impl.ts +11 -10
- package/src/state_machine/finite_state_machine.ts +12 -10
- package/src/state_machine/ua_shelving_state_machine_ex.ts +4 -4
- package/src/state_machine/ua_two_state_variable.ts +12 -9
- package/src/tool_isSubtypeOf.ts +2 -9
- package/src/ua_data_type_impl.ts +4 -4
- package/src/ua_method_impl.ts +24 -14
- package/src/ua_object_type_impl.ts +12 -6
- package/src/ua_reference_type_impl.ts +2 -3
- package/src/ua_variable_impl.ts +142 -96
- package/src/ua_variable_impl_ext_obj.ts +110 -82
- package/src/ua_variable_type_impl.ts +17 -5
package/source/pseudo_session.ts
CHANGED
|
@@ -150,17 +150,24 @@ export class PseudoSession implements IBasicSession {
|
|
|
150
150
|
public browse(nodesToBrowse: BrowseDescriptionLike[], callback: ResponseCallback<BrowseResult[]>): void;
|
|
151
151
|
public browse(nodeToBrowse: BrowseDescriptionLike): Promise<BrowseResult>;
|
|
152
152
|
public browse(nodesToBrowse: BrowseDescriptionLike[]): Promise<BrowseResult[]>;
|
|
153
|
-
public browse(
|
|
153
|
+
public browse(
|
|
154
|
+
nodesToBrowse: BrowseDescriptionLike | BrowseDescriptionLike[],
|
|
155
|
+
callback?: ResponseCallback<BrowseResult> | ResponseCallback<BrowseResult[]>
|
|
156
|
+
// biome-ignore lint/suspicious/noConfusingVoidType: implementation must satisfy both the void (callback) and Promise<T> (thenify-wrapped) overloads; biome's suggested undefined-in-union fix breaks the "not all code paths return a value" check
|
|
157
|
+
): void | Promise<BrowseResult> | Promise<BrowseResult[]> {
|
|
154
158
|
const isArray = Array.isArray(nodesToBrowse);
|
|
155
159
|
if (!isArray) {
|
|
156
|
-
|
|
157
|
-
|
|
160
|
+
const callbackSingle = callback as ResponseCallback<BrowseResult> | undefined;
|
|
161
|
+
this.browse([nodesToBrowse as BrowseDescriptionLike], (err, results) => {
|
|
162
|
+
callbackSingle?.(err, results ? results[0] : undefined);
|
|
158
163
|
});
|
|
164
|
+
return;
|
|
159
165
|
}
|
|
166
|
+
const callbackArray = callback as ResponseCallback<BrowseResult[]> | undefined;
|
|
160
167
|
const browseAll = (nodesToBrowse: BrowseDescriptionOptions[], callack: ResponseCallback<BrowseResult[]>) => {
|
|
161
168
|
const results: BrowseResult[] = [];
|
|
162
169
|
for (const browseDescription of nodesToBrowse as BrowseDescriptionOptions[]) {
|
|
163
|
-
browseDescription.referenceTypeId = resolveNodeId(browseDescription.referenceTypeId
|
|
170
|
+
browseDescription.referenceTypeId = resolveNodeId(browseDescription.referenceTypeId || NodeId.nullNodeId);
|
|
164
171
|
const _browseDescription = coerceBrowseDescription(browseDescription);
|
|
165
172
|
const nodeId = resolveNodeId(_browseDescription.nodeId);
|
|
166
173
|
const r = this[$addressSpace].browseSingleNode(nodeId, _browseDescription, this[$context]);
|
|
@@ -179,7 +186,7 @@ export class PseudoSession implements IBasicSession {
|
|
|
179
186
|
maxBrowseContinuationPoints: this.maxBrowseContinuationPoints
|
|
180
187
|
},
|
|
181
188
|
nodesToBrowse as BrowseDescriptionOptions[],
|
|
182
|
-
|
|
189
|
+
callbackArray
|
|
183
190
|
);
|
|
184
191
|
});
|
|
185
192
|
}
|
|
@@ -188,7 +195,11 @@ export class PseudoSession implements IBasicSession {
|
|
|
188
195
|
public read(nodesToRead: ReadValueIdOptions[], callback: ResponseCallback<DataValue[]>): void;
|
|
189
196
|
public read(nodeToRead: ReadValueIdOptions): Promise<DataValue>;
|
|
190
197
|
public read(nodesToRead: ReadValueIdOptions[]): Promise<DataValue[]>;
|
|
191
|
-
public read(
|
|
198
|
+
public read(
|
|
199
|
+
nodesToRead: ReadValueIdOptions[] | ReadValueIdOptions,
|
|
200
|
+
callback?: ResponseCallback<DataValue> | ResponseCallback<DataValue[]>
|
|
201
|
+
// biome-ignore lint/suspicious/noConfusingVoidType: implementation must satisfy both the void (callback) and Promise<T> (thenify-wrapped) overloads; biome's suggested undefined-in-union fix breaks the "not all code paths return a value" check
|
|
202
|
+
): void | Promise<DataValue> | Promise<DataValue[]> {
|
|
192
203
|
const isArray = Array.isArray(nodesToRead);
|
|
193
204
|
if (!isArray) {
|
|
194
205
|
nodesToRead = [nodesToRead as ReadValueIdOptions];
|
|
@@ -197,7 +208,10 @@ export class PseudoSession implements IBasicSession {
|
|
|
197
208
|
const context = this[$context];
|
|
198
209
|
|
|
199
210
|
const readV = async (nodeToRead: ReadValueIdOptions): Promise<DataValue> => {
|
|
200
|
-
|
|
211
|
+
if (!nodeToRead.nodeId) {
|
|
212
|
+
return new DataValue({ statusCode: StatusCodes.BadNodeIdUnknown });
|
|
213
|
+
}
|
|
214
|
+
const obj = this[$addressSpace].findNode(nodeToRead.nodeId);
|
|
201
215
|
if (!obj) {
|
|
202
216
|
return new DataValue({ statusCode: StatusCodes.BadNodeIdUnknown });
|
|
203
217
|
}
|
|
@@ -206,15 +220,23 @@ export class PseudoSession implements IBasicSession {
|
|
|
206
220
|
return await (obj as UAVariable).readValueAsync(context);
|
|
207
221
|
}
|
|
208
222
|
assert(!!nodeToRead.nodeId, "expecting a nodeId");
|
|
209
|
-
|
|
210
|
-
|
|
223
|
+
if (!nodeToRead.attributeId) {
|
|
224
|
+
throw new Error("expecting a attributeId");
|
|
225
|
+
}
|
|
226
|
+
const attributeId = nodeToRead.attributeId;
|
|
211
227
|
const indexRange = nodeToRead.indexRange;
|
|
212
228
|
const dataEncoding = nodeToRead.dataEncoding;
|
|
213
229
|
const dataValue = obj.readAttribute(context, attributeId, indexRange, dataEncoding);
|
|
214
230
|
return dataValue;
|
|
215
231
|
};
|
|
216
232
|
Promise.all(_nodesToRead.map(async (nodeToRead: ReadValueIdOptions) => await readV(nodeToRead)))
|
|
217
|
-
.then((dataValues) =>
|
|
233
|
+
.then((dataValues) => {
|
|
234
|
+
if (isArray) {
|
|
235
|
+
(callback as ResponseCallback<DataValue[]> | undefined)?.(null, dataValues);
|
|
236
|
+
} else {
|
|
237
|
+
(callback as ResponseCallback<DataValue> | undefined)?.(null, dataValues[0]);
|
|
238
|
+
}
|
|
239
|
+
})
|
|
218
240
|
.catch((err) => callback?.(err));
|
|
219
241
|
}
|
|
220
242
|
|
|
@@ -236,22 +258,26 @@ export class PseudoSession implements IBasicSession {
|
|
|
236
258
|
public browseNext(
|
|
237
259
|
continuationPoints: Buffer | Buffer[],
|
|
238
260
|
releaseContinuationPoints: boolean,
|
|
239
|
-
callback?: ResponseCallback<
|
|
240
|
-
|
|
261
|
+
callback?: ResponseCallback<BrowseResult> | ResponseCallback<BrowseResult[]>
|
|
262
|
+
// biome-ignore lint/suspicious/noConfusingVoidType: implementation must satisfy both the void (callback) and Promise<T> (thenify-wrapped) overloads; biome's suggested undefined-in-union fix breaks the "not all code paths return a value" check
|
|
263
|
+
): void | Promise<BrowseResult> | Promise<BrowseResult[]> {
|
|
241
264
|
setImmediate(() => {
|
|
242
265
|
if (continuationPoints instanceof Buffer) {
|
|
243
|
-
|
|
266
|
+
const callbackSingle = callback as ResponseCallback<BrowseResult> | undefined;
|
|
267
|
+
this.browseNext([continuationPoints], releaseContinuationPoints, (err, _results) => {
|
|
244
268
|
if (err) {
|
|
245
|
-
|
|
269
|
+
callbackSingle?.(err);
|
|
270
|
+
return;
|
|
246
271
|
}
|
|
247
|
-
|
|
272
|
+
callbackSingle?.(null, _results?.[0]);
|
|
248
273
|
});
|
|
274
|
+
return;
|
|
249
275
|
}
|
|
250
276
|
innerBrowseNext(
|
|
251
277
|
{ continuationPointManager: this.continuationPointManager },
|
|
252
278
|
continuationPoints as Buffer[],
|
|
253
279
|
releaseContinuationPoints,
|
|
254
|
-
callback
|
|
280
|
+
callback as ResponseCallback<BrowseResult[]> | undefined
|
|
255
281
|
);
|
|
256
282
|
});
|
|
257
283
|
}
|
|
@@ -261,7 +287,11 @@ export class PseudoSession implements IBasicSession {
|
|
|
261
287
|
public call(methodsToCall: CallMethodRequestLike[], callback: ResponseCallback<CallMethodResult[]>): void;
|
|
262
288
|
public call(methodToCall: CallMethodRequestLike): Promise<CallMethodResult>;
|
|
263
289
|
public call(methodsToCall: CallMethodRequestLike[]): Promise<CallMethodResult[]>;
|
|
264
|
-
public call(
|
|
290
|
+
public call(
|
|
291
|
+
methodsToCall: CallMethodRequestLike | CallMethodRequestLike[],
|
|
292
|
+
callback?: ResponseCallback<CallMethodResult> | ResponseCallback<CallMethodResult[]>
|
|
293
|
+
// biome-ignore lint/suspicious/noConfusingVoidType: implementation must satisfy both the void (callback) and Promise<T> (thenify-wrapped) overloads; biome's suggested undefined-in-union fix breaks the "not all code paths return a value" check
|
|
294
|
+
): void | Promise<CallMethodResult> | Promise<CallMethodResult[]> {
|
|
265
295
|
const isArray = Array.isArray(methodsToCall);
|
|
266
296
|
if (!isArray) {
|
|
267
297
|
methodsToCall = [methodsToCall as CallMethodRequestLike];
|
|
@@ -281,7 +311,11 @@ export class PseudoSession implements IBasicSession {
|
|
|
281
311
|
})
|
|
282
312
|
)
|
|
283
313
|
.then((callMethodResults) => {
|
|
284
|
-
|
|
314
|
+
if (isArray) {
|
|
315
|
+
(callback as ResponseCallback<CallMethodResult[]> | undefined)?.(null, callMethodResults);
|
|
316
|
+
} else {
|
|
317
|
+
(callback as ResponseCallback<CallMethodResult> | undefined)?.(null, callMethodResults[0]);
|
|
318
|
+
}
|
|
285
319
|
})
|
|
286
320
|
.catch((err) => {
|
|
287
321
|
callback?.(err);
|
|
@@ -290,7 +324,11 @@ export class PseudoSession implements IBasicSession {
|
|
|
290
324
|
|
|
291
325
|
public getArgumentDefinition(methodId: MethodId): Promise<ArgumentDefinition>;
|
|
292
326
|
public getArgumentDefinition(methodId: MethodId, callback: ResponseCallback<ArgumentDefinition>): void;
|
|
293
|
-
public getArgumentDefinition(
|
|
327
|
+
public getArgumentDefinition(
|
|
328
|
+
methodId: MethodId,
|
|
329
|
+
callback?: ResponseCallback<ArgumentDefinition>
|
|
330
|
+
// biome-ignore lint/suspicious/noConfusingVoidType: implementation must satisfy both the void (callback) and Promise<T> (thenify-wrapped) overloads; biome's suggested undefined-in-union fix breaks the "not all code paths return a value" check
|
|
331
|
+
): void | Promise<ArgumentDefinition> {
|
|
294
332
|
getArgumentDefinitionHelper(this, methodId)
|
|
295
333
|
.then((result) => {
|
|
296
334
|
callback?.(null, result);
|
|
@@ -304,7 +342,11 @@ export class PseudoSession implements IBasicSession {
|
|
|
304
342
|
public translateBrowsePath(browsePath: BrowsePath, callback: ResponseCallback<BrowsePathResult>): void;
|
|
305
343
|
public translateBrowsePath(browsePath: BrowsePath): Promise<BrowsePathResult>;
|
|
306
344
|
public translateBrowsePath(browsePaths: BrowsePath[]): Promise<BrowsePathResult[]>;
|
|
307
|
-
public translateBrowsePath(
|
|
345
|
+
public translateBrowsePath(
|
|
346
|
+
browsePaths: BrowsePath[] | BrowsePath,
|
|
347
|
+
callback?: ResponseCallback<BrowsePathResult> | ResponseCallback<BrowsePathResult[]>
|
|
348
|
+
// biome-ignore lint/suspicious/noConfusingVoidType: implementation must satisfy both the void (callback) and Promise<T> (thenify-wrapped) overloads; biome's suggested undefined-in-union fix breaks the "not all code paths return a value" check
|
|
349
|
+
): void | Promise<BrowsePathResult> | Promise<BrowsePathResult[]> {
|
|
308
350
|
const isArray = Array.isArray(browsePaths);
|
|
309
351
|
if (!isArray) {
|
|
310
352
|
browsePaths = [browsePaths as BrowsePath];
|
|
@@ -312,23 +354,32 @@ export class PseudoSession implements IBasicSession {
|
|
|
312
354
|
const browsePathResults = (browsePaths as BrowsePath[]).map((browsePath: BrowsePath) => {
|
|
313
355
|
return this[$addressSpace].browsePath(browsePath);
|
|
314
356
|
});
|
|
315
|
-
|
|
357
|
+
if (isArray) {
|
|
358
|
+
(callback as ResponseCallback<BrowsePathResult[]> | undefined)?.(null, browsePathResults);
|
|
359
|
+
} else {
|
|
360
|
+
(callback as ResponseCallback<BrowsePathResult> | undefined)?.(null, browsePathResults[0]);
|
|
361
|
+
}
|
|
316
362
|
}
|
|
317
363
|
public write(nodeToWrite: WriteValueOptions, callback: ResponseCallback<StatusCode>): void;
|
|
318
364
|
public write(nodesToWrite: WriteValueOptions[], callback: ResponseCallback<StatusCode[]>): void;
|
|
319
365
|
public write(nodeToWrite: WriteValueOptions): Promise<StatusCode>;
|
|
320
366
|
public write(nodesToWrite: WriteValueOptions[]): Promise<StatusCode[]>;
|
|
321
|
-
public write(
|
|
367
|
+
public write(
|
|
368
|
+
nodesToWrite: WriteValueOptions[] | WriteValueOptions,
|
|
369
|
+
callback?: ResponseCallback<StatusCode> | ResponseCallback<StatusCode[]>
|
|
370
|
+
// biome-ignore lint/suspicious/noConfusingVoidType: implementation must satisfy both the void (callback) and Promise<T> (thenify-wrapped) overloads; biome's suggested undefined-in-union fix breaks the "not all code paths return a value" check
|
|
371
|
+
): void | Promise<StatusCode> | Promise<StatusCode[]> {
|
|
322
372
|
const isArray = Array.isArray(nodesToWrite);
|
|
323
373
|
const _nodesToWrite: WriteValueOptions[] = !isArray ? [nodesToWrite] : nodesToWrite;
|
|
324
374
|
const context = this[$context];
|
|
325
375
|
setImmediate(() => {
|
|
326
376
|
const statusCodesPromises = _nodesToWrite.map((nodeToWrite: WriteValueOptions) => {
|
|
327
|
-
assert(!!nodeToWrite.nodeId, "expecting a nodeId");
|
|
328
377
|
assert(!!nodeToWrite.attributeId, "expecting a attributeId");
|
|
329
378
|
|
|
330
|
-
|
|
331
|
-
|
|
379
|
+
if (!nodeToWrite.nodeId) {
|
|
380
|
+
return StatusCodes.BadNodeIdUnknown;
|
|
381
|
+
}
|
|
382
|
+
const obj = this[$addressSpace].findNode(nodeToWrite.nodeId);
|
|
332
383
|
if (!obj) {
|
|
333
384
|
return StatusCodes.BadNodeIdUnknown;
|
|
334
385
|
}
|
|
@@ -340,7 +391,11 @@ export class PseudoSession implements IBasicSession {
|
|
|
340
391
|
});
|
|
341
392
|
Promise.all(statusCodesPromises)
|
|
342
393
|
.then((statusCodes) => {
|
|
343
|
-
|
|
394
|
+
if (isArray) {
|
|
395
|
+
(callback as ResponseCallback<StatusCode[]> | undefined)?.(null, statusCodes as StatusCode[]);
|
|
396
|
+
} else {
|
|
397
|
+
(callback as ResponseCallback<StatusCode> | undefined)?.(null, statusCodes[0]);
|
|
398
|
+
}
|
|
344
399
|
})
|
|
345
400
|
.catch((err) => {
|
|
346
401
|
callback?.(err);
|
|
@@ -349,8 +404,6 @@ export class PseudoSession implements IBasicSession {
|
|
|
349
404
|
}
|
|
350
405
|
}
|
|
351
406
|
|
|
352
|
-
// tslint:disable:no-var-requires
|
|
353
|
-
// tslint:disable:max-line-length
|
|
354
407
|
import { withCallback } from "thenify-ex";
|
|
355
408
|
|
|
356
409
|
PseudoSession.prototype.read = withCallback(PseudoSession.prototype.read);
|
|
@@ -70,6 +70,7 @@ function getUserName(userIdentityToken: AnyUserIdentityToken): string {
|
|
|
70
70
|
// The canonical definition now lives in node-opcua-constants so that
|
|
71
71
|
// client-side packages can use it without pulling in address-space.
|
|
72
72
|
import { WellKnownRoles } from "node-opcua-constants";
|
|
73
|
+
|
|
73
74
|
export { WellKnownRoles } from "node-opcua-constants";
|
|
74
75
|
|
|
75
76
|
/** @deprecated Use WellKnownRoles instead */
|
package/source/xml_writer.ts
CHANGED
|
@@ -3,7 +3,7 @@ export type TranslationTable = Map<number, number>;
|
|
|
3
3
|
export interface XmlWriter {
|
|
4
4
|
translationTable: TranslationTable;
|
|
5
5
|
priorityTable: number[];
|
|
6
|
-
visitedNode: Set<
|
|
6
|
+
visitedNode: Set<string>;
|
|
7
7
|
|
|
8
8
|
startDocument(options: { encoding: string; version: string }): void;
|
|
9
9
|
startElement(elementName: string): this;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module node-opcua-address-space
|
|
3
3
|
*/
|
|
4
|
-
// tslint:disable:max-classes-per-file
|
|
5
|
-
// tslint:disable:no-console
|
|
6
4
|
import chalk from "chalk";
|
|
7
5
|
import {
|
|
8
6
|
CloneHelper,
|
|
@@ -26,7 +24,6 @@ import { _clone_hierarchical_references } from "./base_node_private";
|
|
|
26
24
|
const warningLog = make_warningLog("INSTANTIATE");
|
|
27
25
|
const errorLog = make_errorLog("INSTANTIATE");
|
|
28
26
|
|
|
29
|
-
// eslint-disable-next-line prefer-const
|
|
30
27
|
const doTrace = checkDebugFlag("INSTANTIATE");
|
|
31
28
|
const traceLog = errorLog;
|
|
32
29
|
|
|
@@ -18,20 +18,19 @@ const errorLog = make_errorLog(__filename);
|
|
|
18
18
|
const doTrace = checkDebugFlag("INSTANTIATE");
|
|
19
19
|
const traceLog = errorLog;
|
|
20
20
|
|
|
21
|
-
export
|
|
21
|
+
export interface OptionalMap {
|
|
22
|
+
[key: string]: OptionalMap;
|
|
23
|
+
}
|
|
22
24
|
export class MandatoryChildOrRequestedOptionalFilter implements CloneFilter {
|
|
23
25
|
private readonly optionalsMap: OptionalMap;
|
|
24
26
|
private readonly references: UAReference[];
|
|
25
27
|
private readonly copyAlsoAllOptionals: boolean = false;
|
|
26
28
|
|
|
27
|
-
private readonly _instance: BaseNode;
|
|
28
|
-
|
|
29
29
|
constructor(instance: BaseNode, copyAlsoAllOptionals: boolean, optionalsMap: OptionalMap) {
|
|
30
30
|
this.copyAlsoAllOptionals = copyAlsoAllOptionals;
|
|
31
31
|
// should we clone the node to be a component or propertyOf of a instance
|
|
32
32
|
assert(null !== instance);
|
|
33
33
|
this.optionalsMap = optionalsMap;
|
|
34
|
-
this._instance = instance;
|
|
35
34
|
this.references = instance.findReferencesEx("Aggregates", BrowseDirection.Forward);
|
|
36
35
|
}
|
|
37
36
|
|
package/src/address_space.ts
CHANGED
|
@@ -9,6 +9,8 @@ import type {
|
|
|
9
9
|
IEventData,
|
|
10
10
|
IHistoricalDataNodeOptions,
|
|
11
11
|
ISessionContext,
|
|
12
|
+
IVariableHistorian,
|
|
13
|
+
IVariableHistorianOptions,
|
|
12
14
|
MethodCallInterceptor,
|
|
13
15
|
RaiseEventData,
|
|
14
16
|
ShutdownTask,
|
|
@@ -75,7 +77,6 @@ const errorLog = make_errorLog(__filename);
|
|
|
75
77
|
const debugLog = make_debugLog(__filename);
|
|
76
78
|
const warningLog = make_warningLog(__filename);
|
|
77
79
|
|
|
78
|
-
// tslint:disable-next-line:no-var-requires
|
|
79
80
|
const Dequeue = require("dequeue");
|
|
80
81
|
|
|
81
82
|
const regexNumberColumnString = /^([0-9]+):(.*)/;
|
|
@@ -152,6 +153,10 @@ function isNodeIdString(str: unknown): boolean {
|
|
|
152
153
|
*
|
|
153
154
|
* const addressSpace = AddressSpace.create();
|
|
154
155
|
*/
|
|
156
|
+
export interface IHistorizerFactory {
|
|
157
|
+
create(node: UAVariable, options: IVariableHistorianOptions): IVariableHistorian;
|
|
158
|
+
}
|
|
159
|
+
|
|
155
160
|
export class AddressSpace implements AddressSpacePrivate {
|
|
156
161
|
public get rootFolder(): UARootFolder {
|
|
157
162
|
const rootFolder = this.findNode(this.resolveNodeId("RootFolder"));
|
|
@@ -163,7 +168,7 @@ export class AddressSpace implements AddressSpacePrivate {
|
|
|
163
168
|
}
|
|
164
169
|
|
|
165
170
|
public static isNonEmptyQualifiedName = isNonEmptyQualifiedName;
|
|
166
|
-
public static historizerFactory?:
|
|
171
|
+
public static historizerFactory?: IHistorizerFactory;
|
|
167
172
|
|
|
168
173
|
public static create(): AddressSpace {
|
|
169
174
|
return new AddressSpace();
|
|
@@ -184,6 +189,8 @@ export class AddressSpace implements AddressSpacePrivate {
|
|
|
184
189
|
private readonly _private_namespaceIndex: number;
|
|
185
190
|
private readonly _namespaceArray: NamespacePrivate[];
|
|
186
191
|
private _shutdownTask?: ShutdownTask[];
|
|
192
|
+
private _eventIdCounter?: Buffer;
|
|
193
|
+
public $$extraDataTypeManager?: ExtraDataTypeManager;
|
|
187
194
|
private _modelChangeTransactionCounter = 0;
|
|
188
195
|
private _modelChanges: ModelChangeStructureDataType[] = [];
|
|
189
196
|
public _methodCallInterceptors: MethodCallInterceptor[] = [];
|
|
@@ -213,12 +220,10 @@ export class AddressSpace implements AddressSpacePrivate {
|
|
|
213
220
|
* @internal
|
|
214
221
|
*/
|
|
215
222
|
public getDataTypeManager(): ExtraDataTypeManager {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
);
|
|
221
|
-
return addressSpacePriv.$$extraDataTypeManager;
|
|
223
|
+
if (!this.$$extraDataTypeManager) {
|
|
224
|
+
throw new Error("expecting a $$extraDataTypeManager please make sure ensureDatatypeExtracted is called");
|
|
225
|
+
}
|
|
226
|
+
return this.$$extraDataTypeManager;
|
|
222
227
|
}
|
|
223
228
|
|
|
224
229
|
public getNamespaceUri(namespaceIndex: number): string {
|
|
@@ -283,7 +288,7 @@ export class AddressSpace implements AddressSpacePrivate {
|
|
|
283
288
|
public registerNamespace(namespaceUri: string): NamespacePrivate {
|
|
284
289
|
let index = this._namespaceArray.findIndex((ns) => ns.namespaceUri === namespaceUri);
|
|
285
290
|
if (index !== -1) {
|
|
286
|
-
assert(
|
|
291
|
+
assert(this._namespaceArray[index].addressSpace === this);
|
|
287
292
|
return this._namespaceArray[index];
|
|
288
293
|
}
|
|
289
294
|
index = this._namespaceArray.length;
|
|
@@ -454,7 +459,7 @@ export class AddressSpace implements AddressSpacePrivate {
|
|
|
454
459
|
if (dataType instanceof UADataTypeImpl) {
|
|
455
460
|
return this.findDataType(dataType.nodeId);
|
|
456
461
|
} else if (dataType instanceof NodeId) {
|
|
457
|
-
return _find_by_node_id<UADataType>(this, dataType
|
|
462
|
+
return _find_by_node_id<UADataType>(this, dataType, namespaceIndex);
|
|
458
463
|
}
|
|
459
464
|
if (typeof dataType === "number") {
|
|
460
465
|
if (DataType[dataType] !== undefined) {
|
|
@@ -492,11 +497,12 @@ export class AddressSpace implements AddressSpacePrivate {
|
|
|
492
497
|
}
|
|
493
498
|
|
|
494
499
|
if (dataTypeNode instanceof NodeId) {
|
|
495
|
-
|
|
500
|
+
const foundDataTypeNode = this.findDataType(dataTypeNode);
|
|
496
501
|
/* c8 ignore next */
|
|
497
|
-
if (!
|
|
502
|
+
if (!foundDataTypeNode) {
|
|
498
503
|
throw Error(`cannot find dataTypeNode ${_orig_dataTypeNode.toString()}`);
|
|
499
504
|
}
|
|
505
|
+
dataTypeNode = foundDataTypeNode;
|
|
500
506
|
}
|
|
501
507
|
/* c8 ignore next */
|
|
502
508
|
if (!(dataTypeNode instanceof UADataTypeImpl)) {
|
|
@@ -669,16 +675,15 @@ export class AddressSpace implements AddressSpacePrivate {
|
|
|
669
675
|
*
|
|
670
676
|
*/
|
|
671
677
|
const offset = 16;
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
self._eventIdCounter.writeInt32BE(0, offset);
|
|
678
|
+
if (!this._eventIdCounter) {
|
|
679
|
+
this._eventIdCounter = randomBytes(20);
|
|
680
|
+
this._eventIdCounter.writeInt32BE(0, offset);
|
|
676
681
|
}
|
|
677
|
-
|
|
682
|
+
this._eventIdCounter.writeInt32BE(this._eventIdCounter.readInt32BE(offset) + 1, offset);
|
|
678
683
|
|
|
679
684
|
return new Variant({
|
|
680
685
|
dataType: DataType.ByteString,
|
|
681
|
-
value: Buffer.from(
|
|
686
|
+
value: Buffer.from(this._eventIdCounter)
|
|
682
687
|
}) as VariantT<Buffer, DataType.ByteString>;
|
|
683
688
|
}
|
|
684
689
|
|
|
@@ -758,7 +763,7 @@ export class AddressSpace implements AddressSpacePrivate {
|
|
|
758
763
|
throw new Error("BaseObjectType must be defined in the address space");
|
|
759
764
|
}
|
|
760
765
|
|
|
761
|
-
const hasProperty = (data:
|
|
766
|
+
const hasProperty = (data: RaiseEventData, propertyName: string): boolean => Object.hasOwn(data, propertyName);
|
|
762
767
|
|
|
763
768
|
const visitedProperties: { [key: string]: number } = {};
|
|
764
769
|
const alreadyVisited = (key: string) => Object.hasOwn(visitedProperties, key);
|
|
@@ -781,7 +786,6 @@ export class AddressSpace implements AddressSpacePrivate {
|
|
|
781
786
|
// c8 ignore next
|
|
782
787
|
if (doDebug) {
|
|
783
788
|
if (node.modellingRule === "Mandatory") {
|
|
784
|
-
// tslint:disable:no-console
|
|
785
789
|
errorLog(
|
|
786
790
|
chalk.red("ERROR : AddressSpace#constructEventData(eventType,options) " + "cannot find property ") +
|
|
787
791
|
self.browseName.toString() +
|
|
@@ -822,7 +826,7 @@ export class AddressSpace implements AddressSpacePrivate {
|
|
|
822
826
|
});
|
|
823
827
|
}
|
|
824
828
|
|
|
825
|
-
const populate_data = (self:
|
|
829
|
+
const populate_data = (self: UAObjectType, eventData1: EventData) => {
|
|
826
830
|
if (sameNodeId(baseObjectType?.nodeId, self.nodeId)) {
|
|
827
831
|
return; // nothing to do
|
|
828
832
|
}
|
|
@@ -839,7 +843,8 @@ export class AddressSpace implements AddressSpacePrivate {
|
|
|
839
843
|
throw new Error(chalk.red("Cannot find object with nodeId ") + baseTypeNodeId);
|
|
840
844
|
}
|
|
841
845
|
|
|
842
|
-
|
|
846
|
+
// subtypeOf always points to another node in the ObjectType hierarchy
|
|
847
|
+
populate_data(baseType as UAObjectType, eventData1);
|
|
843
848
|
|
|
844
849
|
// get properties and components from base class
|
|
845
850
|
const properties = self.getProperties();
|
|
@@ -853,7 +858,7 @@ export class AddressSpace implements AddressSpacePrivate {
|
|
|
853
858
|
|
|
854
859
|
for (const node of children) {
|
|
855
860
|
// only keep those that have a "HasModellingRule"
|
|
856
|
-
if (!
|
|
861
|
+
if (!node.modellingRule) {
|
|
857
862
|
continue;
|
|
858
863
|
}
|
|
859
864
|
// ignore also methods
|
|
@@ -1022,13 +1027,26 @@ export class AddressSpace implements AddressSpacePrivate {
|
|
|
1022
1027
|
const _dataType = dataType as UADataTypeImpl;
|
|
1023
1028
|
|
|
1024
1029
|
// to do verify that dataType is of type "Structure"
|
|
1030
|
+
const structureDataType = this.findDataType("Structure");
|
|
1031
|
+
/* c8 ignore next */
|
|
1032
|
+
if (!structureDataType) {
|
|
1033
|
+
throw new Error("getExtensionObjectConstructor: cannot find 'Structure' DataType in standard address Space");
|
|
1034
|
+
}
|
|
1025
1035
|
/* c8 ignore next */
|
|
1026
|
-
if (!_dataType.isSubtypeOf(
|
|
1027
|
-
|
|
1036
|
+
if (!_dataType.isSubtypeOf(structureDataType)) {
|
|
1037
|
+
// c8 ignore next
|
|
1038
|
+
doDebug && debugLog(_dataType.toString());
|
|
1028
1039
|
}
|
|
1029
|
-
assert(_dataType.isSubtypeOf(
|
|
1040
|
+
assert(_dataType.isSubtypeOf(structureDataType));
|
|
1030
1041
|
if (!_dataType._extensionObjectConstructor) {
|
|
1031
|
-
|
|
1042
|
+
if (!this.$$extraDataTypeManager) {
|
|
1043
|
+
throw new Error(
|
|
1044
|
+
`getExtensionObjectConstructor: cannot build a constructor for ${_dataType.browseName.toString()} (${_dataType.nodeId.toString()}): ` +
|
|
1045
|
+
"the DataType manager is not initialised. " +
|
|
1046
|
+
"Make sure generateAddressSpace() completed successfully and/or that ensureDatatypeExtracted(addressSpace) was awaited before using structured DataTypes."
|
|
1047
|
+
);
|
|
1048
|
+
}
|
|
1049
|
+
const dataTypeManager = this.$$extraDataTypeManager;
|
|
1032
1050
|
_dataType._extensionObjectConstructor = dataTypeManager.getExtensionObjectConstructorFromDataType(
|
|
1033
1051
|
_dataType.nodeId
|
|
1034
1052
|
) as ExtensionObjectConstructorFuncWithSchema;
|
|
@@ -1145,7 +1163,7 @@ export class AddressSpace implements AddressSpacePrivate {
|
|
|
1145
1163
|
// check if referenceTypeId is correct
|
|
1146
1164
|
if (browseDescription.referenceTypeId instanceof NodeId) {
|
|
1147
1165
|
if (browseDescription.referenceTypeId.value === 0) {
|
|
1148
|
-
(browseDescription as
|
|
1166
|
+
(browseDescription as unknown as { referenceTypeId: NodeId | null }).referenceTypeId = null;
|
|
1149
1167
|
} else {
|
|
1150
1168
|
const rf = this.findNode(browseDescription.referenceTypeId);
|
|
1151
1169
|
if (!rf || !(rf instanceof UAReferenceTypeImpl)) {
|
|
@@ -1177,7 +1195,7 @@ export class AddressSpace implements AddressSpacePrivate {
|
|
|
1177
1195
|
if (folder && !_isFolder(this, folder)) {
|
|
1178
1196
|
throw new Error(`Parent folder must be of FolderType ${folder.typeDefinition.toString()}`);
|
|
1179
1197
|
}
|
|
1180
|
-
return folder
|
|
1198
|
+
return folder;
|
|
1181
1199
|
}
|
|
1182
1200
|
|
|
1183
1201
|
/**
|
|
@@ -1206,7 +1224,7 @@ export class AddressSpace implements AddressSpacePrivate {
|
|
|
1206
1224
|
public extractRootViews(node: UAObject | UAVariable): UAView[] {
|
|
1207
1225
|
assert(node.nodeClass === NodeClass.Object || node.nodeClass === NodeClass.Variable);
|
|
1208
1226
|
|
|
1209
|
-
const visitedMap:
|
|
1227
|
+
const visitedMap: Record<string, BaseNode> = {};
|
|
1210
1228
|
|
|
1211
1229
|
const q = new Dequeue();
|
|
1212
1230
|
q.push(node);
|
|
@@ -1267,9 +1285,9 @@ export class AddressSpace implements AddressSpacePrivate {
|
|
|
1267
1285
|
|
|
1268
1286
|
// https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore
|
|
1269
1287
|
// const nodeIds = _.uniq(this._modelChanges.map((c: any) => c.affected));
|
|
1270
|
-
const nodeIds = [...new Set(this._modelChanges.map((c
|
|
1288
|
+
const nodeIds = [...new Set(this._modelChanges.map((c) => c.affected))];
|
|
1271
1289
|
|
|
1272
|
-
const nodes = nodeIds.map((nodeId: NodeId) => this.findNode(nodeId)
|
|
1290
|
+
const nodes = nodeIds.map((nodeId: NodeId) => this.findNode(nodeId));
|
|
1273
1291
|
|
|
1274
1292
|
nodes.forEach(_increase_version_number);
|
|
1275
1293
|
// raise events
|
|
@@ -1352,8 +1370,9 @@ export class AddressSpace implements AddressSpacePrivate {
|
|
|
1352
1370
|
} else {
|
|
1353
1371
|
let _nodeId = params.nodeId as NodeId;
|
|
1354
1372
|
assert(!!_nodeId, "missing 'nodeId' in reference");
|
|
1355
|
-
|
|
1356
|
-
|
|
1373
|
+
const _nodeIdWithNodeId = _nodeId as unknown as { nodeId?: NodeId };
|
|
1374
|
+
if (_nodeId && _nodeIdWithNodeId.nodeId) {
|
|
1375
|
+
_nodeId = _nodeIdWithNodeId.nodeId;
|
|
1357
1376
|
}
|
|
1358
1377
|
_nodeId = resolveNodeId(_nodeId);
|
|
1359
1378
|
params.nodeId = _nodeId;
|
|
@@ -1421,7 +1440,11 @@ export class AddressSpace implements AddressSpacePrivate {
|
|
|
1421
1440
|
public _coerceTypeDefinition(typeDefinition: string | NodeId): NodeId {
|
|
1422
1441
|
if (typeof typeDefinition === "string") {
|
|
1423
1442
|
// coerce parent folder to an node
|
|
1424
|
-
const typeDefinitionNode = this.findNode(typeDefinition)
|
|
1443
|
+
const typeDefinitionNode = this.findNode(typeDefinition);
|
|
1444
|
+
/* c8 ignore next */
|
|
1445
|
+
if (!typeDefinitionNode) {
|
|
1446
|
+
throw new Error(`_coerceTypeDefinition: cannot find node ${typeDefinition}`);
|
|
1447
|
+
}
|
|
1425
1448
|
typeDefinition = typeDefinitionNode.nodeId;
|
|
1426
1449
|
}
|
|
1427
1450
|
assert(typeDefinition instanceof NodeId);
|
|
@@ -1454,12 +1477,13 @@ export class AddressSpace implements AddressSpacePrivate {
|
|
|
1454
1477
|
if (!baseTypeNode) {
|
|
1455
1478
|
throw new Error(`Cannot find ObjectType or VariableType for ${baseType.toString()}`);
|
|
1456
1479
|
}
|
|
1480
|
+
const baseTypeNodeWithIsSubtypeOf = baseTypeNode as unknown as { isSubtypeOf?: (t: BaseNode) => boolean };
|
|
1457
1481
|
/* c8 ignore next */
|
|
1458
|
-
if (!
|
|
1482
|
+
if (!baseTypeNodeWithIsSubtypeOf.isSubtypeOf) {
|
|
1459
1483
|
throw new Error(`Cannot find ObjectType or VariableType for ${baseType.toString()}`);
|
|
1460
1484
|
}
|
|
1461
1485
|
/* c8 ignore next */
|
|
1462
|
-
if (!
|
|
1486
|
+
if (!baseTypeNodeWithIsSubtypeOf.isSubtypeOf(topMostBaseTypeNode)) {
|
|
1463
1487
|
throw new Error("wrong type ");
|
|
1464
1488
|
}
|
|
1465
1489
|
return baseTypeNode;
|
|
@@ -1486,7 +1510,7 @@ export class AddressSpace implements AddressSpacePrivate {
|
|
|
1486
1510
|
throw new Error(` Cannot find DataType ${dataType.toString()} in standard address Space`);
|
|
1487
1511
|
}
|
|
1488
1512
|
|
|
1489
|
-
const enumerationNode = this.findDataType("Enumeration")
|
|
1513
|
+
const enumerationNode = this.findDataType("Enumeration");
|
|
1490
1514
|
if (!enumerationNode) {
|
|
1491
1515
|
throw new Error(" Cannot find 'Enumeration' DataType in standard address Space");
|
|
1492
1516
|
}
|
|
@@ -1495,9 +1519,9 @@ export class AddressSpace implements AddressSpacePrivate {
|
|
|
1495
1519
|
|
|
1496
1520
|
private _coerce_Type(
|
|
1497
1521
|
dataType: BaseNode | string | NodeId | number,
|
|
1498
|
-
typeMap:
|
|
1522
|
+
typeMap: Record<string, number | string>,
|
|
1499
1523
|
typeMapName: string,
|
|
1500
|
-
finderMethod:
|
|
1524
|
+
finderMethod: (this: AddressSpace, nodeId: NodeId) => BaseNode | null
|
|
1501
1525
|
): NodeId {
|
|
1502
1526
|
if (typeof dataType === "number") {
|
|
1503
1527
|
return this._coerce_Type(coerceNodeId(dataType), typeMap, typeMapName, finderMethod);
|
|
@@ -36,6 +36,8 @@ export interface AddressSpacePrivate extends IAddressSpace {
|
|
|
36
36
|
|
|
37
37
|
_condition_refresh_in_progress: boolean;
|
|
38
38
|
|
|
39
|
+
$$extraDataTypeManager?: ExtraDataTypeManager;
|
|
40
|
+
|
|
39
41
|
_coerceNode(node: string | BaseNode | NodeIdLike): BaseNode | null;
|
|
40
42
|
|
|
41
43
|
_coerceFolder(folder: string | BaseNode | NodeId): BaseNode | null;
|
|
@@ -31,8 +31,8 @@ function normalizeName(str: string): string {
|
|
|
31
31
|
|
|
32
32
|
const disabledVar = new Variant({
|
|
33
33
|
dataType: "StatusCode",
|
|
34
|
-
value: StatusCodes.BadConditionDisabled
|
|
35
|
-
// statusCode: StatusCodes.BadConditionDisabled
|
|
34
|
+
value: StatusCodes.BadConditionDisabled
|
|
35
|
+
// statusCode: StatusCodes.BadConditionDisabled
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
// list of Condition variables that should not be published as BadConditionDisabled when the condition
|
|
@@ -94,7 +94,8 @@ export class ConditionSnapshotImpl extends EventEmitter implements ConditionSnap
|
|
|
94
94
|
for (const fullBrowsePath of this._map.keys()) {
|
|
95
95
|
const node = this._node_index.get(fullBrowsePath);
|
|
96
96
|
if (!node) {
|
|
97
|
-
|
|
97
|
+
// c8 ignore next
|
|
98
|
+
doDebug && debugLog("cannot node for find key", fullBrowsePath);
|
|
98
99
|
continue;
|
|
99
100
|
}
|
|
100
101
|
if (isDisabled && !Object.hasOwn(_varTable, fullBrowsePath)) {
|
|
@@ -210,12 +211,6 @@ export class ConditionSnapshotImpl extends EventEmitter implements ConditionSnap
|
|
|
210
211
|
}
|
|
211
212
|
return variant;
|
|
212
213
|
}
|
|
213
|
-
|
|
214
|
-
#_is_varValid(varName: string) {
|
|
215
|
-
const key = normalizeName(varName);
|
|
216
|
-
const variant = this._map.get(key);
|
|
217
|
-
return !(variant && variant.dataType === DataType.StatusCode && variant.value === StatusCodes.BadConditionDisabled);
|
|
218
|
-
}
|
|
219
214
|
#_get_varTDefault<T>(dataType: DataType, varName: string, defaultValue: T): T {
|
|
220
215
|
const variant = this.#_get_var_inner(varName);
|
|
221
216
|
if (variant.dataType !== dataType) {
|
|
@@ -281,7 +276,8 @@ export class ConditionSnapshotImpl extends EventEmitter implements ConditionSnap
|
|
|
281
276
|
const node = this._node_index.get(key);
|
|
282
277
|
if (!node) {
|
|
283
278
|
// for instance localTime is optional
|
|
284
|
-
|
|
279
|
+
// c8 ignore next
|
|
280
|
+
doDebug && debugLog(`Cannot serVar ${varName} dataType ${DataType[dataType]}`);
|
|
285
281
|
return;
|
|
286
282
|
}
|
|
287
283
|
assert(node.nodeClass === NodeClass.Variable);
|