taurus-org / taurus

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

Incomplete JDraw synoptic support #1077

Open jufiba opened 4 years ago

jufiba commented 4 years ago

Hi to all,

How complete is the Taurus JDraw synoptic implementation? I am having trouble using the following synoptic:

  Global {
  }
  JDBar {
    summit:385,70,422,105
    origin:437,57
    fillStyle:1
    name:"tango:/leem/safety/water/State"
  }
}

which just makes a square with is green if the State is ON. The error I am getting is:

AttributeError("'NoneType' object has no attribute 'graphicItemSelected'",)

It works fine in JDraw or synopticappli. I have an Ubuntu 18.04.04 system, with python2.7.17, and the latest taurus 4.6.5-alpha.

Juan

reszelaz commented 4 years ago

Sorry if it does not make any sense... I'm not very familiar with the JDraw integration with Taurus, but I wonder if name:"tango:/leem/safety/water/State is accepted?

cpascual commented 4 years ago

I wonder if name:"tango:/leem/safety/water/State is accepted?

I would say it is not (due to the leading /)... but still, the issue can be reproduced with:

JDFile v11 {
  Global {
  }
  JDBar {
    summit:385,70,422,105
    origin:437,57
    fillStyle:1
    name:"sys/tg_test/1/state"
  }
}
cpascual commented 4 years ago

I am looking into this in more detail.

Here are some initial findings:

cpascual commented 4 years ago

I am using the following snippet to debug:

import taurus
taurus.setLogLevel(taurus.Trace)
from taurus.qt.qtgui.application import TaurusApplication
from taurus.qt.qtgui.graphic.jdraw import TaurusJDrawSynopticsView
import sys

app = TaurusApplication(cmd_line_parser=None)
w = TaurusJDrawSynopticsView()
fname = "/tmp/bug1077.jdw"
w.setModel(fname)
w.show()
sys.exit(app.exec_())

When running it on the simplified .jdw from my previous comment I get:

/home/cpascual/miniconda/envs/py3qt5/bin/python /home/cpascual/.PyCharmCE2019.2/config/scratches/scratch_255.py
MainThread     DEBUG    2020-02-25 09:48:53,927 TaurusRootLogger: Cannot import PyQt4. Trying with PyQt5
MainThread     INFO     2020-02-25 09:48:53,937 TaurusRootLogger: Using PyQt5 (v5.9.2 with Qt 5.9.7 and Python 3.7.3)
(...)
MainThread     DEBUG    2020-02-25 09:48:54,431 TaurusJDrawSynopticsView: Starting to parse /tmp/bug1077.jdw
MainThread     WARNING  2020-02-25 09:48:54,443 TaurusJDrawGraphicsFactory: Error fetching object
MainThread     INFO     2020-02-25 09:48:54,443 TaurusJDrawGraphicsFactory: Details:
Traceback (most recent call last):
  File "/nfs/home/cpascual/src/taurus/lib/taurus/qt/qtgui/graphic/jdraw/jdraw.py", line 134, in getObj
    method = getattr(self, method_name)
AttributeError: 'TaurusJDrawGraphicsFactory' object has no attribute 'getBarObj'
MainThread     WARNING  2020-02-25 09:48:54,444 JDraw Parser: Failed to parse /tmp/bug1077.jdw
MainThread     DEBUG    2020-02-25 09:48:54,444 JDraw Parser: Details:
Traceback (most recent call last):
  File "/nfs/home/cpascual/src/taurus/lib/taurus/qt/qtgui/graphic/jdraw/jdraw_parser.py", line 352, in parse
    res = yacc.parse(f.read())
  File "/home/cpascual/miniconda/envs/py3qt5/lib/python3.7/site-packages/ply/yacc.py", line 333, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
  File "/home/cpascual/miniconda/envs/py3qt5/lib/python3.7/site-packages/ply/yacc.py", line 1120, in parseopt_notrack
    p.callable(pslice)
  File "/nfs/home/cpascual/src/taurus/lib/taurus/qt/qtgui/graphic/jdraw/jdraw_parser.py", line 196, in p_single_element
    p.parser.log.info("[%d]: Unable to create obj '%s'" %
AttributeError: 'LRParser' object has no attribute 'log'
MainThread     DEBUG    2020-02-25 09:48:54,445 TaurusJDrawSynopticsView: Obtained NoneType(/tmp/bug1077.jdw)
MainThread     WARNING  2020-02-25 09:48:54,445 TaurusJDrawSynopticsView: TaurusJDrawSynopticsView.setModel(/tmp/bug1077.jdw): Unable to parse /tmp/bug1077.jdw!!!
Traceback (most recent call last):
  File "/home/cpascual/.PyCharmCE2019.2/config/scratches/scratch_255.py", line 10, in <module>
    w.setModel(fname)
  File "/nfs/home/cpascual/src/taurus/lib/taurus/qt/qtgui/graphic/jdraw/jdraw_view.py", line 404, in setModel
    self.scene().graphicItemSelected.connect(self._graphicItemSelected)
AttributeError: 'NoneType' object has no attribute 'graphicItemSelected'

(...)

So, from the line:

AttributeError: 'TaurusJDrawGraphicsFactory' object has no attribute 'getBarObj'

it looks like JDBar is not properly supported, but I'll try to fix the logging issue first

cpascual commented 4 years ago

Hi I haven't been able to fix the logging issue, so I reported it in #1083 (maybe @sergirubio can help with this?)

In any case, I proposed a workaround (see #1082) that should help with this.

Regarding the original question by @jufiba :

How complete is the Taurus JDraw synoptic implementation?

The answer is "not 100% complete". JDBar was not supported, and even with #1082 it is not really implemented. But at least #1082 allows the viewer to load a .jdw file containg JDBar elements without breaking the parsing