# creating a default event object # The event object automatically will have members for all events properties # you probably want to create a custom event type, see other examples myevgen = server.get_event_generator() myevgen.event.Severity = 300 # starting! server.start() print("Available loggers are: ", logging.Logger.manager.loggerDict.keys()) vup = VarUpdater(mysin) # just a stupide class update a variable vup.start() try: # enable following if you want to subscribe to nodes on server side #handler = SubHandler() #sub = server.create_subscription(500, handler) #handle = sub.subscribe_data_change(myvar) # trigger event, all subscribed clients wil receive it var = myarrayvar.get_value() # return a ref to value in db server side! not a copy! var = copy.copy(var) # WARNING: we need to copy before writting again otherwise no data change event will be generated var.append(9.3) myarrayvar.set_value(var) mydevice_var.set_value("Running") myevgen.trigger(message="This is BaseEvent") server.set_attribute_value(myvar.nodeid, ua.DataValue(9.9)) # Server side write method which is a but faster than using set_value embed() finally: vup.stop() server.stop()
myevgen = server.get_event_generator() myevgen.event.Severity = 300 # starting! server.start() print("Available loggers are: ", logging.Logger.manager.loggerDict.keys()) vup = VarUpdater(mysin) # just a stupide class update a variable vup.start() try: # enable following if you want to subscribe to nodes on server side #handler = SubHandler() #sub = server.create_subscription(500, handler) #handle = sub.subscribe_data_change(myvar) # trigger event, all subscribed clients wil receive it var = myarrayvar.get_value( ) # return a ref to value in db server side! not a copy! var = copy.copy( var ) # WARNING: we need to copy before writting again otherwise no data change event will be generated var.append(9.3) myarrayvar.set_value(var) mydevice_var.set_value("Running") myevgen.trigger(message="This is BaseEvent") server.set_attribute_value( myvar.nodeid, ua.DataValue(9.9) ) # Server side write method which is a but faster than using set_value embed() finally: vup.stop() server.stop()
print("Available loggers are: ", logging.Logger.manager.loggerDict.keys()) vup = VarUpdater(machinesin) # just a stupide class update a variable vup.start() try: var = machinearrayvar.get_value( ) # # Rückgabe eines Verweises auf den Wert auf der DB-Serverseite! keine Kopie! var = copy.copy( var ) # WARNING: Wir müssen vor dem erneuten Schreiben kopieren, da sonst kein Datenänderungsereignis generiert wird var.append(9.3) machinearrayvar.set_value(var) machinedevice_var.set_value("Running") myevgen.trigger(message="This is BaseEvent") server.set_attribute_value( machinevar.nodeid, ua.DataValue(9.9) ) # Serverseitige Schreibmethode, die jedoch schneller ist als die Verwendung von set_value # gibt unsere PID aus print("My PID is:", os.getpid()) # zum testen count = 0 while True: time.sleep(5) # count += 0.1 # myvar.set_value(count) Temperature = randint(10, 20) Pressure = randint(10, 20) TIME = datetime.utcnow() count = randint(1, 3)