From 8d8fd6d1ed591601e9926ec2f6a97638196db8dd Mon Sep 17 00:00:00 2001 From: Jasem Mutlaq Date: Tue, 23 Jul 2024 17:57:18 +0300 Subject: [PATCH] Detect mount type since some operations like guiding and meridian flip are not available on azimuth mounts --- drivers.xml | 24 +++--- drivers/telescope/ioptronv3.cpp | 132 ++++++++++++++++++++------------ drivers/telescope/ioptronv3.h | 11 +++ 3 files changed, 107 insertions(+), 60 deletions(-) diff --git a/drivers.xml b/drivers.xml index 70a2363f82..c7a9bd9153 100644 --- a/drivers.xml +++ b/drivers.xml @@ -181,35 +181,35 @@ indi_ioptronv3_telescope - 1.7 + 1.8 indi_ioptronv3_telescope - 1.7 + 1.8 indi_ioptronv3_telescope - 1.7 + 1.8 indi_ioptronv3_telescope - 1.7 + 1.8 indi_ioptronv3_telescope - 1.7 + 1.8 indi_ioptronv3_telescope - 1.7 + 1.8 indi_ioptronv3_telescope - 1.7 + 1.8 indi_ioptronv3_telescope - 1.7 + 1.8 indi_ieq_telescope @@ -249,19 +249,19 @@ indi_ioptronv3_telescope - 1.7 + 1.8 indi_ioptronv3_telescope - 1.7 + 1.8 indi_ioptronv3_telescope - 1.7 + 1.8 indi_ioptronv3_telescope - 1.7 + 1.8 indi_lx200pulsar2 diff --git a/drivers/telescope/ioptronv3.cpp b/drivers/telescope/ioptronv3.cpp index c64d9af19a..d937523ec5 100644 --- a/drivers/telescope/ioptronv3.cpp +++ b/drivers/telescope/ioptronv3.cpp @@ -44,7 +44,7 @@ static std::unique_ptr scope(new IOptronV3()); /* Constructor */ IOptronV3::IOptronV3() { - setVersion(1, 7); + setVersion(1, 8); driver.reset(new Driver(getDeviceName())); @@ -227,16 +227,27 @@ bool IOptronV3::updateProperties() if (isConnected()) { - defineProperty(&HomeSP); + getStartupData(); - /* v3.0 Create PEC switches */ - defineProperty(&PECTrainingSP); - defineProperty(&PECInfoTP); - // End Mod */ + defineProperty(&HomeSP); - defineProperty(&GuideNSNP); - defineProperty(&GuideWENP); - defineProperty(&GuideRateNP); + if (m_MountType != Azimuth) + { + /* v3.0 Create PEC switches */ + defineProperty(&PECTrainingSP); + defineProperty(&PECInfoTP); + // End Mod */ + + defineProperty(&GuideNSNP); + defineProperty(&GuideWENP); + defineProperty(&GuideRateNP); + } + else + { + // Undefine Guider Interface for Azimuth mounts. + setDriverInterface(getDriverInterface() & ~GUIDER_INTERFACE); + syncDriverInfo(); + } defineProperty(&FirmwareTP); defineProperty(&GPSStatusSP); @@ -244,25 +255,29 @@ bool IOptronV3::updateProperties() defineProperty(&HemisphereSP); defineProperty(&SlewModeSP); defineProperty(&DaylightSP); - defineProperty(&CWStateSP); - defineProperty(MeridianActionSP); - defineProperty(MeridianLimitNP); - - getStartupData(); + if (m_MountType != Azimuth) + { + defineProperty(&CWStateSP); + defineProperty(MeridianActionSP); + defineProperty(MeridianLimitNP); + } } else { deleteProperty(HomeSP.name); - /* v3.0 Delete PEC switches */ - deleteProperty(PECTrainingSP.name); - deleteProperty(PECInfoTP.name); - // End Mod*/ - - deleteProperty(GuideNSNP.name); - deleteProperty(GuideWENP.name); - deleteProperty(GuideRateNP.name); + if (m_MountType != Azimuth) + { + /* v3.0 Delete PEC switches */ + deleteProperty(PECTrainingSP.name); + deleteProperty(PECInfoTP.name); + // End Mod*/ + + deleteProperty(GuideNSNP.name); + deleteProperty(GuideWENP.name); + deleteProperty(GuideRateNP.name); + } deleteProperty(FirmwareTP.name); deleteProperty(GPSStatusSP.name); @@ -270,10 +285,13 @@ bool IOptronV3::updateProperties() deleteProperty(HemisphereSP.name); deleteProperty(SlewModeSP.name); deleteProperty(DaylightSP.name); - deleteProperty(CWStateSP.name); - deleteProperty(MeridianActionSP); - deleteProperty(MeridianLimitNP); + if (m_MountType != Azimuth) + { + deleteProperty(CWStateSP.name); + deleteProperty(MeridianActionSP); + deleteProperty(MeridianLimitNP); + } } return true; @@ -291,16 +309,26 @@ void IOptronV3::getStartupData() IUSaveText(&FirmwareT[4], firmwareInfo.DEFirmware.c_str()); FirmwareTP.s = IPS_OK; - IDSetText(&FirmwareTP, nullptr); + //IDSetText(&FirmwareTP, nullptr); + + if (firmwareInfo.Model.find("AZ") != std::string::npos || firmwareInfo.Model.find("AA") != std::string::npos) + m_MountType = Azimuth; + else if (firmwareInfo.Model.find("-EC") != std::string::npos) + m_MountType = EquatorialEncoders; + else + m_MountType = EquatorialNoEncoders; } - LOG_DEBUG("Getting guiding rate..."); - double RARate = 0, DERate = 0; - if (driver->getGuideRate(&RARate, &DERate)) + if (m_MountType != Azimuth) { - GuideRateN[RA_AXIS].value = RARate; - GuideRateN[DEC_AXIS].value = DERate; - IDSetNumber(&GuideRateNP, nullptr); + LOG_DEBUG("Getting guiding rate..."); + double RARate = 0, DERate = 0; + if (driver->getGuideRate(&RARate, &DERate)) + { + GuideRateN[RA_AXIS].value = RARate; + GuideRateN[DEC_AXIS].value = DERate; + //IDSetNumber(&GuideRateNP, nullptr); + } } int utcOffsetMinutes = 0; @@ -336,7 +364,7 @@ void IOptronV3::getStartupData() DaylightS[0].s = dayLightSavings ? ISS_ON : ISS_OFF; DaylightS[1].s = !dayLightSavings ? ISS_ON : ISS_OFF; DaylightSP.s = IPS_OK; - IDSetSwitch(&DaylightSP, nullptr); + //IDSetSwitch(&DaylightSP, nullptr); } // Get Longitude and Latitude from mount @@ -370,15 +398,18 @@ void IOptronV3::getStartupData() IOP_MB_STATE action; uint8_t degrees = 0; - if (driver->getMeridianBehavior(action, degrees)) + if (m_MountType != Azimuth) { - MeridianActionSP.reset(); - MeridianActionSP[action].setState(ISS_ON); - MeridianActionSP.setState(IPS_OK); - MeridianLimitNP[0].setValue(degrees); + if (driver->getMeridianBehavior(action, degrees)) + { + MeridianActionSP.reset(); + MeridianActionSP[action].setState(ISS_ON); + MeridianActionSP.setState(IPS_OK); + MeridianLimitNP[0].setValue(degrees); - LOGF_INFO("Reading mount meridian behavior: When mount reaches %.f degrees past meridian, it will %s.", - MeridianLimitNP[0].getValue(), MeridianActionSP[IOP_MB_STOP].getState() == ISS_ON ? "stop" : "flip"); + LOGF_INFO("Reading mount meridian behavior: When mount reaches %.f degrees past meridian, it will %s.", + MeridianLimitNP[0].getValue(), MeridianActionSP[IOP_MB_STOP].getState() == ISS_ON ? "stop" : "flip"); + } } double parkAZ = LocationN[LOCATION_LATITUDE].value >= 0 ? 0 : 180; @@ -850,16 +881,21 @@ bool IOptronV3::ReadScopeStatus() } } } - if (pierState == IOP_PIER_UNKNOWN) - setPierSide(PIER_UNKNOWN); - else - setPierSide(pierState == IOP_PIER_EAST ? PIER_EAST : PIER_WEST); - if (IUFindOnSwitchIndex(&CWStateSP) != cwState) + if (m_MountType != Azimuth) { - IUResetSwitch(&CWStateSP); - CWStateS[cwState].s = ISS_ON; - IDSetSwitch(&CWStateSP, nullptr); + if (pierState == IOP_PIER_UNKNOWN) + setPierSide(PIER_UNKNOWN); + else + setPierSide(pierState == IOP_PIER_EAST ? PIER_EAST : PIER_WEST); + + + if (IUFindOnSwitchIndex(&CWStateSP) != cwState) + { + IUResetSwitch(&CWStateSP); + CWStateS[cwState].s = ISS_ON; + IDSetSwitch(&CWStateSP, nullptr); + } } NewRaDec(currentRA, currentDEC); diff --git a/drivers/telescope/ioptronv3.h b/drivers/telescope/ioptronv3.h index 9f2d059747..0725db956b 100644 --- a/drivers/telescope/ioptronv3.h +++ b/drivers/telescope/ioptronv3.h @@ -103,6 +103,17 @@ class IOptronV3 : public INDI::Telescope, public INDI::GuiderInterface */ bool GetPECDataStatus(bool enabled); + typedef enum + { + Azimuth, + EquatorialEncoders, + EquatorialNoEncoders, + Unknown + } MountType; + + + MountType m_MountType {Unknown}; + /* Mod v3.0 Adding PEC Recording Switches */ ISwitch PECTrainingS[2]; ISwitchVectorProperty PECTrainingSP;