Commit b0d222d9 authored by yogesh.m's avatar yogesh.m

update

parent 58d3fa08
......@@ -4,6 +4,7 @@ from asyncua import ua, Server
import socket
import threading
from time import sleep
import json
localIP = "2.2.2.5"
localPort = 20002
......@@ -68,6 +69,16 @@ class 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():
prev_hash = 0
sleep(1)
......@@ -75,15 +86,21 @@ def hash_receive():
bytesAddressPair = UDPServerSocket.recvfrom(bufferSize)
message = bytesAddressPair[0]
hierarchy=pickle.loads(message)
hierarchy=json.loads(hierarchy)
if(prev_hash!=hierarchy["hash"] and asr.idx):
asyncio.run(asr.delete_all_objects())
for object in hierarchy:
if(object!="hash"):
display_name=object
asyncio.run(asr.add_object(object,hierarchy))
print("changed")
print(hierarchy)
analyse_hierarchy(hierarchy)
# asyncio.run(asr.delete_all_objects())
# for object in hierarchy:
# if(object!="hash"):
# display_name=object
# asyncio.run(asr.add_object(object,hierarchy))
prev_hash=hierarchy["hash"]
def st():
t1=threading.Thread(target=hash_receive)
t1.start()
asyncio.run(asr.start_server("opc.tcp://2.2.2.5:53531/myopc/free","http://klopc.com"))
\ No newline at end of file
asyncio.run(asr.start_server("opc.tcp://2.2.2.5:53531/myopc/free","http://klopc.com"))
st()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment