Push state change event during DevRestart

Hi all,

I would like to push a device state attribute change event during the DevRestart admin command executed on that device.

I try to do it in the init_device():


from tango import DevState
from tango.server import run
from tango.server import Device
class Clock(Device):

def init_device(self):
self.set_change_event("state", True, False)
self.set_state(DevState.ON)
self.push_change_event("state")
if __name__ == "__main__":
run((Clock,))


But I don't receive it on the client side.

Is it possible?

Cheers,
Zibi
Edited 1 year ago
Hi Zibi,

Indeed, it looks like this use case was not foreseen.
If you put the push_change_event() call in the always_executed_hook(), the event is sent correctly after a restart device or restart server (if you read an attribute/pipe or execute a command).

When you restart a device the DeviceImpl object is destroyed and constructed again.
To fix the issue https://gitlab.com/tango-controls/cppTango/-/issues/887, the info related to the clients interested in the events of a specific attribute of this device is memorized (https://gitlab.com/tango-controls/cppTango/-/blob/9.5.0-rc1/src/server/dserver.cpp#L852) before the destruction (https://gitlab.com/tango-controls/cppTango/-/blob/9.5.0-rc1/src/server/dserver.cpp#L882-900) and restored (https://gitlab.com/tango-controls/cppTango/-/blob/9.5.0-rc1/src/server/dserver.cpp#L1019) after the Device creation (https://gitlab.com/tango-controls/cppTango/-/blob/9.5.0-rc1/src/server/dserver.cpp#L910).
init_device() is called during the Device construction (in the Constructor), before restoring the information related to the clients interested in the events.

We have to see whether we could restore this event information in one of the Device_XImpl constructors instead, but we might need to store this information in some global variable instead of local ones.
If this is a blocking point for you, could you please create an issue on cppTango?

Kind regards,
Reynald
Rosenberg's Law: Software is easy to make, except when you want it to do something new.
Corollary: The only software that's worth making is software that does something new.
Thanks Reynald for your fast reply. I created an issue in cppTango: https://gitlab.com/tango-controls/cppTango/-/issues/1168.
Let's move the discussion there. Cheers!
 
Register or login to create to post a reply.