bool QHYCCD::StartExposure(float duration) { int ret = QHYCCD_ERROR; #ifndef OSX_EMBEDED_MODE if (streamer->isBusy()) { DEBUG(INDI::Logger::DBG_ERROR, "Cannot take exposure while streaming/recording is active."); return false; } #endif //AbortPrimaryFrame = false; if (duration < MINIMUM_CCD_EXPOSURE) { DEBUGF(INDI::Logger::DBG_WARNING, "Exposure shorter than minimum duration %g s requested. Setting exposure time to %g s.", duration, MINIMUM_CCD_EXPOSURE); duration = MINIMUM_CCD_EXPOSURE; } imageFrameType = PrimaryCCD.getFrameType(); if (imageFrameType == CCDChip::BIAS_FRAME) { duration = MINIMUM_CCD_EXPOSURE; DEBUGF(INDI::Logger::DBG_SESSION, "Bias Frame (s) : %g", duration); } else if(imageFrameType == CCDChip::DARK_FRAME) { ControlQHYCCDShutter(camhandle,MACHANICALSHUTTER_CLOSE); } else { ControlQHYCCDShutter(camhandle,MACHANICALSHUTTER_FREE); } DEBUGF(INDI::Logger::DBG_DEBUG, "Current exposure time is %f us",duration * 1000 * 1000); ExposureRequest = duration; PrimaryCCD.setExposureDuration(duration); if (sim) ret = QHYCCD_SUCCESS; else ret = SetQHYCCDParam(camhandle,CONTROL_EXPOSURE,ExposureRequest * 1000 * 1000); if(ret != QHYCCD_SUCCESS) { DEBUGF(INDI::Logger::DBG_ERROR, "Set expose time failed (%d).", ret); return false; } // lzr: we need to call the following apis every single exposure,the usleep(200000) is important if (sim) ret = QHYCCD_SUCCESS; else ret = SetQHYCCDBinMode(camhandle,camxbin,camybin); if(ret != QHYCCD_SUCCESS) { DEBUGF(INDI::Logger::DBG_SESSION, "Set QHYCCD Bin mode failed (%d)", ret); return false; } DEBUGF(INDI::Logger::DBG_DEBUG, "SetQHYCCDBinMode %dx%d", camxbin, camybin); if (sim) ret = QHYCCD_SUCCESS; else ret = SetQHYCCDResolution(camhandle,camroix,camroiy,camroiwidth,camroiheight); if(ret != QHYCCD_SUCCESS) { DEBUGF(INDI::Logger::DBG_SESSION, "Set QHYCCD ROI resolution failed (%d)", ret); return false; } DEBUGF(INDI::Logger::DBG_DEBUG, "SetQHYCCDResolution camroix %d camroiy %d camroiwidth %d camroiheight %d", camroix,camroiy,camroiwidth,camroiheight); // JM 2016-05-08: Some QHY cameras needs 200ms before you can exposure a frame. Asked QHY to try to minimize this! //usleep(200000); if (sim) ret = QHYCCD_SUCCESS; else ret = ExpQHYCCDSingleFrame(camhandle); if(ret == QHYCCD_ERROR) { DEBUGF(INDI::Logger::DBG_SESSION, "Begin QHYCCD expose failed (%d)", ret); return false; } gettimeofday(&ExpStart, NULL); DEBUGF(INDI::Logger::DBG_DEBUG, "Taking a %g seconds frame...", ExposureRequest); InExposure = true; // if (ExposureRequest*1000 < POLLMS) // SetTimer(ExposureRequest*1000); // else SetTimer(POLLMS); return true; }
bool QHYCCD::StartExposure(float duration) { unsigned int ret = QHYCCD_ERROR; if (Streamer->isBusy()) { DEBUG(INDI::Logger::DBG_ERROR, "Cannot take exposure while streaming/recording is active."); return false; } //AbortPrimaryFrame = false; /* if (duration < MINIMUM_CCD_EXPOSURE) { DEBUGF(INDI::Logger::DBG_WARNING, "Exposure shorter than minimum duration %g s requested. Setting exposure time to %g s.", duration, MINIMUM_CCD_EXPOSURE); duration = MINIMUM_CCD_EXPOSURE; }*/ imageFrameType = PrimaryCCD.getFrameType(); /*if (imageFrameType == CCDChip::BIAS_FRAME) { duration = MINIMUM_CCD_EXPOSURE; DEBUGF(INDI::Logger::DBG_SESSION, "Bias Frame (s) : %g", duration); } else*/ if (GetCCDCapability() & CCD_HAS_SHUTTER) { if (imageFrameType == INDI::CCDChip::DARK_FRAME || imageFrameType == INDI::CCDChip::BIAS_FRAME) ControlQHYCCDShutter(camhandle, MACHANICALSHUTTER_CLOSE); else ControlQHYCCDShutter(camhandle, MACHANICALSHUTTER_FREE); } DEBUGF(INDI::Logger::DBG_DEBUG, "Current exposure time is %f us", duration * 1000 * 1000); ExposureRequest = duration; PrimaryCCD.setExposureDuration(duration); if (sim) ret = QHYCCD_SUCCESS; else { if (LastExposureRequest != ExposureRequest) { ret = SetQHYCCDParam(camhandle, CONTROL_EXPOSURE, ExposureRequest * 1000 * 1000); if (ret != QHYCCD_SUCCESS) { DEBUGF(INDI::Logger::DBG_ERROR, "Set expose time failed (%d).", ret); return false; } LastExposureRequest = ExposureRequest; } } if (sim) ret = QHYCCD_SUCCESS; else ret = SetQHYCCDBinMode(camhandle, camxbin, camybin); if (ret != QHYCCD_SUCCESS) { DEBUGF(INDI::Logger::DBG_SESSION, "Set QHYCCD Bin mode failed (%d)", ret); return false; } DEBUGF(INDI::Logger::DBG_DEBUG, "SetQHYCCDBinMode (%dx%d).", camxbin, camybin); if (sim) ret = QHYCCD_SUCCESS; else ret = SetQHYCCDResolution(camhandle, camroix, camroiy, camroiwidth, camroiheight); if (ret != QHYCCD_SUCCESS) { DEBUGF(INDI::Logger::DBG_SESSION, "Set QHYCCD ROI resolution (%d,%d) (%d,%d) failed (%d)", camroix, camroiy, camroiwidth, camroiheight, ret); return false; } DEBUGF(INDI::Logger::DBG_DEBUG, "SetQHYCCDResolution camroix %d camroiy %d camroiwidth %d camroiheight %d", camroix, camroiy, camroiwidth, camroiheight); if (sim) ret = QHYCCD_SUCCESS; else ret = ExpQHYCCDSingleFrame(camhandle); if (ret == QHYCCD_ERROR) { DEBUGF(INDI::Logger::DBG_SESSION, "Begin QHYCCD expose failed (%d)", ret); return false; } gettimeofday(&ExpStart, NULL); DEBUGF(INDI::Logger::DBG_DEBUG, "Taking a %g seconds frame...", ExposureRequest); InExposure = true; // if (ExposureRequest*1000 < POLLMS) // SetTimer(ExposureRequest*1000); // else SetTimer(POLLMS); return true; }
bool QHYCCD::StartExposure(float duration) { int ret = QHYCCD_ERROR; if (streamer->isBusy()) { DEBUG(INDI::Logger::DBG_ERROR, "Cannot take exposure while streaming/recording is active."); return false; } //AbortPrimaryFrame = false; if (duration < MINIMUM_CCD_EXPOSURE) { DEBUGF(INDI::Logger::DBG_WARNING, "Exposure shorter than minimum duration %g s requested. Setting exposure time to %g s.", duration, MINIMUM_CCD_EXPOSURE); duration = MINIMUM_CCD_EXPOSURE; } imageFrameType = PrimaryCCD.getFrameType(); if (imageFrameType == CCDChip::BIAS_FRAME) { duration = MINIMUM_CCD_EXPOSURE; DEBUGF(INDI::Logger::DBG_SESSION, "Bias Frame (s) : %g", duration); } else if(imageFrameType == CCDChip::DARK_FRAME) { ControlQHYCCDShutter(camhandle,MACHANICALSHUTTER_CLOSE); } else { ControlQHYCCDShutter(camhandle,MACHANICALSHUTTER_FREE); } DEBUGF(INDI::Logger::DBG_DEBUG, "Current exposure time is %f us",duration * 1000 * 1000); ExposureRequest = duration; PrimaryCCD.setExposureDuration(duration); if (sim) ret = QHYCCD_SUCCESS; else ret = SetQHYCCDParam(camhandle,CONTROL_EXPOSURE,ExposureRequest * 1000 * 1000); if(ret != QHYCCD_SUCCESS) { DEBUGF(INDI::Logger::DBG_ERROR, "Set expose time failed (%d).", ret); return false; } // lzr: we need to call the following apis every single exposure,the usleep(200000) is important if (sim) ret = QHYCCD_SUCCESS; else ret = SetQHYCCDBinMode(camhandle,camxbin,camybin); if(ret != QHYCCD_SUCCESS) { DEBUGF(INDI::Logger::DBG_SESSION, "Set QHYCCD Bin mode failed (%d)", ret); return false; } DEBUGF(INDI::Logger::DBG_DEBUG, "SetQHYCCDBinMode %dx%d", camxbin, camybin); if (sim) ret = QHYCCD_SUCCESS; else ret = SetQHYCCDResolution(camhandle,camroix,camroiy,camroiwidth,camroiheight); if(ret != QHYCCD_SUCCESS) { DEBUGF(INDI::Logger::DBG_SESSION, "Set QHYCCD ROI resolution failed (%d)", ret); return false; } DEBUGF(INDI::Logger::DBG_DEBUG, "SetQHYCCDResolution camroix %d camroiy %d camroiwidth %d camroiheight %d", camroix,camroiy,camroiwidth,camroiheight); // Jasem: Removed QHY 300ms delay that was added without specifying the reason. It seems any delay less than 100ms results in QHY Frame error. Again no reason. This renders // exposures less than 100ms useless, but there is nothing I can do about that. usleep(100000); if (sim) ret = QHYCCD_SUCCESS; else ret = ExpQHYCCDSingleFrame(camhandle); if(ret != QHYCCD_SUCCESS) { DEBUGF(INDI::Logger::DBG_SESSION, "Begin QHYCCD expose failed (%d)", ret); return false; } gettimeofday(&ExpStart, NULL); DEBUGF(INDI::Logger::DBG_DEBUG, "Taking a %g seconds frame...", ExposureRequest); InExposure = true; // if (ExposureRequest*1000 < POLLMS) // SetTimer(ExposureRequest*1000); // else SetTimer(POLLMS); return true; }