bluesky / ophyd-async

Hardware abstraction for bluesky written using asyncio
https://blueskyproject.io/ophyd-async
BSD 3-Clause "New" or "Revised" License
7 stars 21 forks source link

Add helper function to observe multiple signals #402

Open DominicOram opened 2 weeks ago

DominicOram commented 2 weeks ago

In https://github.com/DiamondLightSource/hyperion/issues/1450 we had the usecase where we wanted to monitor multiple signals and raise under one condition or stop monitoring cleanly under another. To aid in this it would be good to have an ophyd-async helper that observed multiple signals and gave you any updates that occured e.g.

async def pin_mounted_or_no_pin_found(self):
      async for signal, value in observe_signals_value(self.error_code, self.goinio_pin_sensor):
          if signal is self.error_code and value == self.NO_PIN_ERROR_CODE:
              # We didn't get a pin
              raise RobotLoadFailed(self.NO_PIN_ERROR_CODE, "Pin was not detected")
          elif signal is self.goinio_pin_sensor and value == PinMounted.PIN_MOUNTED:
              # We did get a pin
              break
coretl commented 2 weeks ago

Do we also want to rename observe_value -> observe_signal_value to make them more consistent?