Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
opcua-asyncio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
opcua-asyncio
Commits
527ae461
Commit
527ae461
authored
Sep 02, 2022
by
Christoph Ziebuhr
Committed by
oroulet
Sep 07, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Always take NamespaceIndex into account when comparing NodeIds
parent
7b2b130f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
17 deletions
+17
-17
asyncua/common/events.py
asyncua/common/events.py
+4
-4
asyncua/common/xmlexporter.py
asyncua/common/xmlexporter.py
+1
-1
asyncua/common/xmlimporter.py
asyncua/common/xmlimporter.py
+1
-1
asyncua/server/address_space.py
asyncua/server/address_space.py
+1
-1
tests/test_common.py
tests/test_common.py
+10
-10
No files found.
asyncua/common/events.py
View file @
527ae461
...
@@ -216,7 +216,7 @@ async def select_event_attributes_from_type_node(node: "Node", attributeSelector
...
@@ -216,7 +216,7 @@ async def select_event_attributes_from_type_node(node: "Node", attributeSelector
curr_node
=
node
curr_node
=
node
while
True
:
while
True
:
attributes
.
extend
(
await
attributeSelector
(
curr_node
))
attributes
.
extend
(
await
attributeSelector
(
curr_node
))
if
curr_node
.
nodeid
.
Identifier
==
ua
.
ObjectIds
.
BaseEventType
:
if
curr_node
.
nodeid
==
ua
.
NodeId
(
ua
.
ObjectIds
.
BaseEventType
)
:
break
break
parents
=
await
curr_node
.
get_referenced_nodes
(
parents
=
await
curr_node
.
get_referenced_nodes
(
refs
=
ua
.
ObjectIds
.
HasSubtype
,
direction
=
ua
.
BrowseDirection
.
Inverse
refs
=
ua
.
ObjectIds
.
HasSubtype
,
direction
=
ua
.
BrowseDirection
.
Inverse
...
@@ -247,7 +247,7 @@ async def get_event_obj_from_type_node(node):
...
@@ -247,7 +247,7 @@ async def get_event_obj_from_type_node(node):
if
node
.
nodeid
.
Identifier
in
asyncua
.
common
.
event_objects
.
IMPLEMENTED_EVENTS
.
keys
():
if
node
.
nodeid
.
Identifier
in
asyncua
.
common
.
event_objects
.
IMPLEMENTED_EVENTS
.
keys
():
return
asyncua
.
common
.
event_objects
.
IMPLEMENTED_EVENTS
[
node
.
nodeid
.
Identifier
]()
return
asyncua
.
common
.
event_objects
.
IMPLEMENTED_EVENTS
[
node
.
nodeid
.
Identifier
]()
parent_
identifier
,
parent_eventtype
=
await
_find_parent_eventtype
(
node
)
parent_
nodeid
,
parent_eventtype
=
await
_find_parent_eventtype
(
node
)
class
CustomEvent
(
parent_eventtype
):
class
CustomEvent
(
parent_eventtype
):
...
@@ -270,7 +270,7 @@ async def get_event_obj_from_type_node(node):
...
@@ -270,7 +270,7 @@ async def get_event_obj_from_type_node(node):
async
def
init
(
self
):
async
def
init
(
self
):
curr_node
=
node
curr_node
=
node
while
curr_node
.
nodeid
.
Identifier
!=
parent_identifier
:
while
curr_node
.
nodeid
!=
parent_nodeid
:
for
prop
in
await
curr_node
.
get_properties
():
for
prop
in
await
curr_node
.
get_properties
():
await
self
.
_add_new_property
(
prop
,
None
)
await
self
.
_add_new_property
(
prop
,
None
)
for
var
in
await
curr_node
.
get_variables
():
for
var
in
await
curr_node
.
get_variables
():
...
@@ -298,5 +298,5 @@ async def _find_parent_eventtype(node):
...
@@ -298,5 +298,5 @@ async def _find_parent_eventtype(node):
raise
UaError
(
"Parent of event type could not be found"
)
raise
UaError
(
"Parent of event type could not be found"
)
if
parents
[
0
].
nodeid
.
NamespaceIndex
==
0
:
if
parents
[
0
].
nodeid
.
NamespaceIndex
==
0
:
if
parents
[
0
].
nodeid
.
Identifier
in
asyncua
.
common
.
event_objects
.
IMPLEMENTED_EVENTS
.
keys
():
if
parents
[
0
].
nodeid
.
Identifier
in
asyncua
.
common
.
event_objects
.
IMPLEMENTED_EVENTS
.
keys
():
return
parents
[
0
].
nodeid
.
Identifier
,
asyncua
.
common
.
event_objects
.
IMPLEMENTED_EVENTS
[
parents
[
0
].
nodeid
.
Identifier
]
return
parents
[
0
].
nodeid
,
asyncua
.
common
.
event_objects
.
IMPLEMENTED_EVENTS
[
parents
[
0
].
nodeid
.
Identifier
]
return
await
_find_parent_eventtype
(
parents
[
0
])
return
await
_find_parent_eventtype
(
parents
[
0
])
asyncua/common/xmlexporter.py
View file @
527ae461
...
@@ -357,7 +357,7 @@ class XmlExporter:
...
@@ -357,7 +357,7 @@ class XmlExporter:
refs
=
await
obj
.
get_references
()
refs
=
await
obj
.
get_references
()
refs_el
=
Et
.
SubElement
(
parent_el
,
'References'
)
refs_el
=
Et
.
SubElement
(
parent_el
,
'References'
)
for
ref
in
refs
:
for
ref
in
refs
:
if
ref
.
ReferenceTypeId
.
Identifier
in
o_ids
.
ObjectIdNames
:
if
ref
.
ReferenceTypeId
.
NamespaceIndex
==
0
and
ref
.
ReferenceTypeId
.
Identifier
in
o_ids
.
ObjectIdNames
:
ref_name
=
o_ids
.
ObjectIdNames
[
ref
.
ReferenceTypeId
.
Identifier
]
ref_name
=
o_ids
.
ObjectIdNames
[
ref
.
ReferenceTypeId
.
Identifier
]
else
:
else
:
ref_name
=
self
.
_node_to_string
(
ref
.
ReferenceTypeId
)
ref_name
=
self
.
_node_to_string
(
ref
.
ReferenceTypeId
)
...
...
asyncua/common/xmlimporter.py
View file @
527ae461
...
@@ -173,7 +173,7 @@ class XmlImporter:
...
@@ -173,7 +173,7 @@ class XmlImporter:
dangling_refs_to_missing_nodes
.
discard
(
new_node_id
)
dangling_refs_to_missing_nodes
.
discard
(
new_node_id
)
dangling_refs_to_missing_nodes
.
discard
(
ref
.
NodeId
)
dangling_refs_to_missing_nodes
.
discard
(
ref
.
NodeId
)
if
ref
.
ReferenceTypeId
.
Identifier
not
in
__unidirectional_types
:
if
ref
.
ReferenceTypeId
.
NamespaceIndex
!=
0
or
ref
.
ReferenceTypeId
.
Identifier
not
in
__unidirectional_types
:
ref_key
=
(
new_node_id
,
ref
.
NodeId
,
ref
.
ReferenceTypeId
)
ref_key
=
(
new_node_id
,
ref
.
NodeId
,
ref
.
ReferenceTypeId
)
node_reference_map
[
ref_key
]
=
ref
node_reference_map
[
ref_key
]
=
ref
...
...
asyncua/server/address_space.py
View file @
527ae461
...
@@ -298,7 +298,7 @@ class NodeManagementService:
...
@@ -298,7 +298,7 @@ class NodeManagementService:
# check properties
# check properties
for
ref
in
self
.
_aspace
[
item
.
ParentNodeId
].
references
:
for
ref
in
self
.
_aspace
[
item
.
ParentNodeId
].
references
:
if
ref
.
ReferenceTypeId
.
Identifier
==
ua
.
ObjectIds
.
HasProperty
:
if
ref
.
ReferenceTypeId
==
ua
.
NodeId
(
ua
.
ObjectIds
.
HasProperty
)
:
if
item
.
BrowseName
.
Name
==
ref
.
BrowseName
.
Name
:
if
item
.
BrowseName
.
Name
==
ref
.
BrowseName
.
Name
:
self
.
logger
.
warning
(
self
.
logger
.
warning
(
f"AddNodesItem: Requested Browsename
{
item
.
BrowseName
.
Name
}
"
f"AddNodesItem: Requested Browsename
{
item
.
BrowseName
.
Name
}
"
...
...
tests/test_common.py
View file @
527ae461
...
@@ -823,16 +823,16 @@ async def test_add_node_with_type(opc):
...
@@ -823,16 +823,16 @@ async def test_add_node_with_type(opc):
f
=
await
objects
.
add_folder
(
3
,
'MyFolder_TypeTest'
)
f
=
await
objects
.
add_folder
(
3
,
'MyFolder_TypeTest'
)
o
=
await
f
.
add_object
(
3
,
'MyObject1'
,
ua
.
ObjectIds
.
BaseObjectType
)
o
=
await
f
.
add_object
(
3
,
'MyObject1'
,
ua
.
ObjectIds
.
BaseObjectType
)
assert
ua
.
ObjectIds
.
BaseObjectType
==
(
await
o
.
read_type_definition
()).
Identifier
assert
ua
.
NodeId
(
ua
.
ObjectIds
.
BaseObjectType
)
==
await
o
.
read_type_definition
()
o
=
await
f
.
add_object
(
3
,
'MyObject2'
,
ua
.
NodeId
(
ua
.
ObjectIds
.
BaseObjectType
,
0
))
o
=
await
f
.
add_object
(
3
,
'MyObject2'
,
ua
.
NodeId
(
ua
.
ObjectIds
.
BaseObjectType
,
0
))
assert
ua
.
ObjectIds
.
BaseObjectType
==
(
await
o
.
read_type_definition
()).
Identifier
assert
ua
.
NodeId
(
ua
.
ObjectIds
.
BaseObjectType
)
==
await
o
.
read_type_definition
()
base_otype
=
opc
.
opc
.
get_node
(
ua
.
ObjectIds
.
BaseObjectType
)
base_otype
=
opc
.
opc
.
get_node
(
ua
.
ObjectIds
.
BaseObjectType
)
custom_otype
=
await
base_otype
.
add_object_type
(
2
,
'MyFooObjectType2'
)
custom_otype
=
await
base_otype
.
add_object_type
(
2
,
'MyFooObjectType2'
)
o
=
await
f
.
add_object
(
3
,
'MyObject3'
,
custom_otype
.
nodeid
)
o
=
await
f
.
add_object
(
3
,
'MyObject3'
,
custom_otype
.
nodeid
)
assert
custom_otype
.
nodeid
.
Identifier
==
(
await
o
.
read_type_definition
()).
Identifier
assert
custom_otype
.
nodeid
==
await
o
.
read_type_definition
()
references
=
await
o
.
get_references
(
refs
=
ua
.
ObjectIds
.
HasTypeDefinition
,
direction
=
ua
.
BrowseDirection
.
Forward
)
references
=
await
o
.
get_references
(
refs
=
ua
.
ObjectIds
.
HasTypeDefinition
,
direction
=
ua
.
BrowseDirection
.
Forward
)
assert
1
==
len
(
references
)
assert
1
==
len
(
references
)
...
@@ -852,7 +852,7 @@ async def test_references_for_added_nodes(opc):
...
@@ -852,7 +852,7 @@ async def test_references_for_added_nodes(opc):
)
)
assert
objects
in
nodes
assert
objects
in
nodes
assert
objects
==
await
o
.
get_parent
()
assert
objects
==
await
o
.
get_parent
()
assert
ua
.
ObjectIds
.
BaseObjectType
==
(
await
o
.
read_type_definition
()).
Identifier
assert
ua
.
NodeId
(
ua
.
ObjectIds
.
BaseObjectType
)
==
await
o
.
read_type_definition
()
assert
[]
==
await
o
.
get_references
(
ua
.
ObjectIds
.
HasModellingRule
)
assert
[]
==
await
o
.
get_references
(
ua
.
ObjectIds
.
HasModellingRule
)
o2
=
await
o
.
add_object
(
3
,
'MySecondObject'
)
o2
=
await
o
.
add_object
(
3
,
'MySecondObject'
)
...
@@ -865,7 +865,7 @@ async def test_references_for_added_nodes(opc):
...
@@ -865,7 +865,7 @@ async def test_references_for_added_nodes(opc):
)
)
assert
o
in
nodes
assert
o
in
nodes
assert
o
==
await
o2
.
get_parent
()
assert
o
==
await
o2
.
get_parent
()
assert
ua
.
ObjectIds
.
BaseObjectType
==
(
await
o2
.
read_type_definition
()).
Identifier
assert
ua
.
NodeId
(
ua
.
ObjectIds
.
BaseObjectType
)
==
await
o2
.
read_type_definition
()
assert
[]
==
await
o2
.
get_references
(
ua
.
ObjectIds
.
HasModellingRule
)
assert
[]
==
await
o2
.
get_references
(
ua
.
ObjectIds
.
HasModellingRule
)
v
=
await
o
.
add_variable
(
3
,
'MyVariable'
,
6
)
v
=
await
o
.
add_variable
(
3
,
'MyVariable'
,
6
)
...
@@ -878,7 +878,7 @@ async def test_references_for_added_nodes(opc):
...
@@ -878,7 +878,7 @@ async def test_references_for_added_nodes(opc):
)
)
assert
o
in
nodes
assert
o
in
nodes
assert
o
==
await
v
.
get_parent
()
assert
o
==
await
v
.
get_parent
()
assert
ua
.
ObjectIds
.
BaseDataVariableType
==
(
await
v
.
read_type_definition
()).
Identifier
assert
ua
.
NodeId
(
ua
.
ObjectIds
.
BaseDataVariableType
)
==
await
v
.
read_type_definition
()
assert
[]
==
await
v
.
get_references
(
ua
.
ObjectIds
.
HasModellingRule
)
assert
[]
==
await
v
.
get_references
(
ua
.
ObjectIds
.
HasModellingRule
)
p
=
await
o
.
add_property
(
3
,
'MyProperty'
,
2
)
p
=
await
o
.
add_property
(
3
,
'MyProperty'
,
2
)
...
@@ -891,7 +891,7 @@ async def test_references_for_added_nodes(opc):
...
@@ -891,7 +891,7 @@ async def test_references_for_added_nodes(opc):
)
)
assert
o
in
nodes
assert
o
in
nodes
assert
o
==
await
p
.
get_parent
()
assert
o
==
await
p
.
get_parent
()
assert
ua
.
ObjectIds
.
PropertyType
==
(
await
p
.
read_type_definition
()).
Identifier
assert
ua
.
NodeId
(
ua
.
ObjectIds
.
PropertyType
)
==
await
p
.
read_type_definition
()
assert
[]
==
await
p
.
get_references
(
ua
.
ObjectIds
.
HasModellingRule
)
assert
[]
==
await
p
.
get_references
(
ua
.
ObjectIds
.
HasModellingRule
)
m
=
await
objects
.
get_child
(
"2:ServerMethod"
)
m
=
await
objects
.
get_child
(
"2:ServerMethod"
)
...
@@ -943,7 +943,7 @@ async def test_copy_node(opc):
...
@@ -943,7 +943,7 @@ async def test_copy_node(opc):
assert
4
==
len
(
await
mydevice
.
get_children
())
assert
4
==
len
(
await
mydevice
.
get_children
())
_
=
await
mydevice
.
get_child
([
"0:controller"
])
_
=
await
mydevice
.
get_child
([
"0:controller"
])
prop
=
await
mydevice
.
get_child
([
"0:controller"
,
"0:state"
])
prop
=
await
mydevice
.
get_child
([
"0:controller"
,
"0:state"
])
assert
ua
.
ObjectIds
.
PropertyType
==
(
await
prop
.
read_type_definition
()).
Identifier
assert
ua
.
NodeId
(
ua
.
ObjectIds
.
PropertyType
)
==
await
prop
.
read_type_definition
()
assert
"Running"
==
await
prop
.
read_value
()
assert
"Running"
==
await
prop
.
read_value
()
assert
prop
.
nodeid
!=
prop_t
.
nodeid
assert
prop
.
nodeid
!=
prop_t
.
nodeid
...
@@ -985,7 +985,7 @@ async def test_instantiate_1(opc):
...
@@ -985,7 +985,7 @@ async def test_instantiate_1(opc):
with
pytest
.
raises
(
ua
.
uaerrors
.
BadNoMatch
):
with
pytest
.
raises
(
ua
.
uaerrors
.
BadNoMatch
):
await
mydevice
.
get_child
([
"0:MyDeviceDerived"
])
await
mydevice
.
get_child
([
"0:MyDeviceDerived"
])
assert
ua
.
ObjectIds
.
PropertyType
==
(
await
prop
.
read_type_definition
()).
Identifier
assert
ua
.
NodeId
(
ua
.
ObjectIds
.
PropertyType
)
==
await
prop
.
read_type_definition
()
assert
"Running"
==
await
prop
.
read_value
()
assert
"Running"
==
await
prop
.
read_value
()
assert
prop
.
nodeid
!=
prop_t
.
nodeid
assert
prop
.
nodeid
!=
prop_t
.
nodeid
...
@@ -1022,7 +1022,7 @@ async def test_instantiate_string_nodeid(opc):
...
@@ -1022,7 +1022,7 @@ async def test_instantiate_string_nodeid(opc):
obj_nodeid_ident
=
obj
.
nodeid
.
Identifier
obj_nodeid_ident
=
obj
.
nodeid
.
Identifier
prop
=
await
mydevice
.
get_child
([
"0:controller"
,
"0:state"
])
prop
=
await
mydevice
.
get_child
([
"0:controller"
,
"0:state"
])
assert
"InstDevice.controller"
==
obj_nodeid_ident
assert
"InstDevice.controller"
==
obj_nodeid_ident
assert
ua
.
ObjectIds
.
PropertyType
==
(
await
prop
.
read_type_definition
()).
Identifier
assert
ua
.
NodeId
(
ua
.
ObjectIds
.
PropertyType
)
==
await
prop
.
read_type_definition
()
assert
"Running"
==
await
prop
.
read_value
()
assert
"Running"
==
await
prop
.
read_value
()
assert
prop
.
nodeid
!=
prop_t
.
nodeid
assert
prop
.
nodeid
!=
prop_t
.
nodeid
await
opc
.
opc
.
delete_nodes
([
dev_t
])
await
opc
.
opc
.
delete_nodes
([
dev_t
])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment