node-opcua-address-space 2.60.0 → 2.62.2
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/helpers/multiform_func.d.ts +11 -0
- package/dist/source/helpers/multiform_func.js +74 -0
- package/dist/source/helpers/multiform_func.js.map +1 -0
- package/dist/src/address_space.js +4 -1
- package/dist/src/address_space.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.d.ts +0 -1
- package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.js +23 -5
- package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.js.map +1 -1
- package/dist/src/base_node_impl.js +2 -0
- package/dist/src/base_node_impl.js.map +1 -1
- package/dist/src/base_node_private.d.ts +3 -3
- package/dist/src/base_node_private.js +196 -23
- package/dist/src/base_node_private.js.map +1 -1
- package/dist/src/ua_method_impl.js +2 -1
- package/dist/src/ua_method_impl.js.map +1 -1
- package/dist/src/ua_object_impl.js +2 -1
- package/dist/src/ua_object_impl.js.map +1 -1
- package/dist/src/ua_object_type_impl.js +1 -0
- package/dist/src/ua_object_type_impl.js.map +1 -1
- package/dist/src/ua_variable_impl.d.ts +6 -12
- package/dist/src/ua_variable_impl.js +61 -37
- package/dist/src/ua_variable_impl.js.map +1 -1
- package/dist/src/ua_variable_type_impl.js +48 -34
- package/dist/src/ua_variable_type_impl.js.map +1 -1
- package/dist/src/ua_view_impl.js +1 -1
- package/dist/src/ua_view_impl.js.map +1 -1
- package/package.json +30 -30
- package/source/helpers/multiform_func.ts +76 -0
- package/src/address_space.ts +11 -8
- package/src/alarms_and_conditions/ua_limit_alarm_impl.ts +29 -9
- package/src/base_node_impl.ts +3 -1
- package/src/base_node_private.ts +276 -34
- package/src/ua_method_impl.ts +10 -2
- package/src/ua_object_impl.ts +10 -2
- package/src/ua_object_type_impl.ts +1 -0
- package/src/ua_variable_impl.ts +156 -132
- package/src/ua_variable_type_impl.ts +80 -39
- package/src/ua_view_impl.ts +1 -1
- package/test_helpers/test_fixtures/fixture_simple_statemachine_nodeset2.xml +9 -0
- package/test_helpers/test_fixtures/fixuture_nodeset_objects_with_some_methods.xml +9 -1
- package/test_helpers/test_fixtures/mini.Node.Set2.xml +8 -1
|
@@ -21,10 +21,10 @@ import {
|
|
|
21
21
|
UAVariableType,
|
|
22
22
|
CloneFilter
|
|
23
23
|
} from "node-opcua-address-space-base";
|
|
24
|
-
import { ReferenceTypeIds } from "node-opcua-constants";
|
|
24
|
+
import { ObjectTypeIds, ReferenceTypeIds, VariableTypeIds } from "node-opcua-constants";
|
|
25
25
|
import { coerceQualifiedName, NodeClass, QualifiedName, BrowseDirection, AttributeIds } from "node-opcua-data-model";
|
|
26
26
|
import { DataValue, DataValueLike } from "node-opcua-data-value";
|
|
27
|
-
import { checkDebugFlag, make_debugLog, make_warningLog } from "node-opcua-debug";
|
|
27
|
+
import { checkDebugFlag, make_debugLog, make_warningLog, make_errorLog } from "node-opcua-debug";
|
|
28
28
|
import { coerceNodeId, makeNodeId, NodeId, NodeIdLike, sameNodeId } from "node-opcua-nodeid";
|
|
29
29
|
import { StatusCodes } from "node-opcua-status-code";
|
|
30
30
|
import { UInt32 } from "node-opcua-basic-types";
|
|
@@ -40,10 +40,16 @@ import { _clone_children_references, ToStringBuilder, UAVariableType_toString }
|
|
|
40
40
|
import * as tools from "./tool_isSupertypeOf";
|
|
41
41
|
import { get_subtypeOfObj } from "./tool_isSupertypeOf";
|
|
42
42
|
import { get_subtypeOf } from "./tool_isSupertypeOf";
|
|
43
|
+
import { resolveReferenceNode } from "./reference_impl";
|
|
43
44
|
|
|
44
45
|
const debugLog = make_debugLog(__filename);
|
|
45
46
|
const doDebug = checkDebugFlag(__filename);
|
|
46
47
|
const warningLog = make_warningLog(__filename);
|
|
48
|
+
const errorLog = make_errorLog(__filename);
|
|
49
|
+
|
|
50
|
+
// eslint-disable-next-line prefer-const
|
|
51
|
+
let doTrace = false;
|
|
52
|
+
const traceLog = errorLog;
|
|
47
53
|
|
|
48
54
|
interface InstantiateS {
|
|
49
55
|
propertyOf?: any;
|
|
@@ -125,7 +131,6 @@ export class UAVariableTypeImpl extends BaseNodeImpl implements UAVariableType {
|
|
|
125
131
|
|
|
126
132
|
if (options.value) {
|
|
127
133
|
this.value = new Variant(options.value);
|
|
128
|
-
// xx console.log("setting ",this.value.toString());
|
|
129
134
|
}
|
|
130
135
|
}
|
|
131
136
|
|
|
@@ -240,6 +245,7 @@ export class UAVariableTypeImpl extends BaseNodeImpl implements UAVariableType {
|
|
|
240
245
|
componentOf: options.componentOf,
|
|
241
246
|
dataType,
|
|
242
247
|
description: options.description || this.description,
|
|
248
|
+
displayName: options.displayName || this.displayName,
|
|
243
249
|
eventSourceOf: options.eventSourceOf,
|
|
244
250
|
minimumSamplingInterval: options.minimumSamplingInterval,
|
|
245
251
|
modellingRule: options.modellingRule,
|
|
@@ -303,7 +309,7 @@ class MandatoryChildOrRequestedOptionalFilter implements CloneFilter {
|
|
|
303
309
|
const n = addressSpace.findNode(r.nodeId)!;
|
|
304
310
|
// istanbul ignore next
|
|
305
311
|
if (!n) {
|
|
306
|
-
|
|
312
|
+
warningLog(" cannot find node ", r.nodeId.toString());
|
|
307
313
|
return false;
|
|
308
314
|
}
|
|
309
315
|
return n.browseName!.name!.toString() === node.browseName!.name!.toString();
|
|
@@ -321,7 +327,24 @@ class MandatoryChildOrRequestedOptionalFilter implements CloneFilter {
|
|
|
321
327
|
switch (modellingRule) {
|
|
322
328
|
case null:
|
|
323
329
|
case undefined:
|
|
324
|
-
|
|
330
|
+
debugLog(
|
|
331
|
+
"node ",
|
|
332
|
+
node.browseName.toString(),
|
|
333
|
+
node.nodeId.toString(),
|
|
334
|
+
" has no modellingRule ",
|
|
335
|
+
node.parentNodeId?.toString()
|
|
336
|
+
);
|
|
337
|
+
/**
|
|
338
|
+
* in some badly generated NodeSet2.xml file, the modellingRule is not specified
|
|
339
|
+
*
|
|
340
|
+
* but in some other NodeSet2.xml, this means that the data are only attached to the Type node and shall not be
|
|
341
|
+
* instantiate in the corresponding instance (example is the state variable of a finite state machine that are only
|
|
342
|
+
* defined in the Type node)
|
|
343
|
+
*
|
|
344
|
+
* we should not consider it as an error, and treat it as not present
|
|
345
|
+
*/
|
|
346
|
+
return false;
|
|
347
|
+
|
|
325
348
|
case "Mandatory":
|
|
326
349
|
return true; // keep;
|
|
327
350
|
case "Optional":
|
|
@@ -364,11 +387,11 @@ function _get_parent_as_VariableOrObjectType(originalObject: BaseNode): UAVariab
|
|
|
364
387
|
|
|
365
388
|
// istanbul ignore next
|
|
366
389
|
if (parents.length > 1) {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
390
|
+
warningLog(" object ", originalObject.browseName.toString(), " has more than one parent !");
|
|
391
|
+
warningLog(originalObject.toString());
|
|
392
|
+
warningLog(" parents : ");
|
|
370
393
|
for (const parent of parents) {
|
|
371
|
-
|
|
394
|
+
warningLog(" ", parent.toString(), addressSpace.findNode(parent.nodeId)!.browseName.toString());
|
|
372
395
|
}
|
|
373
396
|
return null;
|
|
374
397
|
}
|
|
@@ -389,8 +412,12 @@ interface CloneInfo {
|
|
|
389
412
|
original: UAVariableType | UAObjectType;
|
|
390
413
|
}
|
|
391
414
|
class CloneHelper {
|
|
415
|
+
public level = 0;
|
|
392
416
|
private readonly mapOrgToClone: Map<string, CloneInfo> = new Map();
|
|
393
417
|
|
|
418
|
+
public pad(): string {
|
|
419
|
+
return " ".padEnd(this.level * 2, " ");
|
|
420
|
+
}
|
|
394
421
|
public registerClonedObject<TT extends UAVariableType | UAObjectType, T extends UAObject | UAVariable | UAMethod>(
|
|
395
422
|
objInType: TT,
|
|
396
423
|
clonedObj: T
|
|
@@ -433,7 +460,6 @@ class CloneHelper {
|
|
|
433
460
|
// find subTypeOf
|
|
434
461
|
}
|
|
435
462
|
}
|
|
436
|
-
|
|
437
463
|
// install properties and components on a instantiated Object
|
|
438
464
|
//
|
|
439
465
|
// based on their ModelingRule
|
|
@@ -446,39 +472,66 @@ class CloneHelper {
|
|
|
446
472
|
function _initialize_properties_and_components<B extends UAObject | UAVariable | UAMethod, T extends UAObjectType | UAVariableType>(
|
|
447
473
|
instance: B,
|
|
448
474
|
topMostType: T,
|
|
449
|
-
|
|
475
|
+
typeDefinitionNode: T,
|
|
450
476
|
copyAlsoModellingRules: boolean,
|
|
451
477
|
optionalsMap: OptionalMap,
|
|
452
478
|
extraInfo: CloneHelper
|
|
453
479
|
) {
|
|
454
480
|
if (doDebug) {
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
481
|
+
debugLog("instance browseName =", instance.browseName.toString());
|
|
482
|
+
debugLog("typeNode =", typeDefinitionNode.browseName.toString());
|
|
483
|
+
debugLog("optionalsMap =", Object.keys(optionalsMap).join(" "));
|
|
458
484
|
|
|
459
|
-
const c =
|
|
460
|
-
|
|
485
|
+
const c = typeDefinitionNode.findReferencesEx("Aggregates");
|
|
486
|
+
debugLog("typeDefinition aggregates =", c.map((x) => x.node!.browseName.toString()).join(" "));
|
|
461
487
|
}
|
|
462
488
|
optionalsMap = optionalsMap || {};
|
|
463
489
|
|
|
464
|
-
if (sameNodeId(topMostType.nodeId,
|
|
490
|
+
if (sameNodeId(topMostType.nodeId, typeDefinitionNode.nodeId)) {
|
|
465
491
|
return; // nothing to do
|
|
466
492
|
}
|
|
467
493
|
|
|
468
|
-
const
|
|
469
|
-
const baseType = typeNode.subtypeOfObj;
|
|
494
|
+
const filter = new MandatoryChildOrRequestedOptionalFilter(instance, optionalsMap);
|
|
470
495
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
496
|
+
doTrace &&
|
|
497
|
+
traceLog(
|
|
498
|
+
chalk.cyan(extraInfo.pad(), "cloning relevant member of typeDefinition class"),
|
|
499
|
+
typeDefinitionNode.browseName.toString()
|
|
500
|
+
);
|
|
475
501
|
|
|
476
|
-
const
|
|
502
|
+
const browseNameMap = new Set<string>();
|
|
477
503
|
|
|
478
|
-
_clone_children_references(
|
|
504
|
+
_clone_children_references(typeDefinitionNode, instance, copyAlsoModellingRules, filter, extraInfo, browseNameMap);
|
|
505
|
+
|
|
506
|
+
// now apply recursion on baseTypeDefinition to get properties and components from base class
|
|
507
|
+
|
|
508
|
+
const baseTypeDefinitionNodeId = typeDefinitionNode.subtypeOf;
|
|
509
|
+
const baseTypeDefinition = typeDefinitionNode.subtypeOfObj!;
|
|
510
|
+
|
|
511
|
+
doTrace &&
|
|
512
|
+
traceLog(
|
|
513
|
+
chalk.cyan(
|
|
514
|
+
extraInfo.pad(),
|
|
515
|
+
"now apply recursion on baseTypeDefinition to get properties and components from base class"
|
|
516
|
+
),
|
|
517
|
+
baseTypeDefinition.browseName.toString()
|
|
518
|
+
);
|
|
519
|
+
|
|
520
|
+
// istanbul ignore next
|
|
521
|
+
if (!baseTypeDefinition) {
|
|
522
|
+
throw new Error(chalk.red("Cannot find object with nodeId ") + baseTypeDefinitionNodeId);
|
|
523
|
+
}
|
|
524
|
+
extraInfo.level++;
|
|
525
|
+
_initialize_properties_and_components(
|
|
526
|
+
instance,
|
|
527
|
+
topMostType,
|
|
528
|
+
baseTypeDefinition,
|
|
529
|
+
copyAlsoModellingRules,
|
|
530
|
+
optionalsMap,
|
|
531
|
+
extraInfo
|
|
532
|
+
);
|
|
533
|
+
extraInfo.level--;
|
|
479
534
|
|
|
480
|
-
// get properties and components from base class
|
|
481
|
-
_initialize_properties_and_components(instance, topMostType, baseType, copyAlsoModellingRules, optionalsMap, extraInfo);
|
|
482
535
|
}
|
|
483
536
|
|
|
484
537
|
/**
|
|
@@ -589,8 +642,6 @@ function findNonHierarchicalReferences(originalObject: BaseNode): UAReference[]
|
|
|
589
642
|
|
|
590
643
|
if (child) {
|
|
591
644
|
const baseRef = findNonHierarchicalReferences(child);
|
|
592
|
-
// xx console.log(" ... ",originalObject.browseName.toString(),
|
|
593
|
-
// parent.browseName.toString(), references.length, baseRef.length);
|
|
594
645
|
references = ([] as UAReference[]).concat(references, baseRef);
|
|
595
646
|
}
|
|
596
647
|
}
|
|
@@ -685,15 +736,6 @@ function reconstructFunctionalGroupType(extraInfo: any) {
|
|
|
685
736
|
for (const { original, cloned } of extraInfo.mapOrgToClone.values()) {
|
|
686
737
|
const organizedByArray = original.findReferencesEx("Organizes", BrowseDirection.Inverse);
|
|
687
738
|
|
|
688
|
-
// function dumpRef(r) {
|
|
689
|
-
// var referenceTd = addressSpace.findNode(r.referenceTypeId);
|
|
690
|
-
// var obj = addressSpace.findNode(r.nodeId);
|
|
691
|
-
// return "<-- " + referenceTd.browseName.toString() + " -- " + obj.browseName.toString();
|
|
692
|
-
// }
|
|
693
|
-
//
|
|
694
|
-
// console.log("xxxxx ========================================================",
|
|
695
|
-
// originalObject.browseName.toString(),
|
|
696
|
-
// organizedByArray.map(dumpRef).join("\n"));
|
|
697
739
|
for (const ref of organizedByArray) {
|
|
698
740
|
const info = extraInfo.mapOrgToClone.get(ref.nodeId.toString());
|
|
699
741
|
if (!info) continue;
|
|
@@ -712,7 +754,6 @@ function reconstructFunctionalGroupType(extraInfo: any) {
|
|
|
712
754
|
nodeId: cloned.nodeId,
|
|
713
755
|
referenceType: ref.referenceType
|
|
714
756
|
});
|
|
715
|
-
// xx console.log("xxx ============> adding reference ",ref.browse )
|
|
716
757
|
}
|
|
717
758
|
}
|
|
718
759
|
}
|
package/src/ua_view_impl.ts
CHANGED
|
@@ -34,7 +34,7 @@ export class UAViewImpl extends BaseNodeImpl implements UAView {
|
|
|
34
34
|
|
|
35
35
|
switch (attributeId) {
|
|
36
36
|
case AttributeIds.EventNotifier:
|
|
37
|
-
options.value = { dataType: DataType.
|
|
37
|
+
options.value = { dataType: DataType.Byte, value: this.eventNotifier };
|
|
38
38
|
options.statusCode = StatusCodes.Good;
|
|
39
39
|
break;
|
|
40
40
|
|
|
@@ -240,6 +240,15 @@
|
|
|
240
240
|
</References>
|
|
241
241
|
<InverseName>EncodingOf</InverseName>
|
|
242
242
|
</UAReferenceType>
|
|
243
|
+
<UAReferenceType NodeId="i=17603" BrowseName="HasInterface">
|
|
244
|
+
<DisplayName>HasInterface</DisplayName>
|
|
245
|
+
<Documentation>https://reference.opcfoundation.org/v104/Core/docs/Amendment7/11.20</Documentation>
|
|
246
|
+
<References>
|
|
247
|
+
<Reference ReferenceType="HasSubtype" IsForward="false">i=32</Reference>
|
|
248
|
+
</References>
|
|
249
|
+
<InverseName>InterfaceOf</InverseName>
|
|
250
|
+
</UAReferenceType>
|
|
251
|
+
|
|
243
252
|
<UAObjectType NodeId="i=58" BrowseName="BaseObjectType">
|
|
244
253
|
<DisplayName>BaseObjectType</DisplayName>
|
|
245
254
|
<Description>The base type for all object nodes.</Description>
|
|
@@ -357,6 +357,14 @@
|
|
|
357
357
|
<Reference ReferenceType="HasSubtype" IsForward="false">i=58</Reference>
|
|
358
358
|
</References>
|
|
359
359
|
</UAObjectType>
|
|
360
|
-
|
|
360
|
+
|
|
361
|
+
<UAReferenceType NodeId="i=38" BrowseName="HasEncoding">
|
|
362
|
+
<DisplayName>HasEncoding</DisplayName>
|
|
363
|
+
<Documentation>https://reference.opcfoundation.org/v104/Core/docs/Part5/11.13</Documentation>
|
|
364
|
+
<References>
|
|
365
|
+
<Reference ReferenceType="HasSubtype" IsForward="false">i=32</Reference>
|
|
366
|
+
</References>
|
|
367
|
+
<InverseName>EncodingOf</InverseName>
|
|
368
|
+
</UAReferenceType>
|
|
361
369
|
|
|
362
370
|
</UANodeSet>
|
|
@@ -442,7 +442,14 @@
|
|
|
442
442
|
</References>
|
|
443
443
|
<InverseName>HistoricalConfigurationOf</InverseName>
|
|
444
444
|
</UAReferenceType>
|
|
445
|
-
|
|
445
|
+
<UAReferenceType NodeId="i=17603" BrowseName="HasInterface">
|
|
446
|
+
<DisplayName>HasInterface</DisplayName>
|
|
447
|
+
<Documentation>https://reference.opcfoundation.org/v104/Core/docs/Amendment7/11.20</Documentation>
|
|
448
|
+
<References>
|
|
449
|
+
<Reference ReferenceType="HasSubtype" IsForward="false">i=32</Reference>
|
|
450
|
+
</References>
|
|
451
|
+
<InverseName>InterfaceOf</InverseName>
|
|
452
|
+
</UAReferenceType>
|
|
446
453
|
|
|
447
454
|
|
|
448
455
|
<UAObjectType NodeId="i=75" BrowseName="DataTypeSystemType">
|