taurus-org / taurus

Moved to https://gitlab.com/taurus-org/taurus
http://taurus-scada.org
43 stars 46 forks source link

TaurusLabel with bgRole='state #1088

Closed vallsv closed 4 years ago

vallsv commented 4 years ago

Hi,

I would like to know if the behaviour of state have changed since 5 years?

I use TaurusLabel using bgRole=state and i was expecting to have different colors according to the state of the Tango device. But the state looks to be a TaurusDevState (Ready, NotReady) which is not a Tango device state (Open, Close...)

Do you know if there is a way to retrieve the old behaviour? Open->Green Close->Red...

Right now i can't test this shutters, so maybe i am wrong with my diagnosis.

vallsv commented 4 years ago

Maybe i could use model=tango:foo/foo/foo/State + bgRole=value? I don't know if it will always work for all my use cases, at least for the 2 in from of me it's fine.

But:

git grep "<string>state</string>" | wc -l
81

i am afraid for cases like model=tango:foo/foo/foo/Value + bgRole=state? Displaying an attribute as text, and the device status as a background. Was it designed for? I was maybe using a side effect?

reszelaz commented 4 years ago

Hi Valentin, Yes, the state behavior had changed since TEP14. This was accepted on 2016-03-16, so not really 5 years ago, but still maybe this is what you are looking for. I have tried with taurusdemoto set the background role with the following value: parentObj.stateObj.read() for a TaurusLabel configured with an attribute model (mot01/velocity) and it worked for me. But maybe better that @cpascual confirms if this is the right way of doing it. Thanks! Cheers!

vallsv commented 4 years ago

Wow. Ok, i see, This way? <string>parentObj.stateObj.read()</string>. Really nice, i will check that. Thanks a lot for the feedback.

vallsv commented 4 years ago

Here it works with <string>parentObj.stateObj.read().value</string>. So it's fine for me. Thanks a lot for the feedback.

cpascual commented 4 years ago

Hi, I am glad that it is solved, but just for completitude:

w = TaurusLabel()
w.setModel('sys/tg_test/1/state')  # <- state !
w.setBgRole('rvalue')
w = TaurusLabel()
w.setModel('sys/tg_test/1/short_scalar')  # <-- some other attr !
w.setBgRole('parentObj.stateObj.rvalue')

BUT be aware that with this second approach, the label will subscribe only to changes in the model attribute, not in the state attribute, so the background may not refresh properly

vallsv commented 4 years ago

Thanks a lot. So i will try to do the first one as much as possible.