-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
186 additions
and
159 deletions.
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
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 |
---|---|---|
|
@@ -17,26 +17,21 @@ | |
""" | ||
|
||
# ----------------------------------------------------------------------------- | ||
# :author: Pete R. Jemian | ||
# :email: [email protected] | ||
# :copyright: (c) 2017-2025, UChicago Argonne, LLC | ||
# | ||
# Distributed under the terms of the Creative Commons Attribution 4.0 International Public License. | ||
# | ||
# The full license is in the file LICENSE.txt, distributed with this software. | ||
# ----------------------------------------------------------------------------- | ||
|
||
__all__ = [ | ||
"EpicsBssDevice", | ||
] | ||
|
||
# from ..plans import addDeviceDataAsStream | ||
import datetime | ||
|
||
import pyRestTable | ||
from bluesky import plan_stubs as bps | ||
from ophyd import Component | ||
from ophyd import Device | ||
from ophyd import EpicsSignal | ||
|
||
from .core import trim | ||
|
||
|
||
class EpicsEsafExperimenterDevice(Device): | ||
""" | ||
|
@@ -178,9 +173,7 @@ class EpicsProposalDevice(Device): | |
number_users_in_pvs = Component(EpicsSignal, "users_in_pvs") | ||
number_users_total = Component(EpicsSignal, "users_total") | ||
proposal_id = Component(EpicsSignal, "id", string=True) | ||
proprietary_flag = Component( | ||
EpicsSignal, "proprietaryFlag", string=True | ||
) | ||
proprietary_flag = Component(EpicsSignal, "proprietaryFlag", string=True) | ||
raw = Component(EpicsSignal, "raw", string=True, kind="omitted") | ||
start_date = Component(EpicsSignal, "startDate", string=True) | ||
submitted_date = Component(EpicsSignal, "submittedDate", string=True) | ||
|
@@ -240,30 +233,60 @@ class EpicsBssDevice(Device): | |
.. autosummary:: | ||
~_table | ||
~addDeviceDataAsStream | ||
~clear | ||
""" | ||
|
||
esaf = Component(EpicsEsafDevice, "esaf:") | ||
proposal = Component(EpicsProposalDevice, "proposal:") | ||
|
||
ioc_host = Component( | ||
EpicsSignal, "ioc_host", string=True, kind="omitted" | ||
) | ||
ioc_user = Component( | ||
EpicsSignal, "ioc_user", string=True, kind="omitted" | ||
) | ||
status_msg = Component( | ||
EpicsSignal, "status", string=True, kind="omitted" | ||
) | ||
ioc_host = Component(EpicsSignal, "ioc_host", string=True, kind="omitted") | ||
ioc_user = Component(EpicsSignal, "ioc_user", string=True, kind="omitted") | ||
status_msg = Component(EpicsSignal, "status", string=True, kind="omitted") | ||
|
||
def addDeviceDataAsStream(self, stream_name=None): | ||
"""Write the data as a separate stream.""" | ||
yield from bps.create(name=stream_name or "apsbss") | ||
yield from bps.read(self) | ||
yield from bps.save() | ||
|
||
def clear(self): | ||
"""Clear the proposal and ESAF info.""" | ||
self.esaf.clear() | ||
self.proposal.clear() | ||
self.status_msg.put("Cleared") | ||
|
||
def addDeviceDataAsStream(self, stream_name=None): | ||
"""Write the data as a separate stream.""" | ||
yield from bps.create(name=stream_name or "apsbss") | ||
yield from bps.read(self) | ||
yield from bps.save() | ||
def _table(self, *, show_name=False, length=40): | ||
"""Make a table of all Component Signal values.""" | ||
table = pyRestTable.Table() | ||
# table.labels = "signal PV value updated".split() | ||
table.labels = "PV value updated".split() | ||
if show_name: | ||
table.labels.insert(0, "name") | ||
# .walk_signals() might be changed or removed in a future ophyd version. | ||
# At that time, consider using ophyd_registry instead. | ||
for signal in self.walk_signals(): | ||
dt = datetime.datetime.fromtimestamp(signal.item.timestamp).astimezone() | ||
if dt.year < 2000: | ||
dt = "--" | ||
row = [ | ||
signal.item.pvname, | ||
trim(str(signal.item.get()), length=length), | ||
dt, | ||
] | ||
if show_name: | ||
row.insert(0, f"{self.name}.{signal.dotted_name}") | ||
table.addRow(row) | ||
return table | ||
|
||
|
||
# ----------------------------------------------------------------------------- | ||
# :author: Pete R. Jemian | ||
# :email: [email protected] | ||
# :copyright: (c) 2017-2025, UChicago Argonne, LLC | ||
# | ||
# Distributed under the terms of the Creative Commons Attribution 4.0 International Public License. | ||
# | ||
# The full license is in the file LICENSE.txt, distributed with this software. | ||
# ----------------------------------------------------------------------------- |
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
Oops, something went wrong.