/************************************************************************************** ** Main device loop. We check for capture progress here ***************************************************************************************/ void RadioSim::TimerHit() { long timeleft; if (isConnected() == false) return; // No need to reset timer if we are not connected anymore if (InCapture) { timeleft = CalcTimeLeft(); if(timeleft < 0.1) { /* We're done capturing */ LOG_INFO("Capture done, downloading data..."); grabData(); InCapture = false; timeleft = 0.0; } // This is an over simplified timing method, check DetectorSimulator and rtlsdrDetector for better timing checks PrimaryDetector.setCaptureLeft(timeleft); } double value = (DetectorCoordsN[0].value + (360.0 / SIDEREAL_DAY) * POLLMS / 1000.0); if (value >= FOV_DEG) value -= FOV_DEG; Ra = value; DetectorCoordsN[0].value = Ra; IDSetNumber(&DetectorCoordsNP, nullptr); SetTimer(POLLMS); return; }
/************************************************************************************** ** Main device loop. We check for exposure progress ***************************************************************************************/ void FFMVCCD::TimerHit() { long timeleft; if(isConnected() == false) { return; // No need to reset timer if we are not connected anymore } if (InExposure) { timeleft=CalcTimeLeft(); // Less than a 0.1 second away from exposure completion // This is an over simplified timing method, check CCDSimulator and ffmvCCD for better timing checks if (timeleft < 0.1) { /* We're done exposing */ IDMessage(getDeviceName(), "Exposure done, downloading image..."); // Set exposure left to zero PrimaryCCD.setExposureLeft(0); // We're no longer exposing... InExposure = false; /* grab and save image */ grabImage(); } else { // Just update time left in client PrimaryCCD.setExposureLeft(timeleft); } } SetTimer(POLLMS); return; }
bool RollOff::getFullClosedLimitSwitch() { double timeleft = CalcTimeLeft(MotionStart); if (timeleft <= 0) { fullClosedLimitSwitch = ISS_ON; return true; } else return false; }
void FocusMaster::TimerHit() { if (!isConnected()) return; //uint32_t currentTicks = 0; if (FocusTimerNP.s == IPS_BUSY) { float remaining = CalcTimeLeft(focusMoveStart, focusMoveRequest); if (remaining <= 0) { FocusTimerNP.s = IPS_OK; FocusTimerN[0].value = 0; AbortFocuser(); } else FocusTimerN[0].value = remaining * 1000.0; IDSetNumber(&FocusTimerNP, nullptr); } #if 0 bool rc = getPosition(¤tTicks); if (rc) FocusAbsPosN[0].value = currentTicks; if (FocusAbsPosNP.s == IPS_BUSY || FocusRelPosNP.s == IPS_BUSY) { if (targetPosition == FocusAbsPosN[0].value) { if (FocusRelPosNP.s == IPS_BUSY) { FocusRelPosNP.s = IPS_OK; IDSetNumber(&FocusRelPosNP, nullptr); } FocusAbsPosNP.s = IPS_OK; LOG_DEBUG("Focuser reached target position."); } } IDSetNumber(&FocusAbsPosNP, nullptr); #endif SetTimer(POLLMS); }
/******************************************************************************* ** Main device loop. We check for exposure progress *******************************************************************************/ void DSICCD::TimerHit() { long timeleft; if(isConnected() == false) { return; // No need to reset timer if we are not connected anymore } if (InExposure) { timeleft=CalcTimeLeft(); /* Exposure control has been changed to ensure stable operation for short exposures as well as for long exposures (gs) */ if (!dsi->ExposureInProgress()) { /* We're done exposing */ DEBUG(INDI::Logger::DBG_SESSION, "Exposure done, downloading image..."); // Set exposure left to zero PrimaryCCD.setExposureLeft(0); // We're no longer exposing... InExposure = false; /* grab and save image */ grabImage(); /* update temperature as measured after exposure (gs) Attention: no continous temperature update, we always diplay temperature for last exposure (interesting for matching darks) */ if (dsi->hasTempSensor()) { CCDTempN[0].value = dsi->ccdTemp(); IDSetNumber(&CCDTempNP, NULL); } } else { // Just update time left in client PrimaryCCD.setExposureLeft(timeleft); } } SetTimer(POLLMS); return; }
/************************************************************************************** ** Main device loop. We check for capture progress here ***************************************************************************************/ void RadioSim::TimerHit() { long timeleft; if (isConnected() == false) return; // No need to reset timer if we are not connected anymore if (InCapture) { timeleft = CalcTimeLeft(); if(timeleft < 0.1) { /* We're done capturing */ LOG_INFO("Capture done, downloading data..."); timeleft = 0.0; grabData(); } // This is an over simplified timing method, check DetectorSimulator and rtlsdrDetector for better timing checks PrimaryDetector.setCaptureLeft(timeleft); } SetTimer(POLLMS); return; }
/************************************************************************************** ** Main device loop. We check for exposure and temperature progress here ***************************************************************************************/ void INovaCCD::TimerHit() { long timeleft; if(isConnected() == false) return; // No need to reset timer if we are not connected anymore if (InExposure) { timeleft = CalcTimeLeft(); // Less than a 0.1 second away from exposure completion // This is an over simplified timing method, check CCDSimulator and inova for better timing checks if(timeleft >= 0.0) { // Just update time left in client PrimaryCCD.setExposureLeft(timeleft); } else { /* We're done exposing */ LOG_INFO("Exposure done, downloading image..."); RawData = (unsigned char*)iNovaSDK_GrabFrame(); if(RawData != nullptr) { // We're no longer exposing... InExposure = false; grabImage(); } } } SetTimer(POLLMS); return; }
void GPhotoCCD::TimerHit() { long timeleft=1e6; int timerID=-1; if (isConnected() == false) return; if (livePreviewSP.s == IPS_BUSY) { bool rc = capturePreview(); if (rc) timerID = SetTimer(STREAMPOLLMS); else { livePreviewSP.s = IPS_ALERT; DEBUG(INDI::Logger::DBG_ERROR, "Error capturing preview."); livePreviewS[0].s = ISS_OFF; livePreviewS[1].s = ISS_ON; IDSetSwitch(&livePreviewSP, NULL); } } if (FocusTimerNP.s == IPS_BUSY) { char errMsg[MAXRBUF]; if ( gphoto_manual_focus(gphotodrv, focusSpeed, errMsg) != GP_OK) { DEBUGF(INDI::Logger::DBG_ERROR, "Focusing failed: %s", errMsg); FocusTimerNP.s = IPS_ALERT; FocusTimerN[0].value = 0 ; } else { FocusTimerN[0].value -= FOCUS_TIMER; if (FocusTimerN[0].value <= 0) { FocusTimerN[0].value = 0; FocusTimerNP.s = IPS_OK; } else if (timerID == -1) timerID = SetTimer(FOCUS_TIMER); } IDSetNumber(&FocusTimerNP, NULL); } if (InExposure) { timeleft = CalcTimeLeft(); if (timeleft < 1.0) { if (timeleft > 0.25 && timerID == -1) { // a quarter of a second or more // just set a tighter timer timerID = SetTimer(250); } else { if (timeleft > 0.07 && timerID == -1) { // use an even tighter timer timerID = SetTimer(50); } else { // it's real close now, so spin on it while (!sim && timeleft > 0) { int slv; slv = 100000 * timeleft; usleep(slv); } PrimaryCCD.setExposureLeft(0); InExposure = false; /* grab and save image */ bool rc = grabImage(); if (rc == false) { PrimaryCCD.setExposureFailed(); } } } } else { DEBUGF(INDI::Logger::DBG_DEBUG, "Capture in progress. Time left %ld", timeleft); if (timerID == -1) SetTimer(POLLMS); } PrimaryCCD.setExposureLeft(timeleft); } }
void QSICCD::TimerHit() { long timeleft; double ccdTemp; double coolerPower; if(isConnected() == false) return; // No need to reset timer if we are not connected anymore if (InExposure) { bool imageReady; timeleft=CalcTimeLeft(ExpStart, ExposureRequest); if (timeleft < 1) { QSICam.get_ImageReady(&imageReady); while (!imageReady) { usleep(100); QSICam.get_ImageReady(&imageReady); } /* We're done exposing */ DEBUG(INDI::Logger::DBG_SESSION, "Exposure done, downloading image..."); PrimaryCCD.setExposureLeft(0); InExposure = false; /* grab and save image */ grabImage(); } else { DEBUGF(INDI::Logger::DBG_DEBUG, "Image not ready, time left %ld\n", timeleft); PrimaryCCD.setExposureLeft(timeleft); } } switch (TemperatureNP.s) { case IPS_IDLE: case IPS_OK: try { QSICam.get_CCDTemperature(&ccdTemp); } catch (std::runtime_error err) { TemperatureNP.s = IPS_IDLE; DEBUGF(INDI::Logger::DBG_ERROR, "get_CCDTemperature() failed. %s.", err.what()); IDSetNumber(&TemperatureNP, NULL); return; } if (fabs(TemperatureN[0].value - ccdTemp) >= TEMP_THRESHOLD) { TemperatureN[0].value = ccdTemp; IDSetNumber(&TemperatureNP, NULL); } break; case IPS_BUSY: try { QSICam.get_CCDTemperature(&TemperatureN[0].value); } catch (std::runtime_error err) { TemperatureNP.s = IPS_ALERT; DEBUGF(INDI::Logger::DBG_ERROR, "get_CCDTemperature() failed. %s.", err.what()); IDSetNumber(&TemperatureNP, NULL); return; } if (fabs(TemperatureN[0].value - targetTemperature) <= TEMP_THRESHOLD) TemperatureNP.s = IPS_OK; IDSetNumber(&TemperatureNP, NULL); break; case IPS_ALERT: break; } switch (CoolerNP.s) { case IPS_IDLE: case IPS_OK: try { QSICam.get_CoolerPower(&coolerPower); } catch (std::runtime_error err) { CoolerNP.s = IPS_IDLE; DEBUGF(INDI::Logger::DBG_ERROR, "get_CoolerPower() failed. %s.", err.what()); IDSetNumber(&CoolerNP, NULL); return; } if (CoolerN[0].value != coolerPower) { CoolerN[0].value = coolerPower; IDSetNumber(&CoolerNP, NULL); } if (coolerPower > 0) CoolerNP.s = IPS_BUSY; break; case IPS_BUSY: try { QSICam.get_CoolerPower(&coolerPower); } catch (std::runtime_error err) { CoolerNP.s = IPS_ALERT; DEBUGF(INDI::Logger::DBG_ERROR, "get_CoolerPower() failed. %s.", err.what()); IDSetNumber(&CoolerNP, NULL); return; } if (coolerPower == 0) CoolerNP.s = IPS_IDLE; CoolerN[0].value = coolerPower; IDSetNumber(&CoolerNP, NULL); break; case IPS_ALERT: break; } SetTimer(POLLMS); return; }
void FishCampCCD::TimerHit() { int timerHitID = -1, state = -1, rc = -1; float timeleft; double ccdTemp; if (!isConnected()) return; // No need to reset timer if we are not connected anymore if (InExposure) { timeleft = CalcTimeLeft(); if (timeleft < 1.0) { if (timeleft > 0.25) { // a quarter of a second or more // just set a tighter timer timerHitID = SetTimer(250); } else { if (timeleft > 0.07) { // use an even tighter timer timerHitID = SetTimer(50); } else { // it's real close now, so spin on it // We have to wait till the camera is ready to download bool ready = false; int slv; slv = fabs(100000 * timeleft); //0.05s (50000 us) is checked every 5000 us or so while (!sim && !ready) { state = fcUsb_cmd_getState(cameraNum); if (state == 0) ready = true; else usleep(slv); } /* We're done exposing */ LOG_DEBUG("Exposure done, downloading image..."); PrimaryCCD.setExposureLeft(0); InExposure = false; /* grab and save image */ grabImage(); } } } else { LOGF_DEBUG("Image not yet ready. With time left %ld\n", timeleft); PrimaryCCD.setExposureLeft(timeleft); } } switch (TemperatureNP.s) { case IPS_IDLE: case IPS_OK: rc = fcUsb_cmd_getTemperature(cameraNum); LOGF_DEBUG("fcUsb_cmd_getTemperature returns %d", rc); ccdTemp = rc / 100.0; LOGF_DEBUG("Temperature %g", ccdTemp); if (fabs(TemperatureN[0].value - ccdTemp) >= TEMP_THRESHOLD) { TemperatureN[0].value = ccdTemp; IDSetNumber(&TemperatureNP, nullptr); } break; case IPS_BUSY: if (sim) { TemperatureN[0].value = TemperatureRequest; } else { rc = fcUsb_cmd_getTemperature(cameraNum); LOGF_DEBUG("fcUsb_cmd_getTemperature returns %d", rc); TemperatureN[0].value = rc / 100.0; } // If we're within threshold, let's make it BUSY ---> OK if (fabs(TemperatureRequest - TemperatureN[0].value) <= TEMP_THRESHOLD) TemperatureNP.s = IPS_OK; IDSetNumber(&TemperatureNP, nullptr); break; case IPS_ALERT: break; } switch (CoolerNP.s) { case IPS_OK: CoolerN[0].value = fcUsb_cmd_getTECPowerLevel(cameraNum); IDSetNumber(&CoolerNP, nullptr); LOGF_DEBUG("Cooler power level %g %", CoolerN[0].value); break; default: break; } if (timerHitID == -1) SetTimer(POLLMS); return; }
/************************************************************************************** ** Main device loop. We check for exposure and temperature progress here ***************************************************************************************/ void SimpleDetector::TimerHit() { long timeleft; if (!isConnected()) return; // No need to reset timer if we are not connected anymore if (InCapture) { timeleft = CalcTimeLeft(); // Less than a 0.1 second away from exposure completion // This is an over simplified timing method, check DetectorSimulator and simpleDetector for better timing checks if (timeleft < 0.1) { /* We're done exposing */ IDMessage(getDeviceName(), "Capture done, downloading image..."); // Set exposure left to zero PrimaryDetector.setCaptureLeft(0); // We're no longer exposing... InCapture = false; /* grab and save image */ grabFrame(); } else // Just update time left in client PrimaryDetector.setCaptureLeft(timeleft); } // TemperatureNP is defined in INDI::Detector switch (TemperatureNP.s) { case IPS_IDLE: case IPS_OK: break; case IPS_BUSY: /* If target temperature is higher, then increase current Detector temperature */ if (currentDetectorTemperature < TemperatureRequest) currentDetectorTemperature++; /* If target temperature is lower, then decrese current Detector temperature */ else if (currentDetectorTemperature > TemperatureRequest) currentDetectorTemperature--; /* If they're equal, stop updating */ else { TemperatureNP.s = IPS_OK; IDSetNumber(&TemperatureNP, "Target temperature reached."); break; } IDSetNumber(&TemperatureNP, nullptr); break; case IPS_ALERT: break; } SetTimer(POLLMS); }
void CCDSim::TimerHit() { int nexttimer=1000; if(isConnected() == false) return; // No need to reset timer if we are not connected anymore if(InExposure) { if (AbortPrimaryFrame) { InExposure = false; AbortPrimaryFrame = false; } else { float timeleft; timeleft=CalcTimeLeft(ExpStart,ExposureRequest); //IDLog("CCD Exposure left: %g - Requset: %g\n", timeleft, ExposureRequest); if (timeleft < 0) timeleft = 0; PrimaryCCD.setExposureLeft(timeleft); if(timeleft < 1.0) { if(timeleft <= 0.001) { InExposure=false; ExposureComplete(&PrimaryCCD); } else { nexttimer=timeleft*1000; // set a shorter timer } } } } if(InGuideExposure) { float timeleft; timeleft=CalcTimeLeft(GuideExpStart,GuideExposureRequest); //IDLog("GUIDE Exposure left: %g - Requset: %g\n", timeleft, GuideExposureRequest); if (timeleft < 0) timeleft = 0; //ImageExposureN[0].value = timeleft; //IDSetNumber(ImageExposureNP, NULL); GuideCCD.setExposureLeft(timeleft); if(timeleft < 1.0) { if(timeleft <= 0.001) { InGuideExposure=false; if(!AbortGuideFrame) { //IDLog("Sending guider frame\n"); ExposureComplete(&GuideCCD); if(InGuideExposure) { // the call to complete triggered another exposure timeleft=CalcTimeLeft(GuideExpStart,GuideExposureRequest); if(timeleft <1.0) { nexttimer=timeleft*1000; } } } else { IDLog("Not sending guide frame cuz of abort\n"); } AbortGuideFrame=false; } else { nexttimer=timeleft*1000; // set a shorter timer } } } SetTimer(nexttimer); return; }
void FishCampCCD::TimerHit() { int timerHitID = -1, state = -1, rc = -1; long timeleft; double ccdTemp; if (isConnected() == false) return; // No need to reset timer if we are not connected anymore if (InExposure) { timeleft = CalcTimeLeft(); if (timeleft < 1.0) { if (timeleft > 0.25) { // a quarter of a second or more // just set a tighter timer timerHitID = SetTimer(250); } else { if (timeleft > 0.07) { // use an even tighter timer timerHitID = SetTimer(50); } else { // it's real close now, so spin on it while (!sim && timeleft > 0) { state = fcUsb_cmd_getState(cameraNum); if (state == 0) timeleft = 0; int slv; slv = 100000 * timeleft; usleep(slv); } /* We're done exposing */ DEBUG(INDI::Logger::DBG_DEBUG, "Exposure done, downloading image..."); PrimaryCCD.setExposureLeft(0); InExposure = false; /* grab and save image */ grabImage(); } } } else { DEBUGF(INDI::Logger::DBG_DEBUG, "Image not yet ready. With time left %ld\n", timeleft); } PrimaryCCD.setExposureLeft(timeleft); } switch (TemperatureNP.s) { case IPS_IDLE: case IPS_OK: rc = fcUsb_cmd_getTemperature(cameraNum); DEBUGF(INDI::Logger::DBG_DEBUG, "fcUsb_cmd_getTemperature returns %d", rc); ccdTemp = rc / 100.0; DEBUGF(INDI::Logger::DBG_DEBUG, "Temperature %g", ccdTemp); if (fabs(TemperatureN[0].value - ccdTemp) >= TEMP_THRESHOLD) { TemperatureN[0].value = ccdTemp; IDSetNumber(&TemperatureNP, NULL); } break; case IPS_BUSY: if (sim) { TemperatureN[0].value = TemperatureRequest; } else { rc = fcUsb_cmd_getTemperature(cameraNum); DEBUGF(INDI::Logger::DBG_DEBUG, "fcUsb_cmd_getTemperature returns %d", rc); TemperatureN[0].value = rc / 100.0; } // If we're within threshold, let's make it BUSY ---> OK if (fabs(TemperatureRequest - TemperatureN[0].value) <= TEMP_THRESHOLD) TemperatureNP.s = IPS_OK; IDSetNumber(&TemperatureNP, NULL); break; case IPS_ALERT: break; } switch (CoolerNP.s) { case IPS_OK: CoolerN[0].value = fcUsb_cmd_getTECPowerLevel(cameraNum); IDSetNumber(&CoolerNP, NULL); DEBUGF(INDI::Logger::DBG_DEBUG, "Cooler power level %g %", CoolerN[0].value); break; default: break; } if (timerHitID == -1) SetTimer(POLLMS); return; }