def resetCams(self, curTime, cameras, table): resetEndTime = curTime for camera in cameras: exposureStart = max(curTime, self.getTimeWhenCameraCanExpose(table, camera)) # Cameras that have a pre-set exposure time can only use that # exposure time for clearing the sensor, hence why we take the # maximum of the min exposure time and the current exposure time. # \todo Is it possible for getExposureTime() to be less than # getMinExposureTime()? That would be a bug, right? minExposureTime = max(decimal.Decimal('.1'), camera.getMinExposureTime(isExact=True), camera.getExposureTime(isExact=True)) exposureMode = camera.getExposureMode() if exposureMode == cockpit.handlers.camera.TRIGGER_AFTER: table.addToggle(exposureStart + minExposureTime, camera) elif exposureMode == cockpit.handlers.camera.TRIGGER_DURATION: table.addAction(exposureStart, camera, True) table.addAction(exposureStart + minExposureTime, camera, False) else: # TRIGGER_BEFORE case table.addToggle(exposureStart, camera) resetEndTime = max(resetEndTime, exposureStart + minExposureTime) self.cameraToImageCount[camera] += 1 self.cameraToIgnoredImageIndices[camera].add( self.cameraToImageCount[camera]) self.cameraToIsReady[camera] = True return resetEndTime + decimal.Decimal('1e-6')
def getTimeWhenCameraCanExpose(self, table, camera): lastUseTime, action = table.getLastActionFor(camera) if lastUseTime is None: # No actions yet; assume camera is ready at the start of the # experiment. return 0 nextUseTime = lastUseTime if camera.getExposureMode() == cockpit.handlers.camera.TRIGGER_BEFORE: # The camera actually finished exposing (and started reading # out) some time after lastUseTime, depending on its declared # exposure time. nextUseTime += camera.getExposureTime(isExact=True) nextUseTime += self.cameraToReadoutTime[camera] + decimal.Decimal(0.1) return nextUseTime