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
258c975e
Commit
258c975e
authored
May 02, 2018
by
oroulet
Committed by
Christian Bergmiller
Jul 30, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cherry-pick/merge
12562266
parent
093ab1c9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
29 deletions
+21
-29
opcua/common/node.py
opcua/common/node.py
+21
-29
No files found.
opcua/common/node.py
View file @
258c975e
...
...
@@ -619,35 +619,29 @@ class Node:
results
=
await
self
.
server
.
add_references
(
params
)
_check_results
(
results
,
len
(
params
))
async
def
_add_modelling_rule
(
self
,
parent
,
mandatory
=
True
):
if
mandatory
is
not
None
and
await
parent
.
get_node_class
()
==
ua
.
NodeClass
.
ObjectType
:
rule
=
ua
.
ObjectIds
.
ModellingRule_Mandatory
if
mandatory
else
ua
.
ObjectIds
.
ModellingRule_Optional
await
self
.
add_reference
(
rule
,
ua
.
ObjectIds
.
HasModellingRule
,
True
,
False
)
return
self
async
def
set_modelling_rule
(
self
,
mandatory
):
parent
=
await
self
.
get_parent
()
if
parent
is
None
:
return
ua
.
StatusCode
(
ua
.
StatusCodes
.
BadParentNodeIdInvalid
)
if
await
parent
.
get_node_class
()
!=
ua
.
NodeClass
.
ObjectType
:
return
ua
.
StatusCode
(
ua
.
StatusCodes
.
BadTypeMismatch
)
def
set_modelling_rule
(
self
,
mandatory
):
"""
Add a modelling rule reference to Node.
When creating a new object type, its variable and child nodes will not
be instanciated if they do not have modelling rule
if mandatory is None, the modelling rule is removed
"""
# remove all existing modelling rule
rules
=
await
self
.
get_references
(
ua
.
ObjectIds
.
HasModellingRule
)
await
self
.
server
.
delete_references
(
list
(
map
(
self
.
_fill_delete_reference_item
,
rules
)))
await
self
.
_add_modelling_rule
(
parent
,
mandatory
)
return
ua
.
StatusCode
()
# add new modelling rule as requested
if
mandatory
is
not
None
:
rule
=
ua
.
ObjectIds
.
ModellingRule_Mandatory
if
mandatory
else
ua
.
ObjectIds
.
ModellingRule_Optional
await
self
.
add_reference
(
rule
,
ua
.
ObjectIds
.
HasModellingRule
,
True
,
False
)
async
def
add_folder
(
self
,
nodeid
,
bname
):
folder
=
await
opcua
.
common
.
manage_nodes
.
create_folder
(
self
,
nodeid
,
bname
)
return
await
folder
.
_add_modelling_rule
(
self
)
def
add_folder
(
self
,
nodeid
,
bname
):
return
opcua
.
common
.
manage_nodes
.
create_folder
(
self
,
nodeid
,
bname
)
async
def
add_object
(
self
,
nodeid
,
bname
,
objecttype
=
None
):
obj
=
await
opcua
.
common
.
manage_nodes
.
create_object
(
self
,
nodeid
,
bname
,
objecttype
)
return
await
obj
.
_add_modelling_rule
(
self
)
def
add_object
(
self
,
nodeid
,
bname
,
objecttype
=
None
):
return
opcua
.
common
.
manage_nodes
.
create_object
(
self
,
nodeid
,
bname
,
objecttype
)
async
def
add_variable
(
self
,
nodeid
,
bname
,
val
,
varianttype
=
None
,
datatype
=
None
):
var
=
await
opcua
.
common
.
manage_nodes
.
create_variable
(
self
,
nodeid
,
bname
,
val
,
varianttype
,
datatype
)
return
await
var
.
_add_modelling_rule
(
self
)
def
add_variable
(
self
,
nodeid
,
bname
,
val
,
varianttype
=
None
,
datatype
=
None
):
return
opcua
.
common
.
manage_nodes
.
create_variable
(
self
,
nodeid
,
bname
,
val
,
varianttype
,
datatype
)
def
add_object_type
(
self
,
nodeid
,
bname
):
return
opcua
.
common
.
manage_nodes
.
create_object_type
(
self
,
nodeid
,
bname
)
...
...
@@ -658,13 +652,11 @@ class Node:
def
add_data_type
(
self
,
nodeid
,
bname
,
description
=
None
):
return
opcua
.
common
.
manage_nodes
.
create_data_type
(
self
,
nodeid
,
bname
,
description
=
None
)
async
def
add_property
(
self
,
nodeid
,
bname
,
val
,
varianttype
=
None
,
datatype
=
None
):
prop
=
await
opcua
.
common
.
manage_nodes
.
create_property
(
self
,
nodeid
,
bname
,
val
,
varianttype
,
datatype
)
return
await
prop
.
_add_modelling_rule
(
self
)
def
add_property
(
self
,
nodeid
,
bname
,
val
,
varianttype
=
None
,
datatype
=
None
):
return
opcua
.
common
.
manage_nodes
.
create_property
(
self
,
nodeid
,
bname
,
val
,
varianttype
,
datatype
)
async
def
add_method
(
self
,
*
args
):
method
=
await
opcua
.
common
.
manage_nodes
.
create_method
(
self
,
*
args
)
return
await
method
.
_add_modelling_rule
(
self
)
def
add_method
(
self
,
*
args
):
return
opcua
.
common
.
manage_nodes
.
create_method
(
self
,
*
args
)
def
add_reference_type
(
self
,
nodeid
,
bname
,
symmetric
=
True
,
inversename
=
None
):
return
opcua
.
common
.
manage_nodes
.
create_reference_type
(
self
,
nodeid
,
bname
,
symmetric
,
inversename
)
...
...
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