bool IEQPro::updateLocation(double latitude, double longitude, double elevation) { INDI_UNUSED(elevation); if (longitude > 180) longitude -= 360; if (set_ieqpro_longitude(PortFD, longitude) == false) { DEBUG(INDI::Logger::DBG_ERROR, "Failed to set longitude."); return false; } if (set_ieqpro_latitude(PortFD, latitude) == false) { DEBUG(INDI::Logger::DBG_ERROR, "Failed to set longitude."); return false; } char l[32], L[32]; fs_sexa (l, latitude, 3, 3600); fs_sexa (L, longitude, 4, 3600); DEBUGF(INDI::Logger::DBG_SESSION, "Site location updated to Lat %.32s - Long %.32s", l, L); return true; }
bool ioptronHC8406::updateLocation(double latitude, double longitude, double elevation) { INDI_UNUSED(elevation); if (isSimulation()) return true; double final_longitude; if (longitude > 180) final_longitude = longitude - 360.0; else final_longitude = longitude; if (!isSimulation() && setioptronHC8406Longitude(final_longitude) < 0) { DEBUG(INDI::Logger::DBG_ERROR, "Error setting site longitude coordinates"); return false; } if (!isSimulation() && setioptronHC8406Latitude(latitude) < 0) { DEBUG(INDI::Logger::DBG_ERROR, "Error setting site latitude coordinates"); return false; } char l[32], L[32]; fs_sexa(l, latitude, 3, 3600); fs_sexa(L, longitude, 4, 3600); IDMessage(getDeviceName(), "Site location updated to Lat %.32s - Long %.32s", l, L); return true; }
bool IEQPro::Goto(double r,double d) { targetRA=r; targetDEC=d; char RAStr[64], DecStr[64]; fs_sexa(RAStr, targetRA, 2, 3600); fs_sexa(DecStr, targetDEC, 2, 3600); if (set_ieqpro_ra(PortFD, r) == false || set_ieqpro_dec(PortFD, d) == false) { DEBUG(INDI::Logger::DBG_ERROR, "Error setting RA/DEC."); return false; } if (slew_ieqpro(PortFD) == false) { DEBUG(INDI::Logger::DBG_ERROR, "Failed to slew."); return false; } TrackState = SCOPE_SLEWING; IDMessage(getDeviceName(), "Slewing to RA: %s - DEC: %s", RAStr, DecStr); return true; }
void LX200_16::handleAltAzSlew() { int i=0; char altStr[64], azStr[64]; if (horNum.s == IPS_BUSY) { abortSlew(); // sleep for 100 mseconds usleep(100000); } if ((i = slewToAltAz())) { horNum.s = IPS_IDLE; IDSetNumber(&horNum, "Slew not possible"); return; } horNum.s = IPS_BUSY; fs_sexa(azStr, targetAz, 2, 3600); fs_sexa(altStr, targetAlt, 2, 3600); IDSetNumber(&horNum, "Slewing to Alt %s - Az %s", altStr, azStr); return; }
bool LX200_16::handleAltAzSlew() { char altStr[64], azStr[64]; if (HorizontalCoordsNP.s == IPS_BUSY) { abortSlew(PortFD); // sleep for 100 mseconds usleep(100000); } if (isSimulation() == false && slewToAltAz(PortFD)) { HorizontalCoordsNP.s = IPS_ALERT; IDSetNumber(&HorizontalCoordsNP, "Slew is not possible."); return false; } HorizontalCoordsNP.s = IPS_BUSY; fs_sexa(azStr, targetAZ, 2, 3600); fs_sexa(altStr, targetALT, 2, 3600); TrackState = SCOPE_SLEWING; IDSetNumber(&HorizontalCoordsNP, "Slewing to Alt %s - Az %s", altStr, azStr); return true; }
bool SynscanDriver::SetCurrentPark() { char res[SYN_RES] = {0}; // Get Current Az/Alt memset(res, 0, SYN_RES); if (!sendCommand("z", res)) return false; uint32_t n1 = 0, n2 = 0; sscanf(res, "%ux,%ux#", &n1, &n2); double az = static_cast<double>(n1) / 0x100000000 * 360.0; double al = static_cast<double>(n2) / 0x100000000 * 360.0; al = rangeDec(al); char AzStr[16], AltStr[16]; fs_sexa(AzStr, az, 2, 3600); fs_sexa(AltStr, al, 2, 3600); LOGF_DEBUG("Setting current parking position to coordinates Az (%s) Alt (%s)...", AzStr, AltStr); SetAxis1Park(az); SetAxis2Park(al); return true; }
/* fill buf with properly formatted INumber string. return length */ int numberFormat(char *buf, const char *format, double value) { int w, f, s; char m; if (sscanf(format, "%%%d.%d%c", &w, &f, &m) == 3 && m == 'm') { /* INDI sexi format */ switch (f) { case 9: s = 360000; break; case 8: s = 36000; break; case 6: s = 3600; break; case 5: s = 600; break; default: s = 60; break; } return (fs_sexa(buf, value, w - f, s)); } else { /* normal printf format */ return (snprintf(buf, MAXINDIFORMAT, format, value)); } }
bool SynscanDriver::Park() { double parkAZ = GetAxis1Park(); double parkAlt = GetAxis2Park(); char AzStr[16], AltStr[16]; fs_sexa(AzStr, parkAZ, 2, 3600); fs_sexa(AltStr, parkAlt, 2, 3600); LOGF_DEBUG("Parking to Az (%s) Alt (%s)...", AzStr, AltStr); if (GotoAzAlt(parkAZ, parkAlt)) { TrackState = SCOPE_PARKING; LOG_INFO("Parking is in progress..."); return true; } return false; }
/************************************************************************************** ** Client is asking us to slew to a new position ***************************************************************************************/ bool SimpleScope::Goto(double ra, double dec) { targetRA=ra; targetDEC=dec; char RAStr[64], DecStr[64]; // Parse the RA/DEC into strings fs_sexa(RAStr, targetRA, 2, 3600); fs_sexa(DecStr, targetDEC, 2, 3600); // Mark state as slewing TrackState = SCOPE_SLEWING; // Inform client we are slewing to a new position DEBUGF(INDI::Logger::DBG_SESSION, "Slewing to RA: %s - DEC: %s", RAStr, DecStr); // Success! return true; }
void cmd_getTelescopeDEC(BaseSequentialStream *chp, int argc, char *argv){ (void) argv; char out[20]; if (argc != 0 ) { chprintf(chp, "0"); return; } fs_sexa (out, telescopeDEC, 0, 3600,1); chprintf(chp, "%s#",out); }
void cmd_getTargetRA(BaseSequentialStream *chp, int argc, char *argv){ (void) argv; char out[20]; if (argc != 0 ) { chprintf(chp, "0"); return; } fs_sexa (out, targetRA, 0, 3600,0); chprintf(chp, "%s#",out); }
bool ScopeSim::Goto(double r, double d) { targetRA = r; targetDEC = d; char RAStr[64], DecStr[64]; fs_sexa(RAStr, targetRA, 2, 3600); fs_sexa(DecStr, targetDEC, 2, 3600); ln_equ_posn lnradec { 0, 0 }; lnradec.ra = (currentRA * 360) / 24.0; lnradec.dec = currentDEC; ln_get_hrz_from_equ(&lnradec, &lnobserver, ln_get_julian_from_sys(), &lnaltaz); /* libnova measures azimuth from south towards west */ double current_az = range360(lnaltaz.az + 180); //double current_alt =lnaltaz.alt; if (current_az > MIN_AZ_FLIP && current_az < MAX_AZ_FLIP) { lnradec.ra = (r * 360) / 24.0; lnradec.dec = d; ln_get_hrz_from_equ(&lnradec, &lnobserver, ln_get_julian_from_sys(), &lnaltaz); double target_az = range360(lnaltaz.az + 180); //if (targetAz > currentAz && target_az > MIN_AZ_FLIP && target_az < MAX_AZ_FLIP) if (target_az >= current_az && target_az > MIN_AZ_FLIP) { forceMeridianFlip = true; } } TrackState = SCOPE_SLEWING; EqNP.s = IPS_BUSY; DEBUGF(INDI::Logger::DBG_SESSION, "Slewing to RA: %s - DEC: %s", RAStr, DecStr); return true; }
bool IEQPro::Park() { targetRA = GetAxis1Park(); targetDEC = GetAxis2Park(); if (set_ieqpro_ra(PortFD, targetRA) == false || set_ieqpro_dec(PortFD, targetDEC) == false) { DEBUG(INDI::Logger::DBG_ERROR, "Error setting RA/DEC."); return false; } if (park_ieqpro(PortFD)) { char RAStr[64], DecStr[64]; fs_sexa(RAStr, targetRA, 2, 3600); fs_sexa(DecStr, targetDEC, 2, 3600); TrackState = SCOPE_PARKING; DEBUGF(INDI::Logger::DBG_SESSION, "Telescope parking in progress to RA: %s DEC: %s", RAStr, DecStr); return true; } else return false; }
bool ScopeSim::Goto(double r, double d) { targetRA = r; targetDEC = d; char RAStr[64], DecStr[64]; fs_sexa(RAStr, targetRA, 2, 3600); fs_sexa(DecStr, targetDEC, 2, 3600); double current_az = getAzimuth(currentRA, currentDEC); if (current_az > MIN_AZ_FLIP && current_az < MAX_AZ_FLIP) { double target_az = getAzimuth(r, d); //if (targetAz > currentAz && target_az > MIN_AZ_FLIP && target_az < MAX_AZ_FLIP) if (target_az >= current_az && target_az > MIN_AZ_FLIP) { forceMeridianFlip = true; } } if (IUFindOnSwitchIndex(&TrackModeSP) != SLEW_MAX) { IUResetSwitch(&TrackModeSP); TrackModeS[SLEW_MAX].s = ISS_ON; IDSetSwitch(&TrackModeSP, nullptr); } TrackState = SCOPE_SLEWING; EqNP.s = IPS_BUSY; LOGF_INFO("Slewing to RA: %s - DEC: %s", RAStr, DecStr); return true; }
bool SynscanDriver::ReadScopeStatus() { if (isSimulation()) { mountSim(); return true; } char res[SYN_RES] = {0}; // Goto in progress? if (sendCommand("L", res)) m_MountInfo[MI_GOTO_STATUS] = res[0]; // Pier side if (m_isAltAz == false && sendCommand("p", res)) { m_MountInfo[MI_POINT_STATUS] = res[0]; // INDI and mount pier sides are opposite to each other setPierSide(res[0] == 'W' ? PIER_EAST : PIER_WEST); } if (readTracking()) { if (TrackState == SCOPE_SLEWING) { if (isSlewComplete()) { TrackState = (m_TrackingFlag == 2) ? SCOPE_TRACKING : SCOPE_IDLE; HorizontalCoordsNP.s = (m_TrackingFlag == 2) ? IPS_OK : IPS_IDLE; IDSetNumber(&HorizontalCoordsNP, nullptr); } } else if (TrackState == SCOPE_PARKING) { if (isSlewComplete()) { HorizontalCoordsNP.s = IPS_IDLE; IDSetNumber(&HorizontalCoordsNP, nullptr); TrackState = SCOPE_PARKED; SetTrackEnabled(false); SetParked(true); } } else if (TrackState == SCOPE_IDLE && m_TrackingFlag > 0) TrackState = SCOPE_TRACKING; else if (TrackState == SCOPE_TRACKING && m_TrackingFlag == 0) TrackState = SCOPE_IDLE; } sendStatus(); // Get Precise RA/DE memset(res, 0, SYN_RES); if (!sendCommand("e", res)) return false; uint32_t n1 = 0, n2 = 0; sscanf(res, "%x,%x#", &n1, &n2); double ra = static_cast<double>(n1) / 0x100000000 * 360.0; double de = static_cast<double>(n2) / 0x100000000 * 360.0; ln_equ_posn epochPos { 0, 0 }, J2000Pos { 0, 0 }; J2000Pos.ra = range360(ra); J2000Pos.dec = rangeDec(de); // Synscan reports J2000 coordinates so we need to convert from J2000 to JNow ln_get_equ_prec2(&J2000Pos, JD2000, ln_get_julian_from_sys(), &epochPos); CurrentRA = epochPos.ra / 15.0; CurrentDE = epochPos.dec; char Axis1Coords[MAXINDINAME] = {0}, Axis2Coords[MAXINDINAME] = {0}; fs_sexa(Axis1Coords, J2000Pos.ra / 15.0, 2, 3600); fs_sexa(Axis2Coords, J2000Pos.dec, 2, 3600); LOGF_DEBUG("J2000 RA <%s> DE <%s>", Axis1Coords, Axis2Coords); memset(Axis1Coords, 0, MAXINDINAME); memset(Axis2Coords, 0, MAXINDINAME); fs_sexa(Axis1Coords, CurrentRA, 2, 3600); fs_sexa(Axis2Coords, CurrentDE, 2, 3600); LOGF_DEBUG("JNOW RA <%s> DE <%s>", Axis1Coords, Axis2Coords); // Now feed the rest of the system with corrected data NewRaDec(CurrentRA, CurrentDE); // Get precise az/alt memset(res, 0, SYN_RES); if (!sendCommand("z", res)) return false; sscanf(res, "%x,%x#", &n1, &n2); double az = static_cast<double>(n1) / 0x100000000 * 360.0; double al = static_cast<double>(n2) / 0x100000000 * 360.0; al = rangeDec(al); HorizontalCoordsN[AXIS_AZ].value = az; HorizontalCoordsN[AXIS_ALT].value = al; memset(Axis1Coords, 0, MAXINDINAME); memset(Axis2Coords, 0, MAXINDINAME); fs_sexa(Axis1Coords, az, 2, 3600); fs_sexa(Axis2Coords, al, 2, 3600); LOGF_DEBUG("AZ <%s> ALT <%s>", Axis1Coords, Axis2Coords); IDSetNumber(&HorizontalCoordsNP, nullptr); return true; }
bool ScopeSim::ReadScopeStatus() { static struct timeval ltv { 0, 0 }; struct timeval tv { 0, 0 }; double dt = 0, da_ra = 0, da_dec = 0, dx = 0, dy = 0, ra_guide_dt = 0, dec_guide_dt = 0; static double last_dx = 0, last_dy = 0; int nlocked, ns_guide_dir = -1, we_guide_dir = -1; char RA_DISP[64], DEC_DISP[64], RA_GUIDE[64], DEC_GUIDE[64], RA_PE[64], DEC_PE[64], RA_TARGET[64], DEC_TARGET[64]; /* update elapsed time since last poll, don't presume exactly POLLMS */ gettimeofday(&tv, nullptr); if (ltv.tv_sec == 0 && ltv.tv_usec == 0) ltv = tv; dt = tv.tv_sec - ltv.tv_sec + (tv.tv_usec - ltv.tv_usec) / 1e6; ltv = tv; if (fabs(targetRA - currentRA) * 15. >= GOTO_LIMIT) da_ra = GOTO_RATE * dt; else if (fabs(targetRA - currentRA) * 15. >= SLEW_LIMIT) da_ra = SLEW_RATE * dt; else da_ra = FINE_SLEW_RATE * dt; if (fabs(targetDEC - currentDEC) >= GOTO_LIMIT) da_dec = GOTO_RATE * dt; else if (fabs(targetDEC - currentDEC) >= SLEW_LIMIT) da_dec = SLEW_RATE * dt; else da_dec = FINE_SLEW_RATE * dt; if (MovementNSSP.s == IPS_BUSY || MovementWESP.s == IPS_BUSY) { int rate = IUFindOnSwitchIndex(&SlewRateSP); switch (rate) { case SLEW_GUIDE: da_ra = FINE_SLEW_RATE * dt * 0.05; da_dec = FINE_SLEW_RATE * dt * 0.05; break; case SLEW_CENTERING: da_ra = FINE_SLEW_RATE * dt * .1; da_dec = FINE_SLEW_RATE * dt * .1; break; case SLEW_FIND: da_ra = SLEW_RATE * dt; da_dec = SLEW_RATE * dt; break; default: da_ra = GOTO_RATE * dt; da_dec = GOTO_RATE * dt; break; } switch (MovementNSSP.s) { case IPS_BUSY: if (MovementNSS[DIRECTION_NORTH].s == ISS_ON) currentDEC += da_dec; else if (MovementNSS[DIRECTION_SOUTH].s == ISS_ON) currentDEC -= da_dec; break; default: break; } switch (MovementWESP.s) { case IPS_BUSY: if (MovementWES[DIRECTION_WEST].s == ISS_ON) currentRA += da_ra / 15.; else if (MovementWES[DIRECTION_EAST].s == ISS_ON) currentRA -= da_ra / 15.; break; default: break; } NewRaDec(currentRA, currentDEC); return true; } /* Process per current state. We check the state of EQUATORIAL_EOD_COORDS_REQUEST and act acoordingly */ switch (TrackState) { /*case SCOPE_IDLE: EqNP.s = IPS_IDLE; break;*/ case SCOPE_SLEWING: case SCOPE_PARKING: /* slewing - nail it when both within one pulse @ SLEWRATE */ nlocked = 0; dx = targetRA - currentRA; // Always take the shortcut, don't go all around the globe // If the difference between target and current is more than 12 hours, then we need to take the shortest path if (dx > 12) dx -= 24; else if (dx < -12) dx += 24; // In meridian flip, alway force eastward motion (increasing RA) until target is reached. if (forceMeridianFlip) { dx = fabs(dx); if (dx == 0) { dx = 1; da_ra = GOTO_LIMIT; } } if (fabs(dx) * 15. <= da_ra) { currentRA = targetRA; nlocked++; } else if (dx > 0) currentRA += da_ra / 15.; else currentRA -= da_ra / 15.; currentRA = range24(currentRA); dy = targetDEC - currentDEC; if (fabs(dy) <= da_dec) { currentDEC = targetDEC; nlocked++; } else if (dy > 0) currentDEC += da_dec; else currentDEC -= da_dec; EqNP.s = IPS_BUSY; if (nlocked == 2) { forceMeridianFlip = false; if (TrackState == SCOPE_SLEWING) { // Initially no PE in both axis. EqPEN[0].value = currentRA; EqPEN[1].value = currentDEC; IDSetNumber(&EqPENV, nullptr); TrackState = SCOPE_TRACKING; EqNP.s = IPS_OK; DEBUG(INDI::Logger::DBG_SESSION, "Telescope slew is complete. Tracking..."); } else { SetParked(true); EqNP.s = IPS_IDLE; } } break; case SCOPE_IDLE: //currentRA += (TRACKRATE_SIDEREAL/3600.0 * dt) / 15.0; currentRA += (TrackRateN[AXIS_RA].value/3600.0 * dt) / 15.0; currentRA = range24(currentRA); break; case SCOPE_TRACKING: // In case of custom tracking rate if (TrackModeS[1].s == ISS_ON) { currentRA += ( ((TRACKRATE_SIDEREAL/3600.0) - (TrackRateN[AXIS_RA].value/3600.0)) * dt) / 15.0; currentDEC += ( (TrackRateN[AXIS_DE].value/3600.0) * dt); } dt *= 1000; if (guiderNSTarget[GUIDE_NORTH] > 0) { DEBUGF(INDI::Logger::DBG_DEBUG, "Commanded to GUIDE NORTH for %g ms", guiderNSTarget[GUIDE_NORTH]); ns_guide_dir = GUIDE_NORTH; } else if (guiderNSTarget[GUIDE_SOUTH] > 0) { DEBUGF(INDI::Logger::DBG_DEBUG, "Commanded to GUIDE SOUTH for %g ms", guiderNSTarget[GUIDE_SOUTH]); ns_guide_dir = GUIDE_SOUTH; } // WE Guide Selection if (guiderEWTarget[GUIDE_WEST] > 0) { we_guide_dir = GUIDE_WEST; DEBUGF(INDI::Logger::DBG_DEBUG, "Commanded to GUIDE WEST for %g ms", guiderEWTarget[GUIDE_WEST]); } else if (guiderEWTarget[GUIDE_EAST] > 0) { we_guide_dir = GUIDE_EAST; DEBUGF(INDI::Logger::DBG_DEBUG, "Commanded to GUIDE EAST for %g ms", guiderEWTarget[GUIDE_EAST]); } if (ns_guide_dir != -1) { dec_guide_dt = TrackRateN[AXIS_RA].value/3600.0 * GuideRateN[DEC_AXIS].value * guiderNSTarget[ns_guide_dir] / 1000.0 * (ns_guide_dir == GUIDE_NORTH ? 1 : -1); // If time remaining is more that dt, then decrement and if (guiderNSTarget[ns_guide_dir] >= dt) guiderNSTarget[ns_guide_dir] -= dt; else guiderNSTarget[ns_guide_dir] = 0; if (guiderNSTarget[ns_guide_dir] == 0) { GuideNSNP.s = IPS_IDLE; IDSetNumber(&GuideNSNP, nullptr); } EqPEN[DEC_AXIS].value += dec_guide_dt; } if (we_guide_dir != -1) { ra_guide_dt = (TrackRateN[AXIS_RA].value/3600.0) / 15.0 * GuideRateN[RA_AXIS].value * guiderEWTarget[we_guide_dir] / 1000.0 * (we_guide_dir == GUIDE_WEST ? -1 : 1); if (guiderEWTarget[we_guide_dir] >= dt) guiderEWTarget[we_guide_dir] -= dt; else guiderEWTarget[we_guide_dir] = 0; if (guiderEWTarget[we_guide_dir] == 0) { GuideWENP.s = IPS_IDLE; IDSetNumber(&GuideWENP, nullptr); } EqPEN[RA_AXIS].value += ra_guide_dt; } //Mention the followng: // Current RA displacemet and direction // Current DEC displacement and direction // Amount of RA GUIDING correction and direction // Amount of DEC GUIDING correction and direction dx = EqPEN[RA_AXIS].value - targetRA; dy = EqPEN[DEC_AXIS].value - targetDEC; fs_sexa(RA_DISP, fabs(dx), 2, 3600); fs_sexa(DEC_DISP, fabs(dy), 2, 3600); fs_sexa(RA_GUIDE, fabs(ra_guide_dt), 2, 3600); fs_sexa(DEC_GUIDE, fabs(dec_guide_dt), 2, 3600); fs_sexa(RA_PE, EqPEN[RA_AXIS].value, 2, 3600); fs_sexa(DEC_PE, EqPEN[DEC_AXIS].value, 2, 3600); fs_sexa(RA_TARGET, targetRA, 2, 3600); fs_sexa(DEC_TARGET, targetDEC, 2, 3600); if (dx != last_dx || dy != last_dy || ra_guide_dt != 0.0 || dec_guide_dt != 0.0) { last_dx = dx; last_dy = dy; //DEBUGF(INDI::Logger::DBG_DEBUG, "dt is %g\n", dt); DEBUGF(INDI::Logger::DBG_DEBUG, "RA Displacement (%c%s) %s -- %s of target RA %s", dx >= 0 ? '+' : '-', RA_DISP, RA_PE, (EqPEN[RA_AXIS].value - targetRA) > 0 ? "East" : "West", RA_TARGET); DEBUGF(INDI::Logger::DBG_DEBUG, "DEC Displacement (%c%s) %s -- %s of target RA %s", dy >= 0 ? '+' : '-', DEC_DISP, DEC_PE, (EqPEN[DEC_AXIS].value - targetDEC) > 0 ? "North" : "South", DEC_TARGET); DEBUGF(INDI::Logger::DBG_DEBUG, "RA Guide Correction (%g) %s -- Direction %s", ra_guide_dt, RA_GUIDE, ra_guide_dt > 0 ? "East" : "West"); DEBUGF(INDI::Logger::DBG_DEBUG, "DEC Guide Correction (%g) %s -- Direction %s", dec_guide_dt, DEC_GUIDE, dec_guide_dt > 0 ? "North" : "South"); } if (ns_guide_dir != -1 || we_guide_dir != -1) IDSetNumber(&EqPENV, nullptr); break; default: break; } char RAStr[64], DecStr[64]; fs_sexa(RAStr, currentRA, 2, 3600); fs_sexa(DecStr, currentDEC, 2, 3600); DEBUGF(DBG_SCOPE, "Current RA: %s Current DEC: %s", RAStr, DecStr); NewRaDec(currentRA, currentDEC); return true; }
bool ioptronHC8406::Goto(double r, double d) { targetRA = r; targetDEC = d; char RAStr[64], DecStr[64]; fs_sexa(RAStr, targetRA, 2, 3600); fs_sexa(DecStr, targetDEC, 2, 3600); DEBUGF(INDI::Logger::DBG_DEBUG, "<GOTO RA/DEC> %s/%s",RAStr,DecStr); // If moving, let's stop it first. if (EqNP.s == IPS_BUSY) { if (!isSimulation() && abortSlew(PortFD) < 0) { AbortSP.s = IPS_ALERT; IDSetSwitch(&AbortSP, "Abort slew failed."); return false; } AbortSP.s = IPS_OK; EqNP.s = IPS_IDLE; IDSetSwitch(&AbortSP, "Slew aborted."); IDSetNumber(&EqNP, nullptr); if (MovementNSSP.s == IPS_BUSY || MovementWESP.s == IPS_BUSY) { MovementNSSP.s = MovementWESP.s = IPS_IDLE; EqNP.s = IPS_IDLE; IUResetSwitch(&MovementNSSP); IUResetSwitch(&MovementWESP); IDSetSwitch(&MovementNSSP, nullptr); IDSetSwitch(&MovementWESP, nullptr); } // sleep for 100 mseconds usleep(100000); } // If parking/parked, let's unpark it first. /* if (TrackState == SCOPE_PARKING || TrackState == SCOPE_PARKED) { UnPark(); }*/ if (!isSimulation()) { if (setObjectRA(PortFD, targetRA) < 0 || (setObjectDEC(PortFD, targetDEC)) < 0) { EqNP.s = IPS_ALERT; IDSetNumber(&EqNP, "Error setting RA/DEC."); return false; } if (slewioptronHC8406() == 0) //action { EqNP.s = IPS_ALERT; IDSetNumber(&EqNP, "Error Slewing to JNow RA %s - DEC %s\n", RAStr, DecStr); slewError(1); return false; } } TrackState = SCOPE_SLEWING; EqNP.s = IPS_BUSY; DEBUGF(INDI::Logger::DBG_DEBUG, "Slewing to RA: %s - DEC: %s",RAStr,DecStr); return true; }
/************************************************************************************** ** Client is asking us to report telescope status ***************************************************************************************/ bool SimpleScope::ReadScopeStatus() { static struct timeval ltv; struct timeval tv; double dt=0, da_ra=0, da_dec=0, dx=0, dy=0; int nlocked; /* update elapsed time since last poll, don't presume exactly POLLMS */ gettimeofday (&tv, NULL); if (ltv.tv_sec == 0 && ltv.tv_usec == 0) ltv = tv; dt = tv.tv_sec - ltv.tv_sec + (tv.tv_usec - ltv.tv_usec)/1e6; ltv = tv; // Calculate how much we moved since last time da_ra = SLEW_RATE *dt; da_dec = SLEW_RATE *dt; /* Process per current state. We check the state of EQUATORIAL_EOD_COORDS_REQUEST and act acoordingly */ switch (TrackState) { case SCOPE_SLEWING: // Wait until we are "locked" into positon for both RA & DEC axis nlocked = 0; // Calculate diff in RA dx = targetRA - currentRA; // If diff is very small, i.e. smaller than how much we changed since last time, then we reached target RA. if (fabs(dx)*15. <= da_ra) { currentRA = targetRA; nlocked++; } // Otherwise, increase RA else if (dx > 0) currentRA += da_ra/15.; // Otherwise, decrease RA else currentRA -= da_ra/15.; // Calculate diff in DEC dy = targetDEC - currentDEC; // If diff is very small, i.e. smaller than how much we changed since last time, then we reached target DEC. if (fabs(dy) <= da_dec) { currentDEC = targetDEC; nlocked++; } // Otherwise, increase DEC else if (dy > 0) currentDEC += da_dec; // Otherwise, decrease DEC else currentDEC -= da_dec; // Let's check if we recahed position for both RA/DEC if (nlocked == 2) { // Let's set state to TRACKING TrackState = SCOPE_TRACKING; DEBUG(INDI::Logger::DBG_SESSION, "Telescope slew is complete. Tracking..."); } break; default: break; } char RAStr[64], DecStr[64]; // Parse the RA/DEC into strings fs_sexa(RAStr, currentRA, 2, 3600); fs_sexa(DecStr, currentDEC, 2, 3600); DEBUGF(DBG_SCOPE, "Current RA: %s Current DEC: %s", RAStr, DecStr ); NewRaDec(currentRA, currentDEC); return true; }
bool SynscanDriver::sendLocation() { char res[SYN_RES] = {0}; LOG_DEBUG("Reading mount location..."); if (isSimulation()) { LocationN[LOCATION_LATITUDE].value = 29.5; LocationN[LOCATION_LONGITUDE].value = 48; IDSetNumber(&LocationNP, nullptr); return true; } if (!sendCommand("w", res)) return false; double lat, lon; // lets parse this data now int a, b, c, d, e, f, g, h; a = res[0]; b = res[1]; c = res[2]; d = res[3]; e = res[4]; f = res[5]; g = res[6]; h = res[7]; double t1, t2, t3; t1 = c; t2 = b; t3 = a; t1 = t1 / 3600.0; t2 = t2 / 60.0; lat = t1 + t2 + t3; t1 = g; t2 = f; t3 = e; t1 = t1 / 3600.0; t2 = t2 / 60.0; lon = t1 + t2 + t3; if (d == 1) lat = lat * -1; if (h == 1) lon = 360 - lon; LocationN[LOCATION_LATITUDE].value = lat; LocationN[LOCATION_LONGITUDE].value = lon; IDSetNumber(&LocationNP, nullptr); saveConfig(true, "GEOGRAPHIC_COORD"); char LongitudeStr[32] = {0}, LatitudeStr[32] = {0}; fs_sexa(LongitudeStr, lon, 2, 3600); fs_sexa(LatitudeStr, lat, 2, 3600); LOGF_INFO("Mount Longitude %s Latitude %s", LongitudeStr, LatitudeStr); return true; }
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); }