Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC/MAINT: add documentation, docking system conda shim #128

Merged
merged 13 commits into from
Dec 14, 2023
Merged
81 changes: 81 additions & 0 deletions docs/source/grid.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
LUCID Grid Configuration
========================

``LUCID``'s main grid area is an auto-generated series of buttons and indicators,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
``LUCID``'s main grid area is an auto-generated series of buttons and indicators,
``lucid``'s main grid area is an auto-generated series of buttons and indicators,

Should we keep this consistent throughout the docs?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to use LUCID when talking about the app and lucid when talking about the cli invocation, but:

  • I may not have done this correctly in general
  • This might not be the right approach

I'm tempted to turn it all into lucid in general and Lucid in titles

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of this stems from the readme and docs previously using LUCID exclusively despite the lowercase cli entrypoint + my dislike of all caps or special caps names in general

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like my opinion on the matter changes daily. I think it's fine as is, it just stuck out as the only fully-capitalized instance on the page

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to go ahead and change it to my preferences of Lucid or lucid everywhere (down with arbitrary casing!). I think this is noncontroversial because Lucid is essentially a normal word despite being an acronym.

where each indicator represents a device
loaded from a ``happi`` database.

Which Devices are Included?
---------------------------

When ``lucid`` is invoked, the only required argument is the positional ``beamline`` argument.
This argument is used as a ``happi`` search term to fill the grid.

This is equivalent to the following search using the ``happi`` command line,
assuming your beamline is named BEAMLINE:

.. code-block:: bash

happi search beamline=BEAMLINE active=True


All devices that match this search and load without errors will be included in the grid.
All other devices will be excluded.
The search is case-sensitive.

Note that inactive devices are not included,
and that this only targets happi entries that have a beamline associated with them at all.
This requires the ``happi`` containers defined in ``pcdsdevices``,
which define the ``beamline`` field.

Note: if you prefer not to load any devices, you can skip this step by passing
a command-line parameter:

.. code-block:: bash

lucid --skip_happi MY_BEAMLINE


How are the Devices Arranged in the Grid?
-----------------------------------------

The grid is defined by the various metadata values found in the ``happi`` database.
The default metadata keys in use are:

- ``location_group``, to select which column to put a device into
- ``functional_group``, to select with row to put a device into

That is to say, by default we expect the row headers on the left to be functional names like
"imager" or "vacuum" and column headers on the top to be location names like "SB3" or "VLS".
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"imager" or "vacuum" and column headers on the top to be location names like "SB3" or "VLS".
"imager" or "vacuum" and column headers on the top to be location names like "Section 01" or "Section 02".

I like the docs a lot better with pictures, one last nitpick might be to make the examples match the images.

We could take this a step further with the buttons config, but if we do I'd advocate showing two configs. One with the descriptive values and one that matches the toolbar shown in the image.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm not motivated to make an example config that matches the image, I'd be better off redoing the images to be the current config and pasting the current KFE config in.

Instead, I'll add a link to the lucid configs backup repo (which I'll update again at some point) so at least there's a way to see a bunch of valid configs.

I'm also going to merge your suggestion here


You can change which metadata keys are used by passing the
``--row_group_key`` and ``--col_group_key`` command-line parameters
to select the row grouping and column groupings respectively.

Each unique string (case-sensitive) found in the group key metadata for the
active devices will create an additional row or column in the grid
with the corresponding header text.
The rows and the columns will each be sorted in alphabetical order.

Each device indicator will be added to a single square cell in the grid that
corresponds with its metadata sorting.

This provides the following features:

- An alarm indicator that represents the device's worst alarm state,
with mouseover text that will show more precise information
- The option to click the cell and select the device name to open the device's
``typhos`` screen in the right-hand dock area
- The option to click the row or column header to select the device name for the
same purpose as above, where the devices can be from any cell in the corresponding
row or column.


Limitations
-----------

- There are currently no configuration options for row/column ordering or
customization of the happi search used to accumulate devices.
- The only way to adjust the grid is to carefully manipulate the ``happi`` database.
- There are no options for changing the sizes of cells or the sizes of the alarm
indicators held inside the cells.
2 changes: 2 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ LCLS User Control and Interface Design
:caption: User Documentation

launcher.rst
grid.rst
toolbar.rst

.. toctree::
:maxdepth: 2
Expand Down
99 changes: 99 additions & 0 deletions docs/source/toolbar.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
LUCID Toolbar Configuration
===========================

``LUCID`` can be launched with a toolbar file that specifies
the tabs that are displayed below the device grid.
These tabs can be configured to hold buttons
that open other screens.

Invocation
----------

The invocation to include this toolbar file is:

.. code-block:: bash

lucid --toolbar /path/to/toolbar/file.yaml HUTCHNAME

Options and Limitations
-----------------------

- The user can specify an arbitrary number of tabs.
- Each tab can have an arbitrary number of columns.
- The columns are filled from left to right, then from top to bottom.
- Only ``PyDMShellCommand`` and ``PyDMRelatedDisplayButton`` widgets are supported.
- Any available pyqt property or general python attribute can be specified on either
of these button types.

Guidelines
----------

- The related display option (``display``) should be used whenever it is possible to do so,
because the screen will open more quickly compared to a shell script, which will need to
initialize an entire new python shell with new imports.

File Format
-----------

The toolbar configuration is stored in a yaml file that encodes a dictionary.
Each key in this top-level dictionary is the name of a tab to include.
These tabs will be arranged in file order from left to right.

Each of these tab names should contain another dictionary with the following top-level keys:

- ``config`` (optional)
- ``buttons``

The only ``config`` option right now is ``cols``, which defaults to 4.

Here's an example config file structure, omitting only the ``buttons`` sections:

.. code-block:: yaml

tab1_name_with_3_cols:
config:
cols: 3
buttons: see below
tab2_name_with_2_cols:
config:
cols: 2
buttons: see below
tab3_name_with_4_cols:
buttons: see below


The ``buttons`` key should itself point to a dictionary that maps each
button text to a button config dictionary, in order.
LUCID will iterate through these dictionaries and create buttons,
arranging them from left to right across each column before moving to the next row.

The button config dictionary has one special key: ``type``.
The ``type`` key can either be ``shell`` to create a ``PyDMShellCommand`` button,
or it can be ``display`` to create a ``PyDMRelatedDisplayButton``.
If ``type`` is omitted, or is not one of these options,
an inactive ``QPushButton`` will be created.

All other keys in the config dictionary should be mappings from qt property names
to each property's desired value.
This is forward-compatible with any new properties that may be implemented in the future
for these button types.

Here's an example buttons config snippit that shows the structure and some of the
useful properties. This will create two buttons, one with button text "Cool PyDM Display"
and another with button text "Run Neat Script."

.. code-block:: yaml

buttons:
Cool PyDM Display:
type: display
filenames:
- /path/to/some/ui/file.ui
macros:
- "{'PREFIX': 'COOL'}"
Run Neat Script:
type: shell
commands:
- "echo 'neat'"
- /path/to/some/neat/shell/script.sh
redirectCommandOutput: true
20 changes: 20 additions & 0 deletions lucid/dock_shim.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
Shim module for dealing with the repeatedly changing import API for
the conda builds of PyQtAds.

The pypi builds do not seem to have the same issue.
"""
try:
# pre-v4.0.0
from PyQtAds import QtAds as ads
except ImportError:
try:
# from v4.0.0 to v4.1.1
from PyQtAds import ads
except ImportError:
# starting at v4.2.0 (latest, for now)
import PyQtAds as ads

if not hasattr(ads, "CDockWidget"):
import PyQtAds
raise ImportError(f"Submodule name for PyQtAds changed (again): {dir(PyQtAds)}")
2 changes: 1 addition & 1 deletion lucid/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
import typhos.utils
from ophyd.signal import EpicsSignalBase
from pydm import exception
from PyQtAds import ads
from qtpy import QtCore, QtWidgets

import lucid

from . import utils
from .dock_shim import ads

MODULE_PATH = pathlib.Path(__file__).parent

Expand Down
2 changes: 1 addition & 1 deletion lucid/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

import typhos
from pydm import exception
from PyQtAds import ads
from qtpy import QtCore, QtGui, QtWidgets
from qtpy.QtCore import Qt, Signal
from qtpy.QtWidgets import QMainWindow, QSizePolicy, QStyle

import lucid

from . import utils
from .dock_shim import ads

logger = logging.getLogger(__name__)

Expand Down