This repository has been archived by the owner on Aug 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Attr #21
Open
lzytniak
wants to merge
5
commits into
master
Choose a base branch
from
attr
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Attr #21
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,8 @@ | |
from setuptools import setup | ||
|
||
setup( | ||
name="python-svgsynoptic2", | ||
version="3.1", | ||
name="lib-svgsynoptic2", | ||
version="3.7.0", | ||
description="Widget for displaying a SVG synoptic.", | ||
author="Johan Forsberg", | ||
author_email="[email protected]", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,9 +116,11 @@ def run_plugin_command(self, plugin, cmd, args): | |
return getattr(plugins, cmd)(self, args) | ||
|
||
def handle_subscriptions(self, models=[]): | ||
print "handle_subscriptions", models | ||
if self.registry: | ||
# print "handle_subscriptions", models | ||
try: | ||
self.registry.subscribe(models) | ||
except Exception as e: | ||
print('Problem to handle_subscriptions {0}'.format(e)) | ||
|
||
def unsubscribe_listener(self, unsubscribed): | ||
"""Tell the synoptic about unsubscribed models. This is | ||
|
@@ -135,6 +137,7 @@ def filter_fragment(self, model, value): | |
# part of a spectrum or image through "slicing". It is up to the | ||
# client to do this, so we implement it here. | ||
frag = self.registry.eval_validator.getNames(model, fragment=True)[3] | ||
|
||
if frag: | ||
indices = frag[1:-1] | ||
try: | ||
|
@@ -151,6 +154,19 @@ def filter_fragment(self, model, value): | |
pass | ||
return value | ||
|
||
def set_custom_value(self, model, attr_value): | ||
# this is the special case where value is modified for PyAlarm class | ||
# when alarm is trigered PyAlarm attribute returns 'True' value, icon on synoptic is green | ||
# set_custom_value change value for better alarms visualisation | ||
# function can be customised for any other tango device classes | ||
try: | ||
if 'PyAlarm' in PyTango.get_device_proxy(model).info().dev_class: | ||
return not(attr_value) | ||
except Exception as e: | ||
print('Problem to set custom value {0} \n for model {1}'.format(e, model)) | ||
finally: | ||
return attr_value | ||
|
||
def attribute_listener(self, model, evt_src, evt_type, evt_value): | ||
"Handle events" | ||
if evt_type == TaurusEventType.Error: | ||
|
@@ -202,6 +218,8 @@ def attribute_listener(self, model, evt_src, evt_type, evt_value): | |
(model, value)) | ||
|
||
elif isinstance(value, (bool, np.bool_)): | ||
#Change value | ||
#value = self.set_custom_value('/'.join(model.split('/')[:-1]), value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure why this is commented, but I noticed a problem when I have too complicated functions in some parts like this. It is more possible to get error |
||
classes = {"boolean": True, | ||
"boolean-true": bool(value), | ||
"boolean-false": not value} | ||
|
@@ -245,7 +263,7 @@ def on_click(self, kind, name): | |
clicked section. Override this function if you need something | ||
else. | ||
""" | ||
print "on_click", kind, name | ||
# print "on_click", kind, name | ||
if kind == "model" and self.registry.device_validator.isValid(name): | ||
self.select(kind, [name]) | ||
self.emit(Qt.SIGNAL("graphicItemSelected(QString)"), name) | ||
|
@@ -264,9 +282,9 @@ def get_device_panel(self, device): | |
|
||
def on_rightclick(self, kind, name): | ||
"The default behavior for right clicking a device is to open a panel." | ||
if kind == "model" and self.registry.device_validator.isValid(name): | ||
if kind == "model" and (self.registry.device_validator.isValid(name) or | ||
self.registry.attribute_validator.isValid(name)): | ||
if name.lower() in self._panels: | ||
|
||
widget = self._panels[name.lower()] | ||
print "Found existing panel for %s:" % name, widget | ||
if not widget.isVisible(): | ||
|
@@ -275,7 +293,6 @@ def on_rightclick(self, kind, name): | |
widget.raise_() | ||
return | ||
|
||
|
||
# check if we recognise the class of the device | ||
widget = self.get_device_panel(name) | ||
|
||
|
@@ -304,10 +321,15 @@ def _cleanup_panel(self, w): | |
become pretty bogged down.""" | ||
if self.registry: | ||
with self.registry.lock: | ||
print "cleaning up panel for", w.getModel(), "..." | ||
self._panels.pop(str(w.getModel()).lower(), None) | ||
# print "cleaning up panel for", w.getModel(), "..." | ||
# TaurusForm getModel return list | ||
if isinstance(w.getModel(), list): | ||
self._panels.pop(str(w.getModel()[0]).lower(), None) | ||
else: | ||
self._panels.pop(str(w.getModel()).lower(), None) | ||
|
||
w.setModel(None) | ||
print "done!" | ||
# print "done!" | ||
|
||
# Note: the tooltip stuff is broken and not currently in use. | ||
# Currently there is only the default tooltip which displays the | ||
|
@@ -370,7 +392,7 @@ def closeEvent(self, event): | |
|
||
if __name__ == '__main__': | ||
import sys | ||
print sys.argv[1] | ||
# print sys.argv[1] | ||
# qapp = Qt.QApplication([]) | ||
app = TaurusApplication() | ||
sw = TaurusSynopticWidget() | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
finally
like this cause that there is always returnedattr_value
, no matter what happens intry
. There should be return afterexcept
(not inside).