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
8abec216
Commit
8abec216
authored
Apr 13, 2018
by
cirp-usf
Committed by
Christian Bergmiller
Jul 30, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cherry-pick/merge
1354c094
parent
ee39f2e0
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
63 additions
and
51 deletions
+63
-51
opcua/server/address_space.py
opcua/server/address_space.py
+6
-0
opcua/server/standard_address_space/standard_address_space.py
...a/server/standard_address_space/standard_address_space.py
+13
-7
schemas/download.py
schemas/download.py
+30
-30
schemas/generate_address_space.py
schemas/generate_address_space.py
+2
-9
schemas/generate_event_objects.py
schemas/generate_event_objects.py
+3
-3
schemas/generate_model.py
schemas/generate_model.py
+7
-0
schemas/generate_statuscode.py
schemas/generate_statuscode.py
+1
-1
schemas/generate_uaerrors.py
schemas/generate_uaerrors.py
+1
-1
No files found.
opcua/server/address_space.py
View file @
8abec216
...
...
@@ -187,6 +187,12 @@ class NodeManagementService(object):
results
.
append
(
self
.
_add_node
(
item
,
user
))
return
results
def
try_add_nodes
(
self
,
addnodeitems
,
user
=
User
.
Admin
):
for
item
in
addnodeitems
:
ret
=
self
.
_add_node
(
item
,
user
)
if
not
ret
.
StatusCode
.
is_good
():
yield
item
def
_add_node
(
self
,
item
,
user
):
result
=
ua
.
AddNodesResult
()
...
...
opcua/server/standard_address_space/standard_address_space.py
View file @
8abec216
...
...
@@ -15,21 +15,28 @@ from opcua.server.standard_address_space.standard_address_space_part13 import cr
class
PostponeReferences
(
object
):
def
__init__
(
self
,
server
):
self
.
server
=
server
self
.
postponed
=
None
self
.
add_nodes
=
self
.
server
.
add_nodes
self
.
postponed_refs
=
None
self
.
postponed_nodes
=
None
#self.add_nodes = self.server.add_nodes
def
add_nodes
(
self
,
nodes
):
self
.
postponed_nodes
.
extend
(
self
.
server
.
try_add_nodes
(
nodes
))
def
add_references
(
self
,
refs
):
self
.
postponed
.
extend
(
self
.
server
.
try_add_references
(
refs
))
self
.
postponed
_refs
.
extend
(
self
.
server
.
try_add_references
(
refs
))
# no return
def
__enter__
(
self
):
self
.
postponed
=
[]
self
.
postponed_refs
=
[]
self
.
postponed_nodes
=
[]
return
self
def
__exit__
(
self
,
exc_type
,
exc_val
,
exc_tb
):
if
exc_type
is
None
and
exc_val
is
None
:
remaining
=
list
(
self
.
server
.
try_add_references
(
self
.
postponed
))
assert
len
(
remaining
)
==
0
,
remaining
remaining_nodes
=
list
(
self
.
server
.
try_add_nodes
(
self
.
postponed_nodes
))
assert
len
(
remaining_nodes
)
==
0
,
remaining_nodes
remaining_refs
=
list
(
self
.
server
.
try_add_references
(
self
.
postponed_refs
))
assert
len
(
remaining_refs
)
==
0
,
remaining_refs
def
fill_address_space
(
nodeservice
):
with
PostponeReferences
(
nodeservice
)
as
server
:
...
...
@@ -41,4 +48,3 @@ def fill_address_space(nodeservice):
create_standard_address_space_Part10
(
server
)
create_standard_address_space_Part11
(
server
)
create_standard_address_space_Part13
(
server
)
assert
len
(
server
.
postponed
)
==
1561
,
len
(
server
.
postponed
)
schemas/download.py
View file @
8abec216
...
...
@@ -5,36 +5,36 @@ from urllib.request import build_opener
# https://opcfoundation.org/UA/schemas/OPC%20UA%20Schema%20Files%20Readme.xls
resources
=
[
'https://opcfoundation.org/UA/schemas/1.0
3
/Opc.Ua.Types.xsd'
,
'https://opcfoundation.org/UA/schemas/1.0
3
/Opc.Ua.Services.wsdl'
,
'https://opcfoundation.org/UA/schemas/1.0
3
/Opc.Ua.Endpoints.wsdl'
,
'https://opcfoundation.org/UA/schemas/DI/1.0
0
/Opc.Ua.Di.Types.xsd'
,
'https://opcfoundation.org/UA/schemas/ADI/1.
00
/Opc.Ua.Adi.Types.xsd'
,
'https://opcfoundation.org/UA/schemas/1.0
3
/SecuredApplication.xsd'
,
'https://opcfoundation.org/UA/schemas/1.0
3
/UANodeSet.xsd'
,
'https://opcfoundation.org/UA/schemas/1.0
3
/UAVariant.xsd'
,
'https://opcfoundation.org/UA/schemas/1.0
3
/Opc.Ua.NodeSet2.xml'
,
'https://opcfoundation.org/UA/schemas/1.0
3
/Opc.Ua.NodeSet2.Part3.xml'
,
'https://opcfoundation.org/UA/schemas/1.0
3
/Opc.Ua.NodeSet2.Part4.xml'
,
'https://opcfoundation.org/UA/schemas/1.0
3
/Opc.Ua.NodeSet2.Part5.xml'
,
'https://opcfoundation.org/UA/schemas/Opc.Ua.NodeSet2.Part8.xml'
,
'https://opcfoundation.org/UA/schemas/1.0
3
/Opc.Ua.NodeSet2.Part9.xml'
,
'https://opcfoundation.org/UA/schemas/1.0
3
/Opc.Ua.NodeSet2.Part10.xml'
,
'https://opcfoundation.org/UA/schemas/1.0
3
/Opc.Ua.NodeSet2.Part11.xml'
,
'https://opcfoundation.org/UA/schemas/1.0
3
/Opc.Ua.NodeSet2.Part13.xml'
,
'https://opcfoundation.org/UA/schemas/DI/1.0
0
/Opc.Ua.Di.NodeSet2.xml'
,
'https://opcfoundation.org/UA/schemas/ADI/1.
00
/Opc.Ua.Adi.NodeSet2.xml'
,
'https://opcfoundation.org/UA/schemas/1.0
3
/OPCBinarySchema.xsd'
,
'https://opcfoundation.org/UA/schemas/1.0
3
/Opc.Ua.Types.bsd'
,
'https://opcfoundation.org/UA/schemas/DI/1.0
0
/Opc.Ua.Di.Types.bsd'
,
'https://opcfoundation.org/UA/schemas/ADI/1.
00
/Opc.Ua.Adi.Types.bsd'
,
'https://opcfoundation.org/UA/schemas/1.0
3
/AttributeIds.csv'
,
'https://opcfoundation.org/UA/schemas/1.0
3/StatusCodes
.csv'
,
'https://opcfoundation.org/UA/schemas/1.0
3
/NodeIds.csv'
,
'https://opcfoundation.org/UA/schemas/1.0
4
/Opc.Ua.Types.xsd'
,
'https://opcfoundation.org/UA/schemas/1.0
4
/Opc.Ua.Services.wsdl'
,
'https://opcfoundation.org/UA/schemas/1.0
4
/Opc.Ua.Endpoints.wsdl'
,
'https://opcfoundation.org/UA/schemas/DI/1.0/Opc.Ua.Di.Types.xsd'
,
'https://opcfoundation.org/UA/schemas/ADI/1.
1
/Opc.Ua.Adi.Types.xsd'
,
'https://opcfoundation.org/UA/schemas/1.0
4
/SecuredApplication.xsd'
,
'https://opcfoundation.org/UA/schemas/1.0
4
/UANodeSet.xsd'
,
'https://opcfoundation.org/UA/schemas/1.0
4
/UAVariant.xsd'
,
'https://opcfoundation.org/UA/schemas/1.0
4
/Opc.Ua.NodeSet2.xml'
,
'https://opcfoundation.org/UA/schemas/1.0
4
/Opc.Ua.NodeSet2.Part3.xml'
,
'https://opcfoundation.org/UA/schemas/1.0
4
/Opc.Ua.NodeSet2.Part4.xml'
,
'https://opcfoundation.org/UA/schemas/1.0
4
/Opc.Ua.NodeSet2.Part5.xml'
,
'https://opcfoundation.org/UA/schemas/
1.04/
Opc.Ua.NodeSet2.Part8.xml'
,
'https://opcfoundation.org/UA/schemas/1.0
4
/Opc.Ua.NodeSet2.Part9.xml'
,
'https://opcfoundation.org/UA/schemas/1.0
4
/Opc.Ua.NodeSet2.Part10.xml'
,
'https://opcfoundation.org/UA/schemas/1.0
4
/Opc.Ua.NodeSet2.Part11.xml'
,
'https://opcfoundation.org/UA/schemas/1.0
4
/Opc.Ua.NodeSet2.Part13.xml'
,
'https://opcfoundation.org/UA/schemas/DI/1.0/Opc.Ua.Di.NodeSet2.xml'
,
'https://opcfoundation.org/UA/schemas/ADI/1.
1
/Opc.Ua.Adi.NodeSet2.xml'
,
'https://opcfoundation.org/UA/schemas/1.0
4
/OPCBinarySchema.xsd'
,
'https://opcfoundation.org/UA/schemas/1.0
4
/Opc.Ua.Types.bsd'
,
'https://opcfoundation.org/UA/schemas/DI/1.0/Opc.Ua.Di.Types.bsd'
,
'https://opcfoundation.org/UA/schemas/ADI/1.
1
/Opc.Ua.Adi.Types.bsd'
,
'https://opcfoundation.org/UA/schemas/1.0
4
/AttributeIds.csv'
,
'https://opcfoundation.org/UA/schemas/1.0
4/StatusCode
.csv'
,
'https://opcfoundation.org/UA/schemas/1.0
4
/NodeIds.csv'
,
]
opener
=
build_opener
()
...
...
schemas/generate_address_space.py
View file @
8abec216
...
...
@@ -151,14 +151,14 @@ def create_standard_address_space_{self.part!s}(server):
self
.
writecode
(
indent
,
'value = extobj'
)
self
.
writecode
(
indent
,
'attrs.Value = ua.Variant(value, ua.VariantType.ExtensionObject)'
)
elif
obj
.
valuetype
==
"ListOfLocalizedText"
:
value
=
[
f'ua.LocalizedText(
{
self
.
to_value
(
text
)
}
)'
for
text
in
obj
.
value
]
value
=
[
f'ua.LocalizedText(
{
text
!
r
}
)'
for
text
in
obj
.
value
]
self
.
writecode
(
indent
,
f'attrs.Value = [
{
","
.
join
(
value
)
}
]'
)
else
:
if
obj
.
valuetype
.
startswith
(
"ListOf"
):
obj
.
valuetype
=
obj
.
valuetype
[
6
:]
self
.
writecode
(
indent
,
f'attrs.Value = ua.Variant(
{
self
.
to_value
(
obj
.
value
)
}
, ua.VariantType.
{
obj
.
valuetype
}
)'
f'attrs.Value = ua.Variant(
{
obj
.
value
!
r
}
, ua.VariantType.
{
obj
.
valuetype
}
)'
)
if
obj
.
rank
:
self
.
writecode
(
indent
,
f'attrs.ValueRank =
{
obj
.
rank
}
'
)
...
...
@@ -211,13 +211,6 @@ def create_standard_address_space_{self.part!s}(server):
self
.
writecode
(
indent
,
'server.add_nodes([node])'
)
self
.
make_refs_code
(
obj
,
indent
)
def
to_value
(
self
,
val
):
# if type(val) in (str, unicode):
if
isinstance
(
val
,
str
):
return
f'"
{
val
}
"'
else
:
return
val
def
make_method_code
(
self
,
obj
):
indent
=
" "
self
.
writecode
(
indent
)
...
...
schemas/generate_event_objects.py
View file @
8abec216
...
...
@@ -16,7 +16,7 @@ class EventsCodeGenerator(object):
root
=
tree
.
getroot
()
for
child
in
root
:
if
child
.
tag
.
endswith
(
"UAObjectType"
):
print
child
.
attrib
print
(
child
.
attrib
)
def
write
(
self
,
line
):
if
line
:
...
...
@@ -94,7 +94,7 @@ class EventsCodeGenerator(object):
def
generateEventsCode
(
self
,
model
):
self
.
output_file
=
open
(
self
.
output_file
,
"w"
)
self
.
make_header
()
for
event
in
model
.
iter
values
():
for
event
in
model
.
values
():
if
(
event
.
browseName
==
"BaseEvent"
):
self
.
generateEventclass
(
event
)
else
:
...
...
@@ -104,7 +104,7 @@ class EventsCodeGenerator(object):
self
.
write
(
""
)
self
.
write
(
"IMPLEMENTED_EVENTS = {"
)
self
.
iidx
+=
1
for
event
in
model
.
iter
values
():
for
event
in
model
.
values
():
self
.
write
(
"ua.ObjectIds.{0}Type: {0},"
.
format
(
event
.
browseName
))
self
.
write
(
"}"
)
...
...
schemas/generate_model.py
View file @
8abec216
...
...
@@ -313,6 +313,7 @@ class Parser(object):
tree
=
ElementTree
.
parse
(
self
.
path
)
root
=
tree
.
getroot
()
self
.
add_extension_object
()
self
.
add_data_type_definition
()
for
child
in
root
:
tag
=
child
.
tag
[
40
:]
if
tag
==
'StructuredType'
:
...
...
@@ -352,6 +353,12 @@ class Parser(object):
self
.
model
.
structs
.
append
(
obj
)
def
add_data_type_definition
(
self
):
obj
=
Struct
()
obj
.
name
=
"DataTypeDefinition"
self
.
model
.
struct_list
.
append
(
obj
.
name
)
self
.
model
.
structs
.
append
(
obj
)
def
parse_struct
(
self
,
child
):
tag
=
child
.
tag
[
40
:]
struct
=
Struct
()
...
...
schemas/generate_statuscode.py
View file @
8abec216
...
...
@@ -8,7 +8,7 @@ def status_codes():
name
,
val
,
doc
=
line
.
split
(
","
,
2
)
additional
[
int
(
val
,
0
)]
=
(
name
,
val
,
doc
)
inputfile
=
open
(
"StatusCode
s
.csv"
)
inputfile
=
open
(
"StatusCode.csv"
)
result
=
[]
for
line
in
inputfile
:
name
,
val
,
doc
=
line
.
split
(
","
,
2
)
...
...
schemas/generate_uaerrors.py
View file @
8abec216
...
...
@@ -5,7 +5,7 @@ from string import Template
if
__name__
==
"__main__"
:
codes
=
status_codes
()
with
open
(
"../opcua/ua/errors/_auto.py"
,
"w"
)
as
f
:
with
open
(
"../opcua/ua/
ua
errors/_auto.py"
,
"w"
)
as
f
:
preamble
=
"""
\
#AUTOGENERATED!!!
...
...
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