tango-controls / pytango

This project was moved to gitlab.com
http://pytango.rtfd.io
54 stars 44 forks source link

How to create READ_WITH_WRITE attribute in high-level API #312

Closed ajoubertza closed 2 years ago

ajoubertza commented 5 years ago

As part of improvements to POGO PythonHL code generation, testing was done with the TangoTest device xmi file. This includes READ_WITH_WRITE attributes (example), which are not currently handled by POGO. Is this possible with the high level API, and if so, how?

(@tiagocoutinho I'm hoping you can help!)

grm84 commented 5 years ago

Hi @ajoubertza @tiagocoutinho I've just created a python version of TangoTest starting from the xmi file. Its not an exact replica and yes I had to remove READ_WITH_WRITE. I'm using it to test the pybind project but if you think it maybe useful I can commit it, initially to the pybind branch for your comments.

tiagocoutinho commented 5 years ago

I am having trouble trying to create one attribute of this type. In theory it should be something like:

class Dev(Device):
  @attribute(access=AttrWriteType.READ_WITH_WRITE)
  def a1(self):
    return 1.0

but I am getting:

Exiting: Server exited with tango.DevFailed:
DevFailed[
DevError[
    desc = Attribute : a1:  Associated attribute not defined
  origin = Attr::Attr
  reason = API_AttrWrongDefined
severity = ERR]
]

Exited

Isn't READ_WITH_WRITE deprecated in tango? Could you confirm @bourtemb?

ajoubertza commented 5 years ago

but if you think it maybe useful I can commit it, initially to the pybind branch for your comments.

@grm84 It would be useful. I wonder whether it should be included in this repo, or in the https://github.com/tango-controls/TangoTest? Keeping it in the TangoTest repo helps with maintainability (more likely to be updated when things change). However, that repo is kind-of a C++ repo at the moment, and if someone cloned it, they wouldn't be able to run Python script until they installed the dependencies. The easy option is just adding in pytango's examples folder, so you can do that on your branch.

bourtemb commented 5 years ago

Isn't READ_WITH_WRITE deprecated in tango? Could you confirm @bourtemb?

It is not advised to continue to use READ_WITH_WRITE attributes indeed. They have never been officially fully deprecated even though we would like to. @tiagocoutinho you need to associate another attribute when you define a READ_WITH_WRITE attribute. I think the concept is understood by only very few Tango device servers programmers. I don't think we should encourage people to use READ_WITH_WRITE attributes and to create this kind of attributes.

NexeyaSGara commented 5 years ago

So maybe the solution is to remove it from the choices in Pogo ? So advanced user can use it if they want

bourtemb commented 5 years ago

So maybe the solution is to remove it from the choices in Pogo ? So advanced user can use it if they want

Indeed. It's an idea. READ_WITH_WRITE is actually documented as deprecated: https://tango-controls.readthedocs.io/en/latest/development/device-api/ds-guideline/device-server-guidelines.html#static-attribute-properties The question is how do we deal with cases where a user wants to update an old class containing a READ_WITH_WRITE attribute with POGO? Adding a warning message saying that this is deprecated would be already an improvement. We should probably forbid to create new READ_WITH_WRITE attributes too.