Example #1
0
void Focus::newFITS(IBLOB *bp)
{

    INDI_UNUSED(bp);
    QString HFRText;

    // Ignore guide head if there is any.
    if (!strcmp(bp->name, "CCD2"))
        return;

    ISD::CCDChip *targetChip = currentCCD->getChip(ISD::CCDChip::PRIMARY_CCD);
    FITSView *targetImage = targetChip->getImage(FITS_FOCUS);

    FITSImage *image_data = targetImage->getImageData();

    currentCCD->disconnect(this);

    if (targetImage == NULL)
    {
        qDebug() << "Error: targetImage is NULL!" << endl;
        return;
    }

    image_data->findStars();

    double currentHFR= image_data->getHFR(HFR_MAX);

    HFRText = QString("%1").arg(currentHFR, 0,'g', 3);

    if (inFocusLoop == false && focusType == FOCUS_MANUAL && HFR == -1)
            appendLogText(i18n("FITS received. No stars detected."));

    HFROut->setText(HFRText);

    if (inFocusLoop)
    {
        capture();
        return;
    }

    if (focusType == FOCUS_MANUAL || inAutoFocus==false)
        return;

    if (canAbsMove)
        autoFocusAbs(currentHFR);
    else
        autoFocusRel(currentHFR);

}
Example #2
0
bool StarbookDriver::updateTime(ln_date *utc, double utc_offset)
{
    INDI_UNUSED(utc_offset);
    if (last_known_state != starbook::INIT)
    {
        LOGF_WARN("Cannot update time in %s state", starbook::STATE_TO_STR.at(last_known_state).c_str());
        return false;
    }
    starbook::ResponseCode rc;
    utc->hours += floor(utc_offset); // starbook stores local time, go figure
    rc = cmd_interface->SetTime(*utc);
    LogResponse("Updating time", rc);
    return rc == starbook::OK;

}
Example #3
0
bool FocusMaster::sendCommand(const uint8_t *command, char *response)
{
    INDI_UNUSED(response);

    int rc = hid_write(handle, command, 2);

    LOGF_DEBUG("CMD <%#02X %#02X>", command[0], command[1]);

    if (rc < 0)
    {
        LOGF_ERROR("<%#02X %#02X>: Error writing to device %s", command[0], command[1], hid_error(handle));
        return false;
    }

    return true;
}
Example #4
0
bool StarbookDriver::updateLocation(double latitude, double longitude, double elevation) {
    INDI_UNUSED(elevation);
    if (last_known_state != starbook::INIT) {
        LOGF_WARN("Can't update location in %s state", starbook::STATE_TO_STR.at(last_known_state).c_str());
        return false;
    }
    if (TimeT[1].text == nullptr) {
        LOG_WARN("Can't update location before time");
        return false;
    }

    auto utc_offset = static_cast<short>(std::floor(std::strtof(TimeT[1].text, nullptr)));
    LOGF_WARN("UTC offset for location: %i", utc_offset);
    starbook::LnLat posn(latitude, longitude);
    starbook::ResponseCode rc = cmd_interface->SetPlace(posn, utc_offset);
    LogResponse("Updating location", rc);
    return rc == starbook::OK;
}
Example #5
0
void Guide::newFITS(IBLOB *bp)
{
    INDI_UNUSED(bp);

    FITSViewer *fv = currentCCD->getViewer();

    disconnect(currentCCD, SIGNAL(BLOBUpdated(IBLOB*)), this, SLOT(newFITS(IBLOB*)));

    ISD::CCDChip *targetChip = currentCCD->getChip(useGuideHead ? ISD::CCDChip::GUIDE_CCD : ISD::CCDChip::PRIMARY_CCD);
    FITSView *targetImage = targetChip->getImage(FITS_GUIDE);
    FITSImage *image_data = targetImage->getImageData();

    image_data->findStars();

    pmath->set_image(targetImage);
    guider->set_image(targetImage);
    calibration->set_image(targetImage);

    fv->show();

    if (guider->is_guiding())
    {
        guider->guide();

        if (guider->is_guiding())
            capture();
    }
    else if (calibration->is_calibrating())
    {

        pmath->do_processing();
        calibration->process_calibration();

        if (calibration->is_calibrating())
            capture();

        if (calibration->is_finished())
        {
            guider->set_ready(true);
            tabWidget->setTabEnabled(1, true);
        }
    }

}
Example #6
0
bool ScopeScript::ReadScopeStatus()
{
    char name[1024];
    char *s = tmpnam(name);
    INDI_UNUSED(s);
    bool status = RunScript(SCRIPT_STATUS, name, nullptr);
    if (status)
    {
        int parked = 0;
        float ra = 0, dec = 0;
        FILE *file = fopen(name, "r");
        int ret = 0;

        ret = fscanf(file, "%d %f %f", &parked, &ra, &dec);
        fclose(file);
        unlink(name);
        if (parked != 0)
        {
            if (!isParked())
            {
                SetParked(true);
                LOG_INFO("Park succesfully executed");
            }
        }
        else
        {
            if (isParked())
            {
                SetParked(false);
                LOG_INFO("Unpark succesfully executed");
            }
        }
        NewRaDec(ra, dec);
    }
    else
    {
        LOG_ERROR("Failed to read status");
    }
    return status;
}
Example #7
0
TTYBase::TTY_RESPONSE TTYBase::checkTimeout(uint8_t timeout)
{
#if defined(_WIN32) || defined(ANDROID)
    INDI_UNUSED(timeout);
    return TTY_ERRNO;
#else

    if (m_PortFD == -1)
        return TTY_ERRNO;

    struct timeval tv;
    fd_set readout;
    int retval;

    FD_ZERO(&readout);
    FD_SET(m_PortFD, &readout);

    /* wait for 'timeout' seconds */
    tv.tv_sec  = timeout;
    tv.tv_usec = 0;

    /* Wait till we have a change in the m_PortFD status */
    retval = select(m_PortFD + 1, &readout, nullptr, nullptr, &tv);

    /* Return 0 on successful m_PortFD change */
    if (retval > 0)
        return TTY_OK;
    /* Return -1 due to an error */
    else if (retval == -1)
        return TTY_SELECT_ERROR;
    /* Return -2 if time expires before anything interesting happens */
    else
        return TTY_TIME_OUT;

#endif
}
Example #8
0
void ISSnoopDevice(XMLEle* root)
{
    INDI_UNUSED(root);
}
Example #9
0
bool ScopeSim::SetTrackMode(uint8_t mode)
{
    INDI_UNUSED(mode);
    return true;
}
Example #10
0
bool INDI::FilterWheel::GetFilterNames(const char * groupName)
{
    INDI_UNUSED(groupName);
    return false;
}
Example #11
0
IPState DomeSim::ControlShutter(ShutterOperation operation)
{
    INDI_UNUSED(operation);
    shutterTimer = SHUTTER_TIMER;
    return IPS_BUSY;
}
Example #12
0
void QFW::simulationTriggered(bool enable)
{
    INDI_UNUSED(enable);
}
Example #13
0
void DomeScript::TimerHit()
{
    if (!isConnected())
        return;
    char name[1024]={0};
    // N.B. INDI_UNUSED to make it compile on MacOS
    // DO NOT CHANGE
    char *s = tmpnam(name);
    INDI_UNUSED(s);
    bool status = RunScript(SCRIPT_STATUS, name, nullptr);
    if (status)
    {
        int parked = 0, shutter = 0;
        float az   = 0;
        FILE *file = fopen(name, "r");
        int ret    = 0;

        ret = fscanf(file, "%d %d %f", &parked, &shutter, &az);
        fclose(file);
        unlink(name);
        DomeAbsPosN[0].value = az = round(range360(az) * 10) / 10;
        if (parked != 0)
        {
            if (getDomeState() == DOME_PARKING || getDomeState() == DOME_UNPARKED)
            {
                SetParked(true);
                TargetAz = az;
                LOG_INFO("Park succesfully executed");
            }
        }
        else
        {
            if (getDomeState() == DOME_UNPARKING || getDomeState() == DOME_PARKED)
            {
                SetParked(false);
                TargetAz = az;
                LOG_INFO("Unpark succesfully executed");
            }
        }
        if (std::round(az * 10) != std::round(TargetAz * 10))
        {
            LOGF_INFO("Moving %g -> %g %d", std::round(az * 10) / 10,
                   std::round(TargetAz * 10) / 10, getDomeState());
            IDSetNumber(&DomeAbsPosNP, nullptr);
        }
        else if (getDomeState() == DOME_MOVING)
        {
            setDomeState(DOME_SYNCED);
            IDSetNumber(&DomeAbsPosNP, nullptr);
        }
        if (shutterState == SHUTTER_OPENED)
        {
            if (shutter == 0)
            {
                shutterState    = SHUTTER_CLOSED;
                DomeShutterSP.s = IPS_OK;
                IDSetSwitch(&DomeShutterSP, nullptr);
                LOG_INFO("Shutter was succesfully closed");
            }
        }
        else
        {
            if (shutter == 1)
            {
                shutterState    = SHUTTER_OPENED;
                DomeShutterSP.s = IPS_OK;
                IDSetSwitch(&DomeShutterSP, nullptr);
                LOG_INFO("Shutter was succesfully opened");
            }
        }
    }
    else
    {
        LOG_ERROR("Failed to read status");
    }
    SetTimer(POLLMS);
    if (!isParked() && TimeSinceUpdate++ > 4)
    {
        TimeSinceUpdate = 0;
        UpdateMountCoords();
    }
}
Example #14
0
void Triangulate::AddPoint(HtmID id)
{
    INDI_UNUSED(id);
    isvalid = false;
}
Example #15
0
bool INDI::LightBoxInterface::SetLightBoxBrightness(uint16_t value)
{
    INDI_UNUSED(value);
    // Must be implemented by child class
    return false;
}
Example #16
0
bool FocuserInterface::SyncFocuser(uint32_t ticks)
{
    INDI_UNUSED(ticks);
    DEBUGDEVICE(m_defaultDevice->getDeviceName(), Logger::DBG_ERROR, "Focuser does not support syncing.");
    return false;
}
Example #17
0
bool FocuserInterface::SetFocuserMaxPosition(uint32_t ticks)
{
    INDI_UNUSED(ticks);
    return true;
}
Example #18
0
bool FocuserInterface::ReverseFocuser(bool enabled)
{
    INDI_UNUSED(enabled);
    DEBUGDEVICE(m_defaultDevice->getDeviceName(), Logger::DBG_ERROR, "Focuser does not support reverse motion.");
    return false;
}
Example #19
0
IPState FocuserInterface::MoveAbsFocuser(uint32_t ticks)
{
    INDI_UNUSED(ticks);
    // Must be implemented by child class
    return IPS_ALERT;
}
Example #20
0
bool FocuserInterface::processSwitch(const char * dev, const char * name, ISState * states, char * names[], int n)
{
    INDI_UNUSED(dev);
    //  This one is for focus motion
    if (!strcmp(name, FocusMotionSP.name))
    {
        // Record last direction and state.
        FocusDirection prevDirection = FocusMotionS[FOCUS_INWARD].s == ISS_ON ? FOCUS_INWARD : FOCUS_OUTWARD;
        IPState prevState = FocusMotionSP.s;

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

        FocusDirection targetDirection = FocusMotionS[FOCUS_INWARD].s == ISS_ON ? FOCUS_INWARD : FOCUS_OUTWARD;

        if (CanRelMove() || CanAbsMove() || HasVariableSpeed())
        {
            FocusMotionSP.s = IPS_OK;
        }
        // If we are dealing with a simple dumb DC focuser, we move in a specific direction in an open-loop fashion until stopped.
        else
        {
            // If we are reversing direction let's issue abort first.
            if (prevDirection != targetDirection && prevState == IPS_BUSY)
                AbortFocuser();

            FocusMotionSP.s = MoveFocuser(targetDirection, 0, 0);
        }

        IDSetSwitch(&FocusMotionSP, nullptr);

        return true;
    }

    // Abort Focuser
    if (!strcmp(name, FocusAbortSP.name))
    {
        IUResetSwitch(&FocusAbortSP);

        if (AbortFocuser())
        {
            FocusAbortSP.s = IPS_OK;
            if (CanAbsMove() && FocusAbsPosNP.s != IPS_IDLE)
            {
                FocusAbsPosNP.s = IPS_IDLE;
                IDSetNumber(&FocusAbsPosNP, nullptr);
            }
            if (CanRelMove() && FocusRelPosNP.s != IPS_IDLE)
            {
                FocusRelPosNP.s = IPS_IDLE;
                IDSetNumber(&FocusRelPosNP, nullptr);
            }
        }
        else
            FocusAbortSP.s = IPS_ALERT;

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

    // Reverse Motion
    if (!strcmp(name, FocusReverseSP.name))
    {
        bool enabled = !strcmp("ENABLED", IUFindOnSwitchName(states, names, n));

        if (ReverseFocuser(enabled))
        {
            IUUpdateSwitch(&FocusReverseSP, states, names, n);
            FocusReverseSP.s = IPS_OK;
        }
        else
        {
            FocusReverseSP.s = IPS_ALERT;
        }

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

    return false;
}
Example #21
0
bool ScopeSim::SetTrackEnabled(bool enabled)
{
    INDI_UNUSED(enabled);
    return true;
}
Example #22
0
bool RotatorInterface::SyncRotator(double angle)
{
    INDI_UNUSED(angle);
    DEBUGDEVICE(m_defaultDevice->getDeviceName(), Logger::DBG_ERROR, "Rotator does not support syncing.");
    return false;
}
Example #23
0
bool ScopeSim::SetTrackRate(double raRate, double deRate)
{
    INDI_UNUSED(raRate);
    INDI_UNUSED(deRate);
    return true;
}
Example #24
0
bool INDI::LightBoxInterface::EnableLightBox(bool enable)
{
    INDI_UNUSED(enable);
    // Must be implemented by child class
    return false;
}
Example #25
0
void QFW::debugTriggered(bool enable)
{
    INDI_UNUSED(enable);
}
Example #26
0
bool FocusMaster::sync(uint32_t ticks)
{
    INDI_UNUSED(ticks);
    return false;
}
Example #27
0
bool RotatorInterface::processSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
{
    INDI_UNUSED(states);
    INDI_UNUSED(names);
    INDI_UNUSED(n);

    if (dev != nullptr && strcmp(dev, m_defaultDevice->getDeviceName()) == 0)
    {
        ////////////////////////////////////////////
        // Abort
        ////////////////////////////////////////////
        if (strcmp(name, AbortRotatorSP.name) == 0)
        {
            AbortRotatorSP.s = AbortRotator() ? IPS_OK : IPS_ALERT;
            IDSetSwitch(&AbortRotatorSP, nullptr);
            if (AbortRotatorSP.s == IPS_OK)
            {
                if (GotoRotatorNP.s != IPS_OK)
                {
                    GotoRotatorNP.s = IPS_OK;
                    IDSetNumber(&GotoRotatorNP, nullptr);
                }
            }
            return true;
        }
        ////////////////////////////////////////////
        // Home
        ////////////////////////////////////////////
        else if (strcmp(name, HomeRotatorSP.name) == 0)
        {
            HomeRotatorSP.s = HomeRotator();
            IUResetSwitch(&HomeRotatorSP);
            if (HomeRotatorSP.s == IPS_BUSY)
                HomeRotatorS[0].s = ISS_ON;
            IDSetSwitch(&HomeRotatorSP, nullptr);
            return true;
        }
        ////////////////////////////////////////////
        // Reverse Rotator
        ////////////////////////////////////////////
        else if (strcmp(name, ReverseRotatorSP.name) == 0)
        {
            bool rc = false;
            bool enabled = (!strcmp(IUFindOnSwitchName(states, names, n), "ENABLED"));
            rc = ReverseRotator(enabled);

            if (rc)
            {
                IUUpdateSwitch(&ReverseRotatorSP, states, names, n);
                ReverseRotatorSP.s = IPS_OK;
                DEBUGFDEVICE(m_defaultDevice->getDeviceName(), Logger::DBG_SESSION, "Rotator direction is %s.", (enabled ? "reversed" : "normal"));
            }
            else
            {
                ReverseRotatorSP.s = IPS_ALERT;
                DEBUGDEVICE(m_defaultDevice->getDeviceName(), Logger::DBG_SESSION, "Rotator reverse direction failed.");
            }

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

    return false;
}
Example #28
0
bool INDI::CCD::updateCCDFrameType(CCDChip::CCD_FRAME fType)
{
    INDI_UNUSED(fType);
    // Child classes can override this
    return true;
}
Example #29
0
bool RotatorInterface::ReverseRotator(bool enabled)
{
    INDI_UNUSED(enabled);
    DEBUGDEVICE(m_defaultDevice->getDeviceName(), Logger::DBG_ERROR, "Rotator does not support reverse.");
    return false;
}
Example #30
0
bool FocusMaster::getPosition(uint32_t *ticks)
{
    INDI_UNUSED(ticks);
    return false;
}