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

update

parent 9c79907c
...@@ -38,7 +38,6 @@ async def create_node_hierarchy(client, node_objects): ...@@ -38,7 +38,6 @@ async def create_node_hierarchy(client, node_objects):
async def get_send_hash(ENDPOINT,NAMESPACE,server_hash_udp_ip,server_hash_udp_port): async def get_send_hash(ENDPOINT,NAMESPACE,server_hash_udp_ip,server_hash_udp_port):
global nm_no global nm_no
serverAddressPort = (server_hash_udp_ip, server_hash_udp_port) serverAddressPort = (server_hash_udp_ip, server_hash_udp_port)
bufferSize = 1024
UDPClientSocket = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM) UDPClientSocket = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)
async with Client(url=ENDPOINT) as client: async with Client(url=ENDPOINT) as client:
nm_no=await client.get_namespace_index(NAMESPACE) nm_no=await client.get_namespace_index(NAMESPACE)
......
...@@ -60,19 +60,22 @@ async def get_nodes(client,node_objects): ...@@ -60,19 +60,22 @@ async def get_nodes(client,node_objects):
async def main() -> None: async def main() -> None:
global nm_no global nm_no
async with Client(url=ENDPOINT) as client: try:
nm_no = str(await client.get_namespace_index(NAMESPACE)) async with Client(url=ENDPOINT) as client:
object_root_node = client.get_objects_node() nm_no = str(await client.get_namespace_index(NAMESPACE))
objects = await object_root_node.get_children() object_root_node = client.get_objects_node()
node = await get_nodes(client,objects) objects = await object_root_node.get_children()
t1=threading.Thread(target=hash_sender.send_hash,args=(ENDPOINT,NAMESPACE,server_hash_udp_ip,server_hash_udp_port,)) node = await get_nodes(client,objects)
t1.start() t1=threading.Thread(target=hash_sender.send_hash,args=(ENDPOINT,NAMESPACE,server_hash_udp_ip,server_hash_udp_port,))
handler = MyHandler() t1.start()
subscription = await client.create_subscription(period=0, handler=handler) handler = MyHandler()
await subscription.subscribe_data_change(node) subscription = await client.create_subscription(period=0, handler=handler)
while True: await subscription.subscribe_data_change(node)
await handler.process() while True:
await asyncio.sleep(0.01) await handler.process()
await asyncio.sleep(0.01)
except:
print("No connection found for opcua server, check if the server is active")
if __name__ == '__main__': if __name__ == '__main__':
asyncio.run(main()) asyncio.run(main())
......
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