Skip to content

Commit

Permalink
Detect mount type since some operations like guiding and meridian fli…
Browse files Browse the repository at this point in the history
…p are not available on azimuth mounts
  • Loading branch information
knro committed Jul 23, 2024
1 parent da0fe39 commit 8d8fd6d
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 60 deletions.
24 changes: 12 additions & 12 deletions drivers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -181,35 +181,35 @@
</device>
<device label="iOptron iMate" manufacturer="iOptron">
<driver name="iOptronV3">indi_ioptronv3_telescope</driver>
<version>1.7</version>
<version>1.8</version>
</device>
<device label="iOptron CEM26" manufacturer="iOptron">
<driver name="iOptronV3">indi_ioptronv3_telescope</driver>
<version>1.7</version>
<version>1.8</version>
</device>
<device label="iOptron GEM28" manufacturer="iOptron">
<driver name="iOptronV3">indi_ioptronv3_telescope</driver>
<version>1.7</version>
<version>1.8</version>
</device>
<device label="iOptron HEM27" manufacturer="iOptron">
<driver name="iOptronV3">indi_ioptronv3_telescope</driver>
<version>1.7</version>
<version>1.8</version>
</device>
<device label="iOptron HAE29" manufacturer="iOptron">
<driver name="iOptronV3">indi_ioptronv3_telescope</driver>
<version>1.7</version>
<version>1.8</version>
</device>
<device label="iOptron SkyHunter" manufacturer="iOptron">
<driver name="iOptronV3">indi_ioptronv3_telescope</driver>
<version>1.7</version>
<version>1.8</version>
</device>
<device label="iOptron CEM40" manufacturer="iOptron">
<driver name="iOptronV3">indi_ioptronv3_telescope</driver>
<version>1.7</version>
<version>1.8</version>
</device>
<device label="iOptron GEM45" manufacturer="iOptron">
<driver name="iOptronV3">indi_ioptronv3_telescope</driver>
<version>1.7</version>
<version>1.8</version>
</device>
<device label="iOptron iEQ45 Pro" manufacturer="iOptron">
<driver name="iEQ">indi_ieq_telescope</driver>
Expand Down Expand Up @@ -249,19 +249,19 @@
</device>
<device label="iOptron v3" manufacturer="iOptron">
<driver name="iOptronV3">indi_ioptronv3_telescope</driver>
<version>1.7</version>
<version>1.8</version>
</device>
<device label="iOptron CEM120" manufacturer="iOptron">
<driver name="iOptronV3">indi_ioptronv3_telescope</driver>
<version>1.7</version>
<version>1.8</version>
</device>
<device label="iOptron CEM70" manufacturer="iOptron">
<driver name="iOptronV3">indi_ioptronv3_telescope</driver>
<version>1.7</version>
<version>1.8</version>
</device>
<device label="iOptron AZ Pro" manufacturer="iOptron">
<driver name="iOptronV3">indi_ioptronv3_telescope</driver>
<version>1.7</version>
<version>1.8</version>
</device>
<device label="Pulsar2" manufacturer="GTD">
<driver name="Pulsar2">indi_lx200pulsar2</driver>
Expand Down
132 changes: 84 additions & 48 deletions drivers/telescope/ioptronv3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static std::unique_ptr<IOptronV3> scope(new IOptronV3());
/* Constructor */
IOptronV3::IOptronV3()
{
setVersion(1, 7);
setVersion(1, 8);

driver.reset(new Driver(getDeviceName()));

Expand Down Expand Up @@ -227,53 +227,71 @@ 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);
defineProperty(&TimeSourceSP);
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);
deleteProperty(TimeSourceSP.name);
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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions drivers/telescope/ioptronv3.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8d8fd6d

Please sign in to comment.