node-opcua-address-space 2.106.0 → 2.107.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/loader/register_node_promoter.d.ts +1 -1
- package/dist/source/loader/register_node_promoter.js +2 -2
- package/dist/source/loader/register_node_promoter.js.map +1 -1
- package/dist/src/_instantiate_helpers.d.ts +2 -0
- package/dist/src/_instantiate_helpers.js +80 -0
- package/dist/src/_instantiate_helpers.js.map +1 -0
- package/dist/src/_mandatory_child_or_requested_optional_filter.d.ts +9 -0
- package/dist/src/_mandatory_child_or_requested_optional_filter.js +80 -0
- package/dist/src/_mandatory_child_or_requested_optional_filter.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js +3 -0
- 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 +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.d.ts +2 -2
- package/dist/src/alarms_and_conditions/ua_condition_impl.js +2 -1
- package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -1
- package/dist/src/base_node_private.d.ts +1 -1
- package/dist/src/base_node_private.js +82 -82
- package/dist/src/base_node_private.js.map +1 -1
- package/dist/src/namespace_impl.d.ts +1 -1
- package/dist/src/namespace_impl.js +6 -6
- package/dist/src/namespace_impl.js.map +1 -1
- package/dist/src/state_machine/finite_state_machine.d.ts +1 -1
- package/dist/src/state_machine/finite_state_machine.js +204 -19
- package/dist/src/state_machine/finite_state_machine.js.map +1 -1
- package/dist/src/ua_method_impl.js +4 -1
- package/dist/src/ua_method_impl.js.map +1 -1
- package/dist/src/ua_object_impl.js +2 -3
- package/dist/src/ua_object_impl.js.map +1 -1
- package/dist/src/ua_object_type_impl.js +2 -1
- package/dist/src/ua_object_type_impl.js.map +1 -1
- package/dist/src/ua_variable_impl.d.ts +1 -1
- package/dist/src/ua_variable_impl.js +6 -4
- package/dist/src/ua_variable_impl.js.map +1 -1
- package/dist/src/ua_variable_type_impl.d.ts +5 -3
- package/dist/src/ua_variable_type_impl.js +8 -132
- package/dist/src/ua_variable_type_impl.js.map +1 -1
- package/dist/tsconfig_common.tsbuildinfo +1 -1
- package/package.json +17 -17
- package/source/loader/register_node_promoter.ts +3 -6
- package/src/_instantiate_helpers.ts +141 -0
- package/src/_mandatory_child_or_requested_optional_filter.ts +98 -0
- package/src/alarms_and_conditions/ua_alarm_condition_impl.ts +3 -0
- package/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.ts +1 -1
- package/src/alarms_and_conditions/ua_condition_impl.ts +7 -5
- package/src/base_node_private.ts +100 -117
- package/src/namespace_impl.ts +11 -7
- package/src/state_machine/finite_state_machine.ts +250 -37
- package/src/ua_method_impl.ts +4 -1
- package/src/ua_object_impl.ts +2 -3
- package/src/ua_object_type_impl.ts +1 -1
- package/src/ua_variable_impl.ts +7 -7
- package/src/ua_variable_type_impl.ts +4 -202
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
// tslint:disable:max-classes-per-file
|
|
5
5
|
// tslint:disable:no-console
|
|
6
|
-
import chalk from "chalk";
|
|
7
6
|
|
|
8
7
|
import { assert } from "node-opcua-assert";
|
|
9
8
|
import {
|
|
@@ -13,30 +12,23 @@ import {
|
|
|
13
12
|
InstantiateVariableOptions,
|
|
14
13
|
ModellingRuleType,
|
|
15
14
|
INamespace,
|
|
16
|
-
UAMethod,
|
|
17
|
-
UAObject,
|
|
18
|
-
UAObjectType,
|
|
19
|
-
UAReference,
|
|
20
15
|
UAVariable,
|
|
21
16
|
UAVariableType,
|
|
22
|
-
CloneFilter,
|
|
23
|
-
CloneHelper,
|
|
24
|
-
reconstructFunctionalGroupType,
|
|
25
|
-
reconstructNonHierarchicalReferences
|
|
26
17
|
} from "node-opcua-address-space-base";
|
|
27
18
|
|
|
19
|
+
|
|
28
20
|
import { coerceQualifiedName, NodeClass, QualifiedName, BrowseDirection, AttributeIds } from "node-opcua-data-model";
|
|
29
21
|
import { DataValue, DataValueLike } from "node-opcua-data-value";
|
|
30
22
|
import { checkDebugFlag, make_debugLog, make_warningLog, make_errorLog } from "node-opcua-debug";
|
|
31
|
-
import { coerceNodeId, NodeId, NodeIdLike
|
|
23
|
+
import { coerceNodeId, NodeId, NodeIdLike } from "node-opcua-nodeid";
|
|
32
24
|
import { StatusCodes } from "node-opcua-status-code";
|
|
33
25
|
import { UInt32 } from "node-opcua-basic-types";
|
|
34
26
|
import { isNullOrUndefined } from "node-opcua-utils";
|
|
35
27
|
import { DataType, Variant, VariantArrayType, verifyRankAndDimensions } from "node-opcua-variant";
|
|
36
28
|
|
|
37
29
|
import { SessionContext } from "../source/session_context";
|
|
38
|
-
import { makeOptionalsMap, OptionalMap } from "../source/helpers/make_optionals_map";
|
|
39
30
|
|
|
31
|
+
import { initialize_properties_and_components } from "./_instantiate_helpers";
|
|
40
32
|
import { AddressSpacePrivate } from "./address_space_private";
|
|
41
33
|
import { BaseNodeImpl, InternalBaseNodeOptions } from "./base_node_impl";
|
|
42
34
|
import { _clone_hierarchical_references, ToStringBuilder, UAVariableType_toString } from "./base_node_private";
|
|
@@ -88,7 +80,7 @@ export function topMostParentIsObjectTypeOrVariableType(addressSpace: AddressSpa
|
|
|
88
80
|
}
|
|
89
81
|
export interface UAVariableTypeOptions extends InternalBaseNodeOptions {
|
|
90
82
|
/**
|
|
91
|
-
* This attribute indicates whether the Value attribute of the
|
|
83
|
+
* This attribute indicates whether the Value attribute of the Variable is an array and how many dimensions the array has.
|
|
92
84
|
* It may have the following values:
|
|
93
85
|
* * n > 1: the Value is an array with the specified number of dimensions.
|
|
94
86
|
* * OneDimension (1): The value is an array with one dimension.
|
|
@@ -316,167 +308,6 @@ export class UAVariableTypeImpl extends BaseNodeImpl implements UAVariableType {
|
|
|
316
308
|
}
|
|
317
309
|
}
|
|
318
310
|
|
|
319
|
-
/**
|
|
320
|
-
* return true if node is a mandatory child or a requested optional
|
|
321
|
-
* @method MandatoryChildOrRequestedOptionalFilter
|
|
322
|
-
* @param instance
|
|
323
|
-
* @param optionalsMap
|
|
324
|
-
* @return {Boolean}
|
|
325
|
-
*/
|
|
326
|
-
class MandatoryChildOrRequestedOptionalFilter implements CloneFilter {
|
|
327
|
-
private readonly instance: BaseNode;
|
|
328
|
-
private readonly optionalsMap: any;
|
|
329
|
-
private readonly references: UAReference[];
|
|
330
|
-
|
|
331
|
-
constructor(instance: BaseNode, optionalsMap: any) {
|
|
332
|
-
// should we clone the node to be a component or propertyOf of a instance
|
|
333
|
-
assert(optionalsMap !== null && typeof optionalsMap === "object");
|
|
334
|
-
assert(null !== instance);
|
|
335
|
-
this.optionalsMap = optionalsMap;
|
|
336
|
-
this.instance = instance;
|
|
337
|
-
this.references = instance.allReferences();
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
public shouldKeep(node: BaseNode): boolean {
|
|
341
|
-
const addressSpace = node.addressSpace;
|
|
342
|
-
|
|
343
|
-
const alreadyIn = this.references.filter((r: UAReference) => {
|
|
344
|
-
const n = addressSpace.findNode(r.nodeId)!;
|
|
345
|
-
// istanbul ignore next
|
|
346
|
-
if (!n) {
|
|
347
|
-
warningLog(" cannot find node ", r.nodeId.toString());
|
|
348
|
-
return false;
|
|
349
|
-
}
|
|
350
|
-
return n.browseName!.name!.toString() === node.browseName!.name!.toString();
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
if (alreadyIn.length > 0) {
|
|
354
|
-
assert(alreadyIn.length === 1, "Duplication found ?");
|
|
355
|
-
// a child with the same browse name has already been install
|
|
356
|
-
// probably from a SuperClass, we should ignore this.
|
|
357
|
-
return false; // ignore
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
const modellingRule = node.modellingRule;
|
|
361
|
-
|
|
362
|
-
switch (modellingRule) {
|
|
363
|
-
case null:
|
|
364
|
-
case undefined:
|
|
365
|
-
debugLog(
|
|
366
|
-
"node ",
|
|
367
|
-
node.browseName.toString(),
|
|
368
|
-
node.nodeId.toString(),
|
|
369
|
-
" has no modellingRule ",
|
|
370
|
-
node.parentNodeId?.toString()
|
|
371
|
-
);
|
|
372
|
-
/**
|
|
373
|
-
* in some badly generated NodeSet2.xml file, the modellingRule is not specified
|
|
374
|
-
*
|
|
375
|
-
* but in some other NodeSet2.xml, this means that the data are only attached to the Type node and shall not be
|
|
376
|
-
* instantiate in the corresponding instance (example is the state variable of a finite state machine that are only
|
|
377
|
-
* defined in the Type node)
|
|
378
|
-
*
|
|
379
|
-
* we should not consider it as an error, and treat it as not present
|
|
380
|
-
*/
|
|
381
|
-
return false;
|
|
382
|
-
|
|
383
|
-
case "Mandatory":
|
|
384
|
-
return true; // keep;
|
|
385
|
-
case "Optional":
|
|
386
|
-
// only if in requested optionals
|
|
387
|
-
return node.browseName!.name! in this.optionalsMap;
|
|
388
|
-
case "OptionalPlaceholder":
|
|
389
|
-
return false; // ignored
|
|
390
|
-
default:
|
|
391
|
-
return false; // ignored
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
public filterFor(childInstance: UAVariable | UAObject | UAMethod): CloneFilter {
|
|
396
|
-
const browseName: string = childInstance.browseName.name!;
|
|
397
|
-
|
|
398
|
-
let map = {};
|
|
399
|
-
|
|
400
|
-
if (browseName in this.optionalsMap) {
|
|
401
|
-
map = this.optionalsMap[browseName];
|
|
402
|
-
}
|
|
403
|
-
const newFilter = new MandatoryChildOrRequestedOptionalFilter(childInstance, map);
|
|
404
|
-
return newFilter;
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
// install properties and components on a instantiated Object
|
|
409
|
-
//
|
|
410
|
-
// based on their ModelingRule
|
|
411
|
-
// => Mandatory => Installed
|
|
412
|
-
// => Optional => Not Installed , unless it appear in optionals array
|
|
413
|
-
// => OptionalPlaceHolder => Not Installed
|
|
414
|
-
// => null (no modelling rule ) => Not Installed
|
|
415
|
-
//
|
|
416
|
-
|
|
417
|
-
function _initialize_properties_and_components<B extends UAObject | UAVariable | UAMethod, T extends UAObjectType | UAVariableType>(
|
|
418
|
-
instance: B,
|
|
419
|
-
topMostType: T,
|
|
420
|
-
typeDefinitionNode: T,
|
|
421
|
-
copyAlsoModellingRules: boolean,
|
|
422
|
-
optionalsMap: OptionalMap,
|
|
423
|
-
extraInfo: CloneHelper,
|
|
424
|
-
browseNameMap: Set<string>
|
|
425
|
-
) {
|
|
426
|
-
if (doDebug) {
|
|
427
|
-
debugLog("instance browseName =", instance.browseName.toString());
|
|
428
|
-
debugLog("typeNode =", typeDefinitionNode.browseName.toString());
|
|
429
|
-
debugLog("optionalsMap =", Object.keys(optionalsMap).join(" "));
|
|
430
|
-
|
|
431
|
-
const c = typeDefinitionNode.findReferencesEx("Aggregates");
|
|
432
|
-
debugLog("typeDefinition aggregates =", c.map((x) => x.node!.browseName.toString()).join(" "));
|
|
433
|
-
}
|
|
434
|
-
optionalsMap = optionalsMap || {};
|
|
435
|
-
|
|
436
|
-
if (sameNodeId(topMostType.nodeId, typeDefinitionNode.nodeId)) {
|
|
437
|
-
return; // nothing to do
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
const filter = new MandatoryChildOrRequestedOptionalFilter(instance, optionalsMap);
|
|
441
|
-
|
|
442
|
-
doTrace &&
|
|
443
|
-
traceLog(
|
|
444
|
-
chalk.cyan(extraInfo.pad(), "cloning relevant member of typeDefinition class"),
|
|
445
|
-
typeDefinitionNode.browseName.toString()
|
|
446
|
-
);
|
|
447
|
-
|
|
448
|
-
_clone_hierarchical_references(typeDefinitionNode, instance, copyAlsoModellingRules, filter, extraInfo, browseNameMap);
|
|
449
|
-
|
|
450
|
-
// now apply recursion on baseTypeDefinition to get properties and components from base class
|
|
451
|
-
|
|
452
|
-
const baseTypeDefinitionNodeId = typeDefinitionNode.subtypeOf;
|
|
453
|
-
const baseTypeDefinition = typeDefinitionNode.subtypeOfObj!;
|
|
454
|
-
|
|
455
|
-
doTrace &&
|
|
456
|
-
traceLog(
|
|
457
|
-
chalk.cyan(
|
|
458
|
-
extraInfo.pad(),
|
|
459
|
-
"now apply recursion on baseTypeDefinition to get properties and components from base class"
|
|
460
|
-
),
|
|
461
|
-
baseTypeDefinition.browseName.toString()
|
|
462
|
-
);
|
|
463
|
-
|
|
464
|
-
// istanbul ignore next
|
|
465
|
-
if (!baseTypeDefinition) {
|
|
466
|
-
throw new Error(chalk.red("Cannot find object with nodeId ") + baseTypeDefinitionNodeId);
|
|
467
|
-
}
|
|
468
|
-
extraInfo.level++;
|
|
469
|
-
_initialize_properties_and_components(
|
|
470
|
-
instance,
|
|
471
|
-
topMostType,
|
|
472
|
-
baseTypeDefinition,
|
|
473
|
-
copyAlsoModellingRules,
|
|
474
|
-
optionalsMap,
|
|
475
|
-
extraInfo,
|
|
476
|
-
browseNameMap
|
|
477
|
-
);
|
|
478
|
-
extraInfo.level--;
|
|
479
|
-
}
|
|
480
311
|
|
|
481
312
|
/**
|
|
482
313
|
* @method hasChildWithBrowseName
|
|
@@ -535,32 +366,3 @@ export function assertUnusedChildBrowseName(addressSpace: AddressSpacePrivate, o
|
|
|
535
366
|
}
|
|
536
367
|
}
|
|
537
368
|
|
|
538
|
-
exports.assertUnusedChildBrowseName = assertUnusedChildBrowseName;
|
|
539
|
-
exports.initialize_properties_and_components = initialize_properties_and_components;
|
|
540
|
-
|
|
541
|
-
export function initialize_properties_and_components<
|
|
542
|
-
B extends UAObject | UAVariable | UAMethod,
|
|
543
|
-
T extends UAVariableType | UAObjectType
|
|
544
|
-
>(instance: B, topMostType: T, nodeType: T, copyAlsoModellingRules: boolean, optionals?: string[]): void {
|
|
545
|
-
const extraInfo = new CloneHelper();
|
|
546
|
-
|
|
547
|
-
extraInfo.registerClonedObject(instance, nodeType);
|
|
548
|
-
|
|
549
|
-
const optionalsMap = makeOptionalsMap(optionals);
|
|
550
|
-
|
|
551
|
-
const browseNameMap = new Set<string>();
|
|
552
|
-
|
|
553
|
-
_initialize_properties_and_components(
|
|
554
|
-
instance,
|
|
555
|
-
topMostType,
|
|
556
|
-
nodeType,
|
|
557
|
-
copyAlsoModellingRules,
|
|
558
|
-
optionalsMap,
|
|
559
|
-
extraInfo,
|
|
560
|
-
browseNameMap
|
|
561
|
-
);
|
|
562
|
-
|
|
563
|
-
reconstructFunctionalGroupType(extraInfo);
|
|
564
|
-
|
|
565
|
-
reconstructNonHierarchicalReferences(extraInfo);
|
|
566
|
-
}
|