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
98cda158
Commit
98cda158
authored
Sep 10, 2016
by
olivier R-D
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix typo, reduce print
parent
e8152767
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
42 deletions
+10
-42
opcua/common/xmlimporter.py
opcua/common/xmlimporter.py
+0
-27
schemas/generate_address_space.py
schemas/generate_address_space.py
+10
-15
No files found.
opcua/common/xmlimporter.py
View file @
98cda158
...
@@ -21,7 +21,6 @@ def ua_type_to_python(val, uatype):
...
@@ -21,7 +21,6 @@ def ua_type_to_python(val, uatype):
def
to_python
(
val
,
obj
,
attname
):
def
to_python
(
val
,
obj
,
attname
):
print
(
val
,
obj
,
attname
)
if
isinstance
(
obj
,
ua
.
NodeId
)
and
attname
==
"Identifier"
:
if
isinstance
(
obj
,
ua
.
NodeId
)
and
attname
==
"Identifier"
:
return
ua
.
NodeId
.
from_string
(
val
)
return
ua
.
NodeId
.
from_string
(
val
)
else
:
else
:
...
@@ -149,7 +148,6 @@ class XmlImporter(object):
...
@@ -149,7 +148,6 @@ class XmlImporter(object):
if
type
(
v
)
is
str
:
if
type
(
v
)
is
str
:
setattr
(
ext
,
attname
,
to_python
(
v
,
ext
,
attname
))
setattr
(
ext
,
attname
,
to_python
(
v
,
ext
,
attname
))
else
:
else
:
print
(
"v is not string, it is"
,
v
,
type
(
v
))
for
attname2
,
v2
in
v
.
items
():
for
attname2
,
v2
in
v
.
items
():
obj2
=
getattr
(
ext
,
attname
)
obj2
=
getattr
(
ext
,
attname
)
setattr
(
obj2
,
attname2
,
to_python
(
v2
,
obj2
,
attname2
))
setattr
(
obj2
,
attname2
,
to_python
(
v2
,
obj2
,
attname2
))
...
@@ -170,31 +168,6 @@ class XmlImporter(object):
...
@@ -170,31 +168,6 @@ class XmlImporter(object):
return
[
getattr
(
ua
,
vtype
)(
v
)
for
v
in
obj
.
value
]
return
[
getattr
(
ua
,
vtype
)(
v
)
for
v
in
obj
.
value
]
else
:
else
:
return
ua
.
Variant
(
obj
.
value
,
getattr
(
ua
.
VariantType
,
obj
.
valuetype
))
return
ua
.
Variant
(
obj
.
value
,
getattr
(
ua
.
VariantType
,
obj
.
valuetype
))
#if obj.valuetype == 'ListOfLocalizedText':
#return ua.Variant([ua.LocalizedText(txt) for txt in obj.value], None)
#elif obj.valuetype == 'ListOfExtension':
#elif obj.valuetype == 'EnumValueType':
#values = []
#for ev in obj.value:
#enum_value = ua.EnumValueType()
#enum_value.DisplayName = ua.LocalizedText(ev['DisplayName'])
#enum_value.Description = ua.LocalizedText(ev['Description'])
#enum_value.Value = int(ev['Value'])
#values.append(enum_value)
#return values
#elif obj.valuetype == 'Argument':
#values = []
#for arg in obj.value:
#argument = ua.Argument()
#argument.Name = arg['Name']
#argument.Description = ua.LocalizedText(arg['Description'])
#argument.DataType = self.to_nodeid(arg['DataType'])
#argument.ValueRank = int(arg['ValueRank'])
#argument.ArrayDimensions = arg['ArrayDimensions']
#values.append(argument)
#return values
#return ua.Variant(obj.value, getattr(ua.VariantType, obj.valuetype))
def
add_variable_type
(
self
,
obj
):
def
add_variable_type
(
self
,
obj
):
node
=
self
.
_get_node
(
obj
)
node
=
self
.
_get_node
(
obj
)
...
...
schemas/generate_address_space.py
View file @
98cda158
...
@@ -162,22 +162,17 @@ def create_standard_address_space_%s(server):
...
@@ -162,22 +162,17 @@ def create_standard_address_space_%s(server):
print
(
"makeing code for "
,
extobj
.
objname
)
print
(
"makeing code for "
,
extobj
.
objname
)
self
.
writecode
(
indent
,
'extobj = ua.{}()'
.
format
(
extobj
.
objname
))
self
.
writecode
(
indent
,
'extobj = ua.{}()'
.
format
(
extobj
.
objname
))
for
name
,
val
in
extobj
.
body
.
items
():
for
name
,
val
in
extobj
.
body
.
items
():
if
type
(
val
)
is
str
:
for
k
,
v
in
val
.
items
():
raise
Exception
(
"Error val should a dict"
,
name
,
val
)
if
type
(
v
)
is
str
:
#self.writecode(indent, 'extobj.{} = "{}"'.format(name, val))
val
=
_to_val
([
extobj
.
objname
],
k
,
v
)
else
:
self
.
writecode
(
indent
,
'extobj.{} = {}'
.
format
(
k
,
val
))
for
k
,
v
in
val
.
items
():
else
:
if
type
(
v
)
is
str
:
if
k
==
"DataType"
:
#hack for strange nodeid xml format
val
=
_to_val
([
extobj
.
objname
],
k
,
v
)
self
.
writecode
(
indent
,
'extobj.{} = ua.NodeId.from_string("{}")'
.
format
(
k
,
v
[
"Identifier"
]))
self
.
writecode
(
indent
,
'extobj.{} = {}'
.
format
(
k
,
val
))
else
:
if
k
==
"DataType"
:
#hack for strange nodeid xml format
self
.
writecode
(
indent
,
'extobj.{} = ua.NodeId.from_string("{}")'
.
format
(
k
,
v
[
"Identifier"
]))
continue
continue
for
k2
,
v2
in
v
.
items
():
for
k2
,
v2
in
v
.
items
():
val2
=
_to_val
([
extobj
.
objname
,
k
],
k2
,
v2
)
val2
=
_to_val
([
extobj
.
objname
,
k
],
k2
,
v2
)
self
.
writecode
(
indent
,
'extobj.{}.{} = {}'
.
format
(
k
,
k2
,
val2
))
self
.
writecode
(
indent
,
'extobj.{}.{} = {}'
.
format
(
k
,
k2
,
val2
))
def
make_variable_code
(
self
,
obj
):
def
make_variable_code
(
self
,
obj
):
indent
=
" "
indent
=
" "
...
...
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