pcdshub / lightpath

LCLS Lightpath Module
https://pcdshub.github.io/lightpath
Other
4 stars 9 forks source link

Properly handle beamlines that end in the middle of a branch #137

Closed tangkong closed 2 years ago

tangkong commented 2 years ago

Expected Behavior

Beamlines that end in the middle of a branch should only include devices up to their beamline.

Current Behavior

Currently we expect beamlines to be located at the end of a branch. This works in most cases, but some beamlines (XPP) live in the middle of a branch, so their active paths end up including a variety of irrelevant devices.

Possible Solution

This will probably require a slightly different way of specifying where a beamline sits. Perhaps we also allow a device name to designate a beamline.

Steps to Reproduce (for bugs)

initialize the test database (path.json) and look at the active paths for XPP:

Note how the first beam path includes all the L0 devices, even though XPP should really end before xpp_lodcm

In [2]: lc.beamlines['XPP'][0].show_devices()
+-----------+-------------+-----------+----------------+--------------------+---------+
| Name      | Prefix      |  Position | Input Branches |    Output Branches |   State |
+-----------+-------------+-----------+----------------+--------------------+---------+
| im1l0     | IM1L0:XTES  | 699.50000 |         ['L0'] |             ['L0'] | Removed |
| sl1l0     | SL1L0:POWER | 705.86000 |         ['L0'] |             ['L0'] | Removed |
| im2l0     | IM2L0:XTES  | 715.50000 |         ['L0'] |             ['L0'] | Removed |
| mr1l0     | MR1L0       | 740.00000 |         ['L0'] |       ['L0', 'L1'] | Removed |
| im3l0     | IM3L0:XTES  | 749.50000 |         ['L0'] |             ['L0'] | Removed |
| im4l0     | IM4L0:XTES  | 755.50000 |         ['L0'] |             ['L0'] | Removed |
| sl2l0     | SL2L0:POWER | 755.86000 |         ['L0'] |             ['L0'] | Removed |
| xpp_lodcm | XPP:LODCM   | 781.10000 |         ['L0'] |       ['L0', 'L2'] | Removed |
| mr1l3     | MR1L3       | 814.71600 |         ['L0'] |       ['L0', 'L3'] | Removed |
| sl3l0     | SL3L0:POWER | 815.86000 |         ['L0'] |             ['L0'] | Removed |
| mr1l4     | MR1L4       | 817.11600 |         ['L0'] | ['L0', 'L4', 'L5'] | Removed |
| xcs_lodcm | XCS:LODCM   | 964.76000 |         ['L0'] |       ['L0', 'L3'] | Removed |
| im5l0     | IM5L0:XTES  | 970.76000 |         ['L0'] |             ['L0'] | Removed |
| sl4l0     | SL4L0:POWER | 975.86000 |         ['L0'] |             ['L0'] | Removed |
| im6l0     | IM6L0:XTES  | 980.50000 |         ['L0'] |             ['L0'] | Removed |
+-----------+-------------+-----------+----------------+--------------------+---------+

In [3]: lc.beamlines['XPP'][1].show_devices()
+-----------+-------------+-----------+----------------+-----------------+---------+
| Name      | Prefix      |  Position | Input Branches | Output Branches |   State |
+-----------+-------------+-----------+----------------+-----------------+---------+
| im1l0     | IM1L0:XTES  | 699.50000 |         ['L0'] |          ['L0'] | Removed |
| sl1l0     | SL1L0:POWER | 705.86000 |         ['L0'] |          ['L0'] | Removed |
| im2l0     | IM2L0:XTES  | 715.50000 |         ['L0'] |          ['L0'] | Removed |
| mr1l0     | MR1L0       | 740.00000 |         ['L0'] |    ['L0', 'L1'] | Removed |
| im3l0     | IM3L0:XTES  | 749.50000 |         ['L0'] |          ['L0'] | Removed |
| im4l0     | IM4L0:XTES  | 755.50000 |         ['L0'] |          ['L0'] | Removed |
| sl2l0     | SL2L0:POWER | 755.86000 |         ['L0'] |          ['L0'] | Removed |
| xpp_lodcm | XPP:LODCM   | 781.10000 |         ['L0'] |    ['L0', 'L2'] | Removed |
| im1l2     | IM1L2:XTES  | 799.50000 |         ['L2'] |          ['L2'] | Removed |
| sl1l2     | SL1L2:POWER | 805.86000 |         ['L2'] |          ['L2'] | Removed |
| im2l2     | IM2L2:XTES  | 810.50000 |         ['L2'] |          ['L2'] | Removed |
+-----------+-------------+-----------+----------------+-----------------+---------+

Context

leftover from #133

Your Environment

pcds-5.4.1 + #133

tangkong commented 2 years ago

closed by #142