Commit 456983a3 authored by yogesh.m's avatar yogesh.m

update

parent 49ee43c7
import socket
from opcua import Client,ua
client = Client("opc.tcp://DESKTOP-KMDNN6H:53530/OPCUA/SimulationServer")
client.connect()
localIP = "2.2.2.5"
localPort = 20001
bufferSize = 1024
msgFromServer = "Hello UDP Client"
bytesToSend = str.encode(msgFromServer)
# Create a datagram socket
UDPServerSocket = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)
# Bind to address and ip
UDPServerSocket.bind((localIP, localPort))
print("UDP server up and listening")
while (True):
bytesAddressPair = UDPServerSocket.recvfrom(bufferSize)
message = bytesAddressPair[0]
datatype,value,nodeid = message.decode().split("&")
if(datatype=="<class 'float'>"):
client.get_node(nodeid).set_value(float(value))
if(datatype=="<class 'int'>"):
v = ua.DataValue(ua.Variant(int(value), ua.VariantType.Int32))
client.get_node(nodeid).set_value(v)
\ 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