Objects in Tango servers
|
|
---|---|
Dear all, I have a technical question that I hope you can answer. Let us assume I have a python class (e.g. DriverHelper) that is interfacing with a C++ library (a sort of device driver) that is interfacing directly with a hardware device. The python class sort of hooks into the functionality of the device. I now want to create a python Tango device that wraps around some of the functionality of this python class, with Tango-specific attributes and commands etc. Is it possible, inside my Tango device, to instantiate an object of the DriverHelper class and pass on attribute values/commands to it, whilst making sure that the state of the DriverHelper persists with the Tango device? It seems that on different Tango command calls, the state of the object DriverHelper is not being kept. Is there any way around this? Thanks & Regards
Dr Andrea DeMarco, BSc (Hons) (Melita), MSc (Melita), DPhil (UEA)
Lecturer | Researcher Department of Physics Institute of Space Sciences and Astronomy Room 220, Maths and Physics Building University of Malta, Msida MSD2080, MALTA |
|
|
---|---|
Hi, Normally, there is no problem for what you want to do. In fact, I think it's good to separate Tango class and hardware access class. I have done it several times without issues. Maybe your problem is in your DriverHelper class or the way you are using it in the tango class. |
|
|
---|---|
Hi Sebastien, Thanks. It may be my problem is implementation then. There's a lot of code so I'll try to put in salient parts. In my Tango device server, when I start the device, I can run a command like:
TPM is a python helper class (not a Tango device server). I can see the device server passes this command successfully and the communication (tpm_instance) is established. Later on, a Tango client calls a command in my device e.g.
My device server contains this command:
"Device" is an enumerated type, and Filepath is an XML file the helper class requires. The helper class method tpm_instance.loadFirmwareBlocking() is indeed called. However the attributes of tpm_instance (set internally when previously starting up the object during INIT) seem to be of another instance of tpm_instance i.e. the original tpm_instance object seems to have not persisted. I hope the explanation is clear Thanks a lot!
Dr Andrea DeMarco, BSc (Hons) (Melita), MSc (Melita), DPhil (UEA)
Lecturer | Researcher Department of Physics Institute of Space Sciences and Astronomy Room 220, Maths and Physics Building University of Malta, Msida MSD2080, MALTA |
|
|
---|---|
Your code seems ok from my side. Maybe tou will need to add some debug traces to ensure that the object is still the same or not. You can also try to use singleton or module in python to ensure there is only one object created. |