node-opcua-address-space 2.136.0 → 2.138.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/helpers/adjust_browse_direction.js +1 -2
- package/dist/source/helpers/adjust_browse_direction.js.map +1 -1
- package/dist/source/helpers/argument_list.js +6 -7
- package/dist/source/helpers/argument_list.js.map +1 -1
- package/dist/source/helpers/call_helpers.js +1 -2
- package/dist/source/helpers/call_helpers.js.map +1 -1
- package/dist/source/helpers/coerce_enum_value.js +1 -2
- package/dist/source/helpers/coerce_enum_value.js.map +1 -1
- package/dist/source/helpers/dump_tools.js +5 -6
- package/dist/source/helpers/dump_tools.js.map +1 -1
- package/dist/source/helpers/ensure_secure_access.js +1 -2
- package/dist/source/helpers/ensure_secure_access.js.map +1 -1
- package/dist/source/helpers/make_optionals_map.d.ts +1 -3
- package/dist/source/helpers/make_optionals_map.js +7 -4
- package/dist/source/helpers/make_optionals_map.js.map +1 -1
- package/dist/source/helpers/multiform_func.js +2 -3
- package/dist/source/helpers/multiform_func.js.map +1 -1
- package/dist/source/helpers/resolve_opaque_on_address_space.js +1 -2
- package/dist/source/helpers/resolve_opaque_on_address_space.js.map +1 -1
- package/dist/source/index.d.ts +2 -0
- package/dist/source/index.js +2 -0
- package/dist/source/index.js.map +1 -1
- package/dist/source/interfaces/alarms_and_conditions/condition_snapshot.d.ts +0 -3
- package/dist/source/interfaces/alarms_and_conditions/ua_acknowledgeable_condition_ex.d.ts +0 -2
- package/dist/source/interfaces/alarms_and_conditions/ua_condition_ex.d.ts +0 -2
- package/dist/source/interfaces/alarms_and_conditions/ua_discrete_alarm_ex.js.map +1 -1
- package/dist/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.d.ts +1 -1
- package/dist/source/interfaces/state_machine/ua_shelved_state_machine_ex.d.ts +1 -2
- package/dist/source/interfaces/state_machine/ua_state_machine_type.d.ts +1 -0
- package/dist/source/loader/decode_xml_extension_object.d.ts +1 -1
- package/dist/source/loader/decode_xml_extension_object.js +4 -5
- package/dist/source/loader/decode_xml_extension_object.js.map +1 -1
- package/dist/source/loader/ensure_datatype_extracted.js +32 -4
- package/dist/source/loader/ensure_datatype_extracted.js.map +1 -1
- package/dist/source/loader/generateAddressSpaceRaw.js +3 -4
- package/dist/source/loader/generateAddressSpaceRaw.js.map +1 -1
- package/dist/source/loader/load_nodeset2.js +145 -737
- package/dist/source/loader/load_nodeset2.js.map +1 -1
- package/dist/source/loader/make_semver_compatible.js +1 -2
- package/dist/source/loader/make_semver_compatible.js.map +1 -1
- package/dist/source/loader/make_xml_extension_object_parser.d.ts +1 -6
- package/dist/source/loader/make_xml_extension_object_parser.js +52 -73
- package/dist/source/loader/make_xml_extension_object_parser.js.map +1 -1
- package/dist/source/loader/namespace_post_step.d.ts +4 -6
- package/dist/source/loader/namespace_post_step.js +5 -5
- package/dist/source/loader/namespace_post_step.js.map +1 -1
- package/dist/source/loader/parsers/extension_object_parser.d.ts +51 -0
- package/dist/source/loader/parsers/extension_object_parser.js +269 -0
- package/dist/source/loader/parsers/extension_object_parser.js.map +1 -0
- package/dist/source/loader/parsers/localized_text_parser.d.ts +25 -0
- package/dist/source/loader/parsers/localized_text_parser.js +30 -0
- package/dist/source/loader/parsers/localized_text_parser.js.map +1 -0
- package/dist/source/loader/parsers/nodeid_parser.d.ts +11 -0
- package/dist/source/loader/parsers/nodeid_parser.js +20 -0
- package/dist/source/loader/parsers/nodeid_parser.js.map +1 -0
- package/dist/source/loader/parsers/qualified_name_parser.d.ts +26 -0
- package/dist/source/loader/parsers/qualified_name_parser.js +35 -0
- package/dist/source/loader/parsers/qualified_name_parser.js.map +1 -0
- package/dist/source/loader/parsers/variant_parser.d.ts +29 -0
- package/dist/source/loader/parsers/variant_parser.js +328 -0
- package/dist/source/loader/parsers/variant_parser.js.map +1 -0
- package/dist/source/loader/register_node_promoter.js +2 -3
- package/dist/source/loader/register_node_promoter.js.map +1 -1
- package/dist/source/pseudo_session.d.ts +0 -2
- package/dist/source/pseudo_session.js +3 -3
- package/dist/source/pseudo_session.js.map +1 -1
- package/dist/source/session_context.d.ts +1 -1
- package/dist/source/session_context.js +3 -3
- package/dist/source/session_context.js.map +1 -1
- package/dist/source/set_namespace_meta_data.js +1 -2
- package/dist/source/set_namespace_meta_data.js.map +1 -1
- package/dist/source/ua_addin.d.ts +11 -0
- package/dist/source/ua_addin.js +42 -0
- package/dist/source/ua_addin.js.map +1 -0
- package/dist/source/ua_interface.d.ts +3 -0
- package/dist/source/ua_interface.js +45 -0
- package/dist/source/ua_interface.js.map +1 -0
- package/dist/source/xml_writer.d.ts +3 -5
- package/dist/src/_instantiate_helpers.d.ts +1 -1
- package/dist/src/_instantiate_helpers.js +7 -8
- package/dist/src/_instantiate_helpers.js.map +1 -1
- package/dist/src/_mandatory_child_or_requested_optional_filter.d.ts +3 -1
- package/dist/src/_mandatory_child_or_requested_optional_filter.js +6 -5
- package/dist/src/_mandatory_child_or_requested_optional_filter.js.map +1 -1
- package/dist/src/address_space.d.ts +1 -5
- package/dist/src/address_space.js +1 -1
- package/dist/src/address_space.js.map +1 -1
- package/dist/src/address_space_change_event_tools.js +3 -4
- package/dist/src/address_space_change_event_tools.js.map +1 -1
- package/dist/src/alarms_and_conditions/condition.d.ts +4 -7
- package/dist/src/alarms_and_conditions/condition.js +1 -25
- package/dist/src/alarms_and_conditions/condition.js.map +1 -1
- package/dist/src/alarms_and_conditions/condition_snapshot_impl.d.ts +2 -20
- package/dist/src/alarms_and_conditions/condition_snapshot_impl.js +211 -234
- package/dist/src/alarms_and_conditions/condition_snapshot_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/deviation_alarm_helper.js +4 -5
- package/dist/src/alarms_and_conditions/deviation_alarm_helper.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.d.ts +0 -2
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js +1 -2
- package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_base_event_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.d.ts +0 -2
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js +3 -3
- 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 +0 -2
- package/dist/src/alarms_and_conditions/ua_condition_impl.js +10 -12
- package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.js.map +1 -1
- package/dist/src/apply_condition_refresh.d.ts +1 -3
- package/dist/src/apply_condition_refresh.js +4 -5
- package/dist/src/apply_condition_refresh.js.map +1 -1
- package/dist/src/base_node_impl.d.ts +0 -1
- package/dist/src/base_node_impl.js +11 -11
- package/dist/src/base_node_impl.js.map +1 -1
- package/dist/src/base_node_private.d.ts +4 -7
- package/dist/src/base_node_private.js +23 -25
- package/dist/src/base_node_private.js.map +1 -1
- package/dist/src/check_value_rank_compatibility.js +1 -2
- package/dist/src/check_value_rank_compatibility.js.map +1 -1
- package/dist/src/data_access/add_dataItem_stuff.js +1 -2
- package/dist/src/data_access/add_dataItem_stuff.js.map +1 -1
- package/dist/src/data_access/adjust_datavalue_status_code.js +1 -2
- package/dist/src/data_access/adjust_datavalue_status_code.js.map +1 -1
- package/dist/src/data_access/ua_multistate_discrete_impl.js +3 -3
- package/dist/src/data_access/ua_multistate_discrete_impl.js.map +1 -1
- package/dist/src/data_access/ua_multistate_value_discrete_impl.js +5 -5
- package/dist/src/data_access/ua_multistate_value_discrete_impl.js.map +1 -1
- package/dist/src/data_access/ua_two_state_discrete_impl.js +3 -3
- package/dist/src/data_access/ua_two_state_discrete_impl.js.map +1 -1
- package/dist/src/extension_object_array_node.js +4 -5
- package/dist/src/extension_object_array_node.js.map +1 -1
- package/dist/src/get_basic_datatype.js +2 -3
- package/dist/src/get_basic_datatype.js.map +1 -1
- package/dist/src/historical_access/address_space_historical_data_node.js +5 -5
- package/dist/src/historical_access/address_space_historical_data_node.js.map +1 -1
- package/dist/src/index_current.d.ts +3 -1
- package/dist/src/index_current.js +3 -1
- package/dist/src/index_current.js.map +1 -1
- package/dist/src/namespace_impl.d.ts +1 -9
- package/dist/src/namespace_impl.js +19 -12
- package/dist/src/namespace_impl.js.map +1 -1
- package/dist/src/namespace_private.js +1 -2
- package/dist/src/namespace_private.js.map +1 -1
- package/dist/src/nodeid_manager.js +35 -10
- package/dist/src/nodeid_manager.js.map +1 -1
- package/dist/src/nodeset_tools/adjust_namespace_array.js +1 -2
- package/dist/src/nodeset_tools/adjust_namespace_array.js.map +1 -1
- package/dist/src/nodeset_tools/construct_namespace_dependency.d.ts +2 -2
- package/dist/src/nodeset_tools/construct_namespace_dependency.js +12 -12
- package/dist/src/nodeset_tools/construct_namespace_dependency.js.map +1 -1
- package/dist/src/nodeset_tools/dump_to_bsd.js +5 -6
- 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 +53 -46
- package/dist/src/nodeset_tools/nodeset_to_xml.js.map +1 -1
- package/dist/src/private_namespace.js +4 -5
- package/dist/src/private_namespace.js.map +1 -1
- package/dist/src/reference_impl.js +4 -4
- package/dist/src/reference_impl.js.map +1 -1
- package/dist/src/role_permissions.js +1 -2
- package/dist/src/role_permissions.js.map +1 -1
- package/dist/src/state_machine/finite_state_machine.js +6 -6
- package/dist/src/state_machine/finite_state_machine.js.map +1 -1
- package/dist/src/state_machine/ua_shelving_state_machine_ex.d.ts +0 -1
- package/dist/src/state_machine/ua_shelving_state_machine_ex.js +2 -2
- package/dist/src/state_machine/ua_shelving_state_machine_ex.js.map +1 -1
- package/dist/src/state_machine/ua_two_state_variable.js +4 -4
- package/dist/src/state_machine/ua_two_state_variable.js.map +1 -1
- package/dist/src/tool_isSubtypeOf.d.ts +1 -1
- package/dist/src/tool_isSubtypeOf.js +18 -16
- package/dist/src/tool_isSubtypeOf.js.map +1 -1
- package/dist/src/ua_addin.d.ts +11 -0
- package/dist/src/ua_addin.js +43 -0
- package/dist/src/ua_addin.js.map +1 -0
- package/dist/src/ua_data_type_impl.js +7 -6
- package/dist/src/ua_data_type_impl.js.map +1 -1
- package/dist/src/ua_object_type_impl.d.ts +1 -0
- package/dist/src/ua_object_type_impl.js +4 -1
- package/dist/src/ua_object_type_impl.js.map +1 -1
- package/dist/src/ua_reference_type_impl.js +3 -3
- package/dist/src/ua_reference_type_impl.js.map +1 -1
- package/dist/src/ua_variable_impl.js +6 -3
- package/dist/src/ua_variable_impl.js.map +1 -1
- package/dist/src/ua_variable_impl_ext_obj.js +15 -15
- package/dist/src/ua_variable_impl_ext_obj.js.map +1 -1
- package/dist/src/ua_variable_type_impl.d.ts +2 -0
- package/dist/src/ua_variable_type_impl.js +8 -4
- package/dist/src/ua_variable_type_impl.js.map +1 -1
- package/dist/src/validate_data_type_correctness.js +1 -2
- package/dist/src/validate_data_type_correctness.js.map +1 -1
- package/dist/tsconfig_common.tsbuildinfo +1 -1
- package/distHelpers/add_event_generator_object.js +1 -2
- package/distHelpers/add_event_generator_object.js.map +1 -1
- package/distHelpers/alarms_and_conditions_demo.js +1 -2
- package/distHelpers/alarms_and_conditions_demo.js.map +1 -1
- package/distHelpers/assertHasMatchingReference.js +1 -2
- package/distHelpers/assertHasMatchingReference.js.map +1 -1
- package/distHelpers/boiler_system.js +2 -3
- package/distHelpers/boiler_system.js.map +1 -1
- package/distHelpers/create_minimalist_address_space_nodeset.js +1 -2
- package/distHelpers/create_minimalist_address_space_nodeset.js.map +1 -1
- package/distHelpers/date_utils.js +1 -2
- package/distHelpers/date_utils.js.map +1 -1
- package/distHelpers/get_address_space_fixture.js +1 -2
- package/distHelpers/get_address_space_fixture.js.map +1 -1
- package/distHelpers/get_mini_address_space.js +2 -2
- package/distHelpers/get_mini_address_space.js.map +1 -1
- package/distNodeJS/generate_address_space.js +2 -3
- package/distNodeJS/generate_address_space.js.map +1 -1
- package/package.json +24 -24
- package/source/helpers/make_optionals_map.ts +9 -6
- package/source/index.ts +3 -0
- package/source/interfaces/alarms_and_conditions/instantiate_exclusive_deviation_alarm_options.ts +3 -1
- package/source/interfaces/alarms_and_conditions/instantiate_exclusive_limit_alarm_options.ts +3 -1
- package/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_deviation_alarm_options.ts +3 -1
- package/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_limit_alarm_options.ts +3 -1
- package/source/interfaces/alarms_and_conditions/ua_discrete_alarm_ex.ts +3 -1
- package/source/interfaces/alarms_and_conditions/ua_exclusive_deviation_alarm_ex.ts +18 -16
- package/source/interfaces/alarms_and_conditions/ua_exclusive_limit_alarm_ex.ts +5 -3
- package/source/interfaces/data_access/ua_multistate_discrete_ex.ts +4 -2
- package/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.ts +4 -2
- package/source/interfaces/state_machine/ua_program_state_machine_type.ts +3 -1
- package/source/interfaces/state_machine/ua_shelved_state_machine_ex.ts +1 -1
- package/source/interfaces/state_machine/ua_state_machine_type.ts +14 -7
- package/source/loader/decode_xml_extension_object.ts +4 -3
- package/source/loader/ensure_datatype_extracted.ts +38 -2
- package/source/loader/generateAddressSpaceRaw.ts +4 -4
- package/source/loader/load_nodeset2.ts +212 -901
- package/source/loader/make_xml_extension_object_parser.ts +87 -123
- package/source/loader/namespace_post_step.ts +6 -5
- package/source/loader/parsers/extension_object_parser.ts +364 -0
- package/source/loader/parsers/localized_text_parser.ts +34 -0
- package/source/loader/parsers/nodeid_parser.ts +17 -0
- package/source/loader/parsers/qualified_name_parser.ts +43 -0
- package/source/loader/parsers/variant_parser.ts +427 -0
- package/source/loader/register_node_promoter.ts +2 -5
- package/source/session_context.ts +1 -1
- package/source/ua_addin.ts +53 -0
- package/source/ua_interface.ts +49 -0
- package/source/xml_writer.ts +4 -5
- package/src/_instantiate_helpers.ts +9 -3
- package/src/_mandatory_child_or_requested_optional_filter.ts +9 -7
- package/src/address_space.ts +1 -1
- package/src/alarms_and_conditions/condition.ts +0 -32
- package/src/alarms_and_conditions/condition_snapshot_impl.ts +176 -189
- package/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.ts +1 -3
- package/src/alarms_and_conditions/ua_base_event_impl.ts +6 -2
- package/src/alarms_and_conditions/ua_condition_impl.ts +11 -13
- package/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.ts +3 -1
- package/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.ts +3 -1
- package/src/apply_condition_refresh.ts +4 -4
- package/src/base_node_impl.ts +13 -13
- package/src/base_node_private.ts +6 -11
- package/src/data_access/ua_multistate_value_discrete_impl.ts +1 -1
- package/src/historical_access/address_space_historical_data_node.ts +3 -3
- package/src/index_current.ts +4 -1
- package/src/namespace_impl.ts +21 -10
- package/src/nodeid_manager.ts +46 -17
- package/src/nodeset_tools/construct_namespace_dependency.ts +9 -8
- package/src/nodeset_tools/dump_to_bsd.ts +7 -7
- package/src/nodeset_tools/nodeset_to_xml.ts +70 -44
- package/src/private_namespace.ts +2 -1
- package/src/tool_isSubtypeOf.ts +20 -16
- package/src/ua_data_type_impl.ts +5 -4
- package/src/ua_object_type_impl.ts +7 -2
- package/src/ua_reference_type_impl.ts +6 -6
- package/src/ua_variable_impl.ts +4 -0
- package/src/ua_variable_impl_ext_obj.ts +2 -1
- package/src/ua_variable_type_impl.ts +11 -1
|
@@ -18,31 +18,24 @@ import {
|
|
|
18
18
|
UAVariableType
|
|
19
19
|
} from "node-opcua-address-space-base";
|
|
20
20
|
import { assert, renderError } from "node-opcua-assert";
|
|
21
|
-
import {
|
|
22
|
-
import { EUInformation } from "node-opcua-data-access";
|
|
21
|
+
import { StatusCodes } from "node-opcua-basic-types";
|
|
23
22
|
import {
|
|
24
23
|
AccessLevelFlag,
|
|
25
24
|
coerceLocalizedText,
|
|
26
|
-
|
|
25
|
+
LocalizedText,
|
|
27
26
|
makeAccessLevelFlag,
|
|
28
27
|
NodeClass,
|
|
29
28
|
QualifiedName,
|
|
30
|
-
QualifiedNameOptions,
|
|
31
29
|
stringToQualifiedName
|
|
32
30
|
} from "node-opcua-data-model";
|
|
33
31
|
import { checkDebugFlag, make_debugLog, make_errorLog } from "node-opcua-debug";
|
|
34
|
-
import { ExtensionObject } from "node-opcua-extension-object";
|
|
35
32
|
import { getBuiltInType } from "node-opcua-factory";
|
|
36
|
-
import { NodeId,
|
|
37
|
-
import { Argument } from "node-opcua-service-call";
|
|
33
|
+
import { NodeId, resolveNodeId } from "node-opcua-nodeid";
|
|
38
34
|
import { ErrorCallback } from "node-opcua-status-code";
|
|
39
|
-
import { EnumFieldOptions,
|
|
40
|
-
import { DataType, Variant, VariantArrayType, VariantOptions } from "node-opcua-variant";
|
|
35
|
+
import { EnumFieldOptions, StructureFieldOptions } from "node-opcua-types";
|
|
36
|
+
import { DataType, Variant, VariantArrayType, VariantOptions, VariantOptionsT } from "node-opcua-variant";
|
|
41
37
|
import {
|
|
42
38
|
_definitionParser,
|
|
43
|
-
FragmentClonerParser,
|
|
44
|
-
InternalFragmentClonerReaderState,
|
|
45
|
-
ParserLike,
|
|
46
39
|
ReaderState,
|
|
47
40
|
ReaderStateParserLike,
|
|
48
41
|
Xml2Json,
|
|
@@ -56,8 +49,9 @@ import { NamespacePrivate } from "../../src/namespace_private";
|
|
|
56
49
|
import { NodeSetLoaderOptions } from "../interfaces/nodeset_loader_options";
|
|
57
50
|
import { promoteObjectsAndVariables } from "./namespace_post_step";
|
|
58
51
|
import { ensureDatatypeExtracted } from "./ensure_datatype_extracted";
|
|
59
|
-
import { decodeXmlExtensionObject } from "./decode_xml_extension_object";
|
|
60
52
|
import { makeSemverCompatible } from "./make_semver_compatible";
|
|
53
|
+
import { makeVariantReader } from "./parsers/variant_parser";
|
|
54
|
+
import { ExtensionObject } from "node-opcua-extension-object";
|
|
61
55
|
|
|
62
56
|
const doDebug = checkDebugFlag(__filename);
|
|
63
57
|
const debugLog = make_debugLog(__filename);
|
|
@@ -91,7 +85,12 @@ function convertAccessLevel(accessLevel?: string | null): AccessLevelFlag {
|
|
|
91
85
|
|
|
92
86
|
type Task = (addressSpace: IAddressSpace) => Promise<void>;
|
|
93
87
|
|
|
94
|
-
function makeDefaultVariant(
|
|
88
|
+
function makeDefaultVariant(
|
|
89
|
+
addressSpace: IAddressSpace,
|
|
90
|
+
dataTypeNode: NodeId,
|
|
91
|
+
valueRank: number,
|
|
92
|
+
arrayDimensions?: number[] | null
|
|
93
|
+
): VariantOptions | undefined {
|
|
95
94
|
let variant: VariantOptions = { dataType: DataType.Null };
|
|
96
95
|
|
|
97
96
|
const nodeDataType = addressSpace.findNode(dataTypeNode) as UADataType;
|
|
@@ -160,7 +159,7 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
|
|
|
160
159
|
const postTasks1_InitializeVariable: Task[] = [];
|
|
161
160
|
const postTasks2_AssignedExtensionObjectToDataValue: Task[] = [];
|
|
162
161
|
|
|
163
|
-
let
|
|
162
|
+
let aliasMap: Map<string, NodeId> = new Map();
|
|
164
163
|
|
|
165
164
|
/**
|
|
166
165
|
* @param aliasName
|
|
@@ -169,33 +168,32 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
|
|
|
169
168
|
assert(typeof nodeIdInXmlContext === "string");
|
|
170
169
|
const nodeId = _translateNodeId(nodeIdInXmlContext);
|
|
171
170
|
assert(nodeId instanceof NodeId);
|
|
172
|
-
|
|
171
|
+
aliasMap.set(aliasName, nodeId);
|
|
173
172
|
addressSpace1.getNamespace(nodeId.namespace).addAlias(aliasName, nodeId);
|
|
174
173
|
}
|
|
175
174
|
|
|
176
|
-
let
|
|
175
|
+
let namespaceUriTranslationMap: Map<number, number> = new Map();
|
|
177
176
|
let namespaceCounter = 0;
|
|
178
|
-
let
|
|
177
|
+
let foundNamespaceMap: Map<string, NamespacePrivate> = new Map();
|
|
179
178
|
let models: Model[] = [];
|
|
180
179
|
let performedCalled = false;
|
|
181
180
|
|
|
182
181
|
function _reset_namespace_translation() {
|
|
183
182
|
debugLog("_reset_namespace_translation");
|
|
184
|
-
|
|
185
|
-
|
|
183
|
+
namespaceUriTranslationMap.clear();
|
|
184
|
+
foundNamespaceMap.clear();
|
|
186
185
|
namespaceCounter = 0;
|
|
187
|
-
|
|
186
|
+
aliasMap.clear();
|
|
188
187
|
models = [];
|
|
189
188
|
performedCalled = false;
|
|
190
189
|
}
|
|
191
190
|
|
|
192
191
|
function _translateNamespaceIndex(innerIndex: number) {
|
|
193
|
-
const namespaceIndex =
|
|
192
|
+
const namespaceIndex = namespaceUriTranslationMap.get(innerIndex);
|
|
194
193
|
|
|
195
194
|
// istanbul ignore next
|
|
196
195
|
if (namespaceIndex === undefined) {
|
|
197
|
-
errorLog("
|
|
198
|
-
errorLog("Error; namespace_uri_translation", namespace_uri_translation);
|
|
196
|
+
errorLog("Error; namespace_uri_translation", namespaceUriTranslationMap.entries());
|
|
199
197
|
throw new Error("_translateNamespaceIndex() ! Cannot find namespace definition for index " + innerIndex);
|
|
200
198
|
}
|
|
201
199
|
return namespaceIndex;
|
|
@@ -222,7 +220,7 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
|
|
|
222
220
|
}
|
|
223
221
|
|
|
224
222
|
function _register_namespace_uri_in_translation_table(namespaceUri: string): void {
|
|
225
|
-
if (
|
|
223
|
+
if (foundNamespaceMap.has(namespaceUri)) {
|
|
226
224
|
return;
|
|
227
225
|
}
|
|
228
226
|
const namespace = addressSpace1.getNamespace(namespaceUri);
|
|
@@ -231,15 +229,15 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
|
|
|
231
229
|
if (!namespace) {
|
|
232
230
|
throw new Error(
|
|
233
231
|
"cannot find namespace for " +
|
|
234
|
-
|
|
235
|
-
|
|
232
|
+
namespaceUri +
|
|
233
|
+
"\nplease make sure to initialize your address space with the corresponding nodeset files"
|
|
236
234
|
);
|
|
237
235
|
}
|
|
238
|
-
|
|
236
|
+
foundNamespaceMap.set(namespaceUri, namespace);
|
|
239
237
|
|
|
240
238
|
const index_in_xml = namespaceCounter;
|
|
241
239
|
namespaceCounter++;
|
|
242
|
-
|
|
240
|
+
namespaceUriTranslationMap.set(index_in_xml, namespace.index);
|
|
243
241
|
|
|
244
242
|
doDebug &&
|
|
245
243
|
debugLog(
|
|
@@ -320,8 +318,10 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
|
|
|
320
318
|
const reg = /ns=([0-9]+);(.*)/;
|
|
321
319
|
|
|
322
320
|
function _translateNodeId(nodeId: string): NodeId {
|
|
323
|
-
if (
|
|
324
|
-
|
|
321
|
+
if (aliasMap.has(nodeId)) {
|
|
322
|
+
// note alias are already translated to the right namespaces
|
|
323
|
+
const aliasedNodeId = aliasMap.get(nodeId)!;
|
|
324
|
+
return aliasedNodeId;
|
|
325
325
|
}
|
|
326
326
|
const m = nodeId.match(reg);
|
|
327
327
|
if (m) {
|
|
@@ -385,18 +385,19 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
|
|
|
385
385
|
}
|
|
386
386
|
}
|
|
387
387
|
};
|
|
388
|
-
|
|
388
|
+
// #region UAObject
|
|
389
389
|
const state_UAObject = {
|
|
390
390
|
init(this: any, name: string, attrs: XmlAttributes) {
|
|
391
391
|
_perform();
|
|
392
392
|
|
|
393
|
-
this.obj = {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
393
|
+
this.obj = {
|
|
394
|
+
nodeClass: NodeClass.Object,
|
|
395
|
+
isAbstract: coerceBoolean(attrs.IsAbstract),
|
|
396
|
+
nodeId: convertToNodeId(attrs.NodeId) || null,
|
|
397
|
+
browseName: convertQualifiedName(attrs.BrowseName),
|
|
398
|
+
eventNotifier: coerceByte(attrs.EventNotifier) || 0,
|
|
399
|
+
symbolicName: attrs.SymbolicName || null
|
|
400
|
+
};
|
|
400
401
|
|
|
401
402
|
this.isDraft = attrs.ReleaseStatus === "Draft";
|
|
402
403
|
this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
|
|
@@ -423,17 +424,19 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
|
|
|
423
424
|
References: references_parser
|
|
424
425
|
}
|
|
425
426
|
};
|
|
426
|
-
|
|
427
|
+
// #endregion
|
|
428
|
+
// #region UAObjectType
|
|
427
429
|
const state_UAObjectType = {
|
|
428
430
|
init(this: any, name: string, attrs: XmlAttributes) {
|
|
429
431
|
_perform();
|
|
430
432
|
|
|
431
|
-
this.obj = {
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
433
|
+
this.obj = {
|
|
434
|
+
nodeClass: NodeClass.ObjectType,
|
|
435
|
+
isAbstract: coerceBoolean(attrs.IsAbstract),
|
|
436
|
+
nodeId: convertToNodeId(attrs.NodeId) || null,
|
|
437
|
+
browseName: convertQualifiedName(attrs.BrowseName),
|
|
438
|
+
eventNotifier: coerceByte(attrs.EventNotifier) || 0
|
|
439
|
+
};
|
|
437
440
|
},
|
|
438
441
|
finish(this: any) {
|
|
439
442
|
_internal_createNode(this.obj);
|
|
@@ -454,16 +457,18 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
|
|
|
454
457
|
References: references_parser
|
|
455
458
|
}
|
|
456
459
|
};
|
|
457
|
-
|
|
460
|
+
// #endregion
|
|
461
|
+
// #region UAReferenceType
|
|
458
462
|
const state_UAReferenceType = {
|
|
459
463
|
init(this: any, name: string, attrs: XmlAttributes) {
|
|
460
464
|
_perform();
|
|
461
465
|
|
|
462
|
-
this.obj = {
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
466
|
+
this.obj = {
|
|
467
|
+
nodeClass: NodeClass.ReferenceType,
|
|
468
|
+
isAbstract: coerceBoolean(attrs.IsAbstract),
|
|
469
|
+
nodeId: convertToNodeId(attrs.NodeId) || null,
|
|
470
|
+
browseName: convertQualifiedName(attrs.BrowseName)
|
|
471
|
+
};
|
|
467
472
|
},
|
|
468
473
|
finish(this: any) {
|
|
469
474
|
_internal_addReferenceType(this.obj);
|
|
@@ -489,21 +494,22 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
|
|
|
489
494
|
References: references_parser
|
|
490
495
|
}
|
|
491
496
|
};
|
|
492
|
-
|
|
497
|
+
// #endregion
|
|
498
|
+
// #region UADataType
|
|
493
499
|
const pendingSimpleTypeToRegister: any[] = [];
|
|
494
|
-
|
|
495
500
|
const state_UADataType = {
|
|
496
501
|
init(this: any, name: string, attrs: XmlAttributes) {
|
|
497
502
|
_perform();
|
|
498
503
|
|
|
499
|
-
this.obj = {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
504
|
+
this.obj = {
|
|
505
|
+
nodeClass: NodeClass.DataType,
|
|
506
|
+
isAbstract: coerceBoolean(attrs.IsAbstract) || false,
|
|
507
|
+
nodeId: convertToNodeId(attrs.NodeId) || null,
|
|
508
|
+
browseName: convertQualifiedName(attrs.BrowseName),
|
|
509
|
+
displayName: "",
|
|
510
|
+
description: "",
|
|
511
|
+
symbolicName: attrs.SymbolicName
|
|
512
|
+
};
|
|
507
513
|
|
|
508
514
|
this.isDraft = attrs.ReleaseStatus === "Draft";
|
|
509
515
|
this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
|
|
@@ -562,815 +568,91 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
|
|
|
562
568
|
Definition: _definitionParser
|
|
563
569
|
}
|
|
564
570
|
};
|
|
565
|
-
|
|
566
|
-
const
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
finish(this: any) {
|
|
574
|
-
this.parent.localizedText.locale = this.text.trim();
|
|
575
|
-
}
|
|
576
|
-
},
|
|
577
|
-
Text: {
|
|
578
|
-
finish(this: any) {
|
|
579
|
-
this.parent.localizedText.text = this.text.trim();
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
};
|
|
585
|
-
interface QualifiedNameParserChild {
|
|
586
|
-
parent: {
|
|
587
|
-
qualifiedName: QualifiedNameOptions;
|
|
588
|
-
};
|
|
589
|
-
text: string;
|
|
590
|
-
}
|
|
591
|
-
const qualifiedName_parser = {
|
|
592
|
-
QualifiedName: {
|
|
593
|
-
init(this: any) {
|
|
594
|
-
this.qualifiedName = {
|
|
595
|
-
namespaceIndex: 0,
|
|
596
|
-
name: null
|
|
597
|
-
} as QualifiedNameOptions;
|
|
598
|
-
},
|
|
599
|
-
parser: {
|
|
600
|
-
Name: {
|
|
601
|
-
finish(this: QualifiedNameParserChild) {
|
|
602
|
-
this.parent.qualifiedName.name = this.text.trim();
|
|
603
|
-
}
|
|
604
|
-
},
|
|
605
|
-
NamespaceIndex: {
|
|
606
|
-
finish(this: QualifiedNameParserChild) {
|
|
607
|
-
const ns = parseInt(this.text, 10);
|
|
608
|
-
const t = _translateNodeId(resolveNodeId(`ns=${ns};i=1`).toString());
|
|
609
|
-
this.parent.qualifiedName.namespaceIndex = t.namespace;
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
};
|
|
615
|
-
const nodeId_parser = {
|
|
616
|
-
NodeId: {
|
|
617
|
-
init(this: any) {
|
|
618
|
-
this.nodeId = "";
|
|
619
|
-
},
|
|
620
|
-
parser: {
|
|
621
|
-
Identifier: {
|
|
622
|
-
finish(this: any) {
|
|
623
|
-
this.parent.nodeId = _translateNodeId(resolveNodeId(this.text.trim()).toString());
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
};
|
|
629
|
-
const enumValueType_parser = {
|
|
630
|
-
EnumValueType: {
|
|
631
|
-
init(this: any) {
|
|
632
|
-
this.enumValueType = new EnumValueType({
|
|
633
|
-
description: undefined,
|
|
634
|
-
displayName: undefined,
|
|
635
|
-
value: coerceInt64(-1)
|
|
636
|
-
});
|
|
637
|
-
},
|
|
638
|
-
parser: {
|
|
639
|
-
Value: {
|
|
640
|
-
// note: Value may be missing, in this case value shall be set to -1(64)
|
|
641
|
-
finish(this: any) {
|
|
642
|
-
// Low part
|
|
643
|
-
this.parent.enumValueType.value = coerceInt64(parseInt(this.text, 10));
|
|
644
|
-
}
|
|
645
|
-
},
|
|
646
|
-
|
|
647
|
-
DisplayName: {
|
|
648
|
-
...localizedText_parser.LocalizedText,
|
|
649
|
-
finish(this: any) {
|
|
650
|
-
this.parent.enumValueType.displayName = { ...this.localizedText };
|
|
651
|
-
}
|
|
652
|
-
},
|
|
653
|
-
|
|
654
|
-
Description: {
|
|
655
|
-
...localizedText_parser.LocalizedText,
|
|
656
|
-
finish(this: any) {
|
|
657
|
-
this.parent.enumValueType.description = { ...this.localizedText };
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
},
|
|
661
|
-
finish(this: any) {
|
|
662
|
-
this.enumValueType = new EnumValueType(this.enumValueType);
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
};
|
|
666
|
-
|
|
667
|
-
const argument_parser = {
|
|
668
|
-
Argument: {
|
|
669
|
-
init(this: any) {
|
|
670
|
-
this.argument = new Argument({});
|
|
671
|
-
},
|
|
672
|
-
parser: {
|
|
673
|
-
Name: {
|
|
674
|
-
finish(this: any) {
|
|
675
|
-
this.parent.argument.name = this.text.trim();
|
|
676
|
-
}
|
|
677
|
-
},
|
|
678
|
-
|
|
679
|
-
DataType: {
|
|
680
|
-
parser: {
|
|
681
|
-
Identifier: {
|
|
682
|
-
finish(this: any) {
|
|
683
|
-
this.parent.parent.argument.dataType = _translateNodeId(resolveNodeId(this.text.trim()).toString());
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
},
|
|
688
|
-
ValueRank: {
|
|
689
|
-
finish(this: any) {
|
|
690
|
-
this.parent.argument.valueRank = parseInt(this.text.trim(), 10);
|
|
691
|
-
}
|
|
692
|
-
},
|
|
693
|
-
|
|
694
|
-
ArrayDimensions: {
|
|
695
|
-
finish(this: any) {
|
|
696
|
-
// xx this.parent.argument.arrayDimensions =[];
|
|
697
|
-
}
|
|
698
|
-
},
|
|
699
|
-
Description: {
|
|
700
|
-
init(this: any) {
|
|
701
|
-
this._text = "";
|
|
702
|
-
this.locale = null;
|
|
703
|
-
this.text = null;
|
|
704
|
-
},
|
|
705
|
-
parser: {
|
|
706
|
-
Locale: {
|
|
707
|
-
init(this: any) {
|
|
708
|
-
this.text = "";
|
|
709
|
-
},
|
|
710
|
-
finish(this: any) {
|
|
711
|
-
this.parent.locale = this.text.trim();
|
|
712
|
-
}
|
|
713
|
-
},
|
|
714
|
-
Text: {
|
|
715
|
-
finish(this: any) {
|
|
716
|
-
this.text = this.text || "";
|
|
717
|
-
this.parent._text = this.text.trim();
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
},
|
|
721
|
-
finish(this: any) {
|
|
722
|
-
this.parent.argument.description = coerceLocalizedText(this._text);
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
},
|
|
726
|
-
finish(this: any) {
|
|
727
|
-
// xx this.argument = new Argument(this.argument);
|
|
728
|
-
}
|
|
729
|
-
}
|
|
730
|
-
};
|
|
731
|
-
|
|
732
|
-
const Range_parser = {
|
|
733
|
-
Range: {
|
|
734
|
-
init(this: any) {
|
|
735
|
-
this.range = new Range({});
|
|
736
|
-
},
|
|
737
|
-
parser: {
|
|
738
|
-
Low: {
|
|
739
|
-
finish(this: any) {
|
|
740
|
-
this.parent.range.low = parseFloat(this.text);
|
|
741
|
-
}
|
|
742
|
-
},
|
|
743
|
-
|
|
744
|
-
High: {
|
|
745
|
-
finish(this: any) {
|
|
746
|
-
this.parent.range.high = parseFloat(this.text);
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
};
|
|
752
|
-
|
|
753
|
-
const EUInformation_parser = {
|
|
754
|
-
EUInformation: {
|
|
755
|
-
init(this: any) {
|
|
756
|
-
this.euInformation = new EUInformation({});
|
|
757
|
-
},
|
|
758
|
-
parser: {
|
|
759
|
-
NamespaceUri: {
|
|
760
|
-
finish(this: any) {
|
|
761
|
-
this.parent.euInformation.namespaceUri = this.text;
|
|
762
|
-
}
|
|
763
|
-
},
|
|
764
|
-
UnitId: {
|
|
765
|
-
finish(this: any) {
|
|
766
|
-
this.parent.euInformation.unitId = parseInt(this.text, 10);
|
|
767
|
-
}
|
|
768
|
-
},
|
|
769
|
-
|
|
770
|
-
DisplayName: {
|
|
771
|
-
...localizedText_parser.LocalizedText,
|
|
772
|
-
finish(this: any) {
|
|
773
|
-
this.parent.euInformation.displayName = { ...this.localizedText };
|
|
774
|
-
}
|
|
775
|
-
},
|
|
776
|
-
|
|
777
|
-
Description: {
|
|
778
|
-
...localizedText_parser.LocalizedText,
|
|
779
|
-
finish(this: any) {
|
|
780
|
-
this.parent.euInformation.description = { ...this.localizedText };
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
},
|
|
784
|
-
finish(this: any) {
|
|
785
|
-
this.euInformation = new EUInformation(this.euInformation);
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
};
|
|
789
|
-
|
|
790
|
-
const _extensionObject_inner_parser = {
|
|
791
|
-
TypeId: {
|
|
792
|
-
parser: {
|
|
793
|
-
Identifier: {
|
|
794
|
-
finish(this: ExtensionObjectTypeIdIdentifierParser) {
|
|
795
|
-
const typeDefinitionId = this.text.trim();
|
|
796
|
-
const self = this.parent.parent; // ExtensionObject
|
|
797
|
-
self.typeDefinitionId = resolveNodeId(typeDefinitionId);
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
},
|
|
802
|
-
|
|
803
|
-
Body2: new FragmentClonerParser(),
|
|
804
|
-
|
|
805
|
-
Body: {
|
|
806
|
-
parser: {
|
|
807
|
-
Argument: argument_parser.Argument,
|
|
808
|
-
EUInformation: EUInformation_parser.EUInformation,
|
|
809
|
-
EnumValueType: enumValueType_parser.EnumValueType,
|
|
810
|
-
Range: Range_parser.Range
|
|
811
|
-
},
|
|
812
|
-
startElement(this: ExtensionObjectBodyParser, elementName: string, attrs: any) {
|
|
813
|
-
const self = this.parent; // ExtensionObject
|
|
814
|
-
self.extensionObject = null;
|
|
815
|
-
self.extensionObjectPojo = null;
|
|
816
|
-
|
|
817
|
-
if (!Object.prototype.hasOwnProperty.call(this.parser, elementName)) {
|
|
818
|
-
// treat it as a opaque XML bloc for the time being
|
|
819
|
-
// until we find the definition of this object, so we know how to interpret the fields
|
|
820
|
-
this._cloneFragment = new InternalFragmentClonerReaderState();
|
|
821
|
-
this.engine!._promote(this._cloneFragment, this.engine!.currentLevel, elementName, attrs);
|
|
822
|
-
}
|
|
823
|
-
},
|
|
824
|
-
finish(this: ExtensionObjectBodyParser) {
|
|
825
|
-
const self = this.parent; // ExtensionObject
|
|
826
|
-
|
|
827
|
-
// typeDefinitionId is also the "Default XML" encoding nodeId !
|
|
828
|
-
switch (self.typeDefinitionId.toString()) {
|
|
829
|
-
case "i=7616": // EnumValueType
|
|
830
|
-
case "ns=0;i=7616": // EnumValueType
|
|
831
|
-
self.extensionObject = self.parser.Body.parser.EnumValueType.enumValueType;
|
|
832
|
-
assert(self.extensionObject !== null && typeof self.extensionObject === "object");
|
|
833
|
-
assert(self.extensionObject instanceof ExtensionObject);
|
|
834
|
-
break;
|
|
835
|
-
case "i=297": // Arguments
|
|
836
|
-
case "ns=0;i=297": // Arguments
|
|
837
|
-
self.extensionObject = self.parser.Body.parser.Argument.argument;
|
|
838
|
-
assert(self.extensionObject !== null && typeof self.extensionObject === "object");
|
|
839
|
-
assert(self.extensionObject instanceof ExtensionObject);
|
|
840
|
-
break;
|
|
841
|
-
case "i=888":
|
|
842
|
-
case "ns=0;i=888": // EUInformation
|
|
843
|
-
self.extensionObject = self.parser.Body.parser.EUInformation.euInformation;
|
|
844
|
-
assert(self.extensionObject !== null && typeof self.extensionObject === "object");
|
|
845
|
-
assert(self.extensionObject instanceof ExtensionObject);
|
|
846
|
-
break;
|
|
847
|
-
case "i=885": // Range
|
|
848
|
-
case "ns=0;i=885":
|
|
849
|
-
self.extensionObject = self.parser.Body.parser.Range.range;
|
|
850
|
-
assert(self.extensionObject !== null && typeof self.extensionObject === "object");
|
|
851
|
-
assert(self.extensionObject instanceof ExtensionObject);
|
|
852
|
-
break;
|
|
853
|
-
default: {
|
|
854
|
-
// istanbul ignore next
|
|
855
|
-
if (!this._cloneFragment) {
|
|
856
|
-
// the XML file is probably not exposing standard UA extension object correctly.
|
|
857
|
-
// this has been seen in some generated xml files using the dataType nodeId instead of the default encoding
|
|
858
|
-
// nodeid
|
|
859
|
-
errorLog(
|
|
860
|
-
"[NODE-OPCUA-E12] standard OPCUA Extension object from (namespace=0) has a invalid TypeId",
|
|
861
|
-
self.typeDefinitionId.toString()
|
|
862
|
-
);
|
|
863
|
-
break;
|
|
864
|
-
}
|
|
865
|
-
this.bodyXML = this._cloneFragment!.value;
|
|
866
|
-
this._cloneFragment!.value = null;
|
|
867
|
-
|
|
868
|
-
// the "Default Xml" encoding nodeId
|
|
869
|
-
const xmlEncodingNodeId = _translateNodeId(self.typeDefinitionId.toString());
|
|
870
|
-
|
|
871
|
-
if (xmlEncodingNodeId.isEmpty()) {
|
|
872
|
-
debugLog("xmlEncodingNodeId is empty for " + self.typeDefinitionId.toString());
|
|
873
|
-
break;
|
|
874
|
-
}
|
|
875
|
-
let captureXmlBody = this.bodyXML;
|
|
876
|
-
// istanbul ignore next
|
|
877
|
-
if (doDebug) {
|
|
878
|
-
debugLog("xxxx ", chalk.yellow(captureXmlBody));
|
|
879
|
-
}
|
|
880
|
-
// this is a user defined Extension Object
|
|
881
|
-
// istanbul ignore next
|
|
882
|
-
debugLog(
|
|
883
|
-
"load nodeset2: typeDefinitionId in ExtensionObject Default XML = " + xmlEncodingNodeId.toString()
|
|
884
|
-
);
|
|
885
|
-
|
|
886
|
-
let captured = self.postTaskData;
|
|
887
|
-
self.extensionObjectPojo = null;
|
|
888
|
-
const task = async (addressSpace2: IAddressSpace) => {
|
|
889
|
-
const extensionObject: ExtensionObject | null = await decodeXmlExtensionObject(
|
|
890
|
-
addressSpace2,
|
|
891
|
-
xmlEncodingNodeId,
|
|
892
|
-
captureXmlBody
|
|
893
|
-
);
|
|
894
|
-
if (captured) {
|
|
895
|
-
captured.postponedExtensionObject = extensionObject;
|
|
896
|
-
}
|
|
897
|
-
(captureXmlBody as any) = undefined;
|
|
898
|
-
(captured as any) = undefined;
|
|
899
|
-
};
|
|
900
|
-
postTasks0_DecodePojoString.push(task);
|
|
901
|
-
assert(!self.extensionObject || self.extensionObject instanceof ExtensionObject);
|
|
902
|
-
|
|
903
|
-
break;
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
};
|
|
909
|
-
|
|
910
|
-
const extensionObject_parser = {
|
|
911
|
-
ExtensionObject: {
|
|
912
|
-
init(this: ExtensionObjectParser) {
|
|
913
|
-
this.typeDefinitionId = NodeId.nullNodeId;
|
|
914
|
-
this.extensionObject = null;
|
|
915
|
-
this.extensionObjectPojo = null;
|
|
916
|
-
this.postTaskData = { postponedExtensionObject: null };
|
|
917
|
-
},
|
|
918
|
-
parser: _extensionObject_inner_parser,
|
|
919
|
-
finish(this: ExtensionObjectParser) {
|
|
920
|
-
/* empty */
|
|
921
|
-
}
|
|
571
|
+
// #endregion
|
|
572
|
+
const canIngore = (
|
|
573
|
+
{ isDraft, isDeprecated }: { isDraft: boolean; isDeprecated: boolean },
|
|
574
|
+
node: { browseName: QualifiedName; nodeClass: NodeClass }
|
|
575
|
+
) => {
|
|
576
|
+
if (isDraft && !options.loadDraftNodes) {
|
|
577
|
+
debugLog("Ignoring Draft =", NodeClass[node.nodeClass], node.browseName.toString());
|
|
578
|
+
return true;
|
|
922
579
|
}
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
const _parser: ParserLike = {};
|
|
927
|
-
|
|
928
|
-
const r: ReaderStateParserLike = {
|
|
929
|
-
init(this: { value: T | undefined }, name: string, attrs: XmlAttributes) {
|
|
930
|
-
this.value = undefined;
|
|
931
|
-
},
|
|
932
|
-
|
|
933
|
-
finish(this: { value: T | undefined; text: string }) {
|
|
934
|
-
this.value = parseFunc.call(this, this.text);
|
|
935
|
-
}
|
|
936
|
-
};
|
|
937
|
-
_parser[dataType] = r;
|
|
938
|
-
return _parser;
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
function ListOf<T>(dataType: string, parseFunc: any) {
|
|
942
|
-
return {
|
|
943
|
-
init(this: ListOfTParser<T>) {
|
|
944
|
-
this.listData = [];
|
|
945
|
-
},
|
|
946
|
-
|
|
947
|
-
parser: BasicType_parser<T>(dataType, parseFunc),
|
|
948
|
-
|
|
949
|
-
finish(this: ListOfTParser<T>) {
|
|
950
|
-
this.parent.parent.obj.value = {
|
|
951
|
-
arrayType: VariantArrayType.Array,
|
|
952
|
-
dataType: (DataType as any)[dataType],
|
|
953
|
-
value: this.listData
|
|
954
|
-
};
|
|
955
|
-
},
|
|
956
|
-
endElement(this: ListOfTParser<T>, element: string) {
|
|
957
|
-
this.listData.push(this.parser[dataType].value);
|
|
958
|
-
}
|
|
959
|
-
};
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
function parser2(type: string, p: (a: any) => any): any {
|
|
963
|
-
return {
|
|
964
|
-
finish(this: any) {
|
|
965
|
-
this.parent.parent.obj.value = {
|
|
966
|
-
arrayType: VariantArrayType.Scalar,
|
|
967
|
-
dataType: (DataType as any)[type],
|
|
968
|
-
value: p(this.text)
|
|
969
|
-
};
|
|
970
|
-
}
|
|
971
|
-
};
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
interface PostExtensionObjectData {
|
|
975
|
-
postponedExtensionObject: ExtensionObject | null;
|
|
976
|
-
// variant: Variant;
|
|
977
|
-
// nodeId: NodeId;
|
|
978
|
-
}
|
|
979
|
-
interface ExtensionObjectParser {
|
|
980
|
-
parent: any;
|
|
981
|
-
typeDefinitionId: NodeId;
|
|
982
|
-
extensionObject: ExtensionObject | null;
|
|
983
|
-
extensionObjectPojo: any | null;
|
|
984
|
-
postTaskData?: PostExtensionObjectData;
|
|
985
|
-
parser: {
|
|
986
|
-
Body: ExtensionObjectBodyParser;
|
|
987
|
-
};
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
interface ExtensionObjectTypeIdParser {
|
|
991
|
-
parent: ExtensionObjectParser;
|
|
992
|
-
}
|
|
993
|
-
interface ExtensionObjectTypeIdIdentifierParser {
|
|
994
|
-
text: string;
|
|
995
|
-
parent: ExtensionObjectTypeIdParser;
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
interface ExtensionObjectBodyParser {
|
|
999
|
-
parent: ExtensionObjectParser;
|
|
1000
|
-
_cloneFragment: InternalFragmentClonerReaderState;
|
|
1001
|
-
bodyXML: string;
|
|
1002
|
-
engine: any;
|
|
1003
|
-
NodeSet2ParserEngine: any;
|
|
1004
|
-
parser: any;
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
interface Parser {
|
|
1008
|
-
parent: Parser | any;
|
|
1009
|
-
}
|
|
1010
|
-
interface ListOfTParser<T> extends Parser {
|
|
1011
|
-
listData: T[];
|
|
1012
|
-
parent: Parser;
|
|
1013
|
-
parser: {
|
|
1014
|
-
[key: string]: Parser | any;
|
|
1015
|
-
};
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
interface ListOfExtensionObjectParser extends ListOfTParser<ExtensionObject> {
|
|
1019
|
-
listExtensionObject: (ExtensionObject | null)[];
|
|
1020
|
-
parser: {
|
|
1021
|
-
ExtensionObject: ExtensionObjectParser;
|
|
1022
|
-
};
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
const parseUInt64 = (str: string): UInt64 => coerceUInt64(str);
|
|
1026
|
-
const parseInt64 = (str: string): Int64 => coerceInt64(str);
|
|
1027
|
-
|
|
1028
|
-
const state_Variant = {
|
|
1029
|
-
init: () => {
|
|
1030
|
-
/* empty */
|
|
1031
|
-
},
|
|
1032
|
-
parser: {
|
|
1033
|
-
QualifiedName: {
|
|
1034
|
-
...qualifiedName_parser.QualifiedName,
|
|
1035
|
-
finish(this: any) {
|
|
1036
|
-
this.parent.parent.obj.value = {
|
|
1037
|
-
dataType: DataType.QualifiedName,
|
|
1038
|
-
value: this.qualifiedName
|
|
1039
|
-
};
|
|
1040
|
-
}
|
|
1041
|
-
},
|
|
1042
|
-
LocalizedText: {
|
|
1043
|
-
...localizedText_parser.LocalizedText,
|
|
1044
|
-
finish(this: any) {
|
|
1045
|
-
this.parent.parent.obj.value = {
|
|
1046
|
-
dataType: DataType.LocalizedText,
|
|
1047
|
-
value: this.localizedText
|
|
1048
|
-
};
|
|
1049
|
-
}
|
|
1050
|
-
},
|
|
1051
|
-
XmlElement: {
|
|
1052
|
-
finish(this: any) {
|
|
1053
|
-
this.parent.parent.obj.value = {
|
|
1054
|
-
dataType: DataType.XmlElement,
|
|
1055
|
-
value: this.text
|
|
1056
|
-
};
|
|
1057
|
-
}
|
|
1058
|
-
},
|
|
1059
|
-
String: {
|
|
1060
|
-
finish(this: any) {
|
|
1061
|
-
this.parent.parent.obj.value = {
|
|
1062
|
-
dataType: DataType.String,
|
|
1063
|
-
value: this.text
|
|
1064
|
-
};
|
|
1065
|
-
}
|
|
1066
|
-
},
|
|
1067
|
-
|
|
1068
|
-
Guid: {
|
|
1069
|
-
parser: {
|
|
1070
|
-
String: {
|
|
1071
|
-
finish(this: any) {
|
|
1072
|
-
const guid = this.text;
|
|
1073
|
-
if (!isValidGuid(guid)) {
|
|
1074
|
-
/* ?*/
|
|
1075
|
-
}
|
|
1076
|
-
this.parent.parent.parent.obj.value = {
|
|
1077
|
-
dataType: DataType.Guid,
|
|
1078
|
-
arrayType: VariantArrayType.Scalar,
|
|
1079
|
-
value: this.text
|
|
1080
|
-
};
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
},
|
|
1085
|
-
|
|
1086
|
-
NodeId: {
|
|
1087
|
-
parser: {
|
|
1088
|
-
Identifier: {
|
|
1089
|
-
finish(this: any) {
|
|
1090
|
-
const nodeId = this.text;
|
|
1091
|
-
this.parent.parent.parent.obj.value = {
|
|
1092
|
-
dataType: DataType.NodeId,
|
|
1093
|
-
arrayType: VariantArrayType.Scalar,
|
|
1094
|
-
value: _translateNodeId(resolveNodeId(nodeId).toString())
|
|
1095
|
-
};
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
|
-
},
|
|
1100
|
-
|
|
1101
|
-
Boolean: parser2("Boolean", coerceBoolean),
|
|
1102
|
-
Byte: parser2("Byte", parseInt),
|
|
1103
|
-
Int16: parser2("Int16", parseInt),
|
|
1104
|
-
Int32: parser2("Int32", parseInt),
|
|
1105
|
-
Int8: parser2("Int8", parseInt),
|
|
1106
|
-
SByte: parser2("SByte", parseInt),
|
|
1107
|
-
UInt16: parser2("UInt16", parseInt),
|
|
1108
|
-
UInt32: parser2("UInt32", parseInt),
|
|
1109
|
-
UInt8: parser2("UInt8", parseInt),
|
|
1110
|
-
|
|
1111
|
-
UInt64: parser2("UInt64", parseUInt64),
|
|
1112
|
-
Int64: parser2("Int64", parseInt64),
|
|
1113
|
-
|
|
1114
|
-
ByteString: {
|
|
1115
|
-
init(this: any) {
|
|
1116
|
-
this.value = null;
|
|
1117
|
-
},
|
|
1118
|
-
finish(this: any) {
|
|
1119
|
-
const base64text = this.text;
|
|
1120
|
-
const byteString = Buffer.from(base64text, "base64");
|
|
1121
|
-
this.parent.parent.obj.value = {
|
|
1122
|
-
arrayType: VariantArrayType.Scalar,
|
|
1123
|
-
dataType: DataType.ByteString,
|
|
1124
|
-
value: byteString
|
|
1125
|
-
};
|
|
1126
|
-
}
|
|
1127
|
-
},
|
|
1128
|
-
Float: {
|
|
1129
|
-
finish(this: any) {
|
|
1130
|
-
this.parent.parent.obj.value = {
|
|
1131
|
-
dataType: DataType.Float,
|
|
1132
|
-
value: parseFloat(this.text)
|
|
1133
|
-
};
|
|
1134
|
-
}
|
|
1135
|
-
},
|
|
1136
|
-
|
|
1137
|
-
Double: {
|
|
1138
|
-
finish(this: any) {
|
|
1139
|
-
this.parent.parent.obj.value = {
|
|
1140
|
-
dataType: DataType.Double,
|
|
1141
|
-
value: parseFloat(this.text)
|
|
1142
|
-
};
|
|
1143
|
-
}
|
|
1144
|
-
},
|
|
1145
|
-
|
|
1146
|
-
ListOfExtensionObject: {
|
|
1147
|
-
init(this: ListOfExtensionObjectParser) {
|
|
1148
|
-
this.listExtensionObject = [];
|
|
1149
|
-
},
|
|
1150
|
-
parser: extensionObject_parser,
|
|
1151
|
-
finish(this: ListOfExtensionObjectParser) {
|
|
1152
|
-
installExtensionObjectListInitializationPostTask(this);
|
|
1153
|
-
},
|
|
1154
|
-
startElement(this: ListOfExtensionObjectParser, elementName: string) {
|
|
1155
|
-
/* empty */
|
|
1156
|
-
const extensionObjectParser = this.parser.ExtensionObject;
|
|
1157
|
-
extensionObjectParser.postTaskData = { postponedExtensionObject: null };
|
|
1158
|
-
},
|
|
1159
|
-
endElement(this: ListOfExtensionObjectParser, elementName: string) {
|
|
1160
|
-
const extensionObjectParser = this.parser.ExtensionObject;
|
|
1161
|
-
|
|
1162
|
-
this.listExtensionObject.push(extensionObjectParser.extensionObject);
|
|
1163
|
-
if (this.parser.ExtensionObject.extensionObject === null) {
|
|
1164
|
-
// extension object creation will be postponed
|
|
1165
|
-
const index = this.listExtensionObject.length - 1;
|
|
1166
|
-
let capturedData = extensionObjectParser.postTaskData;
|
|
1167
|
-
|
|
1168
|
-
// istanbul ignore next
|
|
1169
|
-
if (!capturedData) {
|
|
1170
|
-
throw new Error("Internal Error : postponedExtensionObject not resolved");
|
|
1171
|
-
}
|
|
1172
|
-
|
|
1173
|
-
let listExtensionObject = this.listExtensionObject;
|
|
1174
|
-
const task = async (addressSpace2: IAddressSpace) => {
|
|
1175
|
-
// istanbul ignore next
|
|
1176
|
-
if (!capturedData!.postponedExtensionObject) {
|
|
1177
|
-
throw new Error("Internal Error : postponedExtensionObject not resolved");
|
|
1178
|
-
}
|
|
1179
|
-
listExtensionObject[index] = capturedData!.postponedExtensionObject!;
|
|
1180
|
-
capturedData = undefined;
|
|
1181
|
-
(listExtensionObject as any) = undefined;
|
|
1182
|
-
};
|
|
1183
|
-
postTasks2_AssignedExtensionObjectToDataValue.push(task);
|
|
1184
|
-
}
|
|
1185
|
-
}
|
|
1186
|
-
},
|
|
1187
|
-
|
|
1188
|
-
ListOfLocalizedText: {
|
|
1189
|
-
init(this: ListOfTParser<LocalizedTextOptions>) {
|
|
1190
|
-
this.listData = [];
|
|
1191
|
-
},
|
|
1192
|
-
parser: localizedText_parser,
|
|
1193
|
-
finish(this: ListOfTParser<QualifiedNameOptions>) {
|
|
1194
|
-
this.parent.parent.obj.value = {
|
|
1195
|
-
arrayType: VariantArrayType.Array,
|
|
1196
|
-
dataType: DataType.LocalizedText,
|
|
1197
|
-
value: this.listData
|
|
1198
|
-
};
|
|
1199
|
-
},
|
|
1200
|
-
endElement(this: ListOfTParser<QualifiedNameOptions> /*element*/) {
|
|
1201
|
-
this.listData.push(this.parser.LocalizedText.localizedText);
|
|
1202
|
-
}
|
|
1203
|
-
},
|
|
1204
|
-
ListOfQualifiedName: {
|
|
1205
|
-
init(this: ListOfTParser<QualifiedNameOptions>) {
|
|
1206
|
-
this.listData = [];
|
|
1207
|
-
},
|
|
1208
|
-
parser: qualifiedName_parser,
|
|
1209
|
-
finish(this: ListOfTParser<QualifiedNameOptions>) {
|
|
1210
|
-
this.parent.parent.obj.value = {
|
|
1211
|
-
arrayType: VariantArrayType.Array,
|
|
1212
|
-
dataType: DataType.QualifiedName,
|
|
1213
|
-
value: this.listData
|
|
1214
|
-
};
|
|
1215
|
-
},
|
|
1216
|
-
endElement(this: ListOfTParser<QualifiedNameOptions> /*element*/) {
|
|
1217
|
-
this.listData.push(this.parser.QualifiedName.qualifiedName);
|
|
1218
|
-
}
|
|
1219
|
-
},
|
|
1220
|
-
ListOfNodeId: {
|
|
1221
|
-
init(this: ListOfTParser<NodeIdLike>) {
|
|
1222
|
-
this.listData = [];
|
|
1223
|
-
},
|
|
1224
|
-
parser: nodeId_parser,
|
|
1225
|
-
finish(this: ListOfTParser<NodeIdLike>) {
|
|
1226
|
-
this.parent.parent.obj.value = {
|
|
1227
|
-
arrayType: VariantArrayType.Array,
|
|
1228
|
-
dataType: DataType.NodeId,
|
|
1229
|
-
value: this.listData
|
|
1230
|
-
};
|
|
1231
|
-
},
|
|
1232
|
-
endElement(this: ListOfTParser<NodeIdLike>, elementName: string) {
|
|
1233
|
-
this.listData.push(this.parser.NodeId.nodeId);
|
|
1234
|
-
}
|
|
1235
|
-
},
|
|
1236
|
-
|
|
1237
|
-
ListOfBoolean: ListOf<boolean>("Boolean", coerceBoolean),
|
|
1238
|
-
|
|
1239
|
-
ListOfByte: ListOf<number>("Byte", parseInt),
|
|
1240
|
-
|
|
1241
|
-
ListOfDouble: ListOf<number>("Double", parseFloat),
|
|
1242
|
-
|
|
1243
|
-
ListOfFloat: ListOf<number>("Float", parseFloat),
|
|
1244
|
-
|
|
1245
|
-
ListOfInt32: ListOf<number>("Int32", parseInt),
|
|
1246
|
-
|
|
1247
|
-
ListOfInt16: ListOf<number>("Int16", parseInt),
|
|
1248
|
-
|
|
1249
|
-
ListOfInt8: ListOf<number>("Int8", parseInt),
|
|
1250
|
-
|
|
1251
|
-
ListOfUInt32: ListOf<number>("UInt32", parseInt),
|
|
1252
|
-
|
|
1253
|
-
ListOfUInt16: ListOf<number>("UInt16", parseInt),
|
|
1254
|
-
|
|
1255
|
-
ListOfUInt8: ListOf<number>("UInt8", parseInt),
|
|
1256
|
-
|
|
1257
|
-
ListOfString: ListOf<string>("String", (value: string) => value),
|
|
1258
|
-
|
|
1259
|
-
ListOfXmlElement: ListOf<string>("XmlElement", (value: string) => value),
|
|
1260
|
-
|
|
1261
|
-
ExtensionObject: {
|
|
1262
|
-
init(this: ExtensionObjectParser) {
|
|
1263
|
-
this.typeDefinitionId = NodeId.nullNodeId;
|
|
1264
|
-
this.extensionObject = null;
|
|
1265
|
-
this.postTaskData = { postponedExtensionObject: null };
|
|
1266
|
-
},
|
|
1267
|
-
parser: _extensionObject_inner_parser,
|
|
1268
|
-
finish(this: ExtensionObjectParser) {
|
|
1269
|
-
// istanbul ignore next
|
|
1270
|
-
if (this.extensionObject && !(this.extensionObject instanceof ExtensionObject)) {
|
|
1271
|
-
throw new Error("expecting an extension object");
|
|
1272
|
-
}
|
|
1273
|
-
this.parent.parent.obj.value = {
|
|
1274
|
-
dataType: DataType.ExtensionObject,
|
|
1275
|
-
value: this.extensionObject
|
|
1276
|
-
};
|
|
1277
|
-
if (!this.extensionObject) {
|
|
1278
|
-
installExtensionObjectInitializationPostTask(this);
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
580
|
+
if (isDeprecated && !options.loadDeprecatedNodes) {
|
|
581
|
+
debugLog("Ignoring Deprecate =", NodeClass[node.nodeClass], node.browseName.toString());
|
|
582
|
+
return true;
|
|
1282
583
|
}
|
|
584
|
+
return false;
|
|
1283
585
|
};
|
|
1284
586
|
|
|
1285
|
-
function
|
|
1286
|
-
let
|
|
1287
|
-
let
|
|
1288
|
-
assert(nodeId, "expecting a nodeid");
|
|
1289
|
-
const task = async (addressSpace2: IAddressSpace) => {
|
|
1290
|
-
const node = addressSpace2.findNode(nodeId)!;
|
|
1291
|
-
if (!node) {
|
|
1292
|
-
debugLog("Cannot find node with nodeId " + nodeId + ". may be the node was marked as deprecated");
|
|
1293
|
-
} else if (node.nodeClass === NodeClass.Variable) {
|
|
1294
|
-
const v = node as UAVariable;
|
|
1295
|
-
assert(v.getBasicDataType() === DataType.ExtensionObject, "expecting an extension object");
|
|
1296
|
-
v.bindExtensionObject(listExtensionObject as ExtensionObject[], { createMissingProp: false });
|
|
1297
|
-
} else if (node.nodeClass === NodeClass.VariableType) {
|
|
1298
|
-
// no need to bind a variable type
|
|
1299
|
-
const v = node as UAVariableType;
|
|
1300
|
-
(v as any) /*fix me*/.value.value = listExtensionObject;
|
|
1301
|
-
}
|
|
1302
|
-
listExtensionObject.slice(0);
|
|
1303
|
-
(listExtensionObject as any) = undefined;
|
|
1304
|
-
(nodeId as any) = undefined;
|
|
1305
|
-
};
|
|
1306
|
-
postTasks2_AssignedExtensionObjectToDataValue.push(task);
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
function installExtensionObjectInitializationPostTask(element: ExtensionObjectParser) {
|
|
1310
|
-
// let's create the mechanism that postpone the creation of the
|
|
1311
|
-
// extension object
|
|
1312
|
-
let data = element.postTaskData!;
|
|
1313
|
-
let variant = element.parent.parent.obj.value;
|
|
1314
|
-
let nodeId = element.parent.parent.obj.nodeId;
|
|
587
|
+
function fixExtensionObjectAndArray(obj: { nodeId: NodeId }, deferred: () => ExtensionObject | ExtensionObject[] | null) {
|
|
588
|
+
// let's create the mechanism that postpone the assignment of the extension object
|
|
589
|
+
let capturedNode = obj;
|
|
1315
590
|
const task = async (addressSpace2: IAddressSpace) => {
|
|
1316
|
-
|
|
591
|
+
const extensionObjOrArray = deferred();
|
|
592
|
+
let nodeId = capturedNode.nodeId;
|
|
1317
593
|
assert(nodeId, "expecting a nodeid");
|
|
1318
594
|
const node = addressSpace2.findNode(nodeId)!;
|
|
595
|
+
|
|
1319
596
|
if (node.nodeClass === NodeClass.Variable) {
|
|
1320
597
|
const v = node as UAVariable;
|
|
1321
598
|
assert(v.getBasicDataType() === DataType.ExtensionObject, "expecting an extension object");
|
|
1322
|
-
|
|
599
|
+
if (extensionObjOrArray != null) {
|
|
600
|
+
v.bindExtensionObject(extensionObjOrArray, { createMissingProp: false });
|
|
601
|
+
}
|
|
1323
602
|
} else if (node.nodeClass === NodeClass.VariableType) {
|
|
1324
603
|
const v = node as UAVariableType;
|
|
1325
|
-
(v as any) /*fix me*/.value.value =
|
|
604
|
+
(v as any) /*fix me*/.value.value = extensionObjOrArray;
|
|
1326
605
|
}
|
|
1327
|
-
|
|
1328
|
-
data.postponedExtensionObject = null;
|
|
1329
|
-
(data as any) = undefined;
|
|
1330
|
-
(variant as any) = undefined;
|
|
1331
|
-
(nodeId as any) = undefined;
|
|
1332
606
|
};
|
|
1333
607
|
postTasks2_AssignedExtensionObjectToDataValue.push(task);
|
|
1334
608
|
}
|
|
609
|
+
// #region UAVariable
|
|
610
|
+
interface IUAVariableProps {
|
|
611
|
+
nodeId: NodeId | null;
|
|
612
|
+
value?: VariantOptions;
|
|
613
|
+
nodeClass: NodeClass;
|
|
614
|
+
browseName: QualifiedName;
|
|
615
|
+
displayName?: LocalizedText;
|
|
616
|
+
description?: LocalizedText;
|
|
617
|
+
parentNodeId: NodeId | null;
|
|
618
|
+
dataType: NodeId | null;
|
|
619
|
+
valueRank: number;
|
|
620
|
+
arrayDimensions: number[] | null;
|
|
621
|
+
minimumSamplingInterval: number;
|
|
622
|
+
historizing: boolean;
|
|
623
|
+
accessLevel: number;
|
|
624
|
+
userAccessLevel: number;
|
|
625
|
+
}
|
|
626
|
+
type ReaderUAVariableL1 = ReaderStateParserLike & { obj: IUAVariableProps; isDraft: boolean; isDeprecated: boolean };
|
|
627
|
+
type ReaderUAVariableL2 = ReaderStateParserLike & { parent: ReaderUAVariableL1; text: string };
|
|
1335
628
|
|
|
1336
|
-
const canIngore = ({ isDraft, isDeprecated }: { isDraft: boolean; isDeprecated: boolean }, node: BaseNode) => {
|
|
1337
|
-
if (isDraft && !options.loadDraftNodes) {
|
|
1338
|
-
debugLog("Ignoring Draft =", NodeClass[node.nodeClass], node.browseName.toString());
|
|
1339
|
-
return true;
|
|
1340
|
-
}
|
|
1341
|
-
if (isDeprecated && !options.loadDeprecatedNodes) {
|
|
1342
|
-
debugLog("Ignoring Deprecate =", NodeClass[node.nodeClass], node.browseName.toString());
|
|
1343
|
-
return true;
|
|
1344
|
-
}
|
|
1345
|
-
return false;
|
|
1346
|
-
};
|
|
1347
629
|
const state_UAVariable = {
|
|
1348
|
-
init(this:
|
|
630
|
+
init(this: ReaderUAVariableL1, name: string, attrs: XmlAttributes) {
|
|
1349
631
|
_perform();
|
|
1350
632
|
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
this.obj
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
this.isDraft = attrs.ReleaseStatus === "Draft";
|
|
1371
|
-
this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
|
|
633
|
+
const valueRank = attrs.ValueRank === undefined ? -1 : coerceInt32(attrs.ValueRank);
|
|
634
|
+
const accessLevel = convertAccessLevel(attrs.AccessLevel);
|
|
635
|
+
const nodeId = convertToNodeId(attrs.NodeId);
|
|
636
|
+
this.obj = {
|
|
637
|
+
value: undefined, // { dataType: DataType.Null },
|
|
638
|
+
nodeClass: NodeClass.Variable,
|
|
639
|
+
browseName: convertQualifiedName(attrs.BrowseName),
|
|
640
|
+
parentNodeId: convertToNodeId(attrs.ParentNodeId),
|
|
641
|
+
dataType: convertToNodeId(attrs.DataType),
|
|
642
|
+
//description: null,
|
|
643
|
+
// displayName: coerceLocalizedText(attrs.BrowseName)!,
|
|
644
|
+
valueRank,
|
|
645
|
+
arrayDimensions: valueRank <= 0 ? null : stringToUInt32Array(attrs.ArrayDimensions),
|
|
646
|
+
minimumSamplingInterval: attrs.MinimumSamplingInterval ? parseInt(attrs.MinimumSamplingInterval, 10) : 0,
|
|
647
|
+
historizing: false,
|
|
648
|
+
nodeId,
|
|
649
|
+
accessLevel: accessLevel,
|
|
650
|
+
userAccessLevel: accessLevel // convertAccessLevel(attrs.UserAccessLevel || attrs.AccessLevel);
|
|
651
|
+
};
|
|
652
|
+
this.isDraft = attrs.ReleaseStatus === "Draft" || false;
|
|
653
|
+
this.isDeprecated = attrs.ReleaseStatus === "Deprecated" || false;
|
|
1372
654
|
},
|
|
1373
|
-
finish(this:
|
|
655
|
+
finish(this: ReaderUAVariableL1) {
|
|
1374
656
|
if (canIngore({ isDraft: this.isDraft, isDeprecated: this.isDeprecated }, this.obj)) {
|
|
1375
657
|
return;
|
|
1376
658
|
}
|
|
@@ -1385,8 +667,8 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
|
|
|
1385
667
|
*/
|
|
1386
668
|
// eslint-disable-next-line prefer-const
|
|
1387
669
|
let capturedVariable: UAVariable;
|
|
1388
|
-
if (this.obj.value) {
|
|
1389
|
-
let capturedValue = this.obj.value;
|
|
670
|
+
if (this.obj.value && this.obj.value.dataType !== DataType.Null) {
|
|
671
|
+
let capturedValue: any | undefined = this.obj.value;
|
|
1390
672
|
const task = async (addressSpace2: IAddressSpace) => {
|
|
1391
673
|
if (false && doDebug) {
|
|
1392
674
|
debugLog("1 setting value to ", capturedVariable.nodeId.toString(), new Variant(capturedValue).toString());
|
|
@@ -1398,7 +680,7 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
|
|
|
1398
680
|
if (capturedValue.dataType !== DataType.ExtensionObject) {
|
|
1399
681
|
postTasks0_InitializeVariable.push(task);
|
|
1400
682
|
} else {
|
|
1401
|
-
// do them later
|
|
683
|
+
// do them later when every thing is created
|
|
1402
684
|
postTasks1_InitializeVariable.push(task);
|
|
1403
685
|
}
|
|
1404
686
|
} else {
|
|
@@ -1406,7 +688,7 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
|
|
|
1406
688
|
const dataTypeNode = capturedVariable.dataType;
|
|
1407
689
|
const valueRank = capturedVariable.valueRank;
|
|
1408
690
|
const arrayDimensions = capturedVariable.arrayDimensions;
|
|
1409
|
-
|
|
691
|
+
|
|
1410
692
|
const value = makeDefaultVariant(addressSpace, dataTypeNode, valueRank, arrayDimensions);
|
|
1411
693
|
if (value) {
|
|
1412
694
|
if (false && doDebug) {
|
|
@@ -1422,93 +704,121 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
|
|
|
1422
704
|
};
|
|
1423
705
|
postTasks0_InitializeVariable.push(task);
|
|
1424
706
|
}
|
|
1425
|
-
this.obj.value =
|
|
707
|
+
this.obj.value = Object.create(null);
|
|
1426
708
|
capturedVariable = _internal_createNode(this.obj) as UAVariable;
|
|
1427
709
|
},
|
|
1428
710
|
parser: {
|
|
1429
711
|
DisplayName: {
|
|
1430
|
-
finish(this:
|
|
1431
|
-
this.parent.obj.displayName = this.text
|
|
712
|
+
finish(this: ReaderUAVariableL2) {
|
|
713
|
+
this.parent.obj.displayName = coerceLocalizedText(this.text)!;
|
|
1432
714
|
}
|
|
1433
715
|
},
|
|
1434
716
|
|
|
1435
717
|
Description: {
|
|
1436
|
-
finish(this:
|
|
1437
|
-
this.parent.obj.description = this.text
|
|
718
|
+
finish(this: ReaderUAVariableL2) {
|
|
719
|
+
this.parent.obj.description = coerceLocalizedText(this.text)!;
|
|
1438
720
|
}
|
|
1439
721
|
},
|
|
1440
722
|
References: references_parser,
|
|
1441
723
|
|
|
1442
|
-
Value:
|
|
724
|
+
Value: makeVariantReader<ReaderUAVariableL2>(
|
|
725
|
+
(self: ReaderUAVariableL2, data: VariantOptions) => {
|
|
726
|
+
self.parent.obj.value = data;
|
|
727
|
+
},
|
|
728
|
+
(self: ReaderUAVariableL2, data: VariantOptions, deferredTask) => {
|
|
729
|
+
self.parent.obj.value = data;
|
|
730
|
+
const capturedVariable = { nodeId: self.parent.obj.nodeId! };
|
|
731
|
+
fixExtensionObjectAndArray(capturedVariable, deferredTask);
|
|
732
|
+
},
|
|
733
|
+
(task) => {
|
|
734
|
+
postTasks0_DecodePojoString.push(task);
|
|
735
|
+
},
|
|
736
|
+
_translateNodeId
|
|
737
|
+
)
|
|
1443
738
|
}
|
|
1444
739
|
};
|
|
1445
|
-
|
|
740
|
+
// #endregion
|
|
741
|
+
// #region UAVariableType
|
|
742
|
+
interface IUAVariableTypeProps extends Omit<IUAVariableProps, "accessLevel" | "userAccessLevel"> {
|
|
743
|
+
isAbstract: boolean;
|
|
744
|
+
}
|
|
745
|
+
type ReaderUAVariableTypeL1 = ReaderStateParserLike & { obj: IUAVariableTypeProps; isDraft: boolean; isDeprecated: boolean };
|
|
746
|
+
type ReaderUAVariableTypeL2 = ReaderStateParserLike & { parent: ReaderUAVariableTypeL1; text: string };
|
|
1446
747
|
const state_UAVariableType = {
|
|
1447
|
-
init(this:
|
|
748
|
+
init(this: ReaderUAVariableTypeL1, name: string, attrs: XmlAttributes) {
|
|
1448
749
|
_perform();
|
|
1449
|
-
|
|
1450
|
-
this.obj = {
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
this.obj.historizing = false;
|
|
1464
|
-
this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
|
|
1465
|
-
|
|
750
|
+
const valueRank = coerceInt32(attrs.ValueRank) || -1;
|
|
751
|
+
this.obj = {
|
|
752
|
+
value: undefined, // { dataType: DataType.Null },
|
|
753
|
+
isAbstract: coerceBoolean(attrs.IsAbstract),
|
|
754
|
+
nodeClass: NodeClass.VariableType,
|
|
755
|
+
browseName: convertQualifiedName(attrs.BrowseName),
|
|
756
|
+
parentNodeId: convertToNodeId(attrs.ParentNodeId) || null,
|
|
757
|
+
dataType: convertToNodeId(attrs.DataType) || null,
|
|
758
|
+
valueRank,
|
|
759
|
+
arrayDimensions: valueRank <= 0 ? null : stringToUInt32Array(attrs.ArrayDimensions),
|
|
760
|
+
minimumSamplingInterval: attrs.MinimumSamplingInterval ? parseInt(attrs.MinimumSamplingInterval, 10) : 0,
|
|
761
|
+
historizing: false,
|
|
762
|
+
nodeId: convertToNodeId(attrs.NodeId) || null
|
|
763
|
+
};
|
|
1466
764
|
this.isDraft = attrs.ReleaseStatus === "Draft";
|
|
1467
765
|
this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
|
|
1468
766
|
},
|
|
1469
|
-
finish(this:
|
|
767
|
+
finish(this: ReaderUAVariableTypeL1) {
|
|
1470
768
|
if (canIngore({ isDraft: this.isDraft, isDeprecated: this.isDeprecated }, this.obj)) {
|
|
1471
769
|
return;
|
|
1472
770
|
}
|
|
1473
771
|
try {
|
|
1474
772
|
_internal_createNode(this.obj);
|
|
1475
773
|
} /* istanbul ignore next */ catch (err) {
|
|
1476
|
-
this.obj
|
|
1477
|
-
// tslint:disable:no-console
|
|
1478
|
-
console.warn(" Cannot create object", JSON.stringify(this.obj, null, " "));
|
|
774
|
+
errorLog(" Cannot create object", JSON.stringify(this.obj, null, " "));
|
|
1479
775
|
throw err;
|
|
1480
776
|
}
|
|
1481
777
|
},
|
|
1482
778
|
parser: {
|
|
1483
779
|
DisplayName: {
|
|
1484
|
-
finish(this:
|
|
1485
|
-
this.parent.obj.displayName = this.text
|
|
780
|
+
finish(this: ReaderUAVariableTypeL2) {
|
|
781
|
+
this.parent.obj.displayName = coerceLocalizedText(this.text || "")!;
|
|
1486
782
|
}
|
|
1487
783
|
},
|
|
1488
784
|
|
|
1489
785
|
Description: {
|
|
1490
|
-
finish(this:
|
|
1491
|
-
this.parent.obj.description = this.text
|
|
786
|
+
finish(this: ReaderUAVariableTypeL2) {
|
|
787
|
+
this.parent.obj.description = coerceLocalizedText(this.text || "")!;
|
|
1492
788
|
}
|
|
1493
789
|
},
|
|
1494
790
|
References: references_parser,
|
|
1495
|
-
Value:
|
|
791
|
+
Value: makeVariantReader<ReaderUAVariableTypeL2>(
|
|
792
|
+
(self: ReaderUAVariableTypeL2, data: VariantOptions) => {
|
|
793
|
+
self.parent.obj.value = data;
|
|
794
|
+
},
|
|
795
|
+
(self: ReaderUAVariableTypeL2, data: VariantOptions, deferredTask) => {
|
|
796
|
+
self.parent.obj.value = data;
|
|
797
|
+
const capturedVariable = { nodeId: self.parent.obj.nodeId! };
|
|
798
|
+
fixExtensionObjectAndArray(capturedVariable, deferredTask);
|
|
799
|
+
},
|
|
800
|
+
(task) => {
|
|
801
|
+
postTasks0_DecodePojoString.push(task);
|
|
802
|
+
},
|
|
803
|
+
_translateNodeId
|
|
804
|
+
)
|
|
1496
805
|
}
|
|
1497
806
|
};
|
|
1498
|
-
|
|
807
|
+
// #endregion
|
|
808
|
+
// #region UAMethod
|
|
1499
809
|
const state_UAMethod = {
|
|
1500
810
|
init(this: any, name: string, attrs: XmlAttributes) {
|
|
1501
811
|
_perform();
|
|
1502
812
|
|
|
1503
|
-
this.obj = {
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
813
|
+
this.obj = {
|
|
814
|
+
nodeClass: NodeClass.Method,
|
|
815
|
+
// MethodDeclarationId
|
|
816
|
+
// ParentNodeId
|
|
817
|
+
browseName: convertQualifiedName(attrs.BrowseName),
|
|
818
|
+
parentNodeId: attrs.ParentNodeId || null,
|
|
819
|
+
nodeId: convertToNodeId(attrs.NodeId) || null,
|
|
820
|
+
methodDeclarationId: attrs.MethodDeclarationId ? _translateNodeId(attrs.MethodDeclarationId) : null,
|
|
821
|
+
};
|
|
1512
822
|
this.isDraft = attrs.ReleaseStatus === "Draft";
|
|
1513
823
|
this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
|
|
1514
824
|
},
|
|
@@ -1527,7 +837,8 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
|
|
|
1527
837
|
References: references_parser
|
|
1528
838
|
}
|
|
1529
839
|
};
|
|
1530
|
-
|
|
840
|
+
// #endregion
|
|
841
|
+
// #region Model
|
|
1531
842
|
interface Model {
|
|
1532
843
|
modelUri: string;
|
|
1533
844
|
version: string;
|
|
@@ -1577,7 +888,7 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
|
|
|
1577
888
|
models.push(model);
|
|
1578
889
|
}
|
|
1579
890
|
});
|
|
1580
|
-
|
|
891
|
+
// #endregion
|
|
1581
892
|
function _updateTranslationTable() {
|
|
1582
893
|
_register_namespace_uri_in_translation_table("http://opcfoundation.org/UA/");
|
|
1583
894
|
for (const namespaceUri of _namespaceUris) {
|
|
@@ -1682,7 +993,7 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
|
|
|
1682
993
|
doDebug &&
|
|
1683
994
|
debugLog(
|
|
1684
995
|
chalk.bgGreenBright("Performing post loading tasks -------------------------------------------") +
|
|
1685
|
-
|
|
996
|
+
chalk.green("DONE")
|
|
1686
997
|
);
|
|
1687
998
|
|
|
1688
999
|
async function performPostLoadingTasks(tasks: Task[]): Promise<void> {
|