Пример #1
0
/**************************************************************************************
** Client is asking us to set a new number
***************************************************************************************/
bool RadioSim::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
{
    if (strcmp (dev, getDeviceName()))
        return false;

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

        DishSize = (DetectorPropertiesN[0].value);

        DetectorPropertiesNP.s = IPS_OK;
        IDSetNumber(&DetectorPropertiesNP, nullptr);
        return true;
    }

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

        DetectorCoordsNP.s = IPS_OK;
        IDSetNumber(&DetectorCoordsNP, nullptr);
        return true;
    }

    return INDI::Detector::ISNewNumber(dev, name, values, names, n);
}
Пример #2
0
/*******************************************************************************
** Client is asking us to set a new number
*******************************************************************************/
bool DSICCD::ISNewNumber(const char *dev, const char *name,
                         double values[], char *names[], int n)
{
    if (!strcmp(dev, getDeviceName()))
    {
        if (!strcmp(name, GainNP.name))
        {
	    IUUpdateNumber(&GainNP, values, names, n);
	    GainNP.s = IPS_OK;
	    IDSetNumber(&GainNP, NULL);

            return true;
        }

        if (!strcmp(name, OffsetNP.name))
        {
	    IUUpdateNumber(&OffsetNP, values, names, n);
	    OffsetNP.s = IPS_OK;
	    IDSetNumber(&OffsetNP, NULL);

            return true;
        }

    }

    // If we didn't process anything above, let the parent handle it.
    return INDI::CCD::ISNewNumber(dev,name,values,names,n);
}
Пример #3
0
bool IEQPro::ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
{
    if (!strcmp (dev, getDeviceName()))
    {

        // Custom Tracking Rate
        if (!strcmp(name, CustomTrackRateNP.name))
        {
            if (TrackModeS[TRACK_CUSTOM].s != ISS_ON)
            {
                CustomTrackRateNP.s = IPS_IDLE;
                DEBUG(INDI::Logger::DBG_ERROR, "Can only set tracking rate if tracking mode is set to custom.");
                IDSetNumber(&CustomTrackRateNP, NULL);
                return true;
            }

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

            if (set_ieqpro_custom_track_rate(PortFD, CustomTrackRateN[0].value))
                CustomTrackRateNP.s = IPS_OK;
            else
                CustomTrackRateNP.s = IPS_ALERT;

            IDSetNumber(&CustomTrackRateNP, NULL);

            return true;

        }

        // Guiding Rate
        if (!strcmp(name, GuideRateNP.name))
        {
            IUUpdateNumber(&GuideRateNP, values, names, n);

            if (set_ieqpro_guide_rate(PortFD, GuideRateN[0].value))
                GuideRateNP.s = IPS_OK;
            else
                GuideRateNP.s = IPS_ALERT;

            IDSetNumber(&GuideRateNP, NULL);

            return true;
        }

        if (!strcmp(name,GuideNSNP.name) || !strcmp(name,GuideWENP.name))
        {
            processGuiderProperties(name, values, names, n);
            return true;
        }
    }

    return INDI::Telescope::ISNewNumber (dev, name, values, names, n);
}
Пример #4
0
bool INDI::GPS::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
{
    if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
    {
        if (strcmp(name, PeriodNP.name) == 0)
        {
            double prevPeriod = PeriodN[0].value;
            IUUpdateNumber(&PeriodNP, values, names, n);
            // Do not remove timer if GPS update is still in progress
            if (timerID > 0 && RefreshSP.s != IPS_BUSY)
            {
                RemoveTimer(timerID);
                timerID = -1;
            }

            if (PeriodN[0].value == 0)
            {
                DEBUG(INDI::Logger::DBG_SESSION, "GPS Update Timer disabled.");
            }
            else
            {
                timerID = SetTimer(PeriodN[0].value*1000);
                if (prevPeriod == 0)
                    DEBUG(INDI::Logger::DBG_SESSION, "GPS Update Timer enabled.");
            }

            PeriodNP.s = IPS_OK;
            IDSetNumber(&PeriodNP, nullptr);

            return true;
        }
    }

    return DefaultDevice::ISNewNumber(dev, name, values, names, n);
}
Пример #5
0
bool ScopeSim::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
{
    //  first check if it's for our device

    if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
    {
        if (strcmp(name, "GUIDE_RATE") == 0)
        {
            IUUpdateNumber(&GuideRateNP, values, names, n);
            GuideRateNP.s = IPS_OK;
            IDSetNumber(&GuideRateNP, nullptr);
            return true;
        }

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

    //  if we didn't process it, continue up the chain, let somebody else
    //  give it a shot
    return INDI::Telescope::ISNewNumber(dev, name, values, names, n);
}
Пример #6
0
bool lacerta_mfoc::SetBacklash(double values[], char *names[], int n)
{
    LOGF_DEBUG("-> BACKLASH_SETTINGS", 0);
    char MFOC_cmd[32]  = ": B ";
    char MFOC_res[32]  = {0};
    int nbytes_read    =  0;
    int nbytes_written =  0;
    int MFOC_tdir_measd = 0;
    int bl_int = 0;
    char bl_char[32]  = {0};
    char MFOC_res_type[32]  = "0";
    BacklashNP.s = IPS_OK;
    IUUpdateNumber(&BacklashNP, values, names, n);
    bl_int = BacklashN[0].value;
    sprintf(bl_char, "%d", bl_int);
    strcat(bl_char, " #");
    strcat(MFOC_cmd, bl_char);

    tty_write_string(PortFD, MFOC_cmd, &nbytes_written);
    LOGF_DEBUG("CMD <%s>", MFOC_cmd);
    tty_write_string(PortFD, ": J #", &nbytes_written);

    tty_read_section(PortFD, MFOC_res, 0xD, FOCUSMFOC_TIMEOUT, &nbytes_read);

    sscanf (MFOC_res, "%s %d", MFOC_res_type, &MFOC_tdir_measd);

    LOGF_DEBUG("RES <%s>", MFOC_res);

    IDSetNumber(&BacklashNP, nullptr);

    return true;
}
Пример #7
0
bool lacerta_mfoc::SetTempComp(double values[], char *names[], int n)
{
    LOGF_INFO("-> TEMPCOMP_SETTINGS", 0);
    char MFOC_cmd[32]  = ": D ";
    char MFOC_res[32]  = {0};
    int nbytes_read    =  0;
    int nbytes_written =  0;
    int MFOC_tc_measd = 0;
    int tc_int = 0;
    char tc_char[32]  = {0};
    char MFOC_res_type[32]  = "0";
    TempCompNP.s = IPS_OK;
    IUUpdateNumber(&TempCompNP, values, names, n);
    tc_int = TempCompN[0].value;
    sprintf(tc_char, "%d", tc_int);
    strcat(tc_char, " #");
    strcat(MFOC_cmd, tc_char);

    tty_write_string(PortFD, MFOC_cmd, &nbytes_written);
    LOGF_DEBUG("CMD <%s>", MFOC_cmd);
    tty_write_string(PortFD, ": U #", &nbytes_written);

    tty_read_section(PortFD, MFOC_res, 0xD, FOCUSMFOC_TIMEOUT, &nbytes_read);

    sscanf (MFOC_res, "%s %d", MFOC_res_type, &MFOC_tc_measd);

    LOGF_DEBUG("RES <%s>", MFOC_res);

    IDSetNumber(&TempCompNP, nullptr);

    return true;
}
Пример #8
0
bool ASICCD::ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
{
    ASI_ERROR_CODE errCode = ASI_SUCCESS;

     if(!strcmp(dev,getDeviceName()))
     {
         if (!strcmp(name, ControlNP.name))
         {
            double oldValues[ControlNP.nnp];
            for (int i=0; i < ControlNP.nnp; i++)
                oldValues[i] = ControlN[i].value;

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

            for (int i=0; i < ControlNP.nnp; i++)
            {
                ASI_BOOL nAuto = *((ASI_BOOL *) ControlN[i].aux1);
                ASI_CONTROL_TYPE nType = *((ASI_CONTROL_TYPE *) ControlN[i].aux0);

                // If value didn't change or if USB bandwidth control is to change, then only continue if ExposureRequest < 250 ms
                if (ControlN[i].value == oldValues[i] || (nType == ASI_BANDWIDTHOVERLOAD && ExposureRequest > 0.25))
                    continue;

                if ( (errCode = ASISetControlValue(m_camInfo->CameraID, nType, ControlN[i].value, ASI_FALSE)) != ASI_SUCCESS)
                {
                    DEBUGF(INDI::Logger::DBG_ERROR, "ASISetControlValue (%s=%g) error (%d)", ControlN[i].name, ControlN[i].value, errCode);
                    ControlNP.s = IPS_ALERT;
                    for (int i=0; i < ControlNP.nnp; i++)
                        ControlN[i].value = oldValues[i];
                    IDSetNumber(&ControlNP, NULL);
                    return false;
                }

                // If it was set to nAuto value to turn it off
                if (nAuto)
                {
                    for (int j=0; j < ControlSP.nsp; j++)
                    {
                        ASI_CONTROL_TYPE swType = *((ASI_CONTROL_TYPE *) ControlS[j].aux);

                        if (swType == nType)
                        {
                            ControlS[j].s = ISS_OFF;
                            break;
                        }
                    }

                    IDSetSwitch(&ControlSP, NULL);
                 }
            }

            ControlNP.s = IPS_OK;
            IDSetNumber(&ControlNP, NULL);
            return true;
         }

     }

    return INDI::CCD::ISNewNumber(dev,name,values,names,n);
}
Пример #9
0
bool INDI::LightBoxInterface::processLightBoxNumber(const char *dev, const char *name, double values[], char *names[],
                                                    int n)
{
    if (strcmp(dev, device->getDeviceName()) == 0)
    {
        // Light Intensity
        if (!strcmp(LightIntensityNP.name, name))
        {
            double prevValue = LightIntensityN[0].value;
            IUUpdateNumber(&LightIntensityNP, values, names, n);

            bool rc = SetLightBoxBrightness(LightIntensityN[0].value);
            if (rc)
                LightIntensityNP.s = IPS_OK;
            else
            {
                LightIntensityN[0].value = prevValue;
                LightIntensityNP.s       = IPS_ALERT;
            }

            IDSetNumber(&LightIntensityNP, nullptr);

            return true;
        }

        if (!strcmp(FilterIntensityNP.name, name))
        {
            if (FilterIntensityN == nullptr)
            {
                for (int i = 0; i < n; i++)
                    addFilterDuration(names[i], values[i]);

                device->defineNumber(&FilterIntensityNP);

                return true;
            }

            IUUpdateNumber(&FilterIntensityNP, values, names, n);
            FilterIntensityNP.s = IPS_OK;
            IDSetNumber(&FilterIntensityNP, nullptr);

            return true;
        }
    }

    return false;
}
Пример #10
0
bool GPhotoCCD::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
{
  if (strcmp(dev, getDeviceName()) == 0)
  {
      if (strstr(name, "FOCUS_"))
          return processFocuserNumber(dev, name, values, names, n);
      
      
      if (!strcmp(name, mMirrorLockNP.name))
      {
          IUUpdateNumber(&mMirrorLockNP, values, names, n);
          mMirrorLockNP.s = IPS_OK;
          IDSetNumber(&mMirrorLockNP, NULL);
          return true;
      }

      if(CamOptions.find(name) != CamOptions.end())
      {
          cam_opt *opt = CamOptions[name];
          if (opt->widget->type != GP_WIDGET_RANGE)
          {
              DEBUGF(INDI::Logger::DBG_ERROR, "ERROR: Property '%s'is not a string", name);
              return false;
          }
          if (opt->widget->readonly)
          {
              DEBUGF(INDI::Logger::DBG_WARNING, "WARNING: Property %s is read-only", name);
              return false;
          }
          if (IUUpdateNumber(&opt->prop.num, values, names, n) < 0)
              return false;
          gphoto_set_widget_num(gphotodrv, opt->widget, values[0]);
          opt->prop.num.s = IPS_OK;
          IDSetNumber(&opt->prop.num, NULL);
          return true;
      }
  }

  return INDI::CCD::ISNewNumber(dev, name, values, names, n);
}
Пример #11
0
bool Weather::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
{
    //  first check if it's for our device
    if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
    {
        if (strcmp(name, "GEOGRAPHIC_COORD") == 0)
        {
            int latindex       = IUFindIndex("LAT", names, n);
            int longindex      = IUFindIndex("LONG", names, n);
            int elevationindex = IUFindIndex("ELEV", names, n);

            if (latindex == -1 || longindex == -1 || elevationindex == -1)
            {
                LocationNP.s = IPS_ALERT;
                IDSetNumber(&LocationNP, "Location data missing or corrupted.");
            }

            double targetLat  = values[latindex];
            double targetLong = values[longindex];
            double targetElev = values[elevationindex];

            return processLocationInfo(targetLat, targetLong, targetElev);
        }

        // Update period
        if (strcmp(name, "WEATHER_UPDATE") == 0)
        {
            IUUpdateNumber(&UpdatePeriodNP, values, names, n);

            UpdatePeriodNP.s = IPS_OK;
            IDSetNumber(&UpdatePeriodNP, nullptr);

            if (UpdatePeriodN[0].value == 0)
                DEBUG(Logger::DBG_SESSION, "Periodic updates are disabled.");
            else
            {
                if (updateTimerID > 0)
                    RemoveTimer(updateTimerID);

                updateTimerID = SetTimer(UpdatePeriodN[0].value * 1000);
            }
            return true;
        }

        // Pass to weather interface
        if (processNumber(dev, name, values, names, n))
            return true;
    }

    return DefaultDevice::ISNewNumber(dev, name, values, names, n);
}
Пример #12
0
bool ScopeDome::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
{
    if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
    {
        if (strcmp(name, DomeHomePositionNP.name) == 0)
        {
            IUUpdateNumber(&DomeHomePositionNP, values, names, n);
            DomeHomePositionNP.s = IPS_OK;
            IDSetNumber(&DomeHomePositionNP, nullptr);
            return true;
        }
    }
    return INDI::Dome::ISNewNumber(dev, name, values, names, n);
}
Пример #13
0
bool WeatherSafetyProxy::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
{
    if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
    {
        if (strcmp(name, softErrorHysteresisNP.name) == 0)
        {
            LOG_DEBUG("WeatherSafetyProxy::ISNewNumber");
            IUUpdateNumber(&softErrorHysteresisNP, values, names, n);
            softErrorHysteresisNP.s = IPS_OK;
            IDSetNumber(&softErrorHysteresisNP, nullptr);
            return true;
        }
    }
    return INDI::Weather::ISNewNumber(dev, name, values, names, n);
}
Пример #14
0
bool IndiRpialtimu::ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
{
	// first we check if it's for our device
    if (!strcmp(dev, getDeviceName()))
    {
		// handle sync with scope
		if(!strcmp(name, AdjustmentNP.name))
		{		
			IUUpdateNumber(&AdjustmentNP, values, names, n);
			IDSetNumber(&AdjustmentNP, "Astroberry AltIMU correction entered - roll: %0.3f, pitch: %0.3f, yaw: %0.3f", AdjustmentN[0].value, AdjustmentN[1].value, AdjustmentN[2].value);
		}
	}
	
	return INDI::DefaultDevice::ISNewNumber(dev,name,values,names,n);
}
Пример #15
0
void INDI::GuiderInterface::processGuiderProperties(const char *name, double values[], char *names[], int n)
{
    if (strcmp(name, GuideNSNP.name) == 0)
    {
        //  We are being asked to send a guide pulse north/south on the st4 port
        IUUpdateNumber(&GuideNSNP, values, names, n);

        if (GuideNSN[DIRECTION_NORTH].value != 0)
        {
            GuideNSN[DIRECTION_SOUTH].value = 0;
            GuideNSNP.s                     = GuideNorth(GuideNSN[DIRECTION_NORTH].value);
        }
        else if (GuideNSN[DIRECTION_SOUTH].value != 0)
            GuideNSNP.s = GuideSouth(GuideNSN[DIRECTION_SOUTH].value);

        IDSetNumber(&GuideNSNP, nullptr);
        return;
    }

    if (strcmp(name, GuideWENP.name) == 0)
    {
        //  We are being asked to send a guide pulse north/south on the st4 port
        IUUpdateNumber(&GuideWENP, values, names, n);

        if (GuideWEN[DIRECTION_WEST].value != 0)
        {
            GuideWEN[DIRECTION_EAST].value = 0;
            GuideWENP.s                    = GuideWest(GuideWEN[DIRECTION_WEST].value);
        }
        else if (GuideWEN[DIRECTION_EAST].value != 0)
            GuideWENP.s = GuideEast(GuideWEN[DIRECTION_EAST].value);

        IDSetNumber(&GuideWENP, nullptr);
        return;
    }
}
Пример #16
0
bool WatchDog::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
{
    if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
    {
        if (!strcmp(HeartBeatNP.name, name))
        {
            double prevHeartBeat = HeartBeatN[0].value;

            if (watchdogClient->isBusy())
            {
                HeartBeatNP.s = IPS_ALERT;
                IDSetNumber(&HeartBeatNP, nullptr);
                LOG_ERROR("Cannot change heart beat while shutdown is in progress...");
                return true;
            }

            IUUpdateNumber(&HeartBeatNP, values, names, n);
            HeartBeatNP.s = IPS_OK;

            if (HeartBeatN[0].value == 0)
                LOG_INFO("Watchdog is disabled.");
            else
            {
                if (isConnected())
                {
                    if (prevHeartBeat != HeartBeatN[0].value)
                        DEBUGF(INDI::Logger::DBG_SESSION,
                               "Watchdog is enabled. Shutdown is triggered after %g minutes of communication loss with "
                               "the client.",
                               HeartBeatN[0].value);

                    LOG_DEBUG("Received heart beat from client.");

                    RemoveTimer(watchDogTimer);
                    watchDogTimer = SetTimer(HeartBeatN[0].value * 60 * 1000);
                }
                else
                    LOG_INFO("Watchdog is armed. Please connect to enable it.");
            }

            IDSetNumber(&HeartBeatNP, nullptr);

            return true;
        }
    }

    return DefaultDevice::ISNewNumber(dev, name, values, names, n);
}
Пример #17
0
bool FishCampCCD::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
{
    if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
    {
        if (!strcmp(name, GainNP.name))
        {
            IUUpdateNumber(&GainNP, values, names, n);
            setGain(GainN[0].value);
            GainNP.s = IPS_OK;
            IDSetNumber(&GainNP, nullptr);
            return true;
        }
    }

    return INDI::CCD::ISNewNumber(dev, name, values, names, n);
}
Пример #18
0
/**
 * Chain of command for setting numeric values
**/
bool IpFocus::ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
{
    if(strcmp(dev,getDeviceName())==0)
    {
        if(strcmp(name,"SEEING_SETTINGS")==0)
        {
            SeeingNP.s = IPS_OK;
            IUUpdateNumber(&SeeingNP, values, names, n);

            IDSetNumber(&SeeingNP,NULL);
            return true;

        }

    }
    return INDI::Focuser::ISNewNumber(dev,name,values,names,n);
}
Пример #19
0
bool SestoSenso::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
{
    if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
    {
        if (strcmp(name, SyncNP.name) == 0)
        {
            IUUpdateNumber(&SyncNP, values, names, n);
            if (sync(SyncN[0].value))
                SyncNP.s = IPS_OK;
            else
                SyncNP.s = IPS_ALERT;
            IDSetNumber(&SyncNP, nullptr);
            return true;
        }
    }

    return INDI::Focuser::ISNewNumber(dev, name, values, names, n);
}
Пример #20
0
/**************************************************************************************
** Client is asking us to set a new number
***************************************************************************************/
bool INovaCCD::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
{
    if (strcmp (dev, getDeviceName()))
        return false;

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

        iNovaSDK_SetAnalogGain(static_cast<int16_t>(CameraPropertiesN[CCD_GAIN_N].value));
        iNovaSDK_SetBlackLevel(static_cast<int16_t>(CameraPropertiesN[CCD_BLACKLEVEL_N].value));

        CameraPropertiesNP.s = IPS_OK;
        IDSetNumber(&CameraPropertiesNP, nullptr);
        return true;
    }

    return INDI::CCD::ISNewNumber(dev, name, values, names, n);
}
Пример #21
0
bool EQModSimulator::ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
{
    //  first check if it's for our device

    if(strcmp(dev,telescope->getDeviceName())==0)
    {
        INumberVectorProperty *nvp =telescope->getNumber(name);
        if ((nvp != SimWormNP) && (nvp != SimRatioNP) & (nvp != SimMotorNP)) return false;
        if (telescope->isConnected()) {
            DEBUGDEVICE(telescope->getDeviceName(), INDI::Logger::DBG_WARNING,"Can not change simulation settings when mount is already connected");
            return false;
        }

        nvp->s=IPS_OK;
        IUUpdateNumber(nvp,values,names,n);
        IDSetNumber(nvp,NULL);
        return true;
    }
    return false;
}
Пример #22
0
bool LX200Autostar::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
{
    if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
    {
        // Focus speed
        if (!strcmp(name, FocusSpeedNP.name))
        {
            if (IUUpdateNumber(&FocusSpeedNP, values, names, n) < 0)
                return false;

            if (!isSimulation())
                setGPSFocuserSpeed(PortFD, ((int)FocusSpeedN[0].value));
            FocusSpeedNP.s = IPS_OK;
            IDSetNumber(&FocusSpeedNP, nullptr);
            return true;
        }
    }

    return LX200Generic::ISNewNumber(dev, name, values, names, n);
}
Пример #23
0
bool FocusSim::ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
{
    if(strcmp(dev,getDeviceName())==0)
    {
        if(strcmp(name,"SEEING_SETTINGS")==0)
        {
            SeeingNP.s = IPS_OK;
            IUUpdateNumber(&SeeingNP, values, names, n);

            IDSetNumber(&SeeingNP,NULL);
            return true;

        }

    }

    //  if we didn't process it, continue up the chain, let somebody else
    //  give it a shot
    return INDI::Focuser::ISNewNumber(dev,name,values,names,n);
}
Пример #24
0
bool ATIKCCD::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
{
    if (dev != nullptr && !strcmp(dev, getDeviceName()))
    {
        if (!strcmp(name, FilterSlotNP.name))
        {
            INDI::FilterInterface::processNumber(dev, name, values, names, n);
            return true;
        }
        else if (!strcmp(name, ControlNP.name))
        {
            std::vector<double> oldValues;
            for (int i = 0; i < ControlNP.nnp; i++)
                oldValues.push_back(ControlN[i].value);

            if (IUUpdateNumber(&ControlNP, values, names, n) < 0)
            {
                ControlNP.s = IPS_ALERT;
                IDSetNumber(&ControlNP, nullptr);
                return true;
            }

            for (int i = 0; i < ControlNP.nnp; i++)
            {
                if (ControlN[i].value == oldValues[i])
                    continue;

                // Gain 0, Offset 1. We add 5 to them to get them to Atik horizon IDs
                uint16_t value = static_cast<uint16_t>(ControlN[i].value);
                ArtemisCameraSpecificOptionSetData(hCam, i + 5, reinterpret_cast<uint8_t*>(&value), 2);
            }

            ControlNP.s = IPS_OK;
            IDSetNumber(&ControlNP, nullptr);
            return true;
        }
    }

    return INDI::CCD::ISNewNumber(dev, name, values, names, n);
}
Пример #25
0
bool INDI::Focuser::ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
{
    //  first check if it's for our device
    if(strcmp(dev,getDeviceName())==0)
    {
        if (!strcmp(name, PresetNP.name))
        {
            IUUpdateNumber(&PresetNP, values, names, n);
            PresetNP.s = IPS_OK;
            IDSetNumber(&PresetNP, NULL);

            //saveConfig();

            return true;
        }

        if (strstr(name, "FOCUS_"))
            return processFocuserNumber(dev, name, values, names, n);

    }

    return DefaultDevice::ISNewNumber(dev,name,values,names,n);
}
Пример #26
0
bool QHYCFW2::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
{
    if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
    {
        if (!strcmp(name, MaxFilterNP.name))
        {
            IUUpdateNumber(&MaxFilterNP, values, names, n);
            MaxFilterNP.s = IPS_OK;
            saveConfig();
            IDSetNumber(&MaxFilterNP, nullptr);
            FilterSlotN[0].max = MaxFilterN[0].value;
            if (isConnected())
                LOG_INFO("Max number of filters updated. You must reconnect for this change to take effect.");
            else
                LOGF_INFO("Max number of filters updated to %.f", MaxFilterN[0].value);

            return true;
        }

    }

    return INDI::FilterWheel::ISNewNumber(dev, name, values, names, n);
}
Пример #27
0
bool CCDSim::ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
{
    //  first check if it's for our device
    //IDLog("INDI::CCD::ISNewNumber %s\n",name);
    if(strcmp(dev,getDeviceName())==0)
    {
        //  This is for our device
        //  Now lets see if it's something we process here

        //IDLog("CCDSim::ISNewNumber %s\n",name);
        if(strcmp(name,"SIMULATOR_SETTINGS")==0)
        {
            IUUpdateNumber(SimulatorSettingsNV, values, names, n);
            SimulatorSettingsNV->s=IPS_OK;

            //  Reset our parameters now
            SetupParms();
            IDSetNumber(SimulatorSettingsNV,NULL);
            saveConfig();

            //IDLog("Frame set to %4.0f,%4.0f %4.0f x %4.0f\n",CcdFrameN[0].value,CcdFrameN[1].value,CcdFrameN[2].value,CcdFrameN[3].value);
            //seeing=SimulatorSettingsN[0].value;
            return true;
        }

        if (strcmp(name, FilterSlotNP.name)==0)
        {
            processFilterProperties(name, values, names, n);
            return true;
        }


    }
    //  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);
}
Пример #28
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);
}
Пример #29
0
bool MaxDomeII::ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
{
    // Ignore if not ours
    if (strcmp (dev, getDeviceName()))
        return false;
    
    nTimeSinceLastCommunication = 0;
    
    // ===================================
    // TicksPerTurn
    // ===================================
    if (!strcmp (name, TicksPerTurnNP.name))
    {
        double nVal;
        char cLog[255];
        int error;
        int nRetry = 3;
        
        if (IUUpdateNumber(&TicksPerTurnNP, values, names, n) < 0)
            return false;
        
        nVal = values[0];
        if (nVal >= 100 && nVal <=500)
        {
            while (nRetry)
            {
                error = SetTicksPerCount_MaxDomeII(PortFD, nVal);
                handle_driver_error(&error,&nRetry);
            }
            if (error >= 0)
            {
                sprintf(cLog, "New Ticks Per Turn set: %lf", nVal);
                nTicksPerTurn = nVal; 
                nHomeTicks = floor(0.5 + nHomeAzimuth * nTicksPerTurn / 360.0); // Calculate Home ticks again
                TicksPerTurnNP.s = IPS_OK;
                TicksPerTurnNP.np[0].value = nVal;
                IDSetNumber(&TicksPerTurnNP, "%s", cLog);
                return true;
            }
            else
            {
                DEBUGF(INDI::Logger::DBG_ERROR, "MAX DOME II: %s",ErrorMessages[-error]);
                TicksPerTurnNP.s = IPS_ALERT;
                IDSetNumber(&TicksPerTurnNP, NULL);
            }

            return false;
        }

        // Incorrect value. 
        TicksPerTurnNP.s = IPS_ALERT;
        IDSetNumber(&TicksPerTurnNP, "Invalid Ticks Per Turn");
            
        return false;
    }
    
    // ===================================
    // HomeAzimuth
    // ===================================
    if (!strcmp (name, HomeAzimuthNP.name))
    {
        double nVal;
        char cLog[255];
		
        if (IUUpdateNumber(&HomeAzimuthNP, values, names, n) < 0)
            return false;
        
        nVal = values[0];
        if (nVal >= 0 && nVal <=360)
        {
            sprintf(cLog, "New home azimuth set: %lf", nVal);
            nHomeAzimuth = nVal;
            nHomeTicks = floor(0.5 + nHomeAzimuth * nTicksPerTurn / 360.0);
            HomeAzimuthNP.s = IPS_OK;
            HomeAzimuthNP.np[0].value = nVal;
            IDSetNumber(&HomeAzimuthNP, "%s", cLog);
            return true;
        }
        // Incorrect value. 
        HomeAzimuthNP.s = IPS_ALERT;
        IDSetNumber(&HomeAzimuthNP, "Invalid home azimuth");
        
        return false;
    }
    
    // ===================================
    // Watch dog
    // ===================================
    if (!strcmp (name, WatchDogNP.name))
    {
        double nVal;
        char cLog[255];
        
        if (IUUpdateNumber(&WatchDogNP, values, names, n) < 0)
            return false;
        
        nVal = values[0];
        if (nVal >= 0 && nVal <=3600)
        {
            sprintf(cLog, "New watch dog set: %lf", nVal);
            WatchDogNP.s = IPS_OK;
            WatchDogNP.np[0].value = nVal;
            IDSetNumber(&WatchDogNP, "%s", cLog);
            return true;
        }
        // Incorrect value. 
        WatchDogNP.s = IPS_ALERT;
        IDSetNumber(&WatchDogNP, "Invalid watch dog time");
            
        return false;
    }
    
    // ===================================
    // Shutter operation azimuth 
    // ===================================
    if (!strcmp (name, ShutterOperationAzimuthNP.name))
    {
        double nVal;
        IPState error;
        int nRetry = 3;
        
        if (IUUpdateNumber(&ShutterOperationAzimuthNP, values, names, n) < 0)
            return false;
        
        nVal = values[0];
        if (nVal >= 0 && nVal < 360)
        {
            
            error = ConfigurePark(nCloseShutterBeforePark, nVal);
            
            if (error == IPS_OK)
            {
                nParkPosition = nVal;
                ShutterOperationAzimuthNP.s = IPS_OK;
                ShutterOperationAzimuthNP.np[0].value = nVal;
                IDSetNumber(&ShutterOperationAzimuthNP, "New shutter operation azimuth set");
            }
            else
            {
                ShutterOperationAzimuthNP.s = IPS_ALERT;
                IDSetNumber(&ShutterOperationAzimuthNP, "%s", ErrorMessages[-error]);
            }
            
            return true;
        }
        // Incorrect value.
        ShutterOperationAzimuthNP.s = IPS_ALERT;
        IDSetNumber(&ShutterOperationAzimuthNP, "Invalid shutter operation azimuth position");
        
        return false;
    }

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

}
Пример #30
0
bool ArmPlat::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
{
    //IDLog( "NewNumber: %s %s %lf %s %d\n", dev, name, values[ 0 ], names[ 0 ], n );
    if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
    {
        /////////////////////////////////////////////
        // Backlash
        /////////////////////////////////////////////
        if (strcmp(name, BacklashNP.name) == 0)
        {
            IUUpdateNumber(&BacklashNP, values, names, n);
            // Only update backlash value if compensation is enabled
            if (BacklashCompensationS[BACKLASH_ENABLED].s == ISS_ON)
            {
                bool rc = setBacklash(BacklashN[0].value);
                BacklashNP.s = rc ? IPS_OK : IPS_ALERT;
            }
            else
            {
                backlash = 0;
                BacklashNP.s = IPS_OK;
            }
            IDSetNumber(&BacklashNP, nullptr);
            return true;
        }

//        if (strcmp(name, SyncNP.name) == 0)
//        {
//            bool rc = sync(static_cast<uint32_t>(values[0]));
//            SyncNP.s = rc ? IPS_OK : IPS_ALERT;
//            if (rc)
//                SyncN[0].value = values[0];

//            IDSetNumber(&SyncNP, nullptr);
//            return true;
//        }
        /////////////////////////////////////////////
        // Relative goto
        /////////////////////////////////////////////
        else if (strcmp(name, FocusRelPosNP.name) == 0)
        {
            IUUpdateNumber(&FocusRelPosNP, values, names, n);
            IDSetNumber(&FocusRelPosNP, nullptr);
            MoveRelFocuser( FocusMotionS[ 0 ].s == ISS_ON ? FOCUS_INWARD : FOCUS_OUTWARD, (uint32_t)values[ 0 ] );
            return true;
        }
        /////////////////////////////////////////////
        // MaxSpeed
        /////////////////////////////////////////////
        else if (strcmp(name, MaxSpeedNP.name) == 0)
        {
            IUUpdateNumber(&MaxSpeedNP, values, names, n);
            bool rc = setMaxSpeed(MaxSpeedN[0].value);
            MaxSpeedNP.s = rc ? IPS_OK : IPS_ALERT;
            IDSetNumber(&MaxSpeedNP, nullptr);
            return true;
        }
    }

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