Commit 2121bfdd authored by yogesh.m's avatar yogesh.m

update

parent 127e43c3
...@@ -2,6 +2,7 @@ from asyncua import Client ...@@ -2,6 +2,7 @@ from asyncua import Client
import asyncio import asyncio
import socket import socket
from time import sleep from time import sleep
import pickle
ENDPOINT = 'opc.tcp://2.2.2.7:53530/OPCUA/SimulationServer' ENDPOINT = 'opc.tcp://2.2.2.7:53530/OPCUA/SimulationServer'
NAMESPACE = 'http://www.prosysopc.com/OPCUA/SimulationServer/' NAMESPACE = 'http://www.prosysopc.com/OPCUA/SimulationServer/'
...@@ -18,20 +19,27 @@ async def get_send_hash(): ...@@ -18,20 +19,27 @@ async def get_send_hash():
nm_no = await client.get_namespace_index("http://www.prosysopc.com/OPCUA/SimulationNodes/") nm_no = await client.get_namespace_index("http://www.prosysopc.com/OPCUA/SimulationNodes/")
while True: while True:
sleep(1) sleep(1)
main_obj = [] main_obj = {}
hierarchy = {} hierarchy = {}
Objects = await root_objects[0].get_children() Objects = await root_objects[0].get_children()
for sub_obj in Objects: for sub_obj in Objects:
if (sub_obj.nodeid.NamespaceIndex == nm_no): if (sub_obj.nodeid.NamespaceIndex == nm_no):
display_name=await sub_obj.read_display_name() display_name=await sub_obj.read_display_name()
identifier_type = sub_obj.nodeid.NodeIdType._name_ identifier_type = sub_obj.nodeid.NodeIdType._name_
ch = await sub_obj.get_children() children = await sub_obj.get_children()
main_obj = main_obj + ch for ch in children:
main_obj["identifier"]=ch.nodeid.Identifier
node_name=await ch.read_display_name()
main_obj["node_name"]=node_name.Text
datatype=await ch.read_data_type_as_variant_type()
main_obj["datatype"] = datatype._value_
hierarchy[display_name.Text] = {} hierarchy[display_name.Text] = {}
hierarchy[display_name.Text]["name"]=identifier_type hierarchy[display_name.Text]["name"]=identifier_type
hierarchy[display_name.Text]["obj"]=main_obj hierarchy[display_name.Text]["obj"]=pickle.dumps(main_obj)
UDPClientSocket.sendto(str.encode(str(hash(str(main_obj)))+"&"+str(hierarchy)), serverAddressPort) hierarchy["hash"]=hash(str(main_obj))
print(str(hash(str(main_obj)))+"&"+str(hierarchy)) hierarchy=pickle.dumps(hierarchy)
UDPClientSocket.sendto(hierarchy, serverAddressPort)
print(hierarchy)
if __name__ == '__main__': if __name__ == '__main__':
asyncio.run(get_send_hash()) asyncio.run(get_send_hash())
\ 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