Exemplo n.º 1
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.º 2
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);
}