trigger an even when value changes #1349
-
hello. I am still a noob and i got stuck. code: server try:
from opcua import ua, Server logging.basicConfig(level=logging.WARN) server = Server() uri = "http://examples.freeopcua.github.io" objects = server.get_objects_node() myobj = objects.add_object(idx, "MyObject") etype = server.create_custom_event_type(idx, 'MyFirstEvent', ua.ObjectIds.BaseEventType, [('Speed', ua.VariantType.Float)]) myevgen = server.get_event_generator(etype, myobj) server.start() try:
finally:
code client try:
from opcua import Client class SubHandler(object):
client = Client("opc.tcp://localhost:4840/freeopcua/server/") try:
finally: |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
why not subscribing the data itself and always have the latest value (the datachangenotification is report by exception so only if the value changes) and be careful in you subhandler the doc string says do not do slow / network tasks in there ... get_value() is a network call! |
Beta Was this translation helpful? Give feedback.
-
In that context, honestly: I dont understand the embed() function. Can someone please explain it? My OPC client is going to run in an exe-file. Is the embed() approach still the way to go for looping infinitely my OPC client? |
Beta Was this translation helpful? Give feedback.
-
is it possible that the "sub.unsubscribe(hanlde)" is not working? After running "sub.unsubscribe(handle)" I still get messages in the output |
Beta Was this translation helpful? Give feedback.
why not subscribing the data itself and always have the latest value (the datachangenotification is report by exception so only if the value changes) and be careful in you subhandler the doc string says do not do slow / network tasks in there ... get_value() is a network call!