This repository was 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 3 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 hidden or 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 |
|---|---|---|
|
|
@@ -135,6 +135,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 +152,16 @@ 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 | ||
| if 'PyAlarm' in PyTango.get_device_proxy(model).info().dev_class: | ||
| return not(attr_value) | ||
| else: | ||
| return attr_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. Using |
||
|
|
||
| def attribute_listener(self, model, evt_src, evt_type, evt_value): | ||
| "Handle events" | ||
| if evt_type == TaurusEventType.Error: | ||
|
|
@@ -202,6 +213,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) | ||
| classes = {"boolean": True, | ||
| "boolean-true": bool(value), | ||
| "boolean-false": not value} | ||
|
|
@@ -264,9 +277,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 +288,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) | ||
|
|
||
|
|
@@ -305,7 +317,12 @@ def _cleanup_panel(self, w): | |
| if self.registry: | ||
| with self.registry.lock: | ||
| print "cleaning up panel for", w.getModel(), "..." | ||
| self._panels.pop(str(w.getModel()).lower(), None) | ||
| # 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!" | ||
|
|
||
|
|
||
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.
Maybe this is better to keep only one return statement:
But it is less "customized friendly"