pcdshub / lightpath

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

MAINT: Handle faulty devices #62

Closed teddyrendahl closed 6 years ago

teddyrendahl commented 6 years ago

Description

The lightpath wasn't suitably protected against faulty devices. Many of the methods shamelessly called device.inserted e.t.c not accepting that these usually involve Channel Access calls that are liable to fail. Now, we only ask for device information in find_device_state. This returns a DeviceState enum that describes the state. This helps limit the number of Channel Access calls and in turn uniformly handle when these things fail.

Motivation and Context

Closes #61

How Has This Been Tested?

Added a test for a broken device

codecov-io commented 6 years ago

Codecov Report

Merging #62 into master will increase coverage by 0.99%. The diff coverage is 89.18%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #62      +/-   ##
==========================================
+ Coverage   86.73%   87.73%   +0.99%     
==========================================
  Files           7        7              
  Lines         407      432      +25     
==========================================
+ Hits          353      379      +26     
+ Misses         54       53       -1
Impacted Files Coverage Δ
lightpath/path.py 85.11% <89.18%> (+3.3%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 79e2ddc...54fd606. Read the comment docs.

ZLLentz commented 6 years ago

btw the assigned tab still has me there after the review, so mission accomplished

teddyrendahl commented 6 years ago

Alright. Per discussion here and offilne, I launched the whole gambit of states. DeviceState now is very specific about what we know about the device.

    Removed:
        Device is removed from the beamline.

    Inserted:
        Device is inserted into the beamline. This may or may not prevent beam
        from reaching downstream devices.

    Unknown:
        Device is reporting neither an inserted or removed state.

    Inconsistent:
        The device is reporting that is both inserted and removed.

    Disconnected:
        We were unable to determine the state of the device because one or more
        of the relevant signals was not available.

    Error:
        Catch-all state for any errors the device reported when asked for its
        state that were not simply a failure to communicate with signals
ZLLentz commented 6 years ago

:+1: