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
b0d222d9
Commit
b0d222d9
authored
Mar 09, 2023
by
yogesh.m
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
58d3fa08
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
6 deletions
+23
-6
asyncua_server.py
asyncua_server.py
+23
-6
No files found.
asyncua_server.py
View file @
b0d222d9
...
@@ -4,6 +4,7 @@ from asyncua import ua, Server
...
@@ -4,6 +4,7 @@ from asyncua import ua, Server
import
socket
import
socket
import
threading
import
threading
from
time
import
sleep
from
time
import
sleep
import
json
localIP
=
"2.2.2.5"
localIP
=
"2.2.2.5"
localPort
=
20002
localPort
=
20002
...
@@ -68,6 +69,16 @@ class asyncua_server():
...
@@ -68,6 +69,16 @@ class asyncua_server():
asr
=
asyncua_server
()
asr
=
asyncua_server
()
def
analyse_hierarchy
(
hierarchy
):
for
key
in
hierarchy
:
if
(
key
!=
"hash"
):
if
(
isinstance
(
hierarchy
[
key
],
dict
)):
print
(
hierarchy
[
key
])
analyse_hierarchy
(
hierarchy
[
key
])
else
:
if
(
key
==
"datatype"
):
print
()
def
hash_receive
():
def
hash_receive
():
prev_hash
=
0
prev_hash
=
0
sleep
(
1
)
sleep
(
1
)
...
@@ -75,15 +86,21 @@ def hash_receive():
...
@@ -75,15 +86,21 @@ def hash_receive():
bytesAddressPair
=
UDPServerSocket
.
recvfrom
(
bufferSize
)
bytesAddressPair
=
UDPServerSocket
.
recvfrom
(
bufferSize
)
message
=
bytesAddressPair
[
0
]
message
=
bytesAddressPair
[
0
]
hierarchy
=
pickle
.
loads
(
message
)
hierarchy
=
pickle
.
loads
(
message
)
hierarchy
=
json
.
loads
(
hierarchy
)
if
(
prev_hash
!=
hierarchy
[
"hash"
]
and
asr
.
idx
):
if
(
prev_hash
!=
hierarchy
[
"hash"
]
and
asr
.
idx
):
asyncio
.
run
(
asr
.
delete_all_objects
())
print
(
"changed"
)
for
object
in
hierarchy
:
print
(
hierarchy
)
if
(
object
!=
"hash"
):
analyse_hierarchy
(
hierarchy
)
display_name
=
object
# asyncio.run(asr.delete_all_objects())
asyncio
.
run
(
asr
.
add_object
(
object
,
hierarchy
))
# for object in hierarchy:
# if(object!="hash"):
# display_name=object
# 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"
))
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