FreeOpcUa / python-opcua

LGPL Pure Python OPC-UA Client and Server
http://freeopcua.github.io/
GNU Lesser General Public License v3.0
1.36k stars 658 forks source link

Datachange event not triggering on external server software with opcua but does with UAExpert #1156

Open DerKenz opened 3 years ago

DerKenz commented 3 years ago

I have an external server which is supposed to trigger an event when I change the value of a node from 0 to 1. It does work when I do it in UAExpert, the value is then reset and some internal calculations are made. With opcua the value of the "controlnode" does change but the event does not trigger and the value is never reset. I tried changing the timestamps but nothing seems to work. Would appreciate any help.

from opcua import ua from opcua import Client import time

url = "opc.tcp://localhost:1234" # Server-IP

client=Client(url)
client.set_password("PW") client.set_user("USER") client.name="USER_2" client.connect()

time.sleep(1.5) print("Connected successfully")

Controlnode=client.get_node("ns=1;i=120")

time.sleep(1.5)

val = ua.DataValue(ua.Variant(int(1509), ua.VariantType.Int32)) val.SourceTimestamp=None val.ServerTimestamp=None val.StatusCode = ua.StatusCode(ua.StatusCodes.Good)

Controlnode.set_attribute(ua.AttributeIds(1).Value,val) time.sleep(1.5)

""" This also does not work """ Controlnode.set_value(ua.Variant(int(1), ua.VariantType.Int32))

AndreasHeine commented 3 years ago

what vendor/type is that external server? does the datachange event goes out if the server changes a value itself?