bool QFW::SelectFilter(int position) { // count from 0 to 6 for positions 1 to 7 position = position - 1; if (position < 0 || position > 6) return false; if (isSimulation()) { CurrentFilter = position + 1; SelectFilterDone(CurrentFilter); return true; } // goto char targetpos[255]={0}; char curpos[255]={0}; int res; // format target position G[0-6] sprintf(targetpos, "G%d\r\n\n", position); // write command res = write(PortFD, targetpos, strlen(targetpos)); // format target marker P[0-6] sprintf(targetpos, "P%d\r\n", position); // check current position do { usleep(100 * 1000); res = read(PortFD, curpos, 255); curpos[res] = 0; } while (strncmp(targetpos, curpos, 2) != 0); // return current position to indi CurrentFilter = position + 1; SelectFilterDone(CurrentFilter); return true; }
void XAGYLWheel::TimerHit() { bool rc = getFilterPosition(); if (rc == false) { SetTimer(500); return; } if (CurrentFilter == TargetFilter) SelectFilterDone(CurrentFilter); else SetTimer(500); }
bool MICCD::SelectFilter(int position) { if (!isSimulation() && gxccd_set_filter(cameraHandle, position - 1) < 0) { char errorStr[MAX_ERROR_LEN]; gxccd_get_last_error(cameraHandle, errorStr, sizeof(errorStr)); LOGF_ERROR("Setting filter failed: %s.", errorStr); return false; } CurrentFilter = position; SelectFilterDone(position); LOGF_DEBUG("Filter changed to %d", position); return true; }
bool QHYCFW2::SelectFilter(int f) { TargetFilter = f; char cmd[8] = {0}, res[8]={0}; int rc = -1, nbytes_written=0, nbytes_read=0; LOGF_DEBUG("CMD <%d>", TargetFilter-1); snprintf(cmd, 2, "%d", TargetFilter-1); if (isSimulation()) snprintf(res, 8, "%d", TargetFilter-1); else { if ((rc = tty_write_string(PortFD, cmd, &nbytes_written)) != TTY_OK) { char error_message[ERRMSG_SIZE]; tty_error_msg(rc, error_message, ERRMSG_SIZE); LOGF_ERROR("Sending command select filter failed: %s", error_message); return false; } if ((rc = tty_read(PortFD, res, 1, 30, &nbytes_read)) != TTY_OK) { char error_message[ERRMSG_SIZE]; tty_error_msg(rc, error_message, ERRMSG_SIZE); LOGF_ERROR("Reading select filter response failed: %s", error_message); return false; } LOGF_DEBUG("RES <%s>", res); } if (atoi(res)+1 == TargetFilter) { CurrentFilter = TargetFilter; SelectFilterDone(CurrentFilter); return true; } return false; }
bool QHYCCD::SelectFilter(int position) { char targetpos; char currentpos[64]; int checktimes = 0; int ret; if (sim) ret = QHYCCD_SUCCESS; else { // JM: THIS WILL CRASH! I am using another method with same result! //sprintf(&targetpos,"%d",position - 1); targetpos = '0' + position; ret = SendOrder2QHYCCDCFW(camhandle,&targetpos,1); } if(ret == QHYCCD_SUCCESS) { while(checktimes < 90) { ret = GetQHYCCDCFWStatus(camhandle,currentpos); if(ret == QHYCCD_SUCCESS) { if((targetpos + 1) == currentpos[0]) { break; } } checktimes++; } CurrentFilter = position; SelectFilterDone(position); DEBUGF(INDI::Logger::DBG_DEBUG, "%s: Filter changed to %d", camid, position); return true; } else DEBUGF(INDI::Logger::DBG_ERROR, "Changing filter failed (%d)", ret); return false; }
bool CCDSim::SelectFilter(int f) { CurrentFilter = f; SelectFilterDone(f); }
bool QFW::SelectFilter(int position) { // count from 0 to 6 for positions 1 to 7 position = position - 1; if (position < 0 || position > 6) return false; if (isSimulation()) { CurrentFilter = position + 1; SelectFilterDone(CurrentFilter); return true; } // goto char targetpos[255]={0}; char curpos[255]={0}; char dmp[255]; int err; int nbytes; // format target position G[0-6] sprintf(targetpos, "G%d\r\n ", position); // write command //int len = strlen(targetpos); err = tty_write_string(PortFD, targetpos, &nbytes); if (err) { char errmsg[255]; tty_error_msg(err, errmsg, MAXRBUF); LOGF_ERROR("Serial write error: %s", errmsg); return false; } //res = write(PortFD, targetpos, len); dump(dmp, targetpos); LOGF_DEBUG("CMD: %s", dmp); // format target marker P[0-6] sprintf(targetpos, "P%d", position); // check current position do { usleep(100 * 1000); //res = read(PortFD, curpos, 255); err = tty_read_section(PortFD, curpos, '\n', QUANTUM_TIMEOUT, &nbytes); if (err) { char errmsg[255]; tty_error_msg(err, errmsg, MAXRBUF); LOGF_ERROR("Serial read error: %s", errmsg); return false; } curpos[nbytes] = 0; dump(dmp, curpos); LOGF_DEBUG("REP: %s", dmp); } while (strncmp(targetpos, curpos, 2) != 0); // return current position to indi CurrentFilter = position + 1; SelectFilterDone(CurrentFilter); LOGF_DEBUG("CurrentFilter set to %d", CurrentFilter); return true; }
void FilterSim::TimerHit() { SelectFilterDone(CurrentFilter); }
///////////////////////////////////////////////////////// /// Cooler & Filter Wheel monitoring ///////////////////////////////////////////////////////// void ATIKCCD::TimerHit() { double currentTemperature = TemperatureN[0].value; int flags, level, minlvl, maxlvl, setpoint; pthread_mutex_lock(&accessMutex); int rc = ArtemisCoolingInfo(hCam, &flags, &level, &minlvl, &maxlvl, &setpoint); pthread_mutex_unlock(&accessMutex); if (rc != ARTEMIS_OK) { LOGF_ERROR("Cooling Info inquiry failed (%d)", rc); genTimerID = SetTimer(TEMP_TIMER_MS); return; } LOGF_DEBUG("Cooling: flags (%d) level (%d), minlvl (%d), maxlvl (%d), setpoint (%d)", flags, level, minlvl, maxlvl, setpoint); int temperature = 0; pthread_mutex_lock(&accessMutex); rc = ArtemisTemperatureSensorInfo(hCam, 1, &temperature); pthread_mutex_unlock(&accessMutex); TemperatureN[0].value = temperature / 100.0; switch (TemperatureNP.s) { case IPS_IDLE: case IPS_OK: if (fabs(currentTemperature - TemperatureN[0].value) > TEMP_THRESHOLD / 10.0) { IDSetNumber(&TemperatureNP, nullptr); } break; case IPS_ALERT: break; case IPS_BUSY: // 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; } if (HasCooler()) { bool coolerChanged = false; double coolerPower = static_cast<double>(level) / maxlvl * 100.0; if (fabs(CoolerN[0].value - coolerPower) > 0.01) { CoolerN[0].value = coolerPower; coolerChanged = true; } // b5 0 = normal control 1=warming up // b6 0 = cooling off 1 = cooling on if (!(flags & 0x20) && // Normal Control? (flags & 0x40)) // Cooling On? { if (CoolerNP.s != IPS_BUSY) coolerChanged = true; CoolerNP.s = IPS_BUSY; } // Otherwise cooler is either warming up or not active else { if (CoolerNP.s != IPS_IDLE) coolerChanged = true; CoolerNP.s = IPS_IDLE; } if (coolerChanged) IDSetNumber(&CoolerNP, nullptr); } // If filter wheel is in motion if (FilterSlotNP.s == IPS_BUSY) { int numFilters, moving, currentPos, targetPos; pthread_mutex_lock(&accessMutex); int rc = ArtemisFilterWheelInfo(hCam, &numFilters, &moving, ¤tPos, &targetPos); pthread_mutex_unlock(&accessMutex); if (rc != ARTEMIS_OK) { LOGF_ERROR("Querying internal filter wheel failed (%d).", rc); } else { if (moving == 0 && currentPos == targetPos) { SelectFilterDone(currentPos + 1); } } } genTimerID = SetTimer(TEMP_TIMER_MS); }