Pattern for event-driven devices (no polling)

Hi

Hopefully an easy question. I want a device that only updates clients via ZMQ events, with no need for polling (this is assumed to be more efficient). However, I also want to archive all changes to the attribute values to HDB++.

Is the code below the correct pattern to follow? Specifically, for each attribute we need to call "set_change_event" and "set_archive_event" initially. And then for each attribute we need to call both "push_change_event" and "push_archive_event" whenever the attribute reading changes? I assume just using "push_change_event" would not be enough to get the values to HDB++.


class MyDevice(Device):

def init_device(self):
super().init_device()
self.set_change_event("attr1", True, True) # (flags not important)
self.set_archive_event("attr1", True, True)

def update_attribute(self, new_value):
self.attr1_value = new_value
push_change_event("attr1", self.attr1_value) # (could include time and quality)
push_archive_event("attr1", self.attr1_value)


That seems to be the pattern used here: https://github.com/MaxIV-KitsControls/tango-facadedevice/blob/37b39f7b8b8e8dabf9223efd359abb5047a6fd38/facadedevice/utils.py#L275

Thanks,
Anton
Edited 1 month ago
Hi Anton,
correct, you need to push both, as hdb++ relies on archive_event and push_change_event won't fire an archive event.
Thank for confirming, Lorenzo.
 
Register or login to create to post a reply.