void INDI::BaseClientQt::sendNewSwitch (const char * deviceName, const char * propertyName, const char * elementName) { INDI::BaseDevice * drv = getDevice(deviceName); if (drv == NULL) return; ISwitchVectorProperty * svp = drv->getSwitch(propertyName); if (svp == NULL) return; ISwitch * sp = IUFindSwitch(svp, elementName); if (sp == NULL) return; sp->s = ISS_ON; sendNewSwitch(svp); }
void INDI_P::newSwitch(const QString & name) { ISwitchVectorProperty *svp = dataProp->getSwitch(); if (svp == NULL) return; ISwitch *sp = IUFindSwitch(svp, name.toLatin1().constData()); if (sp == NULL) return; if (svp->r == ISR_1OFMANY) { IUResetSwitch(svp); sp->s = ISS_ON; } else sp->s = (sp->s == ISS_ON) ? ISS_OFF : ISS_ON; sendSwitch(); }
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(); }
bool ioptronHC8406::ReadScopeStatus() { //return true; //for debug if (!isConnected()) return false; if (isSimulation()) { mountSim(); return true; } switch (TrackState) { case SCOPE_IDLE: DEBUG(INDI::Logger::DBG_WARNING, "<ReadScopeStatus> IDLE"); break; case SCOPE_SLEWING: DEBUG(INDI::Logger::DBG_WARNING, "<ReadScopeStatus> SLEWING"); break; case SCOPE_TRACKING: DEBUG(INDI::Logger::DBG_WARNING, "<ReadScopeStatus> TRACKING"); break; case SCOPE_PARKING: DEBUG(INDI::Logger::DBG_WARNING, "<ReadScopeStatus> PARKING"); break; case SCOPE_PARKED: DEBUG(INDI::Logger::DBG_WARNING, "<ReadScopeStatus> PARKED"); break; default: DEBUG(INDI::Logger::DBG_WARNING, "<ReadScopeStatus> UNDEFINED"); break; } if (TrackState == SCOPE_SLEWING ) { // Check if LX200 is done slewing if (isSlewComplete()) { usleep(1000000); //Wait until :MS# finish if (IUFindSwitch(&CoordSP, "SYNC")->s == ISS_ON || IUFindSwitch(&CoordSP, "SLEW")->s == ISS_ON) { TrackState = SCOPE_IDLE; DEBUG(INDI::Logger::DBG_WARNING, "Slew is complete. IDLE"); SetTrackEnabled(false); } else { TrackState = SCOPE_TRACKING; DEBUG(INDI::Logger::DBG_WARNING, "Slew is complete. TRACKING"); SetTrackEnabled(true); } } } else if (TrackState == SCOPE_PARKING) { // isSlewComplete() not work because is base on actual RA/DEC vs target RA/DEC. DO ALWAYS if (true || isSlewComplete()) { SetParked(true); TrackState = SCOPE_PARKED; } } if (getLX200RA(PortFD, ¤tRA) < 0 || getLX200DEC(PortFD, ¤tDEC) < 0) { EqNP.s = IPS_ALERT; IDSetNumber(&EqNP, "Error reading RA/DEC."); return false; } NewRaDec(currentRA, currentDEC); //sendScopeTime(); //syncSideOfPier(); return true; }
bool RoboFocus::ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n) { if(strcmp(dev,getDeviceName())==0) { if (!strcmp (name, PowerSwitchesSP.name)) { int ret= -1 ; int nset= 0 ; int i= 0 ; int new_s= -1 ; int new_sn= -1 ; int cur_s1LL=0 ; int cur_s2LR=0 ; int cur_s3RL=0 ; int cur_s4RR=0 ; ISwitch *sp ; PowerSwitchesSP.s = IPS_BUSY ; IDSetSwitch(&PowerSwitchesSP, NULL) ; for( nset = i = 0; i < n; i++) { /* Find numbers with the passed names in the SettingsNP property */ sp = IUFindSwitch (&PowerSwitchesSP, names[i]) ; /* If the state found is (PowerSwitchesS[0]) then process it */ if( sp == &PowerSwitchesS[0]){ new_s = (states[i]) ; new_sn= 0; nset++ ; } else if( sp == &PowerSwitchesS[1]){ new_s = (states[i]) ; new_sn= 1; nset++ ; } else if( sp == &PowerSwitchesS[2]){ new_s = (states[i]) ; new_sn= 2; nset++ ; } else if( sp == &PowerSwitchesS[3]){ new_s = (states[i]) ; new_sn= 3; nset++ ; } } if (nset == 1) { cur_s1LL= cur_s2LR= cur_s3RL= cur_s4RR= 0 ; if(( ret= updateRFPowerSwitches(new_s, new_sn, &cur_s1LL, &cur_s2LR, &cur_s3RL, &cur_s4RR)) < 0) { PowerSwitchesSP.s = IPS_ALERT; IDSetSwitch(&PowerSwitchesSP, "Unknown error while reading Robofocus power swicht settings"); return true; } } else { /* Set property state to idle */ PowerSwitchesSP.s = IPS_IDLE ; IDSetNumber(&SettingsNP, "Power switch settings absent or bogus."); return true ; } } } return INDI::Focuser::ISNewSwitch(dev, name, states, names, n); }
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); }
bool Camera_INDIClass::Capture(int duration, usImage& img, int options, const wxRect& subframeArg) { if (Connected) { bool takeSubframe = UseSubframes; wxRect subframe(subframeArg); // we can set the exposure time directly in the camera if (expose_prop) { if (Binning != m_curBinning) { FullSize = wxSize(m_maxSize.x / Binning, m_maxSize.y / Binning); binning_x->value = Binning; binning_y->value = Binning; sendNewNumber(binning_prop); m_curBinning = Binning; } if (subframe.width <= 0 || subframe.height <= 0) { takeSubframe = false; } // Program the size if (!takeSubframe) { subframe = wxRect(0, 0, FullSize.GetWidth(), FullSize.GetHeight()); } if (subframe != m_roi) { frame_x->value = subframe.x*Binning; frame_y->value = subframe.y*Binning; frame_width->value = subframe.width*Binning; frame_height->value = subframe.height*Binning; sendNewNumber(frame_prop); m_roi = subframe; } //printf("Exposing for %d(ms)\n", duration); // set the exposure time, this immediately start the exposure expose_prop->np->value = (double)duration/1000; sendNewNumber(expose_prop); modal = true; // will be reset when the image blob is received unsigned long loopwait = duration > 100 ? 10 : 1; CameraWatchdog watchdog(duration, GetTimeoutMs()); while (modal) { wxMilliSleep(loopwait); if (WorkerThread::TerminateRequested()) return true; if (watchdog.Expired()) { DisconnectWithAlert(CAPT_FAIL_TIMEOUT); return true; } } } // for video camera without exposure time setting else if (video_prop) { takeSubframe = false; //printf("Enabling video capture\n"); ISwitch *v_on = IUFindSwitch(video_prop,"ON"); ISwitch *v_off = IUFindSwitch(video_prop,"OFF"); v_on->s = ISS_ON; v_off->s = ISS_OFF; // start capture, every video frame is received as a blob sendNewSwitch(video_prop); // wait the required time wxMilliSleep(duration); // TODO : add the frames received during exposure //printf("Stop video capture\n"); v_on->s = ISS_OFF; v_off->s = ISS_ON; sendNewSwitch(video_prop); } else { return true; } //printf("Exposure end\n"); if (strcmp(cam_bp->format, ".fits") == 0) { //printf("Processing fits file\n"); // for CCD camera if ( ! ReadFITS(img,takeSubframe,subframe) ) { if (options & CAPTURE_SUBTRACT_DARK) { //printf("Subtracting dark\n"); SubtractDark(img); } if (options & CAPTURE_RECON) { if (PixSizeX != PixSizeY) SquarePixels(img, PixSizeX, PixSizeY); } return false; } else { return true; } } else if (strcmp(cam_bp->format, ".stream") == 0) { //printf("Processing stream file\n"); // for video camera return ReadStream(img); } else { pFrame->Alert(_("Unknown image format: ") + wxString::FromAscii(cam_bp->format)); return true; } } else { // in case the camera is not connected return true; } // we must never go here return true; }
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(); }