Skip to content

Commit c78abcb

Browse files
committed
refactored expose method
1 parent 4db5cfc commit c78abcb

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

pyobs_flipro/fliprocamera.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,8 @@ async def _expose(self, exposure_time: float, open_shutter: bool, abort_event: a
128128
# start exposure
129129
self._driver.start_exposure()
130130

131-
# wait for exposure to finish
132-
while not self._driver.is_available():
133-
# aborted?
134-
if abort_event.is_set():
135-
await self._change_exposure_status(ExposureStatus.IDLE)
136-
raise InterruptedError("Aborted exposure.")
137-
138-
# sleep a little
139-
await asyncio.sleep(0.01)
131+
# wait exposure
132+
await self._wait_exposure(abort_event, exposure_time)
140133

141134
# readout
142135
log.info("Exposure finished, reading out...")
@@ -177,6 +170,23 @@ async def _expose(self, exposure_time: float, open_shutter: bool, abort_event: a
177170
log.info("Readout finished.")
178171
return image
179172

173+
async def _wait_exposure(self, abort_event: asyncio.Event, exposure_time: float) -> None:
174+
"""Wait for exposure to finish.
175+
176+
Params:
177+
abort_event: Event that aborts the exposure.
178+
exposure_time: Exp time in sec.
179+
"""
180+
# wait for exposure to finish
181+
while not self._driver.is_available():
182+
# aborted?
183+
if abort_event.is_set():
184+
await self._change_exposure_status(ExposureStatus.IDLE)
185+
raise InterruptedError("Aborted exposure.")
186+
187+
# sleep a little
188+
await asyncio.sleep(0.01)
189+
180190
async def _abort_exposure(self) -> None:
181191
"""Abort the running exposure. Should be implemented by derived class.
182192

0 commit comments

Comments
 (0)