コード例 #1
0
ファイル: mi_ccd.cpp プロジェクト: azwing/indi
bool MICCD::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
{
    if (strcmp(dev, getDeviceName()) == 0)
    {
        if (!strcmp(name, FilterSlotNP.name))
        {
            INDI::FilterInterface::processNumber(dev, name, values, names, n);
            return true;
        }

        if (!strcmp(name, FanNP.name))
        {
            IUUpdateNumber(&FanNP, values, names, n);

            if (!isSimulation() && gxccd_set_fan(cameraHandle, FanN[0].value) < 0)
            {
                char errorStr[MAX_ERROR_LEN];
                gxccd_get_last_error(cameraHandle, errorStr, sizeof(errorStr));
                LOGF_ERROR("Setting fan failed: %s.", errorStr);
                FanNP.s = IPS_ALERT;
            }
            else
            {
                FanNP.s = IPS_OK;
            }

            IDSetNumber(&FanNP, nullptr);
            return true;
        }

        if (!strcmp(name, WindowHeatingNP.name))
        {
            IUUpdateNumber(&WindowHeatingNP, values, names, n);

            if (!isSimulation() && gxccd_set_window_heating(cameraHandle, WindowHeatingN[0].value) < 0)
            {
                char errorStr[MAX_ERROR_LEN];
                gxccd_get_last_error(cameraHandle, errorStr, sizeof(errorStr));
                LOGF_ERROR("Setting heating failed: %s.", errorStr);
                WindowHeatingNP.s = IPS_ALERT;
            }
            else
            {
                WindowHeatingNP.s = IPS_OK;
            }

            IDSetNumber(&WindowHeatingNP, nullptr);
            return true;
        }

        if (!strcmp(name, TemperatureRampNP.name))
        {
            IUUpdateNumber(&TemperatureRampNP, values, names, n);

            if (!isSimulation() && gxccd_set_temperature_ramp(cameraHandle, TemperatureRampN[0].value) < 0)
            {
                char errorStr[MAX_ERROR_LEN];
                gxccd_get_last_error(cameraHandle, errorStr, sizeof(errorStr));
                LOGF_ERROR("Setting temp. ramp failed: %s.", errorStr);
                TemperatureRampNP.s = IPS_ALERT;
            }
            else
            {
                TemperatureRampNP.s = IPS_OK;
            }

            IDSetNumber(&TemperatureRampNP, nullptr);
            return true;
        }

        if (!strcmp(name, PreflashNP.name))
        {
            IUUpdateNumber(&PreflashNP, values, names, n);

            // set NIR pre-flash if available.
            if (canDoPreflash)
            {
                if (!isSimulation() && gxccd_set_preflash(cameraHandle, PreflashN[0].value, PreflashN[1].value) < 0)
                {
                    char errorStr[MAX_ERROR_LEN];
                    gxccd_get_last_error(cameraHandle, errorStr, sizeof(errorStr));
                    LOGF_ERROR("Setting NIR preflash failed: %s.", errorStr);
                    PreflashNP.s = IPS_ALERT;
                }
                else
                {
                    PreflashNP.s = IPS_OK;
                }
            }

            IDSetNumber(&PreflashNP, nullptr);

            return true;
        }
    }

    return INDI::CCD::ISNewNumber(dev, name, values, names, n);
}
コード例 #2
0
ファイル: mi_ccd.cpp プロジェクト: garlick/indi
bool MICCD::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
{
    if(strcmp(dev, getDeviceName()) == 0)
    {
        if (!strcmp(name, FilterSlotNP.name))
        {
            processFilterSlot(getDeviceName(), values, names);
            return true;
        }

        if (!strcmp(name, FanNP.name))
        {
            IUUpdateNumber(&FanNP, values, names, n);

            if (!isSimulation() && gxccd_set_fan(cameraHandle, FanN[0].value) < 0)
            {
                char errorStr[MAX_ERROR_LEN];
                gxccd_get_last_error(cameraHandle, errorStr, sizeof(errorStr));
                DEBUGF(INDI::Logger::DBG_ERROR, "Setting fan failed: %s.", errorStr);
                FanNP.s = IPS_ALERT;
            }
            else
            {
                FanNP.s = IPS_OK;
            }

            IDSetNumber(&FanNP, NULL);
            return true;
        }

        if (!strcmp(name, WindowHeatingNP.name))
        {
            IUUpdateNumber(&WindowHeatingNP, values, names, n);

            if (!isSimulation() && gxccd_set_window_heating(cameraHandle, WindowHeatingN[0].value) < 0)
            {
                char errorStr[MAX_ERROR_LEN];
                gxccd_get_last_error(cameraHandle, errorStr, sizeof(errorStr));
                DEBUGF(INDI::Logger::DBG_ERROR, "Setting heating failed: %s.", errorStr);
                WindowHeatingNP.s = IPS_ALERT;
            }
            else
            {
                WindowHeatingNP.s = IPS_OK;
            }

            IDSetNumber(&WindowHeatingNP, NULL);
            return true;
        }

        if (!strcmp(name, TemperatureRampNP.name))
        {
            IUUpdateNumber(&TemperatureRampNP, values, names, n);

            if (!isSimulation() && gxccd_set_temperature_ramp(cameraHandle, TemperatureRampN[0].value) < 0)
            {
                char errorStr[MAX_ERROR_LEN];
                gxccd_get_last_error(cameraHandle, errorStr, sizeof(errorStr));
                DEBUGF(INDI::Logger::DBG_ERROR, "Setting temp. ramp failed: %s.", errorStr);
                TemperatureRampNP.s = IPS_ALERT;
            }
            else
            {
                TemperatureRampNP.s = IPS_OK;
            }

            IDSetNumber(&TemperatureRampNP, NULL);
            return true;
        }
    }

    return INDI::CCD::ISNewNumber(dev, name, values, names, n);
}