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
|
@@ -46,7 +46,7 @@ import { NamespaceImpl } from "../namespace_impl";
|
|
|
46
46
|
import { UAMethodImpl } from "../ua_method_impl";
|
|
47
47
|
import { UADataTypeImpl } from "../ua_data_type_impl";
|
|
48
48
|
import { UAVariableTypeImpl } from "../ua_variable_type_impl";
|
|
49
|
-
import { SessionContext } from "../index_current";
|
|
49
|
+
import { AddressSpace, SessionContext } from "../index_current";
|
|
50
50
|
import { UAViewImpl } from "../ua_view_impl";
|
|
51
51
|
|
|
52
52
|
import { DefinitionMap2 } from "../../source/loader/make_xml_extension_object_parser";
|
|
@@ -56,6 +56,7 @@ import {
|
|
|
56
56
|
constructNamespaceDependency,
|
|
57
57
|
constructNamespacePriorityTable
|
|
58
58
|
} from "./construct_namespace_dependency";
|
|
59
|
+
import { start } from "repl";
|
|
59
60
|
|
|
60
61
|
// tslint:disable:no-var-requires
|
|
61
62
|
const XMLWriter = require("xml-writer");
|
|
@@ -84,7 +85,7 @@ function _dumpDescription(xw: XmlWriter, node: { description?: LocalizedText }):
|
|
|
84
85
|
|
|
85
86
|
function translateNodeId(xw: XmlWriter, nodeId: NodeId): NodeId {
|
|
86
87
|
assert(nodeId instanceof NodeId);
|
|
87
|
-
const nn = xw.translationTable
|
|
88
|
+
const nn = xw.translationTable.get(nodeId.namespace);
|
|
88
89
|
const translatedNode = new NodeId(nodeId.identifierType, nodeId.value, nn);
|
|
89
90
|
return translatedNode;
|
|
90
91
|
}
|
|
@@ -95,7 +96,7 @@ function n(xw: XmlWriter, nodeId: NodeId): string {
|
|
|
95
96
|
|
|
96
97
|
function translateBrowseName(xw: XmlWriter, browseName: QualifiedName): QualifiedName {
|
|
97
98
|
assert(browseName instanceof QualifiedName);
|
|
98
|
-
const nn = xw.translationTable
|
|
99
|
+
const nn = xw.translationTable.get(browseName.namespaceIndex);
|
|
99
100
|
const translatedBrowseName = new QualifiedName({ namespaceIndex: nn, name: browseName.name });
|
|
100
101
|
return translatedBrowseName;
|
|
101
102
|
}
|
|
@@ -305,10 +306,13 @@ function _dumpNodeId(xw: XmlWriter, v: NodeId) {
|
|
|
305
306
|
xw.endElement();
|
|
306
307
|
}
|
|
307
308
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
309
|
+
function _dumpVariantValue(
|
|
310
|
+
xw: XmlWriter,
|
|
311
|
+
dataTypeNodeId: NodeId,
|
|
312
|
+
dataType: DataType,
|
|
313
|
+
addressSpace: IAddressSpace,
|
|
314
|
+
value: any
|
|
315
|
+
) {
|
|
312
316
|
if (value === undefined || value === null) {
|
|
313
317
|
return;
|
|
314
318
|
}
|
|
@@ -317,8 +321,8 @@ function _dumpVariantValue(xw: XmlWriter, dataType: DataType, node: UAVariable |
|
|
|
317
321
|
}
|
|
318
322
|
const uax = getPrefix(xw, "http://opcfoundation.org/UA/2008/02/Types.xsd");
|
|
319
323
|
xw.startElement(`${uax}${DataType[dataType]}`);
|
|
320
|
-
const definitionMap = makeDefinitionMap(
|
|
321
|
-
_dumpVariantInnerValue(xw, dataType,
|
|
324
|
+
const definitionMap = makeDefinitionMap(addressSpace);
|
|
325
|
+
_dumpVariantInnerValue(xw, dataType, dataTypeNodeId, definitionMap, addressSpace, value);
|
|
322
326
|
xw.endElement();
|
|
323
327
|
}
|
|
324
328
|
|
|
@@ -326,12 +330,13 @@ function _dumpVariantInnerExtensionObject(
|
|
|
326
330
|
xw: XmlWriter,
|
|
327
331
|
definitionMap: DefinitionMap2,
|
|
328
332
|
definition: StructureDefinition,
|
|
333
|
+
addressSpace: IAddressSpace,
|
|
329
334
|
value: ExtensionObject
|
|
330
335
|
) {
|
|
331
336
|
const namespaceUri = findXsdNamespaceUri(xw, definition.defaultEncodingId);
|
|
332
337
|
const ns = getPrefix(xw, namespaceUri);
|
|
333
338
|
|
|
334
|
-
const isUnion = definition.structureType === StructureType.Union || definition.structureType ===
|
|
339
|
+
const isUnion = definition.structureType === StructureType.Union || definition.structureType === StructureType.UnionWithSubtypedValues;
|
|
335
340
|
|
|
336
341
|
for (const field of definition.fields || []) {
|
|
337
342
|
const dataTypeNodeId = field.dataType;
|
|
@@ -358,12 +363,19 @@ function _dumpVariantInnerExtensionObject(
|
|
|
358
363
|
/** */
|
|
359
364
|
};
|
|
360
365
|
if (definition instanceof StructureDefinition) {
|
|
361
|
-
fun = _dumpVariantInnerExtensionObject.bind(null, xw, definitionMap, definition);
|
|
366
|
+
fun = _dumpVariantInnerExtensionObject.bind(null, xw, definitionMap, definition, addressSpace);
|
|
362
367
|
} else if (definition instanceof EnumDefinition) {
|
|
363
368
|
fun = _dumpVariantInnerValueEnum.bind(null, xw, definition);
|
|
369
|
+
} else if (definition?.dataType == DataType.Variant) {
|
|
370
|
+
fun = (value: Variant)=> {
|
|
371
|
+
|
|
372
|
+
xw.startElement("Value");
|
|
373
|
+
_dumpVariantValue(xw, field.dataType, value.dataType, addressSpace, value.value);
|
|
374
|
+
xw.endElement();
|
|
375
|
+
}
|
|
364
376
|
} else {
|
|
365
377
|
const baseType = definition.dataType;
|
|
366
|
-
fun = _dumpVariantInnerValue.bind(null, xw, baseType, dataTypeNodeId, definitionMap);
|
|
378
|
+
fun = _dumpVariantInnerValue.bind(null, xw, baseType, dataTypeNodeId, definitionMap, addressSpace);
|
|
367
379
|
}
|
|
368
380
|
try {
|
|
369
381
|
if (field.valueRank === -1) {
|
|
@@ -412,6 +424,7 @@ function _dumpVariantInnerValue(
|
|
|
412
424
|
dataType: DataType,
|
|
413
425
|
dataTypeNodeId: NodeId,
|
|
414
426
|
definitionMap: DefinitionMap2,
|
|
427
|
+
addressSpace: IAddressSpace,
|
|
415
428
|
value: any
|
|
416
429
|
): void {
|
|
417
430
|
const uax = getPrefix(xw, "http://opcfoundation.org/UA/2008/02/Types.xsd");
|
|
@@ -468,7 +481,7 @@ function _dumpVariantInnerValue(
|
|
|
468
481
|
break;
|
|
469
482
|
|
|
470
483
|
case DataType.ExtensionObject:
|
|
471
|
-
_dumpVariantExtensionObjectValue(xw, dataTypeNodeId, definitionMap, value as ExtensionObject);
|
|
484
|
+
_dumpVariantExtensionObjectValue(xw, dataTypeNodeId, definitionMap, addressSpace, value as ExtensionObject);
|
|
472
485
|
break;
|
|
473
486
|
case DataType.XmlElement:
|
|
474
487
|
_dumpXmlElement(xw, value as string);
|
|
@@ -476,6 +489,9 @@ function _dumpVariantInnerValue(
|
|
|
476
489
|
case DataType.StatusCode:
|
|
477
490
|
xw.text((value as StatusCode).value.toString());
|
|
478
491
|
break;
|
|
492
|
+
case DataType.Variant:
|
|
493
|
+
_dumpVariantInnerValue(xw, value.dataType, dataTypeNodeId, definitionMap, addressSpace, value.value);
|
|
494
|
+
break;
|
|
479
495
|
default:
|
|
480
496
|
errorLog("_dumpVariantInnerValue incomplete " + value + " " + "DataType=" + dataType + "=" + DataType[dataType]);
|
|
481
497
|
// throw new Error("_dumpVariantInnerValue incomplete " + value + " " + "DataType=" + dataType + "=" + DataType[dataType]);
|
|
@@ -494,6 +510,7 @@ function _dumpVariantExtensionObjectValue_Body(
|
|
|
494
510
|
definitionMap: DefinitionMap2,
|
|
495
511
|
name: string,
|
|
496
512
|
definition: StructureDefinition,
|
|
513
|
+
addressSpace: IAddressSpace,
|
|
497
514
|
value: any
|
|
498
515
|
) {
|
|
499
516
|
if (value) {
|
|
@@ -501,7 +518,7 @@ function _dumpVariantExtensionObjectValue_Body(
|
|
|
501
518
|
const ns = getPrefix(xw, namespaceUri);
|
|
502
519
|
startElementEx(xw, ns, `${name}`, namespaceUri);
|
|
503
520
|
if (value) {
|
|
504
|
-
_dumpVariantInnerExtensionObject(xw, definitionMap, definition, value);
|
|
521
|
+
_dumpVariantInnerExtensionObject(xw, definitionMap, definition, addressSpace, value);
|
|
505
522
|
}
|
|
506
523
|
restoreDefaultNamespace(xw);
|
|
507
524
|
xw.endElement();
|
|
@@ -512,6 +529,7 @@ function _dumpVariantExtensionObjectValue(
|
|
|
512
529
|
xw: XmlWriter,
|
|
513
530
|
dataTypeNodeId: NodeId,
|
|
514
531
|
definitionMap: DefinitionMap2,
|
|
532
|
+
addressSpace: IAddressSpace,
|
|
515
533
|
value: ExtensionObject
|
|
516
534
|
) {
|
|
517
535
|
const { name, definition } = definitionMap.findDefinition(dataTypeNodeId);
|
|
@@ -537,7 +555,13 @@ function _dumpVariantExtensionObjectValue(
|
|
|
537
555
|
xw.endElement();
|
|
538
556
|
startElementEx(xw, uax, "Body", "http://opcfoundation.org/UA/2008/02/Types.xsd");
|
|
539
557
|
|
|
540
|
-
_dumpVariantExtensionObjectValue_Body(
|
|
558
|
+
_dumpVariantExtensionObjectValue_Body(
|
|
559
|
+
xw,
|
|
560
|
+
definitionMap,
|
|
561
|
+
name,
|
|
562
|
+
definition as StructureDefinition,
|
|
563
|
+
addressSpace,
|
|
564
|
+
value);
|
|
541
565
|
|
|
542
566
|
restoreDefaultNamespace(xw);
|
|
543
567
|
xw.endElement();
|
|
@@ -554,7 +578,7 @@ function _dumpVariantExtensionObjectValue2(xw: XmlWriter, addressSpace: IAddress
|
|
|
554
578
|
warningLog("_dumpVariantExtensionObjectValue2: Cannot find dataType for ", dataTypeNodeId.toString());
|
|
555
579
|
return;
|
|
556
580
|
}
|
|
557
|
-
_dumpVariantExtensionObjectValue(xw, dataTypeNode.nodeId, definitionMap, value);
|
|
581
|
+
_dumpVariantExtensionObjectValue(xw, dataTypeNode.nodeId, definitionMap,addressSpace, value);
|
|
558
582
|
}
|
|
559
583
|
|
|
560
584
|
// eslint-disable-next-line complexity
|
|
@@ -677,7 +701,7 @@ function _dumpValue(xw: XmlWriter, node: UAVariable | UAVariableType, variant: V
|
|
|
677
701
|
errorLog("_dumpValue : unsupported arrayType: ", variant.arrayType);
|
|
678
702
|
}
|
|
679
703
|
} else {
|
|
680
|
-
const encodeXml = _dumpVariantValue.bind(null, xw, variant.dataType, node);
|
|
704
|
+
const encodeXml = _dumpVariantValue.bind(null, xw, node.dataType, variant.dataType, node.addressSpace);
|
|
681
705
|
switch (variant.arrayType) {
|
|
682
706
|
case VariantArrayType.Matrix:
|
|
683
707
|
case VariantArrayType.Array:
|
|
@@ -757,7 +781,7 @@ function dumpReferencedNodes(xw: XmlWriter, node: BaseNode, forward: boolean) {
|
|
|
757
781
|
assert(typeDefinitionObj instanceof BaseNodeImpl);
|
|
758
782
|
if (typeDefinitionObj.nodeId.namespace === node.nodeId.namespace) {
|
|
759
783
|
// only output node if it is on the same namespace
|
|
760
|
-
if (!xw.visitedNode
|
|
784
|
+
if (!xw.visitedNode.has(_hash(typeDefinitionObj))) {
|
|
761
785
|
dumpNodeInXml(xw, typeDefinitionObj);
|
|
762
786
|
}
|
|
763
787
|
}
|
|
@@ -773,7 +797,7 @@ function dumpReferencedNodes(xw: XmlWriter, node: BaseNode, forward: boolean) {
|
|
|
773
797
|
assert(r.length === 1);
|
|
774
798
|
if (subTypeOf.nodeId.namespace === node.nodeId.namespace) {
|
|
775
799
|
// only output node if it is on the same namespace
|
|
776
|
-
if (!xw.visitedNode
|
|
800
|
+
if (!xw.visitedNode.has(_hash(subTypeOf))) {
|
|
777
801
|
dumpNodeInXml(xw, subTypeOf);
|
|
778
802
|
}
|
|
779
803
|
}
|
|
@@ -785,7 +809,7 @@ function dumpReferencedNodes(xw: XmlWriter, node: BaseNode, forward: boolean) {
|
|
|
785
809
|
const nodeChild = ReferenceImpl.resolveReferenceNode(addressSpace, reference) as BaseNode;
|
|
786
810
|
assert(nodeChild instanceof BaseNodeImpl);
|
|
787
811
|
if (nodeChild.nodeId.namespace === node.nodeId.namespace) {
|
|
788
|
-
if (!xw.visitedNode
|
|
812
|
+
if (!xw.visitedNode.has(_hash(nodeChild))) {
|
|
789
813
|
debugLog(
|
|
790
814
|
node.nodeId.toString(),
|
|
791
815
|
" dumping child ",
|
|
@@ -1002,14 +1026,14 @@ function dumpUADataType(xw: XmlWriter, node: UADataType) {
|
|
|
1002
1026
|
}
|
|
1003
1027
|
|
|
1004
1028
|
function _markAsVisited(xw: XmlWriter, node: BaseNode) {
|
|
1005
|
-
xw.visitedNode = xw.visitedNode ||
|
|
1006
|
-
assert(!xw.visitedNode
|
|
1007
|
-
xw.visitedNode
|
|
1029
|
+
xw.visitedNode = xw.visitedNode || new Set();
|
|
1030
|
+
assert(!xw.visitedNode.has(_hash(node)));
|
|
1031
|
+
xw.visitedNode.add(_hash(node));
|
|
1008
1032
|
}
|
|
1009
1033
|
|
|
1010
1034
|
function dumpUAVariable(xw: XmlWriter, node: UAVariable) {
|
|
1011
1035
|
assert(node.nodeClass === NodeClass.Variable);
|
|
1012
|
-
if (xw.visitedNode
|
|
1036
|
+
if (xw.visitedNode.has(_hash(node))) {
|
|
1013
1037
|
return;
|
|
1014
1038
|
}
|
|
1015
1039
|
_markAsVisited(xw, node);
|
|
@@ -1054,9 +1078,9 @@ function dumpUAVariable(xw: XmlWriter, node: UAVariable) {
|
|
|
1054
1078
|
|
|
1055
1079
|
function dumpUAVariableType(xw: XmlWriter, node: UAVariableType) {
|
|
1056
1080
|
assert(node.nodeClass === NodeClass.VariableType);
|
|
1057
|
-
xw.visitedNode = xw.visitedNode ||
|
|
1058
|
-
assert(!xw.visitedNode
|
|
1059
|
-
xw.visitedNode
|
|
1081
|
+
xw.visitedNode = xw.visitedNode || new Set();
|
|
1082
|
+
assert(!xw.visitedNode.has(_hash(node)));
|
|
1083
|
+
xw.visitedNode.add(_hash(node));
|
|
1060
1084
|
|
|
1061
1085
|
dumpReferencedNodes(xw, node, false);
|
|
1062
1086
|
|
|
@@ -1112,9 +1136,9 @@ function dumpUAObject(xw: XmlWriter, node: UAObject) {
|
|
|
1112
1136
|
|
|
1113
1137
|
function _dumpUAObject(xw: XmlWriter, node: UAObject) {
|
|
1114
1138
|
assert(node.nodeClass === NodeClass.Object);
|
|
1115
|
-
xw.visitedNode = xw.visitedNode ||
|
|
1116
|
-
assert(!xw.visitedNode
|
|
1117
|
-
xw.visitedNode
|
|
1139
|
+
xw.visitedNode = xw.visitedNode || new Set();
|
|
1140
|
+
assert(!xw.visitedNode.has(_hash(node)));
|
|
1141
|
+
xw.visitedNode.add(_hash(node));
|
|
1118
1142
|
|
|
1119
1143
|
// dump SubTypeOf and HasTypeDefinition
|
|
1120
1144
|
dumpReferencedNodes(xw, node, false);
|
|
@@ -1140,7 +1164,7 @@ function dumpElementInFolder(xw: XmlWriter, node: BaseNodeImpl) {
|
|
|
1140
1164
|
return;
|
|
1141
1165
|
}
|
|
1142
1166
|
|
|
1143
|
-
if (!xw.visitedNode
|
|
1167
|
+
if (!xw.visitedNode.has(_hash(aggregate))) {
|
|
1144
1168
|
aggregate.dumpXML(xw);
|
|
1145
1169
|
}
|
|
1146
1170
|
}
|
|
@@ -1161,7 +1185,7 @@ function dumpAggregates(xw: XmlWriter, node: BaseNode) {
|
|
|
1161
1185
|
if (_hasHigherPriorityThan(xw, aggregate.nodeId.namespace, node.nodeId.namespace)) {
|
|
1162
1186
|
continue;
|
|
1163
1187
|
}
|
|
1164
|
-
if (!xw.visitedNode
|
|
1188
|
+
if (!xw.visitedNode.has(_hash(aggregate))) {
|
|
1165
1189
|
(<BaseNodeImpl>aggregate).dumpXML(xw);
|
|
1166
1190
|
}
|
|
1167
1191
|
}
|
|
@@ -1223,14 +1247,14 @@ function resolveDataTypeName(addressSpace: IAddressSpace, dataType: string | Nod
|
|
|
1223
1247
|
function buildUpAliases(node: BaseNode, xw: XmlWriter, data: BuildAliasesData) {
|
|
1224
1248
|
const addressSpace = node.addressSpace;
|
|
1225
1249
|
|
|
1226
|
-
if (!data.aliases_visited) data.aliases_visited =
|
|
1250
|
+
if (!data.aliases_visited) data.aliases_visited = new Set();
|
|
1227
1251
|
|
|
1228
1252
|
const k = _hash(node);
|
|
1229
1253
|
// istanbul ignore next
|
|
1230
|
-
if (data.aliases_visited
|
|
1254
|
+
if (data.aliases_visited.has(k)) {
|
|
1231
1255
|
return;
|
|
1232
1256
|
}
|
|
1233
|
-
data.aliases_visited
|
|
1257
|
+
data.aliases_visited.add(k);
|
|
1234
1258
|
|
|
1235
1259
|
// put datatype into aliases list
|
|
1236
1260
|
if (node.nodeClass === NodeClass.Variable || node.nodeClass === NodeClass.VariableType) {
|
|
@@ -1331,7 +1355,7 @@ type NodeIdString = string;
|
|
|
1331
1355
|
|
|
1332
1356
|
export interface BuildAliasesData {
|
|
1333
1357
|
aliases: Record<string, NodeIdString>;
|
|
1334
|
-
aliases_visited?:
|
|
1358
|
+
aliases_visited?: Set<string>;
|
|
1335
1359
|
}
|
|
1336
1360
|
interface DumpData extends BuildAliasesData {
|
|
1337
1361
|
elements: Dumpable[];
|
|
@@ -1405,7 +1429,7 @@ NamespaceImpl.prototype.toNodeset2XML = function (this: NamespaceImpl) {
|
|
|
1405
1429
|
if (namespace.index === 0) {
|
|
1406
1430
|
continue;
|
|
1407
1431
|
}
|
|
1408
|
-
const translatedIndex = translationTable
|
|
1432
|
+
const translatedIndex = translationTable.get(namespace.index);
|
|
1409
1433
|
|
|
1410
1434
|
const smallName = `ns${translatedIndex}`;
|
|
1411
1435
|
xw.writeAttribute(`xmlns:${smallName}`, makeTypeXsd(namespace.namespaceUri));
|
|
@@ -1420,10 +1444,12 @@ NamespaceImpl.prototype.toNodeset2XML = function (this: NamespaceImpl) {
|
|
|
1420
1444
|
xw.startElement("NamespaceUris");
|
|
1421
1445
|
|
|
1422
1446
|
// let's sort the dependencies in the same order as the translation table
|
|
1423
|
-
const sortedDependencies = dependency.sort(
|
|
1447
|
+
const sortedDependencies = dependency.sort(
|
|
1448
|
+
(a, b) =>
|
|
1449
|
+
(translationTable.get(a.index)! > translationTable.get(b.index)! ? 1 : -1));
|
|
1424
1450
|
|
|
1425
1451
|
doDebug && debugLog(sortedDependencies.map((a) => a.index + " + " + a.namespaceUri).join("\n"));
|
|
1426
|
-
doDebug && debugLog("translation table ", translationTable);
|
|
1452
|
+
doDebug && debugLog("translation table ", translationTable.entries());
|
|
1427
1453
|
|
|
1428
1454
|
for (const depend of sortedDependencies) {
|
|
1429
1455
|
if (depend.index === 0) {
|
|
@@ -1462,7 +1488,7 @@ NamespaceImpl.prototype.toNodeset2XML = function (this: NamespaceImpl) {
|
|
|
1462
1488
|
}
|
|
1463
1489
|
writeAliases(xw, data.aliases);
|
|
1464
1490
|
|
|
1465
|
-
xw.visitedNode =
|
|
1491
|
+
xw.visitedNode = new Set();
|
|
1466
1492
|
|
|
1467
1493
|
// -------------- writeReferences
|
|
1468
1494
|
xw.writeComment("ReferenceTypes");
|
|
@@ -1494,7 +1520,7 @@ NamespaceImpl.prototype.toNodeset2XML = function (this: NamespaceImpl) {
|
|
|
1494
1520
|
xw.writeComment("DataTypes");
|
|
1495
1521
|
// xx xw.writeComment(" "+ objectTypes.map(x=>x.browseName.name.toString()).join(" "));
|
|
1496
1522
|
for (const dataType of dataTypes.sort(sortByNodeId)) {
|
|
1497
|
-
if (!xw.visitedNode
|
|
1523
|
+
if (!xw.visitedNode.has(_hash(dataType))) {
|
|
1498
1524
|
dumpNodeInXml(xw, dataType);
|
|
1499
1525
|
}
|
|
1500
1526
|
}
|
|
@@ -1539,7 +1565,7 @@ NamespaceImpl.prototype.toNodeset2XML = function (this: NamespaceImpl) {
|
|
|
1539
1565
|
const objectTypes = [...this._objectTypeIterator()].sort(sortByBrowseName);
|
|
1540
1566
|
// xx xw.writeComment(" "+ objectTypes.map(x=>x.browseName.name.toString()).join(" "));
|
|
1541
1567
|
for (const objectType of objectTypes.sort(sortByNodeId)) {
|
|
1542
|
-
if (!xw.visitedNode
|
|
1568
|
+
if (!xw.visitedNode.has(_hash(objectType))) {
|
|
1543
1569
|
dumpNodeInXml(xw, objectType);
|
|
1544
1570
|
}
|
|
1545
1571
|
}
|
|
@@ -1549,7 +1575,7 @@ NamespaceImpl.prototype.toNodeset2XML = function (this: NamespaceImpl) {
|
|
|
1549
1575
|
const variableTypes = [...this._variableTypeIterator()].sort(sortByBrowseName);
|
|
1550
1576
|
// xx xw.writeComment("ObjectTypes "+ variableTypes.map(x=>x.browseName.name.toString()).join(" "));
|
|
1551
1577
|
for (const variableType of variableTypes.sort(sortByNodeId)) {
|
|
1552
|
-
if (!xw.visitedNode
|
|
1578
|
+
if (!xw.visitedNode.has(_hash(variableType))) {
|
|
1553
1579
|
dumpNodeInXml(xw, variableType);
|
|
1554
1580
|
}
|
|
1555
1581
|
}
|
|
@@ -1558,7 +1584,7 @@ NamespaceImpl.prototype.toNodeset2XML = function (this: NamespaceImpl) {
|
|
|
1558
1584
|
xw.writeComment("Other Nodes");
|
|
1559
1585
|
const nodes = [...this.nodeIterator()].sort(sortByBrowseName);
|
|
1560
1586
|
for (const node of nodes.sort(sortByNodeId)) {
|
|
1561
|
-
if (!xw.visitedNode
|
|
1587
|
+
if (!xw.visitedNode.has(_hash(node))) {
|
|
1562
1588
|
dumpNodeInXml(xw, node);
|
|
1563
1589
|
}
|
|
1564
1590
|
}
|
package/src/private_namespace.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
3
|
import { Namespace } from "../source/namespace";
|
|
4
|
+
import { NamespacePrivate } from "./namespace_private";
|
|
4
5
|
import { NodeEntry1, NodeIdManager } from "./nodeid_manager";
|
|
5
6
|
|
|
6
7
|
export function getNodeIdManager(ns: Namespace): NodeIdManager {
|
|
@@ -9,7 +10,7 @@ export function getNodeIdManager(ns: Namespace): NodeIdManager {
|
|
|
9
10
|
}
|
|
10
11
|
export function setSymbols(ns: Namespace, symbols: NodeEntry1[]) {
|
|
11
12
|
const nodeIdManager = getNodeIdManager(ns);
|
|
12
|
-
(ns
|
|
13
|
+
(ns as any).registerSymbolicNames = true;
|
|
13
14
|
nodeIdManager.setSymbols(symbols);
|
|
14
15
|
}
|
|
15
16
|
export function getSymbols(ns: Namespace): NodeEntry1[] {
|
package/src/tool_isSubtypeOf.ts
CHANGED
|
@@ -60,11 +60,15 @@ function _slow_isSubtypeOf<T extends UAType>(this: T, Class: typeof BaseNodeImpl
|
|
|
60
60
|
|
|
61
61
|
export type MemberFuncValue<T, P, R> = (this: T, param: P) => R;
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
|
|
64
|
+
const g_WeakMap = new WeakMap<Object, Map<string, unknown>>();
|
|
65
|
+
|
|
66
|
+
export function wipeMemorizedStuff(node: Object) {
|
|
67
|
+
if (g_WeakMap.has(node)) {
|
|
68
|
+
g_WeakMap.delete(node);
|
|
66
69
|
}
|
|
67
70
|
}
|
|
71
|
+
|
|
68
72
|
// http://jsperf.com/underscore-js-memoize-refactor-test
|
|
69
73
|
// http://addyosmani.com/blog/faster-javascript-memoization/
|
|
70
74
|
function wrap_memoize<T, P, R>(
|
|
@@ -74,26 +78,25 @@ function wrap_memoize<T, P, R>(
|
|
|
74
78
|
if (undefined === hashFunc) {
|
|
75
79
|
hashFunc = (_p: T) => (_p as any).toString();
|
|
76
80
|
}
|
|
77
|
-
|
|
78
81
|
return function memoize(this: any, param: any) {
|
|
79
|
-
|
|
80
|
-
|
|
82
|
+
const self = this;
|
|
83
|
+
if (!g_WeakMap.has(self)) {
|
|
84
|
+
g_WeakMap.set(self,new Map());
|
|
81
85
|
}
|
|
86
|
+
const memoMap = g_WeakMap.get(self)!;
|
|
82
87
|
|
|
83
88
|
const hash = hashFunc!.call(this, param);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (cache_value === undefined) {
|
|
88
|
-
cache_value = func.call(this, param);
|
|
89
|
-
this.__cache[hash] = cache_value;
|
|
89
|
+
if (memoMap.has(hash)) {
|
|
90
|
+
return memoMap.get(hash) as R;
|
|
90
91
|
}
|
|
91
|
-
|
|
92
|
+
const cache_value = func.call(this, param);
|
|
93
|
+
memoMap.set(hash,cache_value);
|
|
94
|
+
return cache_value as R;
|
|
92
95
|
};
|
|
93
96
|
}
|
|
94
97
|
|
|
95
98
|
function hashBaseNode(e: BaseNode): string {
|
|
96
|
-
return e.nodeId.
|
|
99
|
+
return e.nodeId.toString();
|
|
97
100
|
}
|
|
98
101
|
|
|
99
102
|
export type IsSubtypeOfFunc<T extends UAType> = (this: T, baseType: T) => boolean;
|
|
@@ -101,6 +104,7 @@ export type IsSubtypeOfFunc<T extends UAType> = (this: T, baseType: T) => boolea
|
|
|
101
104
|
export type UAType = UAReferenceType | UADataType | UAObjectType | UAVariableType;
|
|
102
105
|
|
|
103
106
|
export function construct_isSubtypeOf<T extends UAType>(Class: typeof BaseNodeImpl): IsSubtypeOfFunc<T> {
|
|
107
|
+
|
|
104
108
|
return wrap_memoize(function (this: T, baseType: T | NodeIdLike): boolean {
|
|
105
109
|
if (!(baseType instanceof Class)) {
|
|
106
110
|
throw new Error(
|
|
@@ -136,9 +140,9 @@ export function get_subtypeOf<T extends BaseNode>(this: T): NodeId | null {
|
|
|
136
140
|
export function get_subtypeOfObj(this: BaseNode): BaseNode | null {
|
|
137
141
|
const _cache = BaseNode_getCache(this);
|
|
138
142
|
|
|
139
|
-
if (
|
|
143
|
+
if (_cache._subtypeOfObj == undefined) {
|
|
140
144
|
const is_subtype_of_ref = this.findReference("HasSubtype", false);
|
|
141
|
-
if (is_subtype_of_ref) {
|
|
145
|
+
if (is_subtype_of_ref ) {
|
|
142
146
|
_cache._subtypeOfObj = ReferenceImpl.resolveReferenceNode(this.addressSpace, is_subtype_of_ref);
|
|
143
147
|
} else {
|
|
144
148
|
_cache._subtypeOfObj = null;
|
package/src/ua_data_type_impl.ts
CHANGED
|
@@ -151,9 +151,9 @@ export class UADataTypeImpl extends BaseNodeImpl implements UADataType {
|
|
|
151
151
|
|
|
152
152
|
public getEncodingNode(encoding_name: string): UAObject | null {
|
|
153
153
|
const _cache = BaseNode_getCache(this);
|
|
154
|
-
_cache._encoding = _cache._encoding ||
|
|
154
|
+
_cache._encoding = _cache._encoding || new Map();
|
|
155
155
|
const key = encoding_name + "Node";
|
|
156
|
-
if (_cache._encoding
|
|
156
|
+
if (!_cache._encoding.has(key)) {
|
|
157
157
|
assert(encoding_name === "Default Binary" || encoding_name === "Default XML" || encoding_name === "Default JSON");
|
|
158
158
|
// could be binary or xml
|
|
159
159
|
const refs = this.findReferences("HasEncoding", true);
|
|
@@ -163,9 +163,10 @@ export class UADataTypeImpl extends BaseNodeImpl implements UADataType {
|
|
|
163
163
|
.filter((obj: any) => obj !== null)
|
|
164
164
|
.filter((obj: any) => obj.browseName.toString() === encoding_name);
|
|
165
165
|
const node = encoding.length === 0 ? null : (encoding[0] as UAObject);
|
|
166
|
-
_cache._encoding
|
|
166
|
+
_cache._encoding.set(key,node);
|
|
167
|
+
return node
|
|
167
168
|
}
|
|
168
|
-
return _cache._encoding
|
|
169
|
+
return _cache._encoding.get(key) || null;
|
|
169
170
|
}
|
|
170
171
|
|
|
171
172
|
public getEncodingNodeId(encoding_name: string): ExpandedNodeId | null {
|
|
@@ -82,8 +82,9 @@ export class UAObjectTypeImpl extends BaseNodeImpl implements UAObjectType {
|
|
|
82
82
|
* @param options
|
|
83
83
|
* @param options.browseName
|
|
84
84
|
* @param [options.description]
|
|
85
|
-
* @param [options.organizedBy] the parent Folder holding this object
|
|
85
|
+
* @param [options.organizedBy] the parent Folder holding this object
|
|
86
86
|
* @param [options.componentOf] the parent Object holding this object
|
|
87
|
+
* @param [options.addInOf]
|
|
87
88
|
* @param [options.notifierOf]
|
|
88
89
|
* @param [options.eventSourceOf]
|
|
89
90
|
* @param [options.optionals = [] name of the optional child to create
|
|
@@ -132,6 +133,7 @@ export class UAObjectTypeImpl extends BaseNodeImpl implements UAObjectType {
|
|
|
132
133
|
eventSourceOf: options.eventSourceOf,
|
|
133
134
|
notifierOf: options.notifierOf,
|
|
134
135
|
organizedBy: options.organizedBy,
|
|
136
|
+
addInOf: options.addInOf,
|
|
135
137
|
references,
|
|
136
138
|
|
|
137
139
|
typeDefinition: this.nodeId,
|
|
@@ -147,7 +149,10 @@ export class UAObjectTypeImpl extends BaseNodeImpl implements UAObjectType {
|
|
|
147
149
|
|
|
148
150
|
const instance = namespace.addObject(opts);
|
|
149
151
|
|
|
150
|
-
|
|
152
|
+
const copyAlsoAllOptionals = options.copyAlsoAllOptionals || false;
|
|
153
|
+
initialize_properties_and_components(
|
|
154
|
+
instance, baseObjectType, this,
|
|
155
|
+
copyAlsoModellingRules, copyAlsoAllOptionals, options.optionals);
|
|
151
156
|
|
|
152
157
|
assert(instance.typeDefinition.toString() === this.nodeId.toString());
|
|
153
158
|
|
|
@@ -53,17 +53,17 @@ function _getAllSubtypes(ref: UAReferenceType) {
|
|
|
53
53
|
return _cache._allSubTypes;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
function _internal_getSubtypeIndex(referenceType: UAReferenceType):
|
|
56
|
+
function _internal_getSubtypeIndex(referenceType: UAReferenceType): Map<string,UAReferenceTypePublic> {
|
|
57
57
|
const possibleReferenceTypes = _getAllSubtypes(referenceType);
|
|
58
58
|
// create a index of reference type with browseName as key for faster search
|
|
59
|
-
const keys:
|
|
59
|
+
const keys: Map<string, UAReferenceType> = new Map();
|
|
60
60
|
for (const refType of possibleReferenceTypes) {
|
|
61
|
-
keys
|
|
61
|
+
keys.set(refType.nodeId.toString(),refType);
|
|
62
62
|
}
|
|
63
63
|
return keys;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
function _getSubtypeIndex(referenceType: UAReferenceType):
|
|
66
|
+
function _getSubtypeIndex(referenceType: UAReferenceType): Map<string, UAReferenceTypePublic> {
|
|
67
67
|
const _cache = BaseNode_getCache(referenceType);
|
|
68
68
|
if (!_cache._subtype_idx || (_cache._subtype_idxVersion && _cache._subtype_idxVersion < ReferenceTypeCounter.count)) {
|
|
69
69
|
// the cache need to be invalidated
|
|
@@ -99,7 +99,7 @@ export class UAReferenceTypeImpl extends BaseNodeImpl implements UAReferenceType
|
|
|
99
99
|
* returns true if self is a super type of baseType
|
|
100
100
|
*/
|
|
101
101
|
public isSubtypeOf = construct_isSubtypeOf<UAReferenceType>(UAReferenceTypeImpl);
|
|
102
|
-
|
|
102
|
+
|
|
103
103
|
/** @deprecated - use `isSubtypeOf` instead*/
|
|
104
104
|
public isSupertypeOf = construct_isSubtypeOf<UAReferenceType>(UAReferenceTypeImpl);
|
|
105
105
|
|
|
@@ -166,6 +166,6 @@ export class UAReferenceTypeImpl extends BaseNodeImpl implements UAReferenceType
|
|
|
166
166
|
const _index = _getSubtypeIndex(this);
|
|
167
167
|
const referenceTypeNodeId = ref instanceof ReferenceImpl ? ref.nodeId : (ref as NodeId);
|
|
168
168
|
const _key = referenceTypeNodeId.toString();
|
|
169
|
-
return
|
|
169
|
+
return _index.has(_key);
|
|
170
170
|
}
|
|
171
171
|
}
|
package/src/ua_variable_impl.ts
CHANGED
|
@@ -94,6 +94,7 @@ import {
|
|
|
94
94
|
import { adjustDataValueStatusCode } from "./data_access/adjust_datavalue_status_code";
|
|
95
95
|
import { _getBasicDataType } from "./get_basic_datatype";
|
|
96
96
|
import { validateDataTypeCorrectness } from "./validate_data_type_correctness";
|
|
97
|
+
import { DataTypeIds } from "node-opcua-constants";
|
|
97
98
|
|
|
98
99
|
const debugLog = make_debugLog(__filename);
|
|
99
100
|
const warningLog = make_warningLog(__filename);
|
|
@@ -1310,6 +1311,9 @@ export class UAVariableImpl extends BaseNodeImpl implements UAVariable {
|
|
|
1310
1311
|
|
|
1311
1312
|
public getDataTypeNode(): UADataType {
|
|
1312
1313
|
const addressSpace = this.addressSpace;
|
|
1314
|
+
if (this.dataType.isEmpty()) {
|
|
1315
|
+
this.dataType = this.resolveNodeId(DataType.Variant);
|
|
1316
|
+
}
|
|
1313
1317
|
const dt = addressSpace.findNode(this.dataType);
|
|
1314
1318
|
// istanbul ignore next
|
|
1315
1319
|
if (!dt) {
|
|
@@ -204,7 +204,8 @@ function getOrCreateProperty(
|
|
|
204
204
|
|
|
205
205
|
// istanbul ignore next
|
|
206
206
|
if (field.dataType.value === DataType.Variant) {
|
|
207
|
-
|
|
207
|
+
// this means that any type of extensions being used here
|
|
208
|
+
debugLog("Warning : variant is not supported in ExtensionObject");
|
|
208
209
|
}
|
|
209
210
|
|
|
210
211
|
if (selectedComponents.length === 1) {
|
|
@@ -50,8 +50,13 @@ interface InstantiateS {
|
|
|
50
50
|
propertyOf?: any;
|
|
51
51
|
componentOf?: any;
|
|
52
52
|
modellingRule?: ModellingRuleType;
|
|
53
|
+
copyAlsoModellingRules?: boolean;
|
|
54
|
+
copyAlsoAllOptionals?: boolean;
|
|
53
55
|
}
|
|
54
56
|
export function topMostParentIsObjectTypeOrVariableType(addressSpace: AddressSpacePrivate, options: InstantiateS): boolean {
|
|
57
|
+
if (options.copyAlsoModellingRules) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
55
60
|
if (options.modellingRule) {
|
|
56
61
|
return true;
|
|
57
62
|
}
|
|
@@ -288,8 +293,13 @@ export class UAVariableTypeImpl extends BaseNodeImpl implements UAVariableType {
|
|
|
288
293
|
const instance = namespace.addVariable(opts);
|
|
289
294
|
|
|
290
295
|
// xx assert(instance.minimumSamplingInterval === options.minimumSamplingInterval);
|
|
296
|
+
const copyAlsoAllOptionals = options.copyAlsoAllOptionals || false;
|
|
291
297
|
|
|
292
|
-
initialize_properties_and_components(
|
|
298
|
+
initialize_properties_and_components(
|
|
299
|
+
instance, baseVariableType, this,
|
|
300
|
+
copyAlsoModellingRules,
|
|
301
|
+
copyAlsoAllOptionals,
|
|
302
|
+
options.optionals);
|
|
293
303
|
|
|
294
304
|
// if VariableType is a type of Structure DataType
|
|
295
305
|
// we need to instantiate a dataValue
|