Exemplo n.º 1
0
bool   ScopeINDI::GetCoordinates(double *ra, double *dec, double *siderealTime)
{
    bool err = true;
    if (coord_prop) {
	INumber *raprop = IUFindNumber(coord_prop,"RA");
	INumber *decprop = IUFindNumber(coord_prop,"DEC");
	if (raprop && decprop) {
	    *ra = raprop->value;   // hours
	    *dec = decprop->value; // degrees
	    err = false;
	}
	if (SiderealTime_prop) {   // LX200 only
	    INumber *stprop = IUFindNumber(coord_prop,"LST"); 
	    if (stprop){
		*siderealTime = stprop->value;
	    }
	}
	else {
	   #ifdef LIBNOVA
	   double lat,lon;
	   double jd = ln_get_julian_from_sys();
	   *siderealTime = ln_get_apparent_sidereal_time (jd);
	   if (!GetSiteLatLong(&lat,&lon)) 
	      *siderealTime = *siderealTime + (lon/15);
	   #else
	   *siderealTime = 0;
	   #endif
	}
    }
    return err;
}
Exemplo n.º 2
0
void EQModSimulator::Connect() {
    char *settingstexts[2];
    char *settingsnames[]= {(char *)"SIM_RASETTING", (char *)"SIM_DESETTING"};
    ISwitch *sw=IUFindOnSwitch(SimModeSP);
    sksim=new SkywatcherSimulator();
    if (!strcmp(sw->name, "SIM_EQ6")) {
        sksim->setupVersion("020300");
        sksim->setupRA(180, 47,12,200,64,2);
        sksim->setupDE(180, 47,12,200,64,2);
    } else {
        if (!strcmp(sw->name, "SIM_HEQ5")) {
            sksim->setupVersion("020301");
            sksim->setupRA(135, 47,9,200,64,2);
            sksim->setupDE(135, 47,9,200,64,2);
        } else {
            if (!strcmp(sw->name, "SIM_NEQ5")) {
                sksim->setupVersion("020302");
                sksim->setupRA(144, 44,9,200,32,2);
                sksim->setupDE(144, 44,9,200,32,2);
            } else {
                if (!strcmp(sw->name, "SIM_NEQ3")) {
                    sksim->setupVersion("020303");
                    sksim->setupRA(130, 55,10,200,32,2);
                    sksim->setupDE(130, 55,10,200,32,2);
                } else {
                    if (!strcmp(sw->name, "SIM_GEEHALEL")) {
                        sksim->setupVersion("0203F0");
                        sksim->setupRA(144, 60,15,400,8,1);
                        sksim->setupDE(144, 60,10,400,8,1);
                    } else {
                        if (!strcmp(sw->name, "SIM_CUSTOM")) {
                            double teeth, num, den, steps, microsteps, highspeed;
                            ISwitch *hssw=IUFindOnSwitch(SimHighSpeedSP);
                            sksim->setupVersion(IUFindText(SimMCVersionTP, "SIM_MCPHRASE")->text);
                            teeth=IUFindNumber(SimWormNP, "RA_TEETH")->value;
                            num=IUFindNumber(SimRatioNP, "RA_RATIO_NUM")->value;
                            den=IUFindNumber(SimRatioNP, "RA_RATIO_DEN")->value;
                            steps=IUFindNumber(SimMotorNP, "RA_MOTOR_STEPS")->value;
                            microsteps=IUFindNumber(SimMotorNP, "RA_MOTOR_USTEPS")->value;
                            highspeed=1;
                            if (!strcmp(hssw->name, "SIM_HALFSTEP")) highspeed=2;
                            sksim->setupRA(teeth, num, den, steps, microsteps, highspeed);

                            teeth=IUFindNumber(SimWormNP, "DE_TEETH")->value;
                            num=IUFindNumber(SimRatioNP, "DE_RATIO_NUM")->value;
                            den=IUFindNumber(SimRatioNP, "DE_RATIO_DEN")->value;
                            steps=IUFindNumber(SimMotorNP, "DE_MOTOR_STEPS")->value;
                            microsteps=IUFindNumber(SimMotorNP, "DE_MOTOR_USTEPS")->value;
                            sksim->setupDE(teeth, num, den, steps, microsteps, highspeed);

                        }
                    }
                }
            }
        }
    }
}
Exemplo n.º 3
0
void Camera_INDIClass::newNumber(INumberVectorProperty *nvp)
{
    // we go here every time a Number value change
    //printf("Camera Receving Number: %s = %g\n", nvp->name, nvp->np->value);
    if (nvp == ccdinfo_prop) {
        PixelSize = IUFindNumber(ccdinfo_prop,"CCD_PIXEL_SIZE")->value;
        PixSizeX = IUFindNumber(ccdinfo_prop,"CCD_PIXEL_SIZE_X")->value;
        PixSizeY = IUFindNumber(ccdinfo_prop,"CCD_PIXEL_SIZE_Y")->value;
        FullSize = wxSize(IUFindNumber(ccdinfo_prop,"CCD_MAX_X")->value,IUFindNumber(ccdinfo_prop,"CCD_MAX_Y")->value);
    }
}
Exemplo n.º 4
0
bool   ScopeINDI::GetSiteLatLong(double *latitude, double *longitude)
{
    bool err = true;
    if (GeographicCoord_prop) {
       INumber *latprop = IUFindNumber(GeographicCoord_prop,"LAT");
       INumber *lonprop = IUFindNumber(GeographicCoord_prop,"LONG");
	if (latprop && lonprop) {
	    *latitude = latprop->value;
	    *longitude = lonprop->value;
	    err = false;
	}
    }
    return err;
}
Exemplo n.º 5
0
bool   ScopeINDI::SlewToCoordinates(double ra, double dec)
{
    bool err = true;
    if (coord_prop && oncoordset_prop) {
	setslew_prop->s = ISS_ON;
	settrack_prop->s = ISS_OFF;
	setsync_prop->s = ISS_OFF;
	sendNewSwitch(oncoordset_prop);
	INumber *raprop = IUFindNumber(coord_prop,"RA");
	INumber *decprop = IUFindNumber(coord_prop,"DEC");
	raprop->value = ra;
	decprop->value = dec;
	sendNewNumber(coord_prop);
	err = false;
    }
    return err;
}
Exemplo n.º 6
0
void Guide::syncTelescopeInfo()
{
    INumberVectorProperty * nvp = currentTelescope->getBaseDevice()->getNumber("TELESCOPE_INFO");

    if (nvp)
    {
        INumber *np = IUFindNumber(nvp, "GUIDER_APERTURE");

        if (np && np->value != 0)
            aperture = np->value;
        else
        {
            np = IUFindNumber(nvp, "TELESCOPE_APERTURE");
            if (np)
                aperture = np->value;
        }

        np = IUFindNumber(nvp, "GUIDER_FOCAL_LENGTH");
        if (np && np->value != 0)
            focal_length = np->value;
        else
        {
            np = IUFindNumber(nvp, "TELESCOPE_FOCAL_LENGTH");
            if (np)
                focal_length = np->value;
        }
    }

    if (ccd_hor_pixel != -1 && ccd_ver_pixel != -1 && focal_length != -1 && aperture != -1)
    {
        pmath->set_guider_params(ccd_hor_pixel, ccd_ver_pixel, aperture, focal_length);
        int x,y,w,h;

        ISD::CCDChip *targetChip = currentCCD->getChip(useGuideHead ? ISD::CCDChip::GUIDE_CCD : ISD::CCDChip::PRIMARY_CCD);

        if (targetChip->getFrame(&x,&y,&w,&h))
            pmath->set_video_params(w, h);

        guider->fill_interface();

    }

    //qDebug() << "SetScope: ccd_pix_w " << ccd_hor_pixel << " - ccd_pix_h " << ccd_ver_pixel << " - focal length " << focal_length << " aperture " << aperture << endl;

}
Exemplo n.º 7
0
void Guide::syncCCDInfo()
{
    INumberVectorProperty * nvp = NULL;

    if (currentCCD == NULL)
        return;

    if (useGuideHead)
        nvp = currentCCD->getBaseDevice()->getNumber("GUIDE_INFO");
    else
        nvp = currentCCD->getBaseDevice()->getNumber("CCD_INFO");

    if (nvp)
    {
        INumber *np = IUFindNumber(nvp, "CCD_PIXEL_SIZE_X");
        if (np)
            ccd_hor_pixel = np->value;

        np = IUFindNumber(nvp, "CCD_PIXEL_SIZE_Y");
        if (np)
            ccd_ver_pixel = np->value;

        np = IUFindNumber(nvp, "CCD_PIXEL_SIZE_Y");
        if (np)
            ccd_ver_pixel = np->value;
    }

    if (ccd_hor_pixel != -1 && ccd_ver_pixel != -1 && focal_length != -1 && aperture != -1)
    {
        pmath->set_guider_params(ccd_hor_pixel, ccd_ver_pixel, aperture, focal_length);
        int x,y,w,h;

        ISD::CCDChip *targetChip = currentCCD->getChip(useGuideHead ? ISD::CCDChip::GUIDE_CCD : ISD::CCDChip::PRIMARY_CCD);

        if (targetChip->getFrame(&x,&y,&w,&h))
            pmath->set_video_params(w, h);

        guider->fill_interface();
    }

    //qDebug() << "SetCCD: ccd_pix_w " << ccd_hor_pixel << " - ccd_pix_h " << ccd_ver_pixel << " - focal length " << focal_length << " aperture " << aperture << endl;
}
Exemplo n.º 8
0
void Telescope::processNumber(INumberVectorProperty *nvp)
{

    if (!strcmp(nvp->name, "EQUATORIAL_EOD_COORD"))
    {
        INumber *RA = IUFindNumber(nvp, "RA");
        INumber *DEC = IUFindNumber(nvp, "DEC");
        if (RA == NULL || DEC == NULL)
            return;

        currentCoord.setRA(RA->value);
        currentCoord.setDec(DEC->value);

        KStars::Instance()->map()->update();

        emit numberUpdated(nvp);

        return;
    }

    if (!strcmp(nvp->name, "HORIZONTAL_COORD"))
    {
        INumber *Az = IUFindNumber(nvp, "AZ");
        INumber *Alt = IUFindNumber(nvp, "ALT");
        if (Az == NULL || Alt == NULL)
            return;

        currentCoord.setAz(Az->value);
        currentCoord.setAlt(Alt->value);
        currentCoord.HorizontalToEquatorial( KStars::Instance()->data()->lst(), KStars::Instance()->data()->geo()->lat() );

        KStars::Instance()->map()->update();

        emit numberUpdated(nvp);

        return;
    }

    DeviceDecorator::processNumber(nvp);

}
Exemplo n.º 9
0
bool   ScopeINDI::GetGuideRates(double *pRAGuideRate, double *pDecGuideRate)
{
    const double dSiderealSecondPerSec = 0.9973;
    bool err;
    double gra,gdec;
    err = true;
    if (GuideRate_prop) {
	INumber *ratera = IUFindNumber(GuideRate_prop,"GUIDE_RATE_WE");
	INumber *ratedec = IUFindNumber(GuideRate_prop,"GUIDE_RATE_NS");
	if (ratera && ratedec) {
	    gra =  ratera->value;  // sidereal rate
	    gdec = ratedec->value;
	    gra = gra * (15.0 * dSiderealSecondPerSec)/3600;    // ASCOM compatible
	    gdec = gdec * (15.0 * dSiderealSecondPerSec)/3600;  // Degrees/sec
	    *pRAGuideRate =  gra;
	    *pDecGuideRate = gdec;
	    err = false;
	}
    }
    return err;
}
Exemplo n.º 10
0
bool Telescope::getEqCoords(double *ra, double *dec)
{
    INumberVectorProperty *EqProp(NULL);
    INumber *RAEle(NULL), *DecEle(NULL);

    EqProp = baseDevice->getNumber("EQUATORIAL_EOD_COORD");
    if (EqProp == NULL)
        return false;

    RAEle  = IUFindNumber(EqProp, "RA");
    if (!RAEle)
        return false;
    DecEle = IUFindNumber(EqProp, "DEC");
    if (!DecEle)
         return false;

    *ra  = RAEle->value;
    *dec = DecEle->value;

    return true;

}
Exemplo n.º 11
0
double ScopeINDI::GetDeclination(void)
{
    if (coord_prop) {
        INumber *decprop = IUFindNumber(coord_prop,"DEC");
        if (decprop) {
            double dec = decprop->value;     // Degrees
	        if (dec > 89.0) dec = 89.0;     // avoid crash when dividing by cos(dec) 
            if (dec < -89.0) dec = -89.0; 
            return radians(dec);
        }
    }
    return UNKNOWN_DECLINATION;
}
Exemplo n.º 12
0
bool LX200_16::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
{
    double newAlt = 0, newAz = 0;

    if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
    {
        if (!strcmp(name, HorizontalCoordsNP.name))
        {
            int i = 0, nset = 0;

            for (nset = i = 0; i < n; i++)
            {
                INumber *horp = IUFindNumber(&HorizontalCoordsNP, names[i]);
                if (horp == &HorizontalCoordsN[0])
                {
                    newAlt = values[i];
                    nset += newAlt >= -90. && newAlt <= 90.0;
                }
                else if (horp == &HorizontalCoordsN[1])
                {
                    newAz = values[i];
                    nset += newAz >= 0. && newAz <= 360.0;
                }
            }

            if (nset == 2)
            {
                if (!isSimulation() && (setObjAz(PortFD, newAz) < 0 || setObjAlt(PortFD, newAlt) < 0))
                {
                    HorizontalCoordsNP.s = IPS_ALERT;
                    IDSetNumber(&HorizontalCoordsNP, "Error setting Alt/Az.");
                    return false;
                }
                targetAZ  = newAz;
                targetALT = newAlt;

                return handleAltAzSlew();
            }
            else
            {
                HorizontalCoordsNP.s = IPS_ALERT;
                IDSetNumber(&HorizontalCoordsNP, "Altitude or Azimuth missing or invalid");
                return false;
            }
        }
    }

    LX200GPS::ISNewNumber(dev, name, values, names, n);
    return true;
}
Exemplo n.º 13
0
void Mount::save()
{
    INumberVectorProperty * nvp = currentTelescope->getBaseDevice()->getNumber("TELESCOPE_INFO");

    if (nvp)
    {

        primaryScopeGroup->setTitle(currentTelescope->getDeviceName());
        guideScopeGroup->setTitle(i18n("%1 guide scope", currentTelescope->getDeviceName()));

        INumber *np = NULL;

        np = IUFindNumber(nvp, "TELESCOPE_APERTURE");
        if (np)
            np->value = primaryScopeApertureIN->value();
        np = IUFindNumber(nvp, "TELESCOPE_FOCAL_LENGTH");
        if (np)
            np->value = primaryScopeFocalIN->value();
        np = IUFindNumber(nvp, "GUIDER_APERTURE");
        if (np)
            np->value = guideScopeApertureIN->value() == 1 ? primaryScopeApertureIN->value() : guideScopeApertureIN->value();
        np = IUFindNumber(nvp, "GUIDER_FOCAL_LENGTH");
        if (np)
            np->value = guideScopeFocalIN->value() == 1 ? primaryScopeFocalIN->value() : guideScopeFocalIN->value();

        ClientManager *clientManager = currentTelescope->getDriverInfo()->getClientManager();

        clientManager->sendNewNumber(nvp);

        currentTelescope->setConfig(SAVE_CONFIG);

        //appendLogText(i18n("Saving telescope information..."));

    }
    else
        appendLogText(i18n("Failed to save telescope information."));
}
Exemplo n.º 14
0
void Focus::processFocusProperties(INumberVectorProperty *nvp)
{

    if (!strcmp(nvp->name, "ABS_FOCUS_POSITION"))
    {
       INumber *pos = IUFindNumber(nvp, "FOCUS_ABSOLUTE_POSITION");
       if (pos)
           pulseStep = pos->value;

       if (canAbsMove && inAutoFocus)
       {
           if (nvp->s == IPS_OK)
               capture();
           else if (nvp->s == IPS_ALERT)
           {
               appendLogText(i18n("Focuser error, check INDI panel."));
               stopFocus();
           }

       }

       return;
    }

    if (!strcmp(nvp->name, "FOCUS_TIMER"))
    {

        if (canAbsMove == false && inAutoFocus)
        {
            if (nvp->s == IPS_OK)
                capture();
            else if (nvp->s == IPS_ALERT)
            {
                appendLogText(i18n("Focuser error, check INDI panel."));
                stopFocus();
            }
        }

        return;
    }

}
Exemplo n.º 15
0
void INDI::BaseClientQt::sendNewNumber (const char * deviceName, const char * propertyName, const char * elementName, double value)
{
    INDI::BaseDevice * drv = getDevice(deviceName);

    if (drv == NULL)
        return;

    INumberVectorProperty * nvp = drv->getNumber(propertyName);

    if (nvp == NULL)
        return;

    INumber * np = IUFindNumber(nvp, elementName);

    if (np == NULL)
        return;

    np->value = value;

    sendNewNumber(nvp);

}
Exemplo n.º 16
0
void Camera_INDIClass::newNumber(INumberVectorProperty *nvp)
{
    // we go here every time a Number value change
    //printf("Camera Receving Number: %s = %g\n", nvp->name, nvp->np->value);
    if (nvp == ccdinfo_prop) {
        PixelSize = IUFindNumber(ccdinfo_prop,"CCD_PIXEL_SIZE")->value;
        PixSizeX = IUFindNumber(ccdinfo_prop,"CCD_PIXEL_SIZE_X")->value;
        PixSizeY = IUFindNumber(ccdinfo_prop,"CCD_PIXEL_SIZE_Y")->value;
        m_maxSize.x = IUFindNumber(ccdinfo_prop,"CCD_MAX_X")->value;
        m_maxSize.y = IUFindNumber(ccdinfo_prop,"CCD_MAX_Y")->value;
        FullSize = wxSize(m_maxSize.x / Binning, m_maxSize.y / Binning);
        m_bitsPerPixel = IUFindNumber(ccdinfo_prop, "CCD_BITSPERPIXEL")->value;
    }
    if (nvp == binning_prop) {
        MaxBinning = wxMin(binning_x->max, binning_y->max);
        Binning = wxMin(binning_x->value, binning_y->value);
        if (Binning > MaxBinning)
            Binning = MaxBinning;
        m_curBinning = Binning;
        FullSize = wxSize(m_maxSize.x / Binning, m_maxSize.y / Binning);
    }
}
Exemplo n.º 17
0
bool SynscanDriver::ISNewNumber(const char * dev, const char * name, double values[], char * names[], int n)
{
    if (dev && !strcmp(dev, getDeviceName()))
    {
        // Guide Rate
        if (strcmp(name, "GUIDE_RATE") == 0)
        {
            IUUpdateNumber(&GuideRateNP, values, names, n);
            GuideRateNP.s = IPS_OK;
            IDSetNumber(&GuideRateNP, nullptr);
            return true;
        }

        // Custom Slew Rate
        if (strcmp(name, CustomSlewRateNP.name) == 0)
        {
            if (TrackState == SCOPE_SLEWING)
            {
                LOG_ERROR("Cannot change rate while slewing.");
                CustomSlewRateNP.s = IPS_ALERT;
                IDSetNumber(&CustomSlewRateNP, nullptr);
                return true;
            }

            IUUpdateNumber(&CustomSlewRateNP, values, names, n);
            CustomSlewRateNP.s = IPS_OK;
            IDSetNumber(&CustomSlewRateNP, nullptr);
            return true;
        }

        // Horizonal Coords
        if (!strcmp(name, HorizontalCoordsNP.name))
        {
            if (isParked())
            {
                LOG_WARN("Unpark mount before issuing GOTO commands.");
                HorizontalCoordsNP.s = IPS_IDLE;
                IDSetNumber(&HorizontalCoordsNP, nullptr);
                return true;
            }

            int nset = 0;
            double newAlt = 0, newAz = 0;
            for (int i = 0; i < n; i++)
            {
                INumber * horp = IUFindNumber(&HorizontalCoordsNP, names[i]);
                if (horp == &HorizontalCoordsN[AXIS_AZ])
                {
                    newAz = values[i];
                    nset += newAz >= 0. && newAz <= 360.0;
                }
                else if (horp == &HorizontalCoordsN[AXIS_ALT])
                {
                    newAlt = values[i];
                    nset += newAlt >= -90. && newAlt <= 90.0;
                }
            }

            if (nset == 2 && GotoAzAlt(newAz, newAlt))
                return true;

            HorizontalCoordsNP.s = IPS_ALERT;
            IDSetNumber(&HorizontalCoordsNP, "Altitude or Azimuth missing or invalid.");
            return false;
        }

        // Guiding
        if (strcmp(name, GuideNSNP.name) == 0 || strcmp(name, GuideWENP.name) == 0)
        {
            processGuiderProperties(name, values, names, n);
            return true;
        }
    }

    return INDI::Telescope::ISNewNumber(dev, name, values, names, n);
}
Exemplo n.º 18
0
void Camera_INDIClass::newProperty(INDI::Property *property)
{
    // Here we receive a list of all the properties after the connection
    // Updated values are not received here but in the newTYPE() functions above.
    // We keep the vector for each interesting property to send some data later.
    //const char* DeviName = property->getDeviceName();
    const char* PropName = property->getName();
#ifdef INDI_PRE_1_1_0
    INDI_TYPE Proptype = property->getType();
#else
    INDI_PROPERTY_TYPE Proptype = property->getType();
#endif

    //printf("Camera Property: %s\n",PropName);

    if (Proptype == INDI_BLOB) {
        //printf("Found BLOB property for %s %s\n", DeviName, PropName);
        has_blob = 1;
    }
    else if ((strcmp(PropName, INDICameraCCDCmd+"EXPOSURE") == 0) && Proptype == INDI_NUMBER) {
        //printf("Found CCD_EXPOSURE for %s %s\n", DeviName, PropName);
        expose_prop = property->getNumber();
    }
    else if ((strcmp(PropName, INDICameraCCDCmd+"FRAME") == 0) && Proptype == INDI_NUMBER) {
        //printf("Found CCD_FRAME for %s %s\n", DeviName, PropName);
        frame_prop = property->getNumber();
        frame_x = IUFindNumber(frame_prop,"X");
        frame_y = IUFindNumber(frame_prop,"Y");
        frame_width = IUFindNumber(frame_prop,"WIDTH");
        frame_height = IUFindNumber(frame_prop,"HEIGHT");
    }
    else if ((strcmp(PropName, INDICameraCCDCmd+"FRAME_TYPE") == 0) && Proptype == INDI_SWITCH) {
        //printf("Found CCD_FRAME_TYPE for %s %s\n", DeviName, PropName);
        frame_type_prop = property->getSwitch();
    }
    else if ((strcmp(PropName, INDICameraCCDCmd+"BINNING") == 0) && Proptype == INDI_NUMBER) {
        //printf("Found CCD_BINNING for %s %s\n",DeviName, PropName);
        binning_prop = property->getNumber();
        binning_x = IUFindNumber(binning_prop,"HOR_BIN");
        binning_y = IUFindNumber(binning_prop,"VER_BIN");
        newNumber(binning_prop);
    }
    else if ((strcmp(PropName, "VIDEO_STREAM") == 0) && Proptype == INDI_SWITCH) {
        //printf("Found Video %s %s\n",DeviName, PropName);
        video_prop = property->getSwitch();
    }
    else if (strcmp(PropName, "DEVICE_PORT") == 0 && Proptype == INDI_TEXT) {
        //printf("Found device port for %s \n",DeviName);
        camera_port = property->getText();
    }
    else if (strcmp(PropName, "CONNECTION") == 0 && Proptype == INDI_SWITCH) {
        //printf("Found CONNECTION for %s %s\n",DeviName, PropName);
        // Check the value here in case the device is already connected
        ISwitch *connectswitch = IUFindSwitch(property->getSwitch(),"CONNECT");
        Connected = (connectswitch->s == ISS_ON);
    }
    else if ((strcmp(PropName, "TELESCOPE_TIMED_GUIDE_NS") == 0) && Proptype == INDI_NUMBER) {
        pulseGuideNS_prop = property->getNumber();
        pulseN_prop = IUFindNumber(pulseGuideNS_prop,"TIMED_GUIDE_N");
        pulseS_prop = IUFindNumber(pulseGuideNS_prop,"TIMED_GUIDE_S");
    }
    else if ((strcmp(PropName, "TELESCOPE_TIMED_GUIDE_WE") == 0) && Proptype == INDI_NUMBER) {
        pulseGuideEW_prop = property->getNumber();
        pulseW_prop = IUFindNumber(pulseGuideEW_prop,"TIMED_GUIDE_W");
        pulseE_prop = IUFindNumber(pulseGuideEW_prop,"TIMED_GUIDE_E");
    }
    else if (strcmp(PropName, INDICameraCCDCmd+"INFO") == 0 && Proptype == INDI_NUMBER) {
        ccdinfo_prop = property->getNumber();
        newNumber(ccdinfo_prop);
    }

    CheckState();
}
Exemplo n.º 19
0
bool Telescope::doPulse(GuideDirection dir, int msecs )
{
    INumberVectorProperty *raPulse  = baseDevice->getNumber("TELESCOPE_TIMED_GUIDE_WE");
    INumberVectorProperty *decPulse = baseDevice->getNumber("TELESCOPE_TIMED_GUIDE_NS");
    INumberVectorProperty *npulse = NULL;
    INumber *dirPulse=NULL;

    if (raPulse == NULL || decPulse == NULL)
        return false;

    switch(dir)
    {
    case RA_INC_DIR:
    dirPulse = IUFindNumber(raPulse, "TIMED_GUIDE_W");
    if (dirPulse == NULL)
        return false;

    npulse = raPulse;
    break;

    case RA_DEC_DIR:
    dirPulse = IUFindNumber(raPulse, "TIMED_GUIDE_E");
    if (dirPulse == NULL)
        return false;

    npulse = raPulse;
    break;

    case DEC_INC_DIR:
    dirPulse = IUFindNumber(decPulse, "TIMED_GUIDE_N");
    if (dirPulse == NULL)
        return false;

    npulse = decPulse;
    break;

    case DEC_DEC_DIR:
    dirPulse = IUFindNumber(decPulse, "TIMED_GUIDE_S");
    if (dirPulse == NULL)
        return false;

    npulse = decPulse;
    break;

    default:
        return false;

    }

    if (dirPulse == NULL || npulse == NULL)
        return false;

    dirPulse->value = msecs;

    clientManager->sendNewNumber(npulse);

    //qDebug() << "Sending pulse for " << npulse->name << " in direction " << dirPulse->name << " for " << msecs << " ms " << endl;

    return true;


}
Exemplo n.º 20
0
void ScopeINDI::newProperty(INDI::Property *property) 
{
    // Here we receive a list of all the properties after the connection
    // Updated values are not received here but in the newTYPE() functions above.
    // We keep the vector for each interesting property to send some data later.
    const char* PropName = property->getName();
    #ifdef INDI_PRE_1_1_0
      INDI_TYPE Proptype = property->getType();
    #else
      INDI_PROPERTY_TYPE Proptype = property->getType();
    #endif 
    
    //printf("Mount Property: %s\n",PropName);
    
    if ((strcmp(PropName, "EQUATORIAL_EOD_COORD") == 0) && Proptype == INDI_NUMBER){
	// Epoch of date
	coord_prop = property->getNumber();
	eod_coord = true;
    }
    else if ((strcmp(PropName, "EQUATORIAL_COORD") == 0) && (!coord_prop) && Proptype == INDI_NUMBER){
	// Epoch J2000, used only if epoch of date is not available
	coord_prop = property->getNumber();
	eod_coord = false;
    }
    else if ((strcmp(PropName, "ON_COORD_SET") == 0) && Proptype == INDI_SWITCH){
	oncoordset_prop = property->getSwitch();
	setslew_prop = IUFindSwitch(oncoordset_prop,"SLEW");
	settrack_prop = IUFindSwitch(oncoordset_prop,"TRACK");
	setsync_prop = IUFindSwitch(oncoordset_prop,"SYNC");
    }
    else if ((strcmp(PropName, "ABORT") == 0) && Proptype == INDI_SWITCH){
       abort_prop = property->getSwitch();
    }
    else if ((strcmp(PropName, "TELESCOPE_MOTION_RATE") == 0) && Proptype == INDI_NUMBER){
	MotionRate_prop = property->getNumber();
    }
    else if ((strcmp(PropName, "TELESCOPE_MOTION_NS") == 0) && Proptype == INDI_SWITCH){
	moveNS_prop = property->getSwitch();
	moveN_prop = IUFindSwitch(moveNS_prop,"MOTION_NORTH");
	moveS_prop = IUFindSwitch(moveNS_prop,"MOTION_SOUTH");
    }
    else if ((strcmp(PropName, "TELESCOPE_MOTION_WE") == 0) && Proptype == INDI_SWITCH){
	moveEW_prop = property->getSwitch();
	moveE_prop = IUFindSwitch(moveEW_prop,"MOTION_EAST");
	moveW_prop = IUFindSwitch(moveEW_prop,"MOTION_WEST");
    }
    else if ((strcmp(PropName, "GUIDE_RATE") == 0) && Proptype == INDI_NUMBER){
	GuideRate_prop = property->getNumber();
    }
    else if ((strcmp(PropName, "TELESCOPE_TIMED_GUIDE_NS") == 0) && Proptype == INDI_NUMBER){
	pulseGuideNS_prop = property->getNumber();
	pulseN_prop = IUFindNumber(pulseGuideNS_prop,"TIMED_GUIDE_N");
	pulseS_prop = IUFindNumber(pulseGuideNS_prop,"TIMED_GUIDE_S");
    }
    else if ((strcmp(PropName, "TELESCOPE_TIMED_GUIDE_WE") == 0) && Proptype == INDI_NUMBER){
	pulseGuideEW_prop = property->getNumber();
       pulseW_prop = IUFindNumber(pulseGuideEW_prop,"TIMED_GUIDE_W");
       pulseE_prop = IUFindNumber(pulseGuideEW_prop,"TIMED_GUIDE_E");
    }
    else if ((strcmp(PropName, "TELESCOPE_PIER_SIDE") == 0) && Proptype == INDI_SWITCH){
        pierside_prop = property->getSwitch();
        piersideEast_prop = IUFindSwitch(pierside_prop,"PIER_EAST");
        piersideWest_prop = IUFindSwitch(pierside_prop,"PIER_WEST");
    }
    else if (strcmp(PropName, "DEVICE_PORT") == 0 && Proptype == INDI_TEXT) {    
	scope_port = property->getText();
    }
    else if (strcmp(PropName, "CONNECTION") == 0 && Proptype == INDI_SWITCH) {
	// Check the value here in case the device is already connected
	ISwitch *connectswitch = IUFindSwitch(property->getSwitch(),"CONNECT");
	if (connectswitch->s == ISS_ON) Scope::Connect();
    }
    else if ((strcmp(PropName, "GEOGRAPHIC_COORD") == 0) && Proptype == INDI_NUMBER){
	GeographicCoord_prop = property->getNumber();
    }
    else if ((strcmp(PropName, "TIME_LST") == 0) && Proptype == INDI_NUMBER){
	SiderealTime_prop = property->getNumber();
    }
    CheckState();
}
Exemplo n.º 21
0
bool Telescope::sendCoords(SkyPoint *ScopeTarget)
{

    INumber *RAEle(NULL), *DecEle(NULL), *AzEle(NULL), *AltEle(NULL);
    INumberVectorProperty *EqProp(NULL), *HorProp(NULL);
    double currentRA=0, currentDEC=0, currentAlt=0, currentAz=0, targetAlt=0;
    bool useJ2000 (false);

    EqProp = baseDevice->getNumber("EQUATORIAL_EOD_COORD");
    if (EqProp == NULL)
    {
    // J2000 Property
        EqProp = baseDevice->getNumber("EQUATORIAL_COORD");
        if (EqProp)
            useJ2000 = true;

    }

    HorProp = baseDevice->getNumber("HORIZONTAL_COORD");

    if (EqProp && EqProp->p == IP_RO)
        EqProp = NULL;

    if (HorProp && HorProp->p == IP_RO)
            HorProp = NULL;

    //qDebug() << "Skymap click - RA: " << scope_target->ra().toHMSString() << " DEC: " << scope_target->dec().toDMSString();

        if (EqProp)
        {
                RAEle  = IUFindNumber(EqProp, "RA");
                if (!RAEle) return false;
                DecEle = IUFindNumber(EqProp, "DEC");
                    if (!DecEle) return false;

           if (useJ2000)
                ScopeTarget->apparentCoord(KStars::Instance()->data()->ut().djd(), (long double) J2000);

              currentRA  = RAEle->value;
              currentDEC = DecEle->value;              

              ScopeTarget->EquatorialToHorizontal(KStarsData::Instance()->lst(), KStarsData::Instance()->geo()->lat());
       }

        if (HorProp)
        {
                AzEle = IUFindNumber(HorProp, "AZ");
                if (!AzEle) return false;
                AltEle = IUFindNumber(HorProp,"ALT");
                if (!AltEle) return false;

            currentAz  = AzEle->value;
            currentAlt = AltEle->value;           
        }

        /* Could not find either properties! */
        if (EqProp == NULL && HorProp == NULL)
            return false;

        //targetAz = ScopeTarget->az().Degrees();
        targetAlt= ScopeTarget->altRefracted().Degrees();

        if (minAlt != -1 && maxAlt != -1)
        {
            if (targetAlt < minAlt || targetAlt > maxAlt)
            {
                KMessageBox::error(NULL, i18n("Requested altitude %1 is outside the specified altitude limit boundary (%2,%3).", QString::number(targetAlt, 'g', 3), QString::number(minAlt, 'g', 3), QString::number(maxAlt, 'g', 3)),
                                   i18n("Telescope Motion"));
                return false;
            }
        }

        if (targetAlt < 0)
        {
            if (KMessageBox::warningContinueCancel(NULL, i18n("Requested altitude is below the horizon. Are you sure you want to proceed?"), i18n("Telescope Motion"),
                                                   KStandardGuiItem::cont(), KStandardGuiItem::cancel(), QString("telescope_coordintes_below_horizon_warning")) == KMessageBox::Cancel)
            {
                if (EqProp)
                {
                    RAEle->value = currentRA;
                    DecEle->value = currentDEC;
                }
                if (HorProp)
                {
                    AzEle->value  = currentAz;
                    AltEle->value = currentAlt;
                }

                return false;
            }
        }

        if (EqProp)
        {
            RAEle->value  = ScopeTarget->ra().Hours();
            DecEle->value = ScopeTarget->dec().Degrees();
            clientManager->sendNewNumber(EqProp);

            if (Options::iNDILogging())
                qDebug() << "ISD:Telescope: Sending coords RA " << RAEle->value << " DEC " << DecEle->value;

            RAEle->value = currentRA;
            DecEle->value = currentDEC;
        }
        // Only send Horizontal Coord property if Equatorial is not available.
        else if (HorProp)
        {
            AzEle->value  = ScopeTarget->az().Degrees();
            AltEle->value = ScopeTarget->alt().Degrees();
            clientManager->sendNewNumber(HorProp);
            AzEle->value  = currentAz;
            AltEle->value = currentAlt;
        }

        return true;

}
Exemplo n.º 22
0
void Mount::syncTelescopeInfo()
{
    INumberVectorProperty * nvp = currentTelescope->getBaseDevice()->getNumber("TELESCOPE_INFO");

    if (nvp)
    {

        primaryScopeGroup->setTitle(currentTelescope->getDeviceName());
        guideScopeGroup->setTitle(i18n("%1 guide scope", currentTelescope->getDeviceName()));

        INumber *np = NULL;

        np = IUFindNumber(nvp, "TELESCOPE_APERTURE");
        if (np && np->value > 0)
            primaryScopeApertureIN->setValue(np->value);

        np = IUFindNumber(nvp, "TELESCOPE_FOCAL_LENGTH");
        if (np && np->value > 0)
            primaryScopeFocalIN->setValue(np->value);

        np = IUFindNumber(nvp, "GUIDER_APERTURE");
        if (np && np->value > 0)
            guideScopeApertureIN->setValue(np->value);

        np = IUFindNumber(nvp, "GUIDER_FOCAL_LENGTH");
        if (np && np->value > 0)
            guideScopeFocalIN->setValue(np->value);

    }

    ISwitchVectorProperty *svp = currentTelescope->getBaseDevice()->getSwitch("TELESCOPE_SLEW_RATE");

    if (svp)
    {
        slewSpeedCombo->clear();
        slewSpeedCombo->setEnabled(true);

        for (int i=0; i < svp->nsp; i++)
            slewSpeedCombo->addItem(i18nc(libindi_strings_context, svp->sp[i].label));

        int index = IUFindOnSwitchIndex(svp);
        slewSpeedCombo->setCurrentIndex(index);
        connect(slewSpeedCombo, SIGNAL(activated(int)), currentTelescope, SLOT(setSlewRate(int)), Qt::UniqueConnection);
    }
    else
    {
        slewSpeedCombo->setEnabled(false);
        disconnect(slewSpeedCombo, SIGNAL(activated(int)), currentTelescope, SLOT(setSlewRate(int)));
    }

    if (currentTelescope->canPark())
    {
        parkB->setEnabled(!currentTelescope->isParked());
        unparkB->setEnabled(currentTelescope->isParked());
        connect(parkB, SIGNAL(clicked()), currentTelescope, SLOT(Park()), Qt::UniqueConnection);
        connect(unparkB, SIGNAL(clicked()), currentTelescope, SLOT(UnPark()), Qt::UniqueConnection);
    }
    else
    {
        parkB->setEnabled(false);
        unparkB->setEnabled(false);
        disconnect(parkB, SIGNAL(clicked()), currentTelescope, SLOT(Park()));
        disconnect(unparkB, SIGNAL(clicked()), currentTelescope, SLOT(UnPark()));
    }

}
Exemplo n.º 23
0
void Telescope::registerProperty(INDI::Property *prop)
{
    if (!strcmp(prop->getName(), "TELESCOPE_INFO"))
    {
        INumberVectorProperty *ti = prop->getNumber();
        if (ti == NULL)
            return;

        bool aperture_ok=false, focal_ok=false;
        double temp=0;

        INumber *aperture = IUFindNumber(ti, "TELESCOPE_APERTURE");
        if (aperture && aperture->value == 0)
        {
            if (getDriverInfo()->getAuxInfo().contains("TELESCOPE_APERTURE"))
            {
                temp = getDriverInfo()->getAuxInfo().value("TELESCOPE_APERTURE").toDouble(&aperture_ok);
                if (aperture_ok)
                {
                    aperture->value = temp;
                    INumber *g_aperture = IUFindNumber(ti, "GUIDER_APERTURE");
                    if (g_aperture && g_aperture->value == 0)
                        g_aperture->value = aperture->value;
                }
            }


        }

        INumber *focal_length = IUFindNumber(ti, "TELESCOPE_FOCAL_LENGTH");
        if (focal_length && focal_length->value == 0)
        {
            if (getDriverInfo()->getAuxInfo().contains("TELESCOPE_FOCAL_LENGTH"))
            {
                    temp = getDriverInfo()->getAuxInfo().value("TELESCOPE_FOCAL_LENGTH").toDouble(&focal_ok);
                    if (focal_ok)
                    {
                        focal_length->value = temp;
                        INumber *g_focal = IUFindNumber(ti, "GUIDER_FOCAL_LENGTH");
                        if (g_focal && g_focal->value == 0)
                            g_focal->value = focal_length->value;
                    }
            }
        }

        if (aperture_ok && focal_ok)
            clientManager->sendNewNumber(ti);
    }

    if (!strcmp(prop->getName(), "TELESCOPE_PARK"))
    {
         ISwitchVectorProperty *svp = prop->getSwitch();

         if (svp)
         {
             ISwitch *sp = IUFindSwitch(svp, "PARK");
             if (sp)
             {
                 IsParked = ( (sp->s == ISS_ON) && svp->s == IPS_OK);
             }
         }
    }

    DeviceDecorator::registerProperty(prop);
}
Exemplo n.º 24
0
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);
}
Exemplo n.º 25
0
bool RoboFocus::ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
{
    int nset=0,i=0;

    if(strcmp(dev,getDeviceName())==0)
    {

        if (!strcmp (name, SettingsNP.name))
        {
            /* new speed */
            double new_duty = 0 ;
            double new_delay = 0 ;
            double new_ticks = 0 ;
            int ret = -1 ;

            for (nset = i = 0; i < n; i++)
            {
                /* Find numbers with the passed names in the SettingsNP property */
                INumber *eqp = IUFindNumber (&SettingsNP, names[i]);

                /* If the number found is  (SettingsN[0]) then process it */
                if (eqp == &SettingsN[0])
                {

                    new_duty = (values[i]);
                    nset += new_duty >= 0 && new_duty <= 255;
                } else if  (eqp == &SettingsN[1])
                {

                    new_delay = (values[i]);
                    nset += new_delay >= 0 && new_delay <= 255;
                } else if  (eqp == &SettingsN[2])
                {

                    new_ticks = (values[i]);
                    nset += new_ticks >= 0 && new_ticks <= 255;
                }
            }

            /* Did we process the three numbers? */
            if (nset == 3)
            {

                /* Set the robofocus state to BUSY */
                SettingsNP.s = IPS_BUSY;


                IDSetNumber(&SettingsNP, NULL);

                if(( ret= updateRFMotorSettings(&new_duty, &new_delay, &new_ticks))< 0)
                {

                    IDSetNumber(&SettingsNP, "Changing to new settings failed");
                    return false;
                }

                currentDuty = new_duty ;
                currentDelay= new_delay ;
                currentTicks= new_ticks ;

                SettingsNP.s = IPS_OK;
                IDSetNumber(&SettingsNP, "Motor settings are now  %3.0f %3.0f %3.0f", currentDuty, currentDelay, currentTicks);
                return true;

            } else
            {
                /* Set property state to idle */
                SettingsNP.s = IPS_IDLE;

                IDSetNumber(&SettingsNP, "Settings absent or bogus.");
                return false ;
            }
        }

        if (!strcmp (name, SetBacklashNP.name))
        {

            double new_back = 0 ;
            int nset = 0;
            int ret= -1 ;

            for (nset = i = 0; i < n; i++)
            {
                /* Find numbers with the passed names in the SetBacklashNP property */
                INumber *eqp = IUFindNumber (&SetBacklashNP, names[i]);

                /* If the number found is SetBacklash (SetBacklashN[0]) then process it */
                if (eqp == &SetBacklashN[0]){

                    new_back = (values[i]);

                    /* limits */
                    nset += new_back >= -0xff && new_back <= 0xff;
                }

                if (nset == 1) {

                    /* Set the robofocus state to BUSY */
                    SetBacklashNP.s = IPS_BUSY;
                    IDSetNumber(&SetBacklashNP, NULL);

                    if(( ret= updateRFBacklash(&new_back)) < 0) {

                        SetBacklashNP.s = IPS_IDLE;
                        IDSetNumber(&SetBacklashNP, "Setting new backlash failed.");

                        return false ;
                    }

                    currentSetBacklash=  new_back ;
                    SetBacklashNP.s = IPS_OK;
                    IDSetNumber(&SetBacklashNP, "Backlash is now  %3.0f", currentSetBacklash) ;
                    return true;
                } else {

                    SetBacklashNP.s = IPS_IDLE;
                    IDSetNumber(&SetBacklashNP, "Need exactly one parameter.");

                    return false ;
                }
            }
        }

        if (!strcmp (name, MinMaxPositionNP.name))
        {
            /* new positions */
            double new_min = 0 ;
            double new_max = 0 ;

            for (nset = i = 0; i < n; i++)
            {
                /* Find numbers with the passed names in the MinMaxPositionNP property */
                INumber *mmpp = IUFindNumber (&MinMaxPositionNP, names[i]);

                /* If the number found is  (MinMaxPositionN[0]) then process it */
                if (mmpp == &MinMaxPositionN[0])
                {

                    new_min = (values[i]);
                    nset += new_min >= 1 && new_min <= 65000;
                } else if  (mmpp == &MinMaxPositionN[1])
                {

                    new_max = (values[i]);
                    nset += new_max >= 1 && new_max <= 65000;
                }
            }

            /* Did we process the two numbers? */
            if (nset == 2)
            {

                /* Set the robofocus state to BUSY */
                MinMaxPositionNP.s = IPS_BUSY;

                currentMinPosition = new_min ;
                currentMaxPosition= new_max ;


                MinMaxPositionNP.s = IPS_OK;
                IDSetNumber(&MinMaxPositionNP, "Minimum and Maximum settings are now  %3.0f %3.0f", currentMinPosition, currentMaxPosition);
                return true;

            } else {
                /* Set property state to idle */
                MinMaxPositionNP.s = IPS_IDLE;

                IDSetNumber(&MinMaxPositionNP, "Minimum and maximum limits absent or bogus.");

                return false;
            }
        }


        if (!strcmp (name, MaxTravelNP.name))
        {

            double new_maxt = 0 ;
            int ret = -1 ;

            for (nset = i = 0; i < n; i++)
            {
                /* Find numbers with the passed names in the MinMaxPositionNP property */
                INumber *mmpp = IUFindNumber (&MaxTravelNP, names[i]);

                /* If the number found is  (MaxTravelN[0]) then process it */
                if (mmpp == &MaxTravelN[0])
                {

                    new_maxt = (values[i]);
                    nset += new_maxt >= 1 && new_maxt <= 64000;
                }
            }
            /* Did we process the one number? */
            if (nset == 1) {

                IDSetNumber(&MinMaxPositionNP, NULL);

                if(( ret= updateRFMaxPosition(&new_maxt))< 0 )
                {
                    MaxTravelNP.s = IPS_IDLE;
                    IDSetNumber(&MaxTravelNP, "Changing to new maximum travel failed");
                    return false ;
                }

                currentMaxTravel=  new_maxt ;
                MaxTravelNP.s = IPS_OK;
                IDSetNumber(&MaxTravelNP, "Maximum travel is now  %3.0f", currentMaxTravel) ;
                return true;

            } else {
                /* Set property state to idle */

                MaxTravelNP.s = IPS_IDLE;
                IDSetNumber(&MaxTravelNP, "Maximum travel absent or bogus.");

                return false ;
            }
        }


        if (!strcmp (name, SetRegisterPositionNP.name))
        {

            double new_apos = 0 ;
            int nset = 0;
            int ret= -1 ;

            for (nset = i = 0; i < n; i++)
            {
                /* Find numbers with the passed names in the SetRegisterPositionNP property */
                INumber *srpp = IUFindNumber (&SetRegisterPositionNP, names[i]);

                /* If the number found is SetRegisterPosition (SetRegisterPositionN[0]) then process it */
                if (srpp == &SetRegisterPositionN[0])
                {

                    new_apos = (values[i]);

                    /* limits are absolute */
                    nset += new_apos >= 0 && new_apos <= 64000;
                }

                if (nset == 1)
                {

                    if((new_apos < currentMinPosition) || (new_apos > currentMaxPosition))
                    {

                        SetRegisterPositionNP.s = IPS_ALERT ;
                        IDSetNumber(&SetRegisterPositionNP, "Value out of limits  %5.0f", new_apos);
                        return false ;
                    }

                    /* Set the robofocus state to BUSY */
                    SetRegisterPositionNP.s = IPS_BUSY;
                    IDSetNumber(&SetRegisterPositionNP, NULL);

                    if(( ret= updateRFSetPosition(&new_apos)) < 0)
                    {

                        SetRegisterPositionNP.s = IPS_OK;
                        IDSetNumber(&SetRegisterPositionNP, "Read out of the set position to %3d failed. Trying to recover the position", ret);

                        if((ret= updateRFPosition( &currentPosition)) < 0)
                        {

                            FocusAbsPosNP.s = IPS_ALERT;
                            IDSetNumber(&FocusAbsPosNP, "Unknown error while reading  Robofocus position: %d", ret);

                            SetRegisterPositionNP.s = IPS_IDLE;
                            IDSetNumber(&SetRegisterPositionNP, "Relative movement failed.");
                        }

                        SetRegisterPositionNP.s = IPS_OK;
                        IDSetNumber(&SetRegisterPositionNP, NULL);

                        FocusAbsPosNP.s = IPS_OK;
                        IDSetNumber(&FocusAbsPosNP, "Robofocus position recovered %5.0f", currentPosition);
                        DEBUG(INDI::Logger::DBG_DEBUG, "Robofocus position recovered resuming normal operation");
                        /* We have to leave here, because new_apos is not set */
                        return true ;
                    }
                    currentPosition= new_apos ;
                    SetRegisterPositionNP.s = IPS_OK;
                    IDSetNumber(&SetRegisterPositionNP, "Robofocus register set to %5.0f", currentPosition);

                    FocusAbsPosNP.s = IPS_OK;
                    IDSetNumber(&FocusAbsPosNP, "Robofocus position is now %5.0f", currentPosition);

                    return true ;

                } else
                {

                    SetRegisterPositionNP.s = IPS_IDLE;
                    IDSetNumber(&SetRegisterPositionNP, "Need exactly one parameter.");

                    return false;
                }

                if((ret= updateRFPosition(&currentPosition)) < 0)
                {

                    FocusAbsPosNP.s = IPS_ALERT;
                    DEBUGF(INDI::Logger::DBG_ERROR, "Unknown error while reading  Robofocus position: %d", ret);
                    IDSetNumber(&FocusAbsPosNP, NULL);

                    return false ;
                }

                SetRegisterPositionNP.s = IPS_OK;
                SetRegisterPositionN[0].value = currentPosition;
                IDSetNumber(&SetRegisterPositionNP, "Robofocus has accepted new register setting" ) ;

                FocusAbsPosNP.s = IPS_OK;
                DEBUGF(INDI::Logger::DBG_SESSION, "Robofocus new position %5.0f", currentPosition);
                IDSetNumber(&FocusAbsPosNP, NULL);

                return true;
            }
        }
    }

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

}
Exemplo n.º 26
0
void LX200_16::ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
{
  double newAlt=0, newAz=0;
  char altStr[64], azStr[64];
  int err;

  // ignore if not ours //
  if (strcmp (dev, thisDevice))
    return;

  if ( !strcmp (name, horNum.name) )
  {
      int i=0, nset=0;

      if (checkPower(&horNum))
	   return;

        for (nset = i = 0; i < n; i++)
	    {
		INumber *horp = IUFindNumber (&horNum, names[i]);
		if (horp == &hor[0])
		{
                    newAlt = values[i];
		    nset += newAlt >= -90. && newAlt <= 90.0;
		} else if (horp == &hor[1])
		{
		    newAz = values[i];
		    nset += newAz >= 0. && newAz <= 360.0;
		}
	    }

	  if (nset == 2)
	  {
	   if ( (err = setObjAz(newAz)) < 0 || (err = setObjAlt(newAlt)) < 0)
	   {
	     handleError(&horNum, err, "Setting Alt/Az");
	     return;
	   }
	        horNum.s = IPS_OK;
	       //horNum.n[0].value = values[0];
	       //horNum.n[1].value = values[1];
	       targetAz  = newAz;
	       targetAlt = newAlt;

	       fs_sexa(azStr, targetAz, 2, 3600);
	       fs_sexa(altStr, targetAlt, 2, 3600);

	       IDSetNumber (&horNum, "Attempting to slew to Alt %s - Az %s", altStr, azStr);
	       handleAltAzSlew();
	  }
	  else
	  {
		horNum.s = IPS_IDLE;
		IDSetNumber(&horNum, "Altitude or Azimuth missing or invalid");
	  }
	
	  return;  
    }

    LX200Autostar::ISNewNumber (dev, name, values, names, n);
}
Exemplo n.º 27
0
bool NFocus::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
{
    int nset = 0, i = 0;

    if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
    {
        if (strcmp(name, SettingsNP.name) == 0)
        {
            /* new speed */
            double new_onTime    = 0;
            double new_offTime   = 0;
            double new_fastDelay = 0;
            int ret              = -1;

            for (nset = i = 0; i < n; i++)
            {
                /* Find numbers with the passed names in the SettingsNP property */
                INumber *eqp = IUFindNumber(&SettingsNP, names[i]);

                /* If the number found is  (SettingsN[0]) then process it */
                if (eqp == &SettingsN[0])
                {
                    new_onTime = (values[i]);
                    nset += static_cast<int>(new_onTime >= 10 && new_onTime <= 250);
                }
                else if (eqp == &SettingsN[1])
                {
                    new_offTime = (values[i]);
                    nset += static_cast<int>(new_offTime >= 1 && new_offTime <= 250);
                }
                else if (eqp == &SettingsN[2])
                {
                    new_fastDelay = (values[i]);
                    nset += static_cast<int>(new_fastDelay >= 1 && new_fastDelay <= 9);
                }
            }

            /* Did we process the three numbers? */
            if (nset == 3)
            {
                if ((ret = updateNFMotorSettings(&new_onTime, &new_offTime, &new_fastDelay)) < 0)
                {
                    IDSetNumber(&SettingsNP, "Changing to new settings failed");
                    return false;
                }

                currentOnTime    = new_onTime;
                currentOffTime   = new_offTime;
                currentFastDelay = new_fastDelay;

                SettingsNP.s = IPS_OK;
                IDSetNumber(&SettingsNP, "Motor settings are now  %3.0f %3.0f %3.0f", currentOnTime, currentOffTime,
                            currentFastDelay);
                return true;
            }
            else
            {
                /* Set property state to idle */
                SettingsNP.s = IPS_IDLE;

                IDSetNumber(&SettingsNP, "Settings absent or bogus.");
                return false;
            }
        }

        if (strcmp(name, InOutScalarNP.name) == 0)
        {
            double new_ioscalar = 0;

            for (nset = i = 0; i < n; i++)
            {
                /* Find numbers with the passed names in the InOutScalarNP property */
                INumber *eqp = IUFindNumber(&InOutScalarNP, names[i]);

                /* If the number found is SetBacklash (SetBacklashN[0]) then process it */
                if (eqp == &InOutScalarN[0])
                {
                    new_ioscalar = (values[i]);

                    /* limits */
                    nset += static_cast<int>(new_ioscalar >= 0 && new_ioscalar <= 2);
                }

                if (nset == 1)
                {
                    /* Set the nfocus state to BUSY */
                    InOutScalarNP.s = IPS_BUSY;
                    /* kraemerf
                    IDSetNumber(&InOutScalarNP, nullptr);

                        if(( ret= updateNFInOutScalar(&new_ioscalar)) < 0) {

                          InOutScalarNP.s = IPS_IDLE;
                          IDSetNumber(&InOutScalarNP, "Setting new in/out scalar failed.");

                          return false ;
                        }
                    */

                    currentInOutScalar = new_ioscalar;
                    InOutScalarNP.s    = IPS_OK;
                    IDSetNumber(&InOutScalarNP, "Direction Scalar is now  %1.2f", currentInOutScalar);
                    return true;
                }
                else
                {
                    InOutScalarNP.s = IPS_IDLE;
                    IDSetNumber(&InOutScalarNP, "Need exactly one parameter.");

                    return false;
                }
            }
        }

        if (strcmp(name, MinMaxPositionNP.name) == 0)
        {
            /* new positions */
            double new_min = 0;
            double new_max = 0;

            for (nset = i = 0; i < n; i++)
            {
                /* Find numbers with the passed names in the MinMaxPositionNP property */
                INumber *mmpp = IUFindNumber(&MinMaxPositionNP, names[i]);

                /* If the number found is  (MinMaxPositionN[0]) then process it */
                if (mmpp == &MinMaxPositionN[0])
                {
                    new_min = (values[i]);
                    nset += static_cast<int>(new_min >= 1 && new_min <= 65000);
                }
                else if (mmpp == &MinMaxPositionN[1])
                {
                    new_max = (values[i]);
                    nset += static_cast<int>(new_max >= 1 && new_max <= 65000);
                }
            }

            /* Did we process the two numbers? */
            if (nset == 2)
            {
                /* Set the nfocus state to BUSY */
                MinMaxPositionNP.s = IPS_BUSY;

                currentMinPosition = new_min;
                currentMaxPosition = new_max;

                MinMaxPositionNP.s = IPS_OK;
                IDSetNumber(&MinMaxPositionNP, "Minimum and Maximum settings are now  %3.0f %3.0f", currentMinPosition,
                            currentMaxPosition);
                return true;
            }
            else
            {
                /* Set property state to idle */
                MinMaxPositionNP.s = IPS_IDLE;

                IDSetNumber(&MinMaxPositionNP, "Minimum and maximum limits absent or bogus.");

                return false;
            }
        }

        if (strcmp(name, MaxTravelNP.name) == 0)
        {
            double new_maxt = 0;
            int ret         = -1;

            for (nset = i = 0; i < n; i++)
            {
                /* Find numbers with the passed names in the MinMaxPositionNP property */
                INumber *mmpp = IUFindNumber(&MaxTravelNP, names[i]);

                /* If the number found is  (MaxTravelN[0]) then process it */
                if (mmpp == &MaxTravelN[0])
                {
                    new_maxt = (values[i]);
                    nset += static_cast<int>(new_maxt >= 1 && new_maxt <= 64000);
                }
            }
            /* Did we process the one number? */
            if (nset == 1)
            {
                IDSetNumber(&MinMaxPositionNP, nullptr);

                if ((ret = setNFMaxPosition(&new_maxt)) < 0)
                {
                    MaxTravelNP.s = IPS_IDLE;
                    IDSetNumber(&MaxTravelNP, "Changing to new maximum travel failed");
                    return false;
                }

                currentMaxTravel    = new_maxt;
                MaxTravelNP.s       = IPS_OK;
                FocusAbsPosN[0].max = currentMaxTravel;
                IUUpdateMinMax(&FocusAbsPosNP);
                IDSetNumber(&MaxTravelNP, "Maximum travel is now  %3.0f", currentMaxTravel);
                return true;
            }
            else
            {
                /* Set property state to idle */

                MaxTravelNP.s = IPS_IDLE;
                IDSetNumber(&MaxTravelNP, "Maximum travel absent or bogus.");

                return false;
            }
        }

        // Sync
        if (strcmp(name, SyncNP.name) == 0)
        {
            double new_apos = values[0];
            int rc          = 0;
            if ((new_apos < currentMinPosition) || (new_apos > currentMaxPosition))
            {
                SyncNP.s = IPS_ALERT;
                IDSetNumber(&SyncNP, "Value out of limits  %5.0f", new_apos);
                return false;
            }

            if ((rc = syncNF(&new_apos)) < 0)
            {
                SyncNP.s = IPS_ALERT;
                IDSetNumber(&SyncNP, "Read out of the set position to %3d failed.", rc);
                return false;
            }

            DEBUGF(INDI::Logger::DBG_DEBUG, "Focuser sycned to %g ticks", new_apos);
            SyncN[0].value = new_apos;
            SyncNP.s       = IPS_OK;
            IDSetNumber(&SyncNP, nullptr);
            IDSetNumber(&FocusAbsPosNP, nullptr);
            return true;
        }
    }

    return INDI::Focuser::ISNewNumber(dev, name, values, names, n);
}
Exemplo n.º 28
0
bool NFocus::ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
{
    int nset=0,i=0;

    if(strcmp(dev,getDeviceName())==0)
    {

        if (!strcmp (name, SettingsNP.name))
        {
          /* new speed */
          double new_onTime = 0 ;
          double new_offTime = 0 ;
          double new_fastDelay = 0 ;
          int ret = -1 ;

          for (nset = i = 0; i < n; i++)
          {
            /* Find numbers with the passed names in the SettingsNP property */
            INumber *eqp = IUFindNumber (&SettingsNP, names[i]);

            /* If the number found is  (SettingsN[0]) then process it */
            if (eqp == &SettingsN[0])
            {

              new_onTime = (values[i]);
              nset += new_onTime >= 10 && new_onTime <= 250;
            } else if  (eqp == &SettingsN[1])
            {

              new_offTime = (values[i]);
              nset += new_offTime >= 1 && new_offTime <= 250;
            } else if  (eqp == &SettingsN[2])
            {

              new_fastDelay = (values[i]);
              nset += new_fastDelay >= 1 && new_fastDelay <= 9;
            }
          }

          /* Did we process the three numbers? */
          if (nset == 3)
          {

            /* Set the nfocus state to BUSY */
            SettingsNP.s = IPS_BUSY;


            IDSetNumber(&SettingsNP, NULL);

            if(( ret= updateNFMotorSettings(&new_onTime, &new_offTime, &new_fastDelay))< 0)
            {

              IDSetNumber(&SettingsNP, "Changing to new settings failed");
              return false;
            }

            currentOnTime = new_onTime ;
            currentOffTime= new_offTime ;
            currentFastDelay= new_fastDelay ;

            SettingsNP.s = IPS_OK;
            IDSetNumber(&SettingsNP, "Motor settings are now  %3.0f %3.0f %3.0f", currentOnTime, currentOffTime, currentFastDelay);
            return true;

          } else
          {
            /* Set property state to idle */
            SettingsNP.s = IPS_IDLE;

            IDSetNumber(&SettingsNP, "Settings absent or bogus.");
            return false ;
          }
        }





        if (!strcmp (name, SetBacklashNP.name))
        {

          double new_back = 0 ;
          int nset = 0;
          int ret= -1 ;

          for (nset = i = 0; i < n; i++)
          {
            /* Find numbers with the passed names in the SetBacklashNP property */
            INumber *eqp = IUFindNumber (&SetBacklashNP, names[i]);

            /* If the number found is SetBacklash (SetBacklashN[0]) then process it */
            if (eqp == &SetBacklashN[0]){

              new_back = (values[i]);

              /* limits */
              nset += new_back >= -0xff && new_back <= 0xff;
            }

            if (nset == 1) {

              /* Set the nfocus state to BUSY */
              SetBacklashNP.s = IPS_BUSY;
              IDSetNumber(&SetBacklashNP, NULL);

              if(( ret= updateNFBacklash(&new_back)) < 0) {

                SetBacklashNP.s = IPS_IDLE;
                IDSetNumber(&SetBacklashNP, "Setting new backlash failed.");

                return false ;
              }

              currentSetBacklash=  new_back ;
              SetBacklashNP.s = IPS_OK;
              IDSetNumber(&SetBacklashNP, "Backlash is now  %3.0f", currentSetBacklash) ;
              return true;
            } else {

              SetBacklashNP.s = IPS_IDLE;
              IDSetNumber(&SetBacklashNP, "Need exactly one parameter.");

              return false ;
            }
          }
        }


        if (!strcmp (name, InOutScalarNP.name))
        {

          double new_ioscalar = 0 ;

          for (nset = i = 0; i < n; i++)
          {
            /* Find numbers with the passed names in the InOutScalarNP property */
            INumber *eqp = IUFindNumber (&InOutScalarNP, names[i]);

            /* If the number found is SetBacklash (SetBacklashN[0]) then process it */
            if (eqp == &InOutScalarN[0]){

              new_ioscalar = (values[i]);

              /* limits */
              nset += new_ioscalar >= 0 && new_ioscalar <= 2;
            }

            if (nset == 1) {

              /* Set the nfocus state to BUSY */
              InOutScalarNP.s = IPS_BUSY;
          /* kraemerf
	    IDSetNumber(&InOutScalarNP, NULL);

              if(( ret= updateNFInOutScalar(&new_ioscalar)) < 0) {

                InOutScalarNP.s = IPS_IDLE;
                IDSetNumber(&InOutScalarNP, "Setting new in/out scalar failed.");

                return false ;
              }
	*/

              currentInOutScalar=  new_ioscalar ;
              InOutScalarNP.s = IPS_OK;
              IDSetNumber(&InOutScalarNP, "Direction Scalar is now  %1.2f", currentInOutScalar) ;
              return true;
            } else {

              InOutScalarNP.s = IPS_IDLE;
              IDSetNumber(&InOutScalarNP, "Need exactly one parameter.");

              return false ;
            }
          }
        }



        if (!strcmp (name, MinMaxPositionNP.name))
        {
          /* new positions */
          double new_min = 0 ;
          double new_max = 0 ;

          for (nset = i = 0; i < n; i++)
          {
            /* Find numbers with the passed names in the MinMaxPositionNP property */
            INumber *mmpp = IUFindNumber (&MinMaxPositionNP, names[i]);

            /* If the number found is  (MinMaxPositionN[0]) then process it */
            if (mmpp == &MinMaxPositionN[0])
            {

              new_min = (values[i]);
              nset += new_min >= 1 && new_min <= 65000;
            } else if  (mmpp == &MinMaxPositionN[1])
            {

              new_max = (values[i]);
              nset += new_max >= 1 && new_max <= 65000;
            }
          }

          /* Did we process the two numbers? */
          if (nset == 2)
          {

            /* Set the nfocus state to BUSY */
            MinMaxPositionNP.s = IPS_BUSY;

            currentMinPosition = new_min ;
            currentMaxPosition= new_max ;


            MinMaxPositionNP.s = IPS_OK;
            IDSetNumber(&MinMaxPositionNP, "Minimum and Maximum settings are now  %3.0f %3.0f", currentMinPosition, currentMaxPosition);
            return true;

          } else {
            /* Set property state to idle */
            MinMaxPositionNP.s = IPS_IDLE;

            IDSetNumber(&MinMaxPositionNP, "Minimum and maximum limits absent or bogus.");

            return false;
          }
        }


        if (!strcmp (name, MaxTravelNP.name))
        {

          double new_maxt = 0 ;
          int ret = -1 ;

          for (nset = i = 0; i < n; i++)
          {
            /* Find numbers with the passed names in the MinMaxPositionNP property */
            INumber *mmpp = IUFindNumber (&MaxTravelNP, names[i]);

            /* If the number found is  (MaxTravelN[0]) then process it */
            if (mmpp == &MaxTravelN[0])
            {

              new_maxt = (values[i]);
              nset += new_maxt >= 1 && new_maxt <= 64000;
            }
          }
          /* Did we process the one number? */
          if (nset == 1) {

            IDSetNumber(&MinMaxPositionNP, NULL);

            if(( ret= updateNFMaxPosition(&new_maxt))< 0 )
            {
              MaxTravelNP.s = IPS_IDLE;
              IDSetNumber(&MaxTravelNP, "Changing to new maximum travel failed");
              return false ;
            }

            currentMaxTravel=  new_maxt ;
            MaxTravelNP.s = IPS_OK;
            IDSetNumber(&MaxTravelNP, "Maximum travel is now  %3.0f", currentMaxTravel) ;
            return true;

          } else {
            /* Set property state to idle */

            MaxTravelNP.s = IPS_IDLE;
            IDSetNumber(&MaxTravelNP, "Maximum travel absent or bogus.");

            return false ;
          }
        }


        if (!strcmp (name, SetRegisterPositionNP.name))
        {

          double new_apos = 0 ;
          int nset = 0;
          int ret= -1 ;

          for (nset = i = 0; i < n; i++)
          {
            /* Find numbers with the passed names in the SetRegisterPositionNP property */
            INumber *srpp = IUFindNumber (&SetRegisterPositionNP, names[i]);

            /* If the number found is SetRegisterPosition (SetRegisterPositionN[0]) then process it */
            if (srpp == &SetRegisterPositionN[0])
            {

              new_apos = (values[i]);

              /* limits are absolute */
              nset += new_apos >= 0 && new_apos <= 64000;
            }

            if (nset == 1)
            {

              if((new_apos < currentMinPosition) || (new_apos > currentMaxPosition))
              {

                SetRegisterPositionNP.s = IPS_ALERT ;
                IDSetNumber(&SetRegisterPositionNP, "Value out of limits  %5.0f", new_apos);
                return false ;
              }

              /* Set the nfocus state to BUSY */
              SetRegisterPositionNP.s = IPS_BUSY;
              IDSetNumber(&SetRegisterPositionNP, NULL);

              if(( ret= updateNFSetPosition(&new_apos)) < 0)
              {

                SetRegisterPositionNP.s = IPS_OK;
                IDSetNumber(&SetRegisterPositionNP, "Read out of the set position to %3d failed. Trying to recover the position", ret);

                if((ret= updateNFPosition( &currentPosition)) < 0)
                {

                  FocusAbsPosNP.s = IPS_ALERT;
                  IDSetNumber(&FocusAbsPosNP, "Unknown error while reading  Nfocus position: %d", ret);

                  SetRegisterPositionNP.s = IPS_IDLE;
                  IDSetNumber(&SetRegisterPositionNP, "Relative movement failed.");
                }

                SetRegisterPositionNP.s = IPS_OK;
                IDSetNumber(&SetRegisterPositionNP, NULL);


                FocusAbsPosNP.s = IPS_OK;
                IDSetNumber(&FocusAbsPosNP, "Nfocus position recovered %5.0f", currentPosition);
                IDMessage( getDeviceName(), "Nfocus position recovered resuming normal operation");
                /* We have to leave here, because new_apos is not set */
                return true ;
              }
              currentPosition= new_apos ;
              SetRegisterPositionNP.s = IPS_OK;
              IDSetNumber(&SetRegisterPositionNP, "Nfocus register set to %5.0f", currentPosition);

              FocusAbsPosNP.s = IPS_OK;
              IDSetNumber(&FocusAbsPosNP, "Nfocus position is now %5.0f", currentPosition);

              return true ;

            } else
            {

              SetRegisterPositionNP.s = IPS_IDLE;
              IDSetNumber(&SetRegisterPositionNP, "Need exactly one parameter.");

              return false;
            }

            if((ret= updateNFPosition(&currentPosition)) < 0)
            {

              FocusAbsPosNP.s = IPS_ALERT;
              IDSetNumber(&FocusAbsPosNP, "Unknown error while reading  Nfocus position: %d", ret);

              return false ;
            }

            SetRegisterPositionNP.s = IPS_OK;
            IDSetNumber(&SetRegisterPositionNP, "Nfocus has accepted new register setting" ) ;

            FocusAbsPosNP.s = IPS_OK;
            IDSetNumber(&FocusAbsPosNP, "Nfocus new position %5.0f", currentPosition);

            return true;
          }
        }



    }

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

}