Skip to content

Commit

Permalink
Merge 296ca28 into d26d29f
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed Aug 4, 2020
2 parents d26d29f + 296ca28 commit 0f6e59d
Show file tree
Hide file tree
Showing 8 changed files with 484 additions and 269 deletions.
77 changes: 51 additions & 26 deletions apstools/beamtime/apsbss.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ def connect_epics(prefix):
PARAMETERS
prefix (str):
prefix
*str* :
EPICS PV prefix
"""
from .apsbss_ophyd import EpicsBssDevice
Expand All @@ -112,7 +113,8 @@ def epicsClear(prefix):
PARAMETERS
prefix (str):
prefix
*str* :
EPICS PV prefix
"""
logger.debug("clear EPICS %s", prefix)
Expand All @@ -133,7 +135,8 @@ def epicsUpdate(prefix):
PARAMETERS
prefix (str):
prefix
*str* :
EPICS PV prefix
"""
logger.debug("update EPICS %s", prefix)
Expand Down Expand Up @@ -239,11 +242,14 @@ def epicsSetup(prefix, beamline, cycle=None):
PARAMETERS
prefix (str):
prefix
*str* :
EPICS PV prefix
beamline (str):
beamline
*str* :
Name of beam line (as defined by the BSS)
cycle (str):
cycle
*str* :
Name of APS run cycle (as defined by the BSS).
optional: default is current APS run cycle name.
"""
Expand Down Expand Up @@ -281,7 +287,8 @@ def getCurrentEsafs(sector):
PARAMETERS
sector (str or int):
sector
*str* or *int* :
Name of sector. If ``str``, must be in ``%02d`` format (``02``, not ``2``).
"""
if isinstance(sector, int):
Expand All @@ -306,7 +313,8 @@ def getCurrentInfo(beamline):
PARAMETERS
beamline (str):
beamline
*str* :
Name of beam line (as defined by the BSS).
"""
sector = beamline.split("-")[0]
Expand Down Expand Up @@ -343,7 +351,8 @@ def getCurrentProposals(beamline):
PARAMETERS
beamline (str):
beamline
*str* :
Name of beam line (as defined by the BSS).
"""
proposals = []
Expand All @@ -361,7 +370,8 @@ def getEsaf(esafId):
PARAMETERS
esafId (int):
esafId
*int* :
ESAF number
"""
try:
Expand All @@ -377,11 +387,14 @@ def getProposal(proposalId, cycle, beamline):
PARAMETERS
proposalId (str):
proposalId
*str* :
Proposal identification number
cycle (str):
cycle
*str* :
Name of APS run cycle (as defined by the BSS)
beamline (str):
beamline
*str* :
Name of beam line (as defined by the BSS)
"""
# avoid possible dm.DmException
Expand All @@ -408,10 +421,11 @@ def iso2datetime(isodate):
PARAMETERS
isodate (str):
isodate
*str* :
Date and time in ISO8601 format. (e.g.: ``2020-07-01T12:34:56.789012``)
"""
return datetime.datetime.fromisoformat(isodate)
return datetime.datetime.fromisoformat(isodate) # FIXME: not in py36


def listAllBeamlines():
Expand Down Expand Up @@ -440,7 +454,8 @@ def listRecentRuns(quantity=6):
PARAMETERS
quantity (int):
quantity
*int* :
number of APS run cycles to include, optional (default: 6)
"""
# 6 runs is the duration of a user proposal
Expand All @@ -459,11 +474,14 @@ def printColumns(items, numColumns=5, width=10):
PARAMETERS
items (list(str)):
items
*[str]* :
List of items to report
numColumns (int):
numColumns
*int* :
number of columns, optional (default: 5)
width (int):
width
*int* :
width of each column, optional (default: 10)
"""
n = len(items)
Expand All @@ -489,9 +507,11 @@ def trim(text, length=40):
PARAMETERS
text (str):
text
*str* :
String, potentially longer than ``length``
length (int):
length
*int* :
maximum length, optional (default: 40)
"""
if length < 1:
Expand Down Expand Up @@ -577,7 +597,8 @@ def cmd_cycles(args):
PARAMETERS
args (obj):
args
*obj* :
Object returned by ``argparse``
"""
if args.full:
Expand Down Expand Up @@ -605,7 +626,8 @@ def cmd_current(args):
PARAMETERS
args (obj):
args
*obj* :
Object returned by ``argparse``
"""
records = getCurrentProposals(args.beamlineName)
Expand Down Expand Up @@ -672,7 +694,8 @@ def cmd_esaf(args):
PARAMETERS
args (obj):
args
*obj* :
Object returned by ``argparse``
"""
try:
Expand All @@ -690,7 +713,8 @@ def cmd_proposal(args):
PARAMETERS
args (obj):
args
*obj* :
Object returned by ``argparse``
"""
try:
Expand All @@ -708,7 +732,8 @@ def cmd_report(args):
PARAMETERS
args (obj):
args
*obj* :
Object returned by ``argparse``
"""
from ..utils import object_explorer
Expand Down
68 changes: 44 additions & 24 deletions apstools/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ class ApsMachineParametersDevice(Device):
~inUserOperations
"""
current = Component(EpicsSignalRO, "S:SRcurrentAI")
lifetime = Component(EpicsSignalRO, "S:SRlifeTimeHrsCC")
Expand Down Expand Up @@ -304,34 +303,42 @@ class ShutterBase(Device):
PARAMETERS
value : str
value
*str* :
any from ``self.choices`` (typically "open" or "close")
valid_open_values : [str]
valid_open_values
*[str]* :
A list of lower-case text values that are acceptable
for use with the ``set()`` command to open the shutter.
valid_close_values : [str]
valid_close_values
*[str]* :
A list of lower-case text values that are acceptable
for use with the ``set()`` command to close the shutter.
open_value : number
open_value
*number* :
The actual value to send to open ``signal`` to open the shutter.
(default = 1)
close_value : number
close_value
*number* :
The actual value to send to close ``signal`` to close the shutter.
(default = 0)
delay_s : float
delay_s
*float* :
time to wait (s) after move is complete,
does not wait if shutter already in position
(default = 0)
busy : Signal
busy
*Signal* :
(internal) tells if a move is in progress
unknown_state : str
unknown_state
*str* :
(constant) Text reported by ``state`` when not open or closed.
cannot move to this position
(default = "unknown")
Expand Down Expand Up @@ -432,10 +439,12 @@ def set(self, value, **kwargs):
PARAMETERS
value : str
value
*str* :
any from ``self.choices`` (typically "open" or "close")
kwargs : dict
kwargs
*dict* :
ignored at this time
"""
Expand Down Expand Up @@ -508,7 +517,8 @@ class OneSignalShutter(ShutterBase):
PARAMETERS
signal : EpicsSignal or Signal
signal
``EpicsSignal`` or ``Signal`` :
(override in subclass)
The ``signal`` is the comunication to the hardware.
In a subclass, the hardware may have more than
Expand Down Expand Up @@ -770,13 +780,16 @@ def wait_for_state(self, target, timeout=10, poll_s=0.01):
PARAMETERS
target : [str]
target
*[str]* :
list of strings containing acceptable values
timeout : non-negative number
timeout
*non-negative number* :
maximum amount of time (seconds) to wait for PSS state to reach target
poll_s : non-negative number
poll_s
*non-negative number* :
Time to wait (seconds) in first polling cycle.
After first poll, this will be increased by ``_poll_factor_``
up to a maximum time of ``_poll_s_max_``.
Expand Down Expand Up @@ -865,13 +878,16 @@ def wait_for_state(self, target, timeout=10, poll_s=0.01):
PARAMETERS
target : [str]
target
*[str]* :
list of strings containing acceptable values
timeout : non-negative number
timeout
*non-negative number* :
Ignored in the simulation.
poll_s : non-negative number
poll_s
*non-negative number* :
Ignored in the simulation.
"""
simulated_response_time_s = np.random.uniform(0.1, 0.9)
Expand Down Expand Up @@ -1658,19 +1674,23 @@ def AD_setup_FrameType(prefix, scheme="NeXus"):
PARAMETERS
prefix (str) : EPICS PV prefix of area detector, such as "13SIM1:"
scheme (str) : any key in the `AD_FrameType_schemes` dictionary
prefix
*str* :
EPICS PV prefix of area detector, such as ``13SIM1:``
scheme
*str* :
any key in the ``AD_FrameType_schemes`` dictionary
This routine prepares the EPICS Area Detector to identify frames
by image type for handling by clients, such as the HDF5 file writing plugin.
With the HDF5 plugin, the `FrameType` PV is added to the NDattributes
With the HDF5 plugin, the ``FrameType`` PV is added to the NDattributes
and then used in the layout file to direct the acquired frame to
the chosen dataset. The `FrameType` PV value provides the HDF5 address
the chosen dataset. The ``FrameType`` PV value provides the HDF5 address
to be used.
To use a different scheme than the defaults, add a new key to
the `AD_FrameType_schemes` dictionary, defining storage values for the
fields of the EPICS `mbbo` record that you will be using.
the ``AD_FrameType_schemes`` dictionary, defining storage values for the
fields of the EPICS ``mbbo`` record that you will be using.
see: https://github.com/BCDA-APS/use_bluesky/blob/master/lessons/sandbox/images_darks_flats.ipynb
Expand Down

0 comments on commit 0f6e59d

Please sign in to comment.