node-opcua-address-space 2.56.2 → 2.60.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/LICENSE +20 -20
- package/dist/source/address_space_ts.d.ts +0 -2
- package/dist/source/helpers/argument_list.js +12 -1
- package/dist/source/helpers/argument_list.js.map +1 -1
- package/dist/source/loader/load_nodeset2.js +76 -67
- package/dist/source/loader/load_nodeset2.js.map +1 -1
- package/dist/source/session_context.js +2 -2
- package/dist/source/session_context.js.map +1 -1
- package/dist/source/set_namespace_meta_data.js +1 -1
- package/dist/src/address_space.d.ts +2 -3
- package/dist/src/address_space.js +9 -6
- package/dist/src/address_space.js.map +1 -1
- package/dist/src/address_space_private.d.ts +2 -3
- package/dist/src/alarms_and_conditions/condition_snapshot.js +3 -3
- package/dist/src/alarms_and_conditions/condition_snapshot.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js +2 -1
- 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 +1 -1
- package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_condition_impl.js +8 -6
- package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.js +1 -1
- package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.js.map +1 -1
- package/dist/src/base_node_private.js +2 -2
- package/dist/src/base_node_private.js.map +1 -1
- package/dist/src/event_data.js +1 -1
- package/dist/src/event_data.js.map +1 -1
- package/dist/src/namespace_impl.d.ts +2 -2
- package/dist/src/namespace_impl.js +9 -9
- package/dist/src/namespace_impl.js.map +1 -1
- package/dist/src/nodeset_tools/nodeset_to_xml.js +16 -10
- package/dist/src/nodeset_tools/nodeset_to_xml.js.map +1 -1
- package/dist/src/nodeset_tools/typedictionary_to_xml.js +17 -10
- package/dist/src/nodeset_tools/typedictionary_to_xml.js.map +1 -1
- package/dist/src/reference_impl.js +1 -1
- package/dist/src/reference_impl.js.map +1 -1
- package/dist/src/state_machine/ua_shelving_state_machine_ex.js +20 -13
- package/dist/src/state_machine/ua_shelving_state_machine_ex.js.map +1 -1
- package/dist/src/ua_data_type_impl.d.ts +15 -5
- package/dist/src/ua_data_type_impl.js +129 -51
- package/dist/src/ua_data_type_impl.js.map +1 -1
- package/dist/src/ua_method_impl.d.ts +3 -2
- package/dist/src/ua_method_impl.js +5 -0
- package/dist/src/ua_method_impl.js.map +1 -1
- package/dist/src/ua_variable_impl.d.ts +6 -6
- package/dist/src/ua_variable_impl.js +236 -188
- package/dist/src/ua_variable_impl.js.map +1 -1
- package/dist/src/ua_variable_type_impl.d.ts +3 -4
- package/dist/src/ua_variable_type_impl.js +13 -18
- package/dist/src/ua_variable_type_impl.js.map +1 -1
- package/distHelpers/add_event_generator_object.js.map +1 -1
- package/distHelpers/mock_session.js +1 -1
- package/distHelpers/mock_session.js.map +1 -1
- package/generate.js +1 -1
- package/nodeJS.d.ts +1 -1
- package/package.json +36 -36
- package/source/address_space_ts.ts +0 -1
- package/source/helpers/argument_list.ts +13 -3
- package/source/loader/load_nodeset2.ts +99 -79
- package/source/session_context.ts +1 -1
- package/source/set_namespace_meta_data.ts +1 -1
- package/source_nodejs/index.ts +1 -1
- package/src/address_space.ts +21 -14
- package/src/address_space_private.ts +3 -3
- package/src/alarms_and_conditions/condition_snapshot.ts +4 -4
- package/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.ts +7 -6
- package/src/alarms_and_conditions/ua_alarm_condition_impl.ts +2 -2
- package/src/alarms_and_conditions/ua_condition_impl.ts +29 -15
- package/src/alarms_and_conditions/ua_off_normal_alarm_impl.ts +1 -1
- package/src/base_node_private.ts +6 -2
- package/src/event_data.ts +1 -1
- package/src/namespace_impl.ts +9 -9
- package/src/nodeset_tools/nodeset_to_xml.ts +22 -12
- package/src/nodeset_tools/typedictionary_to_xml.ts +17 -7
- package/src/reference_impl.ts +3 -3
- package/src/state_machine/ua_shelving_state_machine_ex.ts +32 -19
- package/src/ua_data_type_impl.ts +168 -61
- package/src/ua_method_impl.ts +11 -5
- package/src/ua_variable_impl.ts +290 -218
- package/src/ua_variable_type_impl.ts +9 -15
- package/testHelpers.d.ts +1 -1
- package/test_helpers/add_event_generator_object.ts +4 -3
- package/test_helpers/mock_session.ts +1 -1
- package/test_helpers/test_fixtures/dataType_in_separateNamespace.xml +150 -150
- package/test_helpers/test_fixtures/dataType_in_separateNamespace_basic.xml +57 -57
- package/test_helpers/test_fixtures/dataType_in_separateNamespace_mix.xml +135 -135
- package/test_helpers/test_fixtures/dataType_withEnumeration.xml +82 -82
- package/test_helpers/test_fixtures/dataType_with_isOptionSet.xml +194 -194
- package/test_helpers/test_fixtures/dataType_with_union.xml +1 -1
- package/test_helpers/test_fixtures/fixture_empty_nodeset2.xml +106 -106
- package/test_helpers/test_fixtures/fixture_simple_statemachine_nodeset2.xml +1312 -1303
- package/test_helpers/test_fixtures/fixuture_nodeset_objects_with_some_methods.xml +362 -362
- package/test_helpers/test_fixtures/issue_846.xml +3172 -3172
- package/test_helpers/test_fixtures/issue_899_variable_with_nodeid_value.xml +32 -32
- package/test_helpers/test_fixtures/mini.Node.Set2.xml +14 -0
- package/test_helpers/test_fixtures/mini.nodeset.withVariousVariables.xml +194 -194
- package/test_helpers/test_fixtures/minimalist_nodeset_with_models.xml +8 -8
- package/test_helpers/test_fixtures/minimalist_nodeset_with_models_more_complex.xml +16 -16
- package/test_helpers/test_fixtures/nodeset_with_analog_items.xml +45 -45
- package/dist/source/interfaces/alarms_and_conditions/ua_condition_base_i.d.ts +0 -23
- package/dist/source/interfaces/alarms_and_conditions/ua_condition_base_i.js +0 -3
- package/dist/source/interfaces/alarms_and_conditions/ua_condition_base_i.js.map +0 -1
- package/dist/source/interfaces/data_access/ua_discrete_item.d.ts +0 -6
- package/dist/source/interfaces/data_access/ua_discrete_item.js +0 -3
- package/dist/source/interfaces/data_access/ua_discrete_item.js.map +0 -1
- package/dist/source/interfaces/data_access/ua_multistate_discrete.d.ts +0 -25
- package/dist/source/interfaces/data_access/ua_multistate_discrete.js +0 -3
- package/dist/source/interfaces/data_access/ua_multistate_discrete.js.map +0 -1
- package/dist/source/interfaces/data_access/ua_multistate_value_discrete.d.ts +0 -27
- package/dist/source/interfaces/data_access/ua_multistate_value_discrete.js +0 -3
- package/dist/source/interfaces/data_access/ua_multistate_value_discrete.js.map +0 -1
- package/dist/source/interfaces/data_access/ua_two_state_discrete.d.ts +0 -17
- package/dist/source/interfaces/data_access/ua_two_state_discrete.js +0 -3
- package/dist/source/interfaces/data_access/ua_two_state_discrete.js.map +0 -1
- package/dist/source/interfaces/data_access/ua_y_array_item.d.ts +0 -19
- package/dist/source/interfaces/data_access/ua_y_array_item.js +0 -3
- package/dist/source/interfaces/data_access/ua_y_array_item.js.map +0 -1
- package/dist/source/interfaces/state_machine/exclusive_limit_state_machine.d.ts +0 -11
- package/dist/source/interfaces/state_machine/exclusive_limit_state_machine.js +0 -3
- package/dist/source/interfaces/state_machine/exclusive_limit_state_machine.js.map +0 -1
- package/dist/source/interfaces/state_machine/finite_state_machine.d.ts +0 -70
- package/dist/source/interfaces/state_machine/finite_state_machine.js +0 -3
- package/dist/source/interfaces/state_machine/finite_state_machine.js.map +0 -1
- package/dist/source/interfaces/state_machine/program_finite_state_machine.d.ts +0 -74
- package/dist/source/interfaces/state_machine/program_finite_state_machine.js +0 -3
- package/dist/source/interfaces/state_machine/program_finite_state_machine.js.map +0 -1
- package/dist/source/interfaces/state_machine/state_machine.d.ts +0 -342
- package/dist/source/interfaces/state_machine/state_machine.js +0 -3
- package/dist/source/interfaces/state_machine/state_machine.js.map +0 -1
- package/dist/source/interfaces/state_machine/ua_finite_state_variable.d.ts +0 -18
- package/dist/source/interfaces/state_machine/ua_finite_state_variable.js +0 -3
- package/dist/source/interfaces/state_machine/ua_finite_state_variable.js.map +0 -1
- package/dist/source/interfaces/state_machine/ua_state_variable.d.ts +0 -29
- package/dist/source/interfaces/state_machine/ua_state_variable.js +0 -3
- package/dist/source/interfaces/state_machine/ua_state_variable.js.map +0 -1
- package/dist/source/interfaces/state_machine/ua_two_state_variable.d.ts +0 -26
- package/dist/source/interfaces/state_machine/ua_two_state_variable.js +0 -3
- package/dist/source/interfaces/state_machine/ua_two_state_variable.js.map +0 -1
- package/dist/source/interfaces/subscription_diagnostics_variable.d.ts +0 -41
- package/dist/source/interfaces/subscription_diagnostics_variable.js +0 -3
- package/dist/source/interfaces/subscription_diagnostics_variable.js.map +0 -1
- package/dist/src/alarms_and_conditions/base_event_type.d.ts +0 -26
- package/dist/src/alarms_and_conditions/base_event_type.js +0 -41
- package/dist/src/alarms_and_conditions/base_event_type.js.map +0 -1
- package/dist/src/alarms_and_conditions/shelving_state_machine.d.ts +0 -22
- package/dist/src/alarms_and_conditions/shelving_state_machine.js +0 -241
- package/dist/src/alarms_and_conditions/shelving_state_machine.js.map +0 -1
- package/dist/src/alarms_and_conditions/trip_alarm.d.ts +0 -16
- package/dist/src/alarms_and_conditions/trip_alarm.js +0 -21
- package/dist/src/alarms_and_conditions/trip_alarm.js.map +0 -1
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_base.d.ts +0 -54
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_base.js +0 -255
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_base.js.map +0 -1
- package/dist/src/alarms_and_conditions/ua_alarm_condition_base.d.ts +0 -138
- package/dist/src/alarms_and_conditions/ua_alarm_condition_base.js +0 -460
- package/dist/src/alarms_and_conditions/ua_alarm_condition_base.js.map +0 -1
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm.d.ts +0 -35
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm.js +0 -32
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm.js.map +0 -1
- package/dist/src/alarms_and_conditions/ua_condition_base.d.ts +0 -191
- package/dist/src/alarms_and_conditions/ua_condition_base.js +0 -1029
- package/dist/src/alarms_and_conditions/ua_condition_base.js.map +0 -1
- package/dist/src/alarms_and_conditions/ua_discrete_alarm.d.ts +0 -11
- package/dist/src/alarms_and_conditions/ua_discrete_alarm.js +0 -58
- package/dist/src/alarms_and_conditions/ua_discrete_alarm.js.map +0 -1
- package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm.d.ts +0 -24
- package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm.js +0 -59
- package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm.js.map +0 -1
- package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm.d.ts +0 -14
- package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm.js +0 -17
- package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm.js.map +0 -1
- package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm.d.ts +0 -22
- package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm.js +0 -87
- package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm.js.map +0 -1
- package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm.d.ts +0 -6
- package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm.js +0 -11
- package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm.js.map +0 -1
- package/dist/src/alarms_and_conditions/ua_limit_alarm.d.ts +0 -76
- package/dist/src/alarms_and_conditions/ua_limit_alarm.js +0 -237
- package/dist/src/alarms_and_conditions/ua_limit_alarm.js.map +0 -1
- package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm.d.ts +0 -27
- package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm.js +0 -62
- package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm.js.map +0 -1
- package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm.d.ts +0 -49
- package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm.js +0 -176
- package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm.js.map +0 -1
- package/dist/src/alarms_and_conditions/ua_off_normal_alarm.d.ts +0 -47
- package/dist/src/alarms_and_conditions/ua_off_normal_alarm.js +0 -151
- package/dist/src/alarms_and_conditions/ua_off_normal_alarm.js.map +0 -1
- package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm.d.ts +0 -16
- package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm.js +0 -18
- package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm.js.map +0 -1
- package/dist/src/base_node.d.ts +0 -289
- package/dist/src/base_node.js +0 -1345
- package/dist/src/base_node.js.map +0 -1
- package/dist/src/data_access/ua_analog_item.d.ts +0 -13
- package/dist/src/data_access/ua_analog_item.js +0 -37
- package/dist/src/data_access/ua_analog_item.js.map +0 -1
- package/dist/src/data_access/ua_data_item.d.ts +0 -16
- package/dist/src/data_access/ua_data_item.js +0 -66
- package/dist/src/data_access/ua_data_item.js.map +0 -1
- package/dist/src/data_access/ua_multistate_discrete.d.ts +0 -24
- package/dist/src/data_access/ua_multistate_discrete.js +0 -132
- package/dist/src/data_access/ua_multistate_discrete.js.map +0 -1
- package/dist/src/namespace.d.ts +0 -472
- package/dist/src/namespace.js +0 -1751
- package/dist/src/namespace.js.map +0 -1
- package/dist/src/reference.d.ts +0 -43
- package/dist/src/reference.js +0 -138
- package/dist/src/reference.js.map +0 -1
- package/dist/src/session_context.d.ts +0 -4
- package/dist/src/session_context.js +0 -9
- package/dist/src/session_context.js.map +0 -1
- package/dist/src/ua_data_type.d.ts +0 -83
- package/dist/src/ua_data_type.js +0 -289
- package/dist/src/ua_data_type.js.map +0 -1
- package/dist/src/ua_method.d.ts +0 -41
- package/dist/src/ua_method.js +0 -202
- package/dist/src/ua_method.js.map +0 -1
- package/dist/src/ua_object.d.ts +0 -28
- package/dist/src/ua_object.js +0 -153
- package/dist/src/ua_object.js.map +0 -1
- package/dist/src/ua_object_type.d.ts +0 -49
- package/dist/src/ua_object_type.js +0 -123
- package/dist/src/ua_object_type.js.map +0 -1
- package/dist/src/ua_reference_type.d.ts +0 -42
- package/dist/src/ua_reference_type.js +0 -138
- package/dist/src/ua_reference_type.js.map +0 -1
- package/dist/src/ua_variable.d.ts +0 -339
- package/dist/src/ua_variable.js +0 -1706
- package/dist/src/ua_variable.js.map +0 -1
- package/dist/src/ua_variable_type.d.ts +0 -57
- package/dist/src/ua_variable_type.js +0 -530
- package/dist/src/ua_variable_type.js.map +0 -1
- package/dist/src/ua_view.d.ts +0 -16
- package/dist/src/ua_view.js +0 -42
- package/dist/src/ua_view.js.map +0 -1
package/src/ua_data_type_impl.ts
CHANGED
|
@@ -5,19 +5,28 @@ import * as chalk from "chalk";
|
|
|
5
5
|
|
|
6
6
|
import { assert } from "node-opcua-assert";
|
|
7
7
|
import { NodeClass, QualifiedNameLike } from "node-opcua-data-model";
|
|
8
|
-
import { StructuredTypeSchema } from "node-opcua-factory";
|
|
8
|
+
import { EnumerationDefinition, StructuredTypeSchema } from "node-opcua-factory";
|
|
9
9
|
import { AttributeIds } from "node-opcua-data-model";
|
|
10
10
|
import { DataValue, DataValueLike } from "node-opcua-data-value";
|
|
11
11
|
import { ExtensionObject } from "node-opcua-extension-object";
|
|
12
12
|
import { ExpandedNodeId, NodeId } from "node-opcua-nodeid";
|
|
13
13
|
import { NumericRange } from "node-opcua-numeric-range";
|
|
14
14
|
import { StatusCodes } from "node-opcua-status-code";
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
DataTypeDefinition,
|
|
17
|
+
EnumDefinition,
|
|
18
|
+
EnumFieldOptions,
|
|
19
|
+
StructureDefinition,
|
|
20
|
+
StructureField,
|
|
21
|
+
StructureFieldOptions,
|
|
22
|
+
StructureType
|
|
23
|
+
} from "node-opcua-types";
|
|
16
24
|
import { DataType } from "node-opcua-variant";
|
|
17
|
-
import { UAObject, ISessionContext, UADataType, UAVariable, BaseNode } from "node-opcua-address-space-base";
|
|
25
|
+
import { UAObject, ISessionContext, UADataType, UAVariable, BaseNode, CreateDataTypeOptions } from "node-opcua-address-space-base";
|
|
26
|
+
import { DataTypeIds } from "node-opcua-constants";
|
|
18
27
|
|
|
19
28
|
import { SessionContext } from "../source/session_context";
|
|
20
|
-
import { BaseNodeImpl } from "./base_node_impl";
|
|
29
|
+
import { BaseNodeImpl, InternalBaseNodeOptions } from "./base_node_impl";
|
|
21
30
|
import { BaseNode_References_toString, BaseNode_toString, ToStringBuilder, ToStringOption } from "./base_node_private";
|
|
22
31
|
import * as tools from "./tool_isSupertypeOf";
|
|
23
32
|
import { get_subtypeOf } from "./tool_isSupertypeOf";
|
|
@@ -44,13 +53,10 @@ export interface EnumerationInfo {
|
|
|
44
53
|
nameIndex: { [id: string]: IEnumItem };
|
|
45
54
|
valueIndex: { [id: number]: IEnumItem };
|
|
46
55
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return dataType.nodeId.value as DataType;
|
|
52
|
-
}
|
|
53
|
-
return findBasicDataType(dataType.subtypeOfObj as UADataType);
|
|
56
|
+
export interface UADataTypeOptions extends InternalBaseNodeOptions {
|
|
57
|
+
partialDefinition: StructureFieldOptions[] | EnumFieldOptions[];
|
|
58
|
+
isAbstract?: boolean;
|
|
59
|
+
symbolicName?: string;
|
|
54
60
|
}
|
|
55
61
|
|
|
56
62
|
export class UADataTypeImpl extends BaseNodeImpl implements UADataType {
|
|
@@ -83,18 +89,23 @@ export class UADataTypeImpl extends BaseNodeImpl implements UADataType {
|
|
|
83
89
|
|
|
84
90
|
private enumStrings?: any;
|
|
85
91
|
private enumValues?: any;
|
|
86
|
-
private $
|
|
87
|
-
private $fullDefinition?:
|
|
92
|
+
private $partialDefinition?: StructureFieldOptions[] | EnumFieldOptions[];
|
|
93
|
+
private $fullDefinition?: StructureDefinition | EnumDefinition;
|
|
88
94
|
|
|
89
|
-
constructor(options:
|
|
95
|
+
constructor(options: UADataTypeOptions) {
|
|
90
96
|
super(options);
|
|
91
|
-
|
|
92
|
-
|
|
97
|
+
if (options.partialDefinition) {
|
|
98
|
+
this.$partialDefinition = options.partialDefinition;
|
|
99
|
+
}
|
|
100
|
+
this.isAbstract = options.isAbstract === undefined || options.isAbstract === null ? false : options.isAbstract;
|
|
93
101
|
this.symbolicName = options.symbolicName || this.browseName.name!;
|
|
94
102
|
}
|
|
95
103
|
|
|
96
104
|
public get basicDataType(): DataType {
|
|
97
|
-
return
|
|
105
|
+
return this.getBasicDataType();
|
|
106
|
+
}
|
|
107
|
+
public getBasicDataType(): DataType {
|
|
108
|
+
return this.addressSpace.findCorrespondingBasicDataType(this);
|
|
98
109
|
}
|
|
99
110
|
|
|
100
111
|
public readAttribute(
|
|
@@ -113,7 +124,7 @@ export class UADataTypeImpl extends BaseNodeImpl implements UADataType {
|
|
|
113
124
|
break;
|
|
114
125
|
case AttributeIds.DataTypeDefinition:
|
|
115
126
|
{
|
|
116
|
-
const _definition = this._getDefinition(
|
|
127
|
+
const _definition = this._getDefinition()?.clone();
|
|
117
128
|
if (_definition !== null) {
|
|
118
129
|
options.value = { dataType: DataType.ExtensionObject, value: _definition };
|
|
119
130
|
} else {
|
|
@@ -246,57 +257,92 @@ export class UADataTypeImpl extends BaseNodeImpl implements UADataType {
|
|
|
246
257
|
return indexes;
|
|
247
258
|
}
|
|
248
259
|
|
|
249
|
-
|
|
260
|
+
isStructure(): boolean {
|
|
261
|
+
const definition = this._getDefinition();
|
|
262
|
+
return definition instanceof StructureDefinition;
|
|
263
|
+
}
|
|
264
|
+
getStructureDefinition(): StructureDefinition {
|
|
265
|
+
const definition = this._getDefinition();
|
|
266
|
+
assert(definition instanceof StructureDefinition);
|
|
267
|
+
return definition as StructureDefinition;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
isEnumeration(): boolean {
|
|
271
|
+
const definition = this._getDefinition();
|
|
272
|
+
return definition instanceof EnumDefinition;
|
|
273
|
+
}
|
|
274
|
+
getEnumDefinition(): EnumDefinition {
|
|
275
|
+
const definition = this._getDefinition();
|
|
276
|
+
assert(definition instanceof EnumDefinition);
|
|
277
|
+
return definition as EnumDefinition;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// eslint-disable-next-line complexity
|
|
281
|
+
public _getDefinition(): DataTypeDefinition | null {
|
|
250
282
|
if (this.$fullDefinition !== undefined) {
|
|
251
|
-
return
|
|
283
|
+
return this.$fullDefinition;
|
|
252
284
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
285
|
+
const addressSpace = this.addressSpace;
|
|
286
|
+
const enumeration = addressSpace.findDataType("Enumeration");
|
|
287
|
+
const structure = addressSpace.findDataType("Structure");
|
|
288
|
+
const union = addressSpace.findDataType("Union");
|
|
289
|
+
|
|
290
|
+
// we have a data type from a companion specification
|
|
291
|
+
// let's see if this data type need to be registered
|
|
292
|
+
const isEnumeration = enumeration && this.isSupertypeOf(enumeration);
|
|
293
|
+
const isStructure = structure && this.isSupertypeOf(structure);
|
|
294
|
+
const isUnion = !!(structure && union && this.isSupertypeOf(union));
|
|
295
|
+
|
|
296
|
+
const isRootDataType = (n: UADataType) => n.nodeId.namespace === 0 && n.nodeId.value === DataTypeIds.BaseDataType;
|
|
297
|
+
// https://reference.opcfoundation.org/v104/Core/docs/Part3/8.49/#Table34
|
|
298
|
+
if (isStructure) {
|
|
299
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
300
|
+
let dataTypeNode: UADataTypeImpl | null = this;
|
|
301
|
+
const allPartialDefinitions: StructureFieldOptions[][] = [];
|
|
302
|
+
while (dataTypeNode && !isRootDataType(dataTypeNode)) {
|
|
303
|
+
if (dataTypeNode.$partialDefinition) {
|
|
304
|
+
allPartialDefinitions.push(dataTypeNode.$partialDefinition as StructureFieldOptions[]);
|
|
305
|
+
}
|
|
306
|
+
dataTypeNode = dataTypeNode.subtypeOfObj as UADataTypeImpl | null;
|
|
257
307
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
308
|
+
// merge them:
|
|
309
|
+
const definitionFields: StructureFieldOptions[] = [];
|
|
310
|
+
for (const dd of allPartialDefinitions.reverse()) {
|
|
311
|
+
definitionFields.push(...dd);
|
|
261
312
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
313
|
+
const basicDataType = this.subtypeOfObj?.nodeId || new NodeId();
|
|
314
|
+
const defaultEncodingId = this.binaryEncodingNodeId || this.xmlEncodingNodeId || new NodeId();
|
|
315
|
+
const definitionName = this.browseName.name!;
|
|
316
|
+
this.$fullDefinition = makeStructureDefinition(
|
|
317
|
+
definitionName,
|
|
318
|
+
basicDataType,
|
|
319
|
+
defaultEncodingId,
|
|
320
|
+
definitionFields,
|
|
321
|
+
isUnion
|
|
322
|
+
);
|
|
323
|
+
} else if (isEnumeration) {
|
|
324
|
+
const allPartialDefinitions: StructureFieldOptions[][] = [];
|
|
325
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
326
|
+
let dataTypeNode: UADataTypeImpl | null = this;
|
|
327
|
+
while (dataTypeNode && !isRootDataType(dataTypeNode)) {
|
|
328
|
+
if (dataTypeNode.$partialDefinition) {
|
|
329
|
+
allPartialDefinitions.push(dataTypeNode.$partialDefinition as StructureFieldOptions[]);
|
|
330
|
+
}
|
|
331
|
+
dataTypeNode = dataTypeNode.subtypeOfObj as UADataTypeImpl | null;
|
|
281
332
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
if (this.subtypeOfObj) {
|
|
287
|
-
_baseDefinition = (this.subtypeOfObj as UADataTypeImpl)._getDefinition(mergeWithBase);
|
|
288
|
-
}
|
|
289
|
-
if (this.$fullDefinition && this.$definition instanceof StructureDefinition && _baseDefinition) {
|
|
290
|
-
const b = _baseDefinition as StructureDefinition;
|
|
291
|
-
if (b.fields?.length) {
|
|
292
|
-
const f = this.$fullDefinition as StructureDefinition;
|
|
293
|
-
f.fields = (<StructureField[]>[]).concat(b.fields!, f.fields!);
|
|
333
|
+
// merge them:
|
|
334
|
+
const definitionFields: StructureFieldOptions[] = [];
|
|
335
|
+
for (const dd of allPartialDefinitions.reverse()) {
|
|
336
|
+
definitionFields.push(...dd);
|
|
294
337
|
}
|
|
338
|
+
this.$fullDefinition = makeEnumDefinition(definitionFields);
|
|
295
339
|
}
|
|
296
|
-
|
|
340
|
+
|
|
341
|
+
return this.$fullDefinition!;
|
|
297
342
|
}
|
|
343
|
+
|
|
298
344
|
public getDefinition(): DataTypeDefinition {
|
|
299
|
-
const d = this._getDefinition(
|
|
345
|
+
const d = this._getDefinition();
|
|
300
346
|
if (!d) {
|
|
301
347
|
throw new Error("DataType has no definition property");
|
|
302
348
|
}
|
|
@@ -315,7 +361,7 @@ export class UADataTypeImpl extends BaseNodeImpl implements UADataType {
|
|
|
315
361
|
}
|
|
316
362
|
|
|
317
363
|
function dataTypeDefinition_toString(this: UADataTypeImpl, options: ToStringOption) {
|
|
318
|
-
const definition = this._getDefinition(
|
|
364
|
+
const definition = this._getDefinition();
|
|
319
365
|
if (!definition) {
|
|
320
366
|
return;
|
|
321
367
|
}
|
|
@@ -354,3 +400,64 @@ export function DataType_toString(this: UADataTypeImpl, options: ToStringOption)
|
|
|
354
400
|
|
|
355
401
|
dataTypeDefinition_toString.call(this, options);
|
|
356
402
|
}
|
|
403
|
+
|
|
404
|
+
function makeEnumDefinition(definitionFields: EnumFieldOptions[]) {
|
|
405
|
+
return new EnumDefinition({
|
|
406
|
+
fields: definitionFields.map((x) => ({
|
|
407
|
+
description: x.description,
|
|
408
|
+
name: x.name,
|
|
409
|
+
value: x.value
|
|
410
|
+
}))
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
function makeStructureDefinition(
|
|
414
|
+
name: string,
|
|
415
|
+
baseDataType: NodeId,
|
|
416
|
+
defaultEncodingId: NodeId,
|
|
417
|
+
fields: StructureFieldOptions[],
|
|
418
|
+
isUnion: boolean
|
|
419
|
+
): StructureDefinition {
|
|
420
|
+
// Structure = 0,
|
|
421
|
+
// StructureWithOptionalFields = 1,
|
|
422
|
+
// Union = 2,
|
|
423
|
+
const hasOptionalFields = fields.filter((field) => field.isOptional).length > 0;
|
|
424
|
+
|
|
425
|
+
const structureType = isUnion
|
|
426
|
+
? StructureType.Union
|
|
427
|
+
: hasOptionalFields
|
|
428
|
+
? StructureType.StructureWithOptionalFields
|
|
429
|
+
: StructureType.Structure;
|
|
430
|
+
|
|
431
|
+
const sd = new StructureDefinition({
|
|
432
|
+
baseDataType,
|
|
433
|
+
defaultEncodingId,
|
|
434
|
+
fields,
|
|
435
|
+
structureType
|
|
436
|
+
});
|
|
437
|
+
return sd;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/*
|
|
441
|
+
function lockReadOnlyWithWriteDetection<T>(obj: T): T {
|
|
442
|
+
if (obj instanceof Array) {
|
|
443
|
+
return obj.map(lockReadOnlyWithWriteDetection) as unknown as T;
|
|
444
|
+
}
|
|
445
|
+
if (obj instanceof Object) {
|
|
446
|
+
const _org = obj;
|
|
447
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
448
|
+
lockReadOnlyWithWriteDetection(value);
|
|
449
|
+
}
|
|
450
|
+
obj = new Proxy(obj, {
|
|
451
|
+
get: (target: any, prop: string) => {
|
|
452
|
+
return target[prop];
|
|
453
|
+
},
|
|
454
|
+
set: (target: any, prop: string | symbol, value: any, receiver: any) => {
|
|
455
|
+
console.log("QQQQQ Cannot modify stuff ");
|
|
456
|
+
debugger;
|
|
457
|
+
throw new Error("Invalid");
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
return obj;
|
|
462
|
+
}
|
|
463
|
+
*/
|
package/src/ua_method_impl.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module node-opcua-address-space
|
|
3
3
|
*/
|
|
4
|
+
import { callbackify } from "util";
|
|
4
5
|
import * as chalk from "chalk";
|
|
5
6
|
import { assert } from "node-opcua-assert";
|
|
6
7
|
|
|
@@ -11,13 +12,14 @@ import { make_debugLog, make_errorLog, make_warningLog } from "node-opcua-debug"
|
|
|
11
12
|
import { NodeId } from "node-opcua-nodeid";
|
|
12
13
|
import { NumericRange } from "node-opcua-numeric-range";
|
|
13
14
|
import { Argument } from "node-opcua-service-call";
|
|
14
|
-
import { StatusCodes } from "node-opcua-status-code";
|
|
15
|
+
import { CallbackT, StatusCodes } from "node-opcua-status-code";
|
|
15
16
|
import { CallMethodResultOptions, PermissionType } from "node-opcua-types";
|
|
16
17
|
import { Variant } from "node-opcua-variant";
|
|
17
18
|
import { DataType, VariantLike } from "node-opcua-variant";
|
|
18
19
|
import {
|
|
19
20
|
MethodFunctor,
|
|
20
|
-
|
|
21
|
+
MethodFunctorA,
|
|
22
|
+
MethodFunctorC,
|
|
21
23
|
UAMethod,
|
|
22
24
|
UAObject,
|
|
23
25
|
CloneExtraInfo,
|
|
@@ -122,6 +124,10 @@ export class UAMethodImpl extends BaseNodeImpl implements UAMethod {
|
|
|
122
124
|
|
|
123
125
|
public bindMethod(async_func: MethodFunctor): void {
|
|
124
126
|
assert(typeof async_func === "function");
|
|
127
|
+
if (async_func.length === 2) {
|
|
128
|
+
async_func = callbackify(async_func as MethodFunctorA) as MethodFunctorC;
|
|
129
|
+
}
|
|
130
|
+
assert(async_func.length === 3);
|
|
125
131
|
this._asyncExecutionFunction = async_func;
|
|
126
132
|
}
|
|
127
133
|
public execute(
|
|
@@ -133,13 +139,13 @@ export class UAMethodImpl extends BaseNodeImpl implements UAMethod {
|
|
|
133
139
|
object: UAObject | UAObjectType | null,
|
|
134
140
|
inputArguments: null | VariantLike[],
|
|
135
141
|
context: ISessionContext,
|
|
136
|
-
callback:
|
|
142
|
+
callback: CallbackT<CallMethodResultOptions>
|
|
137
143
|
): void;
|
|
138
144
|
public execute(
|
|
139
145
|
object: UAObject | UAObjectType | null,
|
|
140
146
|
inputArguments: VariantLike[] | null,
|
|
141
147
|
context: ISessionContext,
|
|
142
|
-
callback?:
|
|
148
|
+
callback?: CallbackT<CallMethodResultOptions>
|
|
143
149
|
): any {
|
|
144
150
|
// istanbul ignore next
|
|
145
151
|
if (!callback) {
|
|
@@ -200,7 +206,7 @@ export class UAMethodImpl extends BaseNodeImpl implements UAMethod {
|
|
|
200
206
|
this as UAMethodImpl,
|
|
201
207
|
inputArguments as Variant[],
|
|
202
208
|
context,
|
|
203
|
-
(err: Error | null, callMethodResult
|
|
209
|
+
(err: Error | null, callMethodResult?: CallMethodResultOptions) => {
|
|
204
210
|
if (err) {
|
|
205
211
|
debugLog(err.message);
|
|
206
212
|
debugLog(err);
|