Skip to content

Commit

Permalink
Merge pull request #254 from tangkong/bug_action_writepv
Browse files Browse the repository at this point in the history
BUG: store _setpoint_pv in Target where possible
  • Loading branch information
tangkong authored Sep 16, 2024
2 parents ed13762 + 4e47f4b commit 68d7f2f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
3 changes: 2 additions & 1 deletion atef/widgets/config/data_active.py
Original file line number Diff line number Diff line change
Expand Up @@ -874,8 +874,9 @@ def attr_to_target(self, attr: OphydAttributeData) -> Target:
dot_attr = attr.attr
_attr = '_' + dot_attr.replace('.', '_')
dev_name = full_name[:-len(_attr)]
write_pv = attr.setpoint_pvname or attr.pvname

return Target(device=dev_name, attr=dot_attr, pv=attr.pvname)
return Target(device=dev_name, attr=dot_attr, pv=write_pv)


class ActionRowWidget(TargetRowWidget):
Expand Down
10 changes: 6 additions & 4 deletions atef/widgets/ophyd.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ class OphydAttributeData:
attr: str
description: Dict[str, Any]
docstring: Optional[str]
pvname: str
pvname: str # the readback, if setpoint_pvname is provided.
setpoint_pvname: Optional[str]
read_only: bool
readback: Any
setpoint: Any
readback: Any # readback value
setpoint: Any # setpoint value
units: Optional[str]
signal: ophyd.Signal

Expand All @@ -88,6 +89,7 @@ def from_device_attribute(
description={},
docstring=cpt.doc,
pvname=getattr(inst, "pvname", "(Python)"),
setpoint_pvname=getattr(inst, "setpoint_pvname", None),
read_only=read_only,
readback=None,
setpoint=None,
Expand Down Expand Up @@ -506,7 +508,7 @@ def data(self, index: QtCore.QModelIndex, role: int) -> Optional[str]:
if column == DeviceColumn.read_pvname:
return info.pvname
if column == DeviceColumn.set_pvname:
return getattr(info.signal, 'setpoint_pvname', 'None')
return info.setpoint_pvname
return ""

if role == Qt.ToolTipRole:
Expand Down
22 changes: 22 additions & 0 deletions docs/source/upcoming_release_notes/254-bug_action_writepv.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
254 bug_action_writepv
######################

API Breaks
----------
- N/A

Features
--------
- N/A

Bugfixes
--------
- Store the setpoint pv when creating a Target when possible, instead of storing pvname, which could be the readback pv.

Maintenance
-----------
- N/A

Contributors
------------
- tangkong

0 comments on commit 68d7f2f

Please sign in to comment.