Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
opcua-cloning
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
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yogesh.m
opcua-cloning
Commits
c842b417
You need to sign in or sign up before continuing.
Commit
c842b417
authored
Mar 09, 2023
by
yogesh.m
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
939374c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
15 deletions
+47
-15
asyncua_server.py
asyncua_server.py
+47
-15
No files found.
asyncua_server.py
View file @
c842b417
...
@@ -68,16 +68,51 @@ class asyncua_server():
...
@@ -68,16 +68,51 @@ class asyncua_server():
await
self
.
server
.
stop
()
await
self
.
server
.
stop
()
asr
=
asyncua_server
()
asr
=
asyncua_server
()
identifier_array_received
=
[]
def
analyse_hierarch
y
(
hierarchy
):
def
get_received_hierarchy_arra
y
(
hierarchy
):
for
key
in
hierarchy
:
for
key
in
hierarchy
:
if
(
key
!=
"hash"
):
if
(
key
!=
"hash"
):
if
(
isinstance
(
hierarchy
[
key
],
dict
)):
if
(
isinstance
(
hierarchy
[
key
],
dict
)):
print
(
hierarchy
[
key
])
identifier_array_received
.
append
(
key
)
analyse_hierarchy
(
hierarchy
[
key
])
get_received_hierarchy_array
(
hierarchy
[
key
])
return
identifier_array_received
async
def
get_existing_hierarchy_array
(
client
,
node_objects
):
node_hierarchy
=
{}
for
sub_obj
in
node_objects
:
if
(
"ns=3;"
in
str
(
sub_obj
)):
node
=
client
.
get_node
(
sub_obj
)
children_nodes
=
await
node
.
get_children
()
identifier
=
str
(
children_nodes
[
0
]
.
nodeid
.
Identifier
)
if
children_nodes
else
""
node_class
=
await
sub_obj
.
read_node_class
()
if
(
identifier
not
in
str
(
sub_obj
)):
child_disp_name
=
await
sub_obj
.
read_display_name
()
identifier_name
=
sub_obj
.
nodeid
.
Identifier
node_hierarchy
[
identifier_name
]
=
await
get_existing_hierarchy_array
(
client
,
children_nodes
)
node_hierarchy
[
identifier_name
][
"name"
]
=
child_disp_name
.
Text
if
(
node_class
.
_name_
==
"Variable"
):
datatype
=
await
sub_obj
.
read_data_type_as_variant_type
()
node_hierarchy
[
identifier_name
][
"datatype"
]
=
datatype
.
_value_
else
:
else
:
if
(
key
==
"datatype"
):
disp_name
=
await
sub_obj
.
read_display_name
()
print
()
identifier_name
=
sub_obj
.
nodeid
.
Identifier
node_hierarchy
[
identifier_name
]
=
{}
node_hierarchy
[
identifier_name
][
"name"
]
=
disp_name
.
Text
if
(
node_class
.
_name_
==
"Variable"
):
datatype
=
await
sub_obj
.
read_data_type_as_variant_type
()
node_hierarchy
[
identifier_name
][
"datatype"
]
=
datatype
.
_value_
return
node_hierarchy
def
analyse_hierarchy
(
hierarchy
):
array1
=
get_received_hierarchy_array
(
hierarchy
)
print
(
array1
)
root_node
=
asr
.
server
.
get_root_node
()
object_root_node
=
asyncio
.
run
(
root_node
.
get_children
())
node_objects
=
asyncio
.
run
(
object_root_node
[
0
]
.
get_children
())
print
(
node_objects
)
existing_h
=
asyncio
.
run
(
get_existing_hierarchy_array
(
asr
.
server
,
node_objects
))
print
(
existing_h
)
identifier_array_received
.
clear
()
def
hash_receive
():
def
hash_receive
():
prev_hash
=
0
prev_hash
=
0
...
@@ -89,18 +124,15 @@ def hash_receive():
...
@@ -89,18 +124,15 @@ def hash_receive():
hierarchy
=
json
.
loads
(
hierarchy
)
hierarchy
=
json
.
loads
(
hierarchy
)
if
(
prev_hash
!=
hierarchy
[
"hash"
]
and
asr
.
idx
):
if
(
prev_hash
!=
hierarchy
[
"hash"
]
and
asr
.
idx
):
print
(
"changed"
)
print
(
"changed"
)
print
(
hierarchy
)
analyse_hierarchy
(
hierarchy
)
analyse_hierarchy
(
hierarchy
)
#
asyncio.run(asr.delete_all_objects())
asyncio
.
run
(
asr
.
delete_all_objects
())
#
for object in hierarchy:
for
object
in
hierarchy
:
#
if(object!="hash"):
if
(
object
!=
"hash"
):
#
display_name=object
display_name
=
object
#
asyncio.run(asr.add_object(object,hierarchy))
asyncio
.
run
(
asr
.
add_object
(
object
,
hierarchy
))
prev_hash
=
hierarchy
[
"hash"
]
prev_hash
=
hierarchy
[
"hash"
]
def
st
():
def
st
():
t1
=
threading
.
Thread
(
target
=
hash_receive
)
t1
=
threading
.
Thread
(
target
=
hash_receive
)
t1
.
start
()
t1
.
start
()
asyncio
.
run
(
asr
.
start_server
(
"opc.tcp://2.2.2.5:53531/myopc/free"
,
"http://klopc.com"
))
asyncio
.
run
(
asr
.
start_server
(
"opc.tcp://2.2.2.5:53531/myopc/free"
,
"http://klopc.com"
))
\ No newline at end of file
st
()
\ No newline at end of file
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