diff options
Diffstat (limited to 'indi-lxd650/lxd650.cpp')
-rw-r--r-- | indi-lxd650/lxd650.cpp | 141 |
1 files changed, 124 insertions, 17 deletions
diff --git a/indi-lxd650/lxd650.cpp b/indi-lxd650/lxd650.cpp index 87dd65d..995145d 100644 --- a/indi-lxd650/lxd650.cpp +++ b/indi-lxd650/lxd650.cpp @@ -54,7 +54,8 @@ LXD650::LXD650() DBG_SCOPE = INDI::Logger::getInstance().addDebugLevel("Scope Verbose", "SCOPE"); - SetTelescopeCapability(TELESCOPE_CAN_SYNC | TELESCOPE_CAN_GOTO | TELESCOPE_CAN_ABORT, 4); + SetTelescopeCapability(TELESCOPE_CAN_SYNC | TELESCOPE_CAN_GOTO | TELESCOPE_CAN_ABORT | TELESCOPE_HAS_LOCATION | TELESCOPE_HAS_TIME, 4); + LOG_DEBUG("Initializing from LX200 Basic device..."); } @@ -73,7 +74,7 @@ void LXD650::debugTriggered(bool enable) ***************************************************************************************/ const char *LXD650::getDefaultName() { - return "LX200 Basic"; + return "LXD-650 1697"; } /************************************************************************************** @@ -178,7 +179,7 @@ void LXD650::show_alignment (const char *wot, double ra1, double dec1, double ra fs_sexa (dec2_str, dec2, 2, 3600); - LOGF_DEBUG ("Mapping: %s RA %s DE %s => RA %s DE %s", wot, ra1_str, dec1_str, ra2_str, dec2_str); + LOGF_INFO ("Mapping: %s RA %s DE %s => RA %s DE %s", wot, ra1_str, dec1_str, ra2_str, dec2_str); } @@ -214,16 +215,14 @@ bool LXD650::ReadScopeStatus() } } - INDI::IEquatorialCoordinates MountRADE { currentRA, currentDEC }; - TelescopeDirectionVector TDV = TelescopeDirectionVectorFromEquatorialCoordinates(MountRADE); - #if 0 NewRaDec(currentRA, currentDEC); #else double sky_RA, sky_DEC; - if (!TransformTelescopeToCelestial(TDV, sky_RA, sky_DEC)) { - sky_RA=currentRA; - sky_DEC=currentDEC; + + if (!TelescopeEquatorialToSky(currentRA, currentDEC, sky_RA, sky_DEC)) { + sky_RA = currentRA; + sky_DEC = currentDEC; } NewRaDec(sky_RA, sky_DEC); @@ -241,17 +240,17 @@ bool LXD650::Goto(double r, double d) { #if 1 - TelescopeDirectionVector TDV; - INDI::IEquatorialCoordinates MountRADE { r, d }; + double mount_r, mount_d; - if (TransformCelestialToTelescope(r, d, 0.0, TDV)) { - EquatorialCoordinatesFromTelescopeDirectionVector(TDV, MountRADE); - } // Conversion failed, use values as is + if (!SkyToTelescopeEquatorial(r, d, mount_r, mount_d)) { + mount_r = r; + mount_d = d; + } - show_alignment("Sky->Mount", r, d, MountRADE.rightascension, MountRADE.declination); + show_alignment("Sky->Mount", r, d, mount_r, mount_d); - r=MountRADE.rightascension; - d=MountRADE.declination; + r = mount_r; + d = mount_d; #endif @@ -361,8 +360,15 @@ bool LXD650::Sync (double ra, double dec) NewEntry.ObservationJulianDate, NewEntry.RightAscension, NewEntry.Declination, NewEntry.TelescopeDirection.x, NewEntry.TelescopeDirection.y, NewEntry.TelescopeDirection.z); + show_alignment ("Sync Sky:Mount",ra,dec,currentRA, currentDEC); + + LOGF_INFO ("New sync point Date %lf RA %lf DEC %lf TDV(x %lf y %lf z %lf)", + NewEntry.ObservationJulianDate, NewEntry.RightAscension, NewEntry.Declination, NewEntry.TelescopeDirection.x, + NewEntry.TelescopeDirection.y, NewEntry.TelescopeDirection.z); + if (!CheckForDuplicateSyncPoint (NewEntry)) { GetAlignmentDatabase().push_back (NewEntry); +// bool AddAlignmentEntryEquatorial(double actualRA, double actualDec, double mountRA, double mountDec); // Tell the client about size change UpdateSize(); @@ -391,6 +397,106 @@ bool LXD650::Sync (double ra, double dec) #endif +///////////////////////////////////////////////////////////////////////////////////// +/// +///////////////////////////////////////////////////////////////////////////////////// + +bool LXD650::setLocalDate(uint8_t days, uint8_t months, uint16_t years) +{ + return (setCalenderDate(PortFD, days, months, years) == 0); +} + +bool LXD650::setLocalTime24(uint8_t hour, uint8_t minute, uint8_t second) +{ + return (setLocalTime(PortFD, hour, minute, second) == 0); +} + +bool LXD650::setUTCOffset(double offset) +{ + return (::setUTCOffset(PortFD, (offset * -1.0)) == 0); +} + +bool LXD650::updateTime(ln_date *utc, double utc_offset) +{ + struct ln_zonedate ltm; + double JD; + + if (isSimulation()) + return true; + + ln_date_to_zonedate(utc, <m, utc_offset * 3600.0); + + JD = ln_get_julian_day(utc); + + LOGF_DEBUG("New JD is %.2f", JD); + + // Meade defines UTC Offset as the offset ADDED to local time to yield UTC, which + // is the opposite of the standard definition of UTC offset! + if (setUTCOffset(utc_offset) == false) + { + LOG_ERROR("Error setting UTC Offset."); + return false; + } + + // Set Local Time + if (setLocalTime24(ltm.hours, ltm.minutes, ltm.seconds) == false) + { + LOG_ERROR("Error setting local time."); + return false; + } + + if (setLocalDate(ltm.days, ltm.months, ltm.years) == false) + { + LOG_ERROR("Error setting local date."); + return false; + } + + LOG_INFO("Time updated, updating planetary data..."); + return true; +} + + +///////////////////////////////////////////////////////////////////////////////////// +/// +///////////////////////////////////////////////////////////////////////////////////// +bool LXD650::updateLocation(double latitude, double longitude, double elevation) +{ + // Update INDI Alignment Subsystem Location + UpdateLocation(latitude, longitude, elevation); + LOGF_INFO("Location %.1f %.1f %.1f",latitude,longitude,elevation); + + SetApproximateMountAlignment(latitude >= 0 ? NORTH_CELESTIAL_POLE : SOUTH_CELESTIAL_POLE); + + Initialise(this); + +#if 0 + // update cordwrap position at each init of the alignment subsystem + syncCoordWrapPosition(); +#endif + + // JM 2021-04-10: MUST convert from INDI longitude to standard longitude. + // DO NOT REMOVE + if (longitude > 180) + longitude = longitude - 360; + + if (!isSimulation()) + { + if (setSiteLongitude(PortFD, longitude) < 0) + { + LOG_ERROR("Error setting site longitude coordinates"); + return false; + } + + if (setSiteLatitude(PortFD, latitude) < 0) + { + LOG_ERROR("Error setting site latitude coordinates"); + return false; + } + } + + return true; +} + ///////////////////////////////////////////////////////////////////////////////////// @@ -772,6 +878,7 @@ void LXD650::slewError(int slewCode) bool LXD650::saveConfigItems(FILE *fp) { INDI::Telescope::saveConfigItems(fp); + SaveAlignmentConfigProperties(fp); IUSaveConfigNumber(fp, &SlewAccuracyNP); return true; } |