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

update

parent a404a75a
import asyncio
from asyncua import ua, Server
import random
async def main():
# create a server
server = Server()
await server.init()
# set endpoint information
url = "opc.tcp://localhost:4840/myopc/free"
server.set_endpoint(url)
# create a new address space
uri = "http://klopc.com"
idx = await server.register_namespace(uri)
obj = await server.nodes.objects.add_object(idx, "MyObject")
var = await obj.add_variable(idx, "MyVariable", 0)
await var.set_writable()
# start the server
await server.start()
try:
# keep the server running until interrupted
while True:
await var.write_value(random.randint(1, 100))
await asyncio.sleep(1)
finally:
# stop the server
await server.stop()
if __name__ == "__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