Exemple #1
0
int QSICCD::SetTemperature(double temperature)
{
    bool canSetTemp;
    try
    {
        QSICam.get_CanSetCCDTemperature(&canSetTemp);
    }
    catch (std::runtime_error err)
    {
        DEBUGF(INDI::Logger::DBG_ERROR, "CanSetCCDTemperature() failed. %s.", err.what());
        return -1;
    }

    if (!canSetTemp)
    {
        DEBUG(INDI::Logger::DBG_SESSION, "Cannot set CCD temperature, CanSetCCDTemperature == false\n");
        return -1;
    }

    targetTemperature = temperature;

    // If less than 0.1 of a degree, let's just return OK
    if (fabs(temperature - TemperatureN[0].value) < 0.1)
        return 1;

    activateCooler(true);

    try
    {
        QSICam.put_SetCCDTemperature(temperature);
    }
    catch (std::runtime_error err)
    {
        DEBUGF(INDI::Logger::DBG_ERROR, "put_SetCCDTemperature() failed. %s.", err.what());
        return -1;
    }

    DEBUGF(INDI::Logger::DBG_SESSION, "Setting CCD temperature to %+06.2f C", temperature);
    return 0;
}
Exemple #2
0
int ASICCD::SetTemperature(double temperature)
{
    // If there difference, for example, is less than 0.1 degrees, let's immediately return OK.
    if (fabs(temperature - TemperatureN[0].value) < TEMP_THRESHOLD)
        return 1;

    if (activateCooler(true) == false)
    {
        DEBUG(INDI::Logger::DBG_ERROR, "Failed to activate cooler!");
        return -1;
    }

    if (ASISetControlValue(m_camInfo->CameraID, ASI_TARGET_TEMP, temperature, ASI_TRUE) != ASI_SUCCESS)
    {
        DEBUG(INDI::Logger::DBG_ERROR, "Failed to set temperature!");
        return -1;
    }

    // Otherwise, we set the temperature request and we update the status in TimerHit() function.
    TemperatureRequest = temperature;
    DEBUGF(INDI::Logger::DBG_SESSION, "Setting CCD temperature to %+06.2f C", temperature);
    return 0;
}
Exemple #3
0
int ATIKCCD::SetTemperature(double temperature)
{
    // If there difference, for example, is less than 0.1 degrees, let's immediately return OK.
    if (fabs(temperature - TemperatureN[0].value) < TEMP_THRESHOLD)
        return 1;

    // setpoint is int 1/100 of a degree C.
    int setpoint = static_cast<int>(temperature * 100);

    int rc = ArtemisSetCooling(hCam, setpoint);
    if (rc != ARTEMIS_OK)
    {
        LOGF_ERROR("Failed to set temperature (%d).", rc);
        return -1;
    }

    // Otherwise, we set the temperature request and we update the status in TimerHit() function.
    TemperatureRequest = temperature;
    LOGF_INFO("Setting CCD temperature to %+06.2f C", temperature);

    activateCooler(true);

    return 0;
}
Exemple #4
0
bool ASICCD::ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n)
{
    ASI_ERROR_CODE errCode = ASI_SUCCESS;

    if(!strcmp(dev,getDeviceName()))
    {
        if (!strcmp(name, ControlSP.name))
        {
           IUUpdateSwitch(&ControlSP, states, names, n);

           for (int i=0; i < ControlSP.nsp; i++)
           {
               ASI_CONTROL_TYPE swType = *((ASI_CONTROL_TYPE *) ControlS[i].aux);
               ASI_BOOL swAuto = (ControlS[i].s == ISS_ON) ? ASI_TRUE : ASI_FALSE;

               for (int j=0; j < ControlNP.nnp; j++)
               {
                   ASI_CONTROL_TYPE nType = *((ASI_CONTROL_TYPE *) ControlN[j].aux0);

                   if (swType == nType)
                   {
                        DEBUGF(INDI::Logger::DBG_DEBUG, "ISNewSwitch->SetControlValue %d %.2f", nType, ControlN[j].value);
                       if ( (errCode = ASISetControlValue(m_camInfo->CameraID, nType, ControlN[j].value, swAuto )) != ASI_SUCCESS)
                       {
                           DEBUGF(INDI::Logger::DBG_ERROR, "ASISetControlValue (%s=%g) error (%d)", ControlN[j].name, ControlN[j].value, errCode);
                           ControlNP.s = IPS_ALERT;
                           ControlSP.s = IPS_ALERT;
                           IDSetNumber(&ControlNP, NULL);
                           IDSetSwitch(&ControlSP, NULL);
                           return false;
                       }

                       *((ASI_BOOL *) ControlN[j].aux1) = swAuto;
                       break;

                   }
               }
           }

           ControlSP.s = IPS_OK;
           IDSetSwitch(&ControlSP, NULL);
           return true;

        }

        /* Cooler */
       if (!strcmp (name, CoolerSP.name))
       {
         if (IUUpdateSwitch(&CoolerSP, states, names, n) < 0)
             return false;

         bool rc=false;

         if (CoolerS[0].s == ISS_ON)
           activateCooler(true);
         else
           activateCooler(false);

         return true;
       }

        if (!strcmp(name, VideoFormatSP.name))
        {
            #if !defined(OSX_EMBEDED_MODE) && !defined(__CYGWIN__)
            if (streamer->isBusy())
            {
                VideoFormatSP.s = IPS_ALERT;
                DEBUG(INDI::Logger::DBG_ERROR, "Cannot change format while streaming/recording.");
                IDSetSwitch(&VideoFormatSP, NULL);
                return true;
            }
            #endif

            IUUpdateSwitch(&VideoFormatSP, states, names, n);

            ASI_IMG_TYPE type = getImageType();

            switch (type)
            {
                case ASI_IMG_RAW16:
                    PrimaryCCD.setBPP(16);
                    break;

                default:
                   PrimaryCCD.setBPP(8);
                    break;
            }

            UpdateCCDFrame(PrimaryCCD.getSubX(), PrimaryCCD.getSubY(), PrimaryCCD.getSubW(), PrimaryCCD.getSubH());

            updateRecorderFormat();

            VideoFormatSP.s = IPS_OK;
            IDSetSwitch(&VideoFormatSP, NULL);
            return true;
        }

    }

   return INDI::CCD::ISNewSwitch(dev,name,states,names,n);
}
Exemple #5
0
bool QSICCD::ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n)
{
    if(strcmp(dev,getDeviceName())==0)
    {

        /* Readout Speed */
        if (!strcmp(name, ReadOutSP.name))
        {
            if (IUUpdateSwitch(&ReadOutSP, states, names, n) < 0) return false;

            if (ReadOutS[0].s == ISS_ON)
            {
                try
                {
                 QSICam.put_ReadoutSpeed(QSICamera::HighImageQuality);
                } catch (std::runtime_error err)
                {
                        IUResetSwitch(&ReadOutSP);
                        ReadOutSP.s = IPS_ALERT;
                        DEBUGF(INDI::Logger::DBG_ERROR, "put_ReadoutSpeed() failed. %s.", err.what());
                        IDSetSwitch(&ReadOutSP, NULL);
                        return false;
                }

            }
            else
            {
                try
                {
                 QSICam.put_ReadoutSpeed(QSICamera::FastReadout);
                } catch (std::runtime_error err)
                {
                        IUResetSwitch(&ReadOutSP);
                        ReadOutSP.s = IPS_ALERT;
                        DEBUGF(INDI::Logger::DBG_ERROR, "put_ReadoutSpeed() failed. %s.", err.what());
                        IDSetSwitch(&ReadOutSP, NULL);
                        return false;
                }

                ReadOutSP.s = IPS_OK;
                IDSetSwitch(&ReadOutSP, NULL);

            }

            ReadOutSP.s = IPS_OK;
            IDSetSwitch(&ReadOutSP, NULL);
            return true;
        }


         /* Cooler */
        if (!strcmp (name, CoolerSP.name))
        {
          if (IUUpdateSwitch(&CoolerSP, states, names, n) < 0) return false;

          if (CoolerS[0].s == ISS_ON)
            activateCooler(true);
          else
              activateCooler(false);

          return true;
        }

        /* Shutter */
        if (!strcmp (name, ShutterSP.name))
        {
            if (IUUpdateSwitch(&ShutterSP, states, names, n) < 0) return false;
            shutterControl();
            return true;
        }

        if (!strcmp(name, GainSP.name))
        {
            int prevGain = IUFindOnSwitchIndex(&GainSP);
            IUUpdateSwitch(&GainSP, states, names, n);
            int targetGain = IUFindOnSwitchIndex(&GainSP);

            if (prevGain == targetGain)
            {
                GainSP.s = IPS_OK;
                IDSetSwitch(&GainSP, NULL);
                return true;
            }

            try
            {
                QSICam.put_CameraGain( ((QSICamera::CameraGain) targetGain));

            }  catch (std::runtime_error err)
            {
                                    IUResetSwitch(&GainSP);
                                    GainS[prevGain].s = ISS_ON;
                                    GainSP.s = IPS_ALERT;
                                    DEBUGF(INDI::Logger::DBG_ERROR, "put_CameraGain failed. %s.", err.what());
                                    IDSetSwitch(&GainSP, NULL);
                                    return false;
            }

            GainSP.s = IPS_OK;
            IDSetSwitch(&GainSP, NULL);
            return true;
        }

        if (!strcmp(name, FanSP.name))
        {
            int prevFan = IUFindOnSwitchIndex(&FanSP);
            IUUpdateSwitch(&FanSP, states, names, n);
            int targetFan = IUFindOnSwitchIndex(&FanSP);

            if (prevFan == targetFan)
            {
                FanSP.s = IPS_OK;
                IDSetSwitch(&FanSP, NULL);
                return true;
            }

            try
            {
                QSICam.put_FanMode( ((QSICamera::FanMode) targetFan));

            }  catch (std::runtime_error err)
            {
                                    IUResetSwitch(&FanSP);
                                    FanS[prevFan].s = ISS_ON;
                                    FanSP.s = IPS_ALERT;
                                    DEBUGF(INDI::Logger::DBG_ERROR, "put_FanMode failed. %s.", err.what());
                                    IDSetSwitch(&FanSP, NULL);
                                    return false;
            }

            FanSP.s = IPS_OK;
            IDSetSwitch(&FanSP, NULL);
            return true;
        }

        if (!strcmp(name, ABSP.name))
        {
            int prevAB = IUFindOnSwitchIndex(&ABSP);
            IUUpdateSwitch(&ABSP, states, names, n);
            int targetAB = IUFindOnSwitchIndex(&ABSP);

            if (prevAB == targetAB)
            {
                ABSP.s = IPS_OK;
                IDSetSwitch(&ABSP, NULL);
                return true;
            }

            try
            {
                QSICam.put_AntiBlooming( ((QSICamera::AntiBloom) targetAB));

            }  catch (std::runtime_error err)
            {
                IUResetSwitch(&ABSP);
                ABS[prevAB].s = ISS_ON;
                ABSP.s = IPS_ALERT;
                DEBUGF(INDI::Logger::DBG_ERROR, "put_AntiBlooming failed. %s.", err.what());
                IDSetSwitch(&ABSP, NULL);
                return false;
            }

            ABSP.s = IPS_OK;
            IDSetSwitch(&ABSP, NULL);
            return true;
        }

        /* Filter Wheel */
        if (!strcmp (name, FilterSP.name))
        {
            if (IUUpdateSwitch(&FilterSP, states, names, n) < 0) return false;
            turnWheel();
            return true;
        }
    }

        //  Nobody has claimed this, so, ignore it
        return INDI::CCD::ISNewSwitch(dev,name,states,names,n);
}
Exemple #6
0
bool ATIKCCD::ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
{
    if (dev != nullptr && !strcmp(dev, getDeviceName()))
    {
        // Gain/Offset Presets
        if (!strcmp(name, ControlPresetsSP.name))
        {
            int prevIndex = IUFindOnSwitchIndex(&ControlPresetsSP);
            IUUpdateSwitch(&ControlPresetsSP, states, names, n);
            int targetIndex = IUFindOnSwitchIndex(&ControlPresetsSP);
            uint16_t value = static_cast<uint16_t>(targetIndex + 2);
            uint8_t *data = reinterpret_cast<uint8_t*>(&value);
            int rc = ArtemisCameraSpecificOptionSetData(hCam, ID_AtikHorizonGOPresetMode, data, 2);
            if (rc != ARTEMIS_OK)
            {
                ControlPresetsSP.s = IPS_ALERT;
                IUResetSwitch(&ControlPresetsSP);
                ControlPresetsS[prevIndex].s = ISS_ON;
            }
            else
                ControlPresetsSP.s = IPS_OK;

            IDSetSwitch(&ControlPresetsSP, nullptr);
            return true;
        }

        // Cooler controler
        if (!strcmp(name, CoolerSP.name))
        {
            if (IUUpdateSwitch(&CoolerSP, states, names, n) < 0)
            {
                CoolerSP.s = IPS_ALERT;
                IDSetSwitch(&CoolerSP, nullptr);
                return true;
            }

            bool enabled = (CoolerS[COOLER_ON].s == ISS_ON);

            // If user turns on cooler, but the requested temperature is higher than current temperature
            // then we set temperature to zero degrees. If that was still higher than current temperature
            // we return an error
            if (enabled && TemperatureRequest > TemperatureN[0].value)
            {
                TemperatureRequest = 0;
                // If current temperature is still lower than zero, then we shouldn't risk
                // setting temperature to any arbitrary value. Instead, we report an error and ask
                // user to explicitly set the requested temperature.
                if (TemperatureRequest > TemperatureN[0].value)
                {
                    CoolerS[COOLER_ON].s = ISS_OFF;
                    CoolerS[COOLER_OFF].s = ISS_OFF;
                    CoolerSP.s = IPS_ALERT;
                    LOGF_WARN("Cannot manually activate cooler since current temperature is %.2f. To activate cooler, request a lower temperature.", TemperatureN[0].value);
                    IDSetSwitch(&CoolerSP, nullptr);
                    return true;
                }

                SetTemperature(0);
                return true;
            }

            return activateCooler(enabled);
        }
    }

    return INDI::CCD::ISNewSwitch(dev, name, states, names, n);
}