diff --git a/debian/indi-eqmod/changelog b/debian/indi-eqmod/changelog index 144947f46..e29447b08 100644 --- a/debian/indi-eqmod/changelog +++ b/debian/indi-eqmod/changelog @@ -1,3 +1,9 @@ +indi-eqmod (1.3) bionic; urgency=medium + + * Update homing to be in line with INDI standards + + -- Jasem Mutlaq Mon, 29 Jul 2024 09:00:00 +0300 + indi-eqmod (1.0) bionic; urgency=medium * Add LED Brightness control. diff --git a/indi-eqmod/CMakeLists.txt b/indi-eqmod/CMakeLists.txt index 744cd94dc..edb0ae947 100644 --- a/indi-eqmod/CMakeLists.txt +++ b/indi-eqmod/CMakeLists.txt @@ -1,5 +1,5 @@ -PROJECT(indi-eqmod C CXX) cmake_minimum_required(VERSION 3.16) +PROJECT(indi-eqmod C CXX) LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/") LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake_modules/") @@ -13,7 +13,7 @@ find_package(ZLIB REQUIRED) find_package(GSL REQUIRED) set(EQMOD_VERSION_MAJOR 1) -set(EQMOD_VERSION_MINOR 2) +set(EQMOD_VERSION_MINOR 3) if (CYGWIN) add_definitions(-U__STRICT_ANSI__) diff --git a/indi-eqmod/eqmodbase.cpp b/indi-eqmod/eqmodbase.cpp index 5785784e3..e776129c3 100644 --- a/indi-eqmod/eqmodbase.cpp +++ b/indi-eqmod/eqmodbase.cpp @@ -339,10 +339,6 @@ void EQMod::ISGetProperties(const char *dev) #if defined WITH_ALIGN || defined WITH_ALIGN_GEEHALEL defineProperty(AlignSyncModeSP); #endif - if (mount->HasHomeIndexers()) - { - defineProperty(AutoHomeSP); - } if (mount->HasAuxEncoders()) { @@ -416,7 +412,6 @@ bool EQMod::loadProperties() SyncManageSP = getSwitch("SYNCMANAGE"); BacklashNP = getNumber("BACKLASH"); UseBacklashSP = getSwitch("USEBACKLASH"); - AutoHomeSP = getSwitch("AUTOHOME"); AuxEncoderSP = getSwitch("AUXENCODER"); AuxEncoderNP = getNumber("AUXENCODERVALUES"); ST4GuideRateNSSP = getSwitch("ST4_GUIDE_RATE_NS"); @@ -456,6 +451,40 @@ bool EQMod::loadProperties() bool EQMod::updateProperties() { + // JM 2024.07.29: Need to run this *before* Telescope::updateProperty so we can check if + // the mount supports homing since we need to update the telescope capabilities accordingly. + if (isConnected()) + { + try + { + mount->InquireBoardVersion(MountInformationTP); + + for (const auto &it : MountInformationTP) + { + LOGF_DEBUG("Got Board Property %s: %s", it.getName(), it.getText()); + } + + mount->InquireRAEncoderInfo(SteppersNP); + mount->InquireDEEncoderInfo(SteppersNP); + + for (const auto &it : SteppersNP) + { + LOGF_DEBUG("Got Encoder Property %s: %.0f", it.getLabel(), it.getValue()); + } + + mount->InquireFeatures(); + if (mount->HasHomeIndexers()) + { + LOG_INFO("Mount has home indexers. Enabling Autohome."); + SetTelescopeCapability(GetTelescopeCapability() | TELESCOPE_CAN_HOME_FIND, SLEWMODES); + } + } + catch (EQModError &e) + { + return (e.DefaultHandleException(this)); + } + } + INDI::Telescope::updateProperties(); if (isConnected()) @@ -495,28 +524,6 @@ bool EQMod::updateProperties() #endif try { - mount->InquireBoardVersion(MountInformationTP); - - for (const auto &it : MountInformationTP) - { - LOGF_DEBUG("Got Board Property %s: %s", it.getName(), it.getText()); - } - - mount->InquireRAEncoderInfo(SteppersNP); - mount->InquireDEEncoderInfo(SteppersNP); - - for (const auto &it : SteppersNP) - { - LOGF_DEBUG("Got Encoder Property %s: %.0f", it.getLabel(), it.getValue()); - } - - mount->InquireFeatures(); - if (mount->HasHomeIndexers()) - { - LOG_INFO("Mount has home indexers. Enabling Autohome."); - defineProperty(AutoHomeSP); - } - if (mount->HasAuxEncoders()) { defineProperty(AuxEncoderSP); @@ -585,13 +592,6 @@ bool EQMod::updateProperties() INumber *elevation = IUFindNumber(&LocationNP, "ELEV"); if (latitude && longitude && elevation) updateLocation(latitude->value, longitude->value, elevation->value); - // else - // updateLocation(0.0, 0.0, 0.0); - - // if ((latitude) && (latitude->value < 0.0)) - // SetSouthernHemisphere(true); - // else - // SetSouthernHemisphere(false); sendTimeFromSystem(); } @@ -630,8 +630,6 @@ bool EQMod::updateProperties() deleteProperty(ST4GuideRateWESP); deleteProperty(LEDBrightnessNP); - if (mount->HasHomeIndexers()) - deleteProperty(AutoHomeSP); if (mount->HasAuxEncoders()) { deleteProperty(AuxEncoderSP); @@ -1103,17 +1101,6 @@ bool EQMod::ReadScopeStatus() } } - if (AutohomeState == AUTO_HOME_CONFIRM) - { - if (ah_confirm_timeout > 0) - ah_confirm_timeout -= 1; - if (ah_confirm_timeout == 0) - { - AutohomeState = AUTO_HOME_IDLE; - LOG_INFO("Autohome confirm timeout."); - } - } - if (TrackState == SCOPE_AUTOHOMING) { uint32_t indexRA = 0, indexDE = 0; @@ -1122,7 +1109,6 @@ bool EQMod::ReadScopeStatus() switch (AutohomeState) { case AUTO_HOME_IDLE: - case AUTO_HOME_CONFIRM: AutohomeState = AUTO_HOME_IDLE; TrackState = SCOPE_IDLE; RememberTrackState = TrackState; @@ -1410,9 +1396,9 @@ bool EQMod::ReadScopeStatus() TrackState = SCOPE_IDLE; RememberTrackState = TrackState; AutohomeState = AUTO_HOME_IDLE; - AutoHomeSP.setState(IPS_IDLE); - AutoHomeSP.reset(); - AutoHomeSP.apply(); + HomeSP.setState(IPS_IDLE); + HomeSP.reset(); + HomeSP.apply(); LOG_INFO("Autohome: end"); } else @@ -2791,105 +2777,6 @@ bool EQMod::ISNewSwitch(const char *dev, const char *name, ISState *states, char } //if (MountInformationTP && MountInformationTP->tp && (!strcmp(MountInformationTP->tp[0].text, "EQ8") || !strcmp(MountInformationTP->tp[0].text, "AZEQ6"))) { - if (mount->HasHomeIndexers()) - { - if (AutoHomeSP && AutoHomeSP.isNameMatch(name)) - { - if ((TrackState != SCOPE_IDLE) && (TrackState != SCOPE_AUTOHOMING)) - { - if (TrackState != SCOPE_AUTOHOMING) - { - AutoHomeSP.setState(IPS_IDLE); - AutoHomeSP.reset(); - AutoHomeSP.apply(); - } - LOG_WARN("Can not start AutoHome. Scope not idle"); - return true; - } - - if (TrackState == SCOPE_AUTOHOMING) - { - AutoHomeSP.setState(IPS_IDLE); - AutoHomeSP.reset(); - AutoHomeSP.apply(); - LOG_WARN("Aborting AutoHome."); - Abort(); - return true; - } - - if (AutohomeState == AUTO_HOME_IDLE) - { - AutoHomeSP.setState(IPS_OK); - AutoHomeSP.reset(); - AutoHomeSP.apply(); - LOG_WARN("*** AutoHome NOT TESTED. Press PERFORM AGAIN TO CONFIRM. ***"); - AutohomeState = AUTO_HOME_CONFIRM; - ah_confirm_timeout = 10; - return true; - } - if (AutohomeState == AUTO_HOME_CONFIRM) - { - AutoHomeSP.update(states, names, n); - AutoHomeSP.setState(IPS_BUSY); - LOG_INFO("Starting Autohome."); - AutoHomeSP.apply(); - TrackState = SCOPE_AUTOHOMING; - try - { - LOG_INFO("AutoHome phase 1: turning off aux encoders"); - mount->TurnRAEncoder(false); - mount->TurnDEEncoder(false); - LOG_INFO("AutoHome phase 1: resetting home position indexes"); - mount->ResetRAIndexer(); - mount->ResetDEIndexer(); - LOG_INFO( - "AutoHome phase 1: reading home position indexes to set directions"); - mount->GetRAIndexer(); - mount->GetDEIndexer(); - LOGF_INFO( - "AutoHome phase 1: read home position indexes: RA=0x%x DE=0x%x", - mount->GetlastreadRAIndexer(), mount->GetlastreadDEIndexer()); - if (mount->GetlastreadRAIndexer() == 0) - ah_bSlewingUp_RA = true; - else - ah_bSlewingUp_RA = false; - if (mount->GetlastreadDEIndexer() == 0) - ah_bSlewingUp_DE = true; - else - ah_bSlewingUp_DE = false; - ah_iPosition_RA = mount->GetRAEncoder(); - ah_iPosition_DE = mount->GetDEEncoder(); - ah_iChanges = (5 * mount->GetRAEncoderTotal()) / 360; - if (ah_bSlewingUp_RA) - ah_iPosition_RA = ah_iPosition_RA - ah_iChanges; - else - ah_iPosition_RA = ah_iPosition_RA + ah_iChanges; - ah_iChanges = (5 * mount->GetDEEncoderTotal()) / 360; - if (ah_bSlewingUp_DE) - ah_iPosition_DE = ah_iPosition_DE - ah_iChanges; - else - ah_iPosition_DE = ah_iPosition_DE + ah_iChanges; - LOG_INFO( - "AutoHome phase 1: trying to move further away from home position"); - LOGF_INFO( - "AutoHome phase 1: slewing to RA=0x%x (up=%c) DE=0x%x (up=%c)", ah_iPosition_RA, - (ah_bSlewingUp_RA ? '1' : '0'), ah_iPosition_DE, (ah_bSlewingUp_DE ? '1' : '0')); - mount->AbsSlewTo(ah_iPosition_RA, ah_iPosition_DE, ah_bSlewingUp_RA, ah_bSlewingUp_DE); - AutohomeState = AUTO_HOME_WAIT_PHASE1; - } - catch (EQModError e) - { - AutoHomeSP.setState(IPS_ALERT); - AutoHomeSP.reset(); - AutoHomeSP.apply(); - AutohomeState = AUTO_HOME_IDLE; - TrackState = SCOPE_IDLE; - RememberTrackState = TrackState; - return (e.DefaultHandleException(this)); - } - } - } - } if (mount->HasAuxEncoders()) { @@ -3310,9 +3197,9 @@ bool EQMod::Abort() IDSetSwitch(TrackModeSP, nullptr); #endif AutohomeState = AUTO_HOME_IDLE; - AutoHomeSP.setState(IPS_IDLE); - AutoHomeSP.reset(); - AutoHomeSP.apply(); + HomeSP.setState(IPS_IDLE); + HomeSP.reset(); + HomeSP.apply(); TrackState = SCOPE_IDLE; RememberTrackState = TrackState; @@ -3719,3 +3606,81 @@ bool EQMod::SetTrackEnabled(bool enabled) return true; } + +IPState EQMod::ExecuteHomeAction(TelescopeHomeAction action) +{ + if (action != HOME_FIND) + return IPS_ALERT; + + if ((TrackState != SCOPE_IDLE) && (TrackState != SCOPE_AUTOHOMING)) + { + LOG_WARN("Can not start AutoHome. Scope not idle"); + return IPS_IDLE; + } + + if (TrackState == SCOPE_AUTOHOMING) + { + LOG_WARN("Aborting AutoHome."); + Abort(); + return IPS_IDLE; + } + + if (AutohomeState == AUTO_HOME_IDLE) + { + LOG_INFO("Starting Autohome."); + TrackState = SCOPE_AUTOHOMING; + try + { + LOG_INFO("AutoHome phase 1: turning off aux encoders"); + mount->TurnRAEncoder(false); + mount->TurnDEEncoder(false); + LOG_INFO("AutoHome phase 1: resetting home position indexes"); + mount->ResetRAIndexer(); + mount->ResetDEIndexer(); + LOG_INFO( + "AutoHome phase 1: reading home position indexes to set directions"); + mount->GetRAIndexer(); + mount->GetDEIndexer(); + LOGF_INFO( + "AutoHome phase 1: read home position indexes: RA=0x%x DE=0x%x", + mount->GetlastreadRAIndexer(), mount->GetlastreadDEIndexer()); + if (mount->GetlastreadRAIndexer() == 0) + ah_bSlewingUp_RA = true; + else + ah_bSlewingUp_RA = false; + if (mount->GetlastreadDEIndexer() == 0) + ah_bSlewingUp_DE = true; + else + ah_bSlewingUp_DE = false; + ah_iPosition_RA = mount->GetRAEncoder(); + ah_iPosition_DE = mount->GetDEEncoder(); + ah_iChanges = (5 * mount->GetRAEncoderTotal()) / 360; + if (ah_bSlewingUp_RA) + ah_iPosition_RA = ah_iPosition_RA - ah_iChanges; + else + ah_iPosition_RA = ah_iPosition_RA + ah_iChanges; + ah_iChanges = (5 * mount->GetDEEncoderTotal()) / 360; + if (ah_bSlewingUp_DE) + ah_iPosition_DE = ah_iPosition_DE - ah_iChanges; + else + ah_iPosition_DE = ah_iPosition_DE + ah_iChanges; + LOG_INFO( + "AutoHome phase 1: trying to move further away from home position"); + LOGF_INFO( + "AutoHome phase 1: slewing to RA=0x%x (up=%c) DE=0x%x (up=%c)", ah_iPosition_RA, + (ah_bSlewingUp_RA ? '1' : '0'), ah_iPosition_DE, (ah_bSlewingUp_DE ? '1' : '0')); + mount->AbsSlewTo(ah_iPosition_RA, ah_iPosition_DE, ah_bSlewingUp_RA, ah_bSlewingUp_DE); + AutohomeState = AUTO_HOME_WAIT_PHASE1; + return IPS_BUSY; + } + catch (EQModError e) + { + AutohomeState = AUTO_HOME_IDLE; + TrackState = SCOPE_IDLE; + RememberTrackState = TrackState; + return IPS_ALERT; + } + } + + return IPS_ALERT; +} \ No newline at end of file diff --git a/indi-eqmod/eqmodbase.h b/indi-eqmod/eqmodbase.h index c9859fcf8..85491dab5 100644 --- a/indi-eqmod/eqmodbase.h +++ b/indi-eqmod/eqmodbase.h @@ -118,7 +118,6 @@ class EQMod : public INDI::Telescope, public INDI::GuiderInterface #if defined WITH_ALIGN || defined WITH_ALIGN_GEEHALEL INDI::PropertySwitch AlignSyncModeSP {INDI::Property()}; #endif - INDI::PropertySwitch AutoHomeSP {INDI::Property()}; INDI::PropertySwitch AuxEncoderSP {INDI::Property()}; INDI::PropertyNumber AuxEncoderNP {INDI::Property()}; @@ -212,36 +211,38 @@ class EQMod : public INDI::Telescope, public INDI::GuiderInterface EQMod(); virtual ~EQMod(); - virtual const char *getDefaultName(); - virtual bool Handshake(); - virtual bool Disconnect(); - virtual void TimerHit(); - virtual bool ReadScopeStatus(); - virtual bool initProperties(); - virtual bool updateProperties(); - virtual void ISGetProperties(const char *dev); - virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n); - virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n); - virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n); + virtual const char *getDefaultName() override; + virtual bool Handshake() override; + virtual bool Disconnect() override; + virtual void TimerHit() override; + virtual bool ReadScopeStatus() override; + virtual bool initProperties() override; + virtual bool updateProperties() override; + virtual void ISGetProperties(const char *dev) override; + virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override; + virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override; + virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override; #ifdef WITH_ALIGN virtual bool ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], - char *formats[], char *names[], int n); + char *formats[], char *names[], int n) override; #endif - virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command); - virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command); - virtual bool Abort(); - - virtual IPState GuideNorth(uint32_t ms); - virtual IPState GuideSouth(uint32_t ms); - virtual IPState GuideEast(uint32_t ms); - virtual IPState GuideWest(uint32_t ms); - - bool Goto(double ra, double dec); - bool Park(); - bool UnPark(); - bool SetCurrentPark(); - bool SetDefaultPark(); - bool Sync(double ra, double dec); + virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override; + virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override; + virtual bool Abort() override; + + virtual IPState GuideNorth(uint32_t ms) override; + virtual IPState GuideSouth(uint32_t ms) override; + virtual IPState GuideEast(uint32_t ms) override; + virtual IPState GuideWest(uint32_t ms) override; + + bool Goto(double ra, double dec) override; + bool Park() override; + bool UnPark() override; + bool SetCurrentPark() override; + bool SetDefaultPark() override; + bool Sync(double ra, double dec) override; + + IPState ExecuteHomeAction(TelescopeHomeAction action) override; // Call first time EQMod is run void saveInitialParkPosition(); @@ -251,14 +252,14 @@ class EQMod : public INDI::Telescope, public INDI::GuiderInterface static void abnormalDisconnectCallback(void *userpointer); // Tracking - bool SetTrackMode(uint8_t mode); - bool SetTrackRate(double raRate, double deRate); - bool SetTrackEnabled(bool enabled); + bool SetTrackMode(uint8_t mode) override; + bool SetTrackRate(double raRate, double deRate) override; + bool SetTrackEnabled(bool enabled) override; - virtual bool saveConfigItems(FILE *fp); + virtual bool saveConfigItems(FILE *fp) override; - bool updateTime(ln_date *lndate_utc, double utc_offset); - bool updateLocation(double latitude, double longitude, double elevation); + bool updateTime(ln_date *lndate_utc, double utc_offset) override; + bool updateLocation(double latitude, double longitude, double elevation) override; double getLongitude(); double getLatitude(); @@ -275,7 +276,6 @@ class EQMod : public INDI::Telescope, public INDI::GuiderInterface enum AutoHomeStatus { AUTO_HOME_IDLE, - AUTO_HOME_CONFIRM, AUTO_HOME_WAIT_PHASE1, AUTO_HOME_WAIT_PHASE2, AUTO_HOME_WAIT_PHASE3,