コード例 #1
0
ファイル: qsi_ccd.cpp プロジェクト: rrogge/indi
bool QSICCD::SelectFilter(int targetFilter)
{
    short filter = targetFilter - 1;
    try
    {
        QSICam.put_Position(filter);
    }
    catch (std::runtime_error err)
    {
        FilterSlotNP.s = IPS_ALERT;
        DEBUGF(INDI::Logger::DBG_ERROR, "put_Position() failed. %s.", err.what());
        return false;
    }

    // Check current filter position
    short newFilter = QueryFilter();

    if (newFilter == targetFilter)
    {
        FilterSlotN[0].value = targetFilter;
        FilterSlotNP.s       = IPS_OK;
        DEBUGF(INDI::Logger::DBG_DEBUG, "Filter set to slot #%d", targetFilter);
        IDSetNumber(&FilterSlotNP, nullptr);
        return true;
    }

    IDSetNumber(&FilterSlotNP, nullptr);
    FilterSlotNP.s = IPS_ALERT;
    return false;
}
コード例 #2
0
ファイル: qsi_ccd.cpp プロジェクト: daggerstab/indi
bool QSICCD::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
{
    INumber *np;

    if(strcmp(dev,getDeviceName())==0)
    {
        if (!strcmp(FilterSlotNP.name, name))
        {

            targetFilter = values[0];

            np = IUFindNumber(&FilterSlotNP, names[0]);

            if (!np)
            {
                FilterSlotNP.s = IPS_ALERT;
                IDSetNumber(&FilterSlotNP, "Unknown error. %s is not a member of %s property.", names[0], name);
                return false;
            }

            int filter_count;
            try
            {
                QSICam.get_FilterCount(filter_count);
            } catch (std::runtime_error err)
            {
                DEBUGF(INDI::Logger::DBG_ERROR, "get_FilterCount() failed. %s.", err.what());
                IDSetNumber(&FilterSlotNP, NULL);
            }
            if (targetFilter < FIRST_FILTER || targetFilter > filter_count)
            {
                FilterSlotNP.s = IPS_ALERT;
                DEBUGF(INDI::Logger::DBG_ERROR, "Error: valid range of filter is from %d to %d", FIRST_FILTER, LAST_FILTER);
                IDSetNumber(&FilterSlotNP, NULL);
                return false;
            }

            IUUpdateNumber(&FilterSlotNP, values, names, n);

            FilterSlotNP.s = IPS_BUSY;
            DEBUGF(INDI::Logger::DBG_DEBUG, "Setting current filter to slot %d", targetFilter);
            IDSetNumber(&FilterSlotNP, NULL);


            SelectFilter(targetFilter);

            /* Check current filter position */
            short newFilter = QueryFilter();

            if (newFilter == targetFilter)
            {
                FilterSlotN[0].value = targetFilter;
                FilterSlotNP.s = IPS_OK;
                DEBUGF(INDI::Logger::DBG_DEBUG, "Filter set to slot #%d", targetFilter);
                IDSetNumber(&FilterSlotNP, NULL);
                return true;
            }
            else
                return false;
        }

    }

    //  if we didn't process it, continue up the chain, let somebody else
    //  give it a shot
    return INDI::CCD::ISNewNumber(dev,name,values,names,n);
}
コード例 #3
0
ファイル: qsi_ccd.cpp プロジェクト: daggerstab/indi
void QSICCD::turnWheel()
{
        short current_filter;

        switch (FilterS[0].s)
        {
          case ISS_ON:
            if (current_filter < LAST_FILTER)
                current_filter++;
            else current_filter = FIRST_FILTER;
            try
            {
                current_filter = QueryFilter();
                if(current_filter < LAST_FILTER)
                    current_filter++;
                else current_filter = FIRST_FILTER;

                SelectFilter(current_filter);
            } catch (std::runtime_error err)
            {
                FilterSP.s = IPS_IDLE;
                FilterS[0].s = ISS_OFF;
                FilterS[1].s = ISS_OFF;
                DEBUGF(INDI::Logger::DBG_ERROR, "QSICamera::get_FilterPos() failed. %s.", err.what());
                return;
            }

            FilterSlotN[0].value = current_filter;
            FilterS[0].s = ISS_OFF;
            FilterS[1].s = ISS_OFF;
            FilterSP.s = IPS_OK;
            DEBUGF(INDI::Logger::DBG_DEBUG, "The current filter is %d", current_filter);
            IDSetSwitch(&FilterSP, NULL);
            break;

          case ISS_OFF:
           try
           {
                current_filter = QueryFilter();
                if(current_filter > FIRST_FILTER)
                    current_filter--;
                else
                    current_filter = LAST_FILTER;
              SelectFilter(current_filter);
            } catch (std::runtime_error err)
            {
                FilterSP.s = IPS_IDLE;
                FilterS[0].s = ISS_OFF;
                FilterS[1].s = ISS_OFF;
                DEBUGF(INDI::Logger::DBG_ERROR, "QSICamera::get_FilterPos() failed. %s.", err.what());
                return;
            }

            FilterSlotN[0].value = current_filter;
            FilterS[0].s = ISS_OFF;
            FilterS[1].s = ISS_OFF;
            FilterSP.s = IPS_OK;
            DEBUGF(INDI::Logger::DBG_DEBUG, "The current filter is %d\n", current_filter);
            IDSetSwitch(&FilterSP, NULL);
            IDSetNumber(&FilterSlotNP, NULL);
            break;
        }
}
コード例 #4
0
ファイル: QueryFilter.cpp プロジェクト: Afreeca/qt
Filter* QueryFilter::clone() const {
	return _CLNEW QueryFilter(*this );
}