sardana-org / sardana

Moved to GitLab: https://gitlab.com/sardana-org/sardana
39 stars 52 forks source link

write to DoorOutput from taurus #1602

Open kklmn opened 3 years ago

kklmn commented 3 years ago

Hello,

I know I can write to DoorOutput from a macro using its .output() method. Can I do writing from a Qt class using taurus? I get door as taurus.Device('..../Door/01') and I expected a writing method there but cannot find it except write() and writeln() that print to the terminal.

Thank you!

guifrecuni commented 3 years ago

The Output is read-only tango attribute because it was designed to be one of the "streams/channels" that macros could use to send information. So the actual writting mechanism is not an open API neither to macros nor to TANGO clients. I'd say that the you could simply define a "input2output " macro that sends to output whatever is in it's parameter with a self.output(par)

kklmn commented 3 years ago

Ok, thank you for the explanation @guifrecuni ! I also had this idea of channeled writing through an ad hoc macro, just hoped there was a dedicated solution.

reszelaz commented 3 years ago

Hi @kklmn,

Could you please explain with some more detail what you would like to achieve?

Is it that you develop a complete GUI app, where DoorOutput is one of the widgets? You execute macros from the same GUI app e.g. using macroexecutor widget which output gets appended to the DoorOutput, and for example, would like to add some extra text in between the macros executions e.g. a line separator?

Thanks!

kklmn commented 3 years ago

I have two GUI made with Taurus GUI, each having several custom Qt panels. One GUI has Sardana integration widgets (ExpConfig, Macro, DoorOutput). The other GUI has motor panels and optimization panels to tune the optics. They register a door listener and get data from it during some specific scans, analyze them and go to the optimal positions.

I wanted to write the tuning results to DoorOutput, as it may also give some recommendations to the user. I don't want to use a modal (blocking) MessageBox (several reasons here, the main one is a remote operation with only one screen in view), I don't want a non-blocking MessageBox too, as it may lose the focus and get hidden. Presently I use print() to the terminal where I started the GUIs, but this is only used at debugging time. I thought DoorOutput was the most appropriate.

reszelaz commented 3 years ago

Thanks for the explanation.

They register a door listener and get data from it during some specific scans, analyze them and go to the optimal positions.

Do you do something similar to calculating scan statistics? I understand that you do the analysis in the GUI process based on the DoorOutput results?

I wanted to write the tuning results to DoorOutput, as it may also give some recommendations to the user.

I imagine that there should be a way to simply append some text to the DoorOutput widget. In the end, it is just a QPlainTextEdit. I see that we expose appendHtmlText() method on this class. But I have never tried to use it out of the macro execution context. Do you have a reference to this widget in your code, or this one got created behind the scene by the Taurus GUI framework?

kklmn commented 3 years ago

Hi @reszelaz!

Do you do something similar to calculating scan statistics?

This is a bit more complex. In one scan I find a maximum of the sum of two exp channels; in the 2sn scan I find crossing points of these two exp channels by using scipy.

I understand that you do the analysis in the GUI process based on the DoorOutput results?

The scan data I get from a listener to RecordData, not directly from DoorOutput. I guess DoorOutput does the same: registers to the door's RecordData.

I see that we expose appendHtmlText() method ...

Yes, this might work if I had the instance of the DoorOutput widget. All these widgets (Sardana widgets and my custom widgets) are instantiated by Taurus GUI.

But I don't see why DoorOutput should be read only and not user-writable via the door object.