Hi Tangoers,
I try to set the memorized option on an attribut using W7 - Python 2.7.11 - PyTango 8.1.6
The declaration of the attribut is :
'freeze' : [
[ PyTango.ArgType.DevBoolean,
PyTango.AttrDataFormat.SCALAR,
PyTango.AttrWriteType.READ_WRITE],
but when I try this :
MAttr = self.get_device_attr()
attr = MAttr.get_attr_by_name("freeze")
attr.set_memorized(True)
I get that :
-------> Received a DevFailed exception: DevFailed[
DevError[
desc = AttributeError: 'WAttribute' object has no attribute
'set_memorized'
origin = File
"C:\Python\lib\site-packages\PyTango\device_class.py", line 518,
in __DeviceClass__device_factory
device = self._new_device(deviceImplClass, klass, dev_name)
File "C:\Python\lib\site-packages\PyTango\device_class.py", line
498, in __DeviceClass__new_device
return klass(dev_class, dev_name)
File
"D:\cchappet\git\PyGMT\src\PyGMT\GMTTango\devices\Survbal\SurvbalManagerImpl.py",
line 30, in __init__
attr.set_memorized(True)
ONERA - The
French Aerospace Lab - Centre du Fauga-Mauzac
Nous suivre sur:
www.onera.fr | Twitter | LinkedIn | Facebook
Avertissement/disclaimer http://www.onera.fr/onera-en/emails-terms
Hi,
I think you have to try :
attr.set_memorized()
attr.set_memorized_init(False or True) // reload the value in db
Sébastien GARA
Ingénieur d’études - Formateur TANGO / Research engineer - TANGO Trainer
NEXEYA France
24 avenue de Pasleck
CS 30019
16400 La Couronne
France
Tel: 33 (0)5.45.24.22.36
sebastien.gara@nexeya.com / www.nexeya.com
Retrouvez-nous sur / Find us on :
https://plus.google.com/u/0/b/116619432754563830101/116619432754563830101/posts
http://www.youtube.com/channel/UCJzQii0D-woM0vHX7DSerSQ
http://www.dailymotion.com/nexeya
Afin de contribuer au respect de l'environnement, merci de n'imprimer ce courriel qu'en cas de nécessité.
Ce message et les fichiers pouvant être attachés sont confidentiels, réservés à l'usage unique des destinataires et n'engagent NEXEYA sous aucune forme que ce soit.
This email and any files transmitted with it are confidential, intented solely for the unique use of the recipients and don't commit NEXEYA.
De : Christophe Chappet [mailto:Christoph...@onera.fr]
Envoyé : mercredi 29 juin 2016 08:57
À : ta...@esrf.fr
Objet : Memorized Attributes
Hi Sébastien,
I think I have to learn reading documentation :-( , you are right, no parameter for set_memorized()
Nevertheless, it still doesn't work.
Using the attached example, I get :
desc = AttributeError: 'WAttribute'
object has no attribute 'set_memorized' with
PyTango.AttrWriteType.READ_WRITE
desc = AttributeError: 'Attribute' object has no attribute 'set_memorized' with PyTango.AttrWriteType.READ
That's true, set_memorized is only defined in Attr class.Hi Jairo,
Thanks, it works this way.
You can set attribute properties when defining the list of attributes. For example: attr_list = { ... 'RFDelta': [[PyTango.DevDouble, PyTango.SCALAR, PyTango.READ_WRITE], { 'unit': 'Hz', 'memorized': 'true' }], ... } Memorized value can be "true_without_hard_applied" or "true", which correspond to the tango cpp versions MEMORIZED and MEMORIZED_WRITE_INIT explained in section A.2.2.1.3 of: http://ftp.esrf.fr/pub/cs/tango/tango_92.pdf Hope this helps. Regards, Jairo On Wednesday 29 June 2016 08:56:39 Christophe Chappet wrote:
Last question, what is the best way to initialize the value of a memorized attribute ?
Do I have to create a "__value" property for each attribute or is there a clever way ?
Yes, I realized that I just have to initialize the class variable and it's works.
The read_myattribut is only called is myattribut
is not initialised in the database.
attr_list = { 'instrument' : [
[ PyTango.ArgType.DevString,
PyTango.AttrDataFormat.SCALAR,
PyTango.AttrWriteType.READ_WRITE],
{
'label':"instrument",
'unit':"",
'format':"",
'memorized': 'true',
} ],
}
class TestDeviceServerImpl(PyTango.Device_4Impl):
def __init__(self,cl,name):
PyTango.Device_4Impl.__init__(self,cl,name)
self.instrument = "1234"
def read_instrument(self, the_att):
the_att.set_value(self.instrument)
Thanks,
Christophe