Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Home support to base class #2090

Merged
merged 5 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions drivers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
</device>
<device label="LX200 OnStep" manufacturer="OnStep">
<driver name="LX200 OnStep">indi_lx200_OnStep</driver>
<version>1.22</version>
<version>1.23</version>
</device>
<device label="WARPDRIVE" manufacturer="WarpAstron">
<driver name="LX200 OnStep">indi_lx200_OnStep</driver>
<version>1.22</version>
<version>1.23</version>
</device>
<device label="LX200 OpenAstroTech" manufacturer="OpenAstroTech">
<driver name="LX200 OpenAstroTech">indi_lx200_OpenAstroTech</driver>
Expand Down Expand Up @@ -77,7 +77,7 @@
</device>
<device label="Pegasus NYX-101" manufacturer="Pegasus Astro">
<driver name="Pegasus NYX-101">indi_lx200_pegasus_nyx101</driver>
<version>2.1</version>
<version>2.2</version>
</device>
<device label="ZWO AM5 WiFi" manufacturer="ZWO">
<driver name="ZWO AM5">indi_lx200am5</driver>
Expand Down
138 changes: 51 additions & 87 deletions drivers/telescope/ieqpro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ IEQPro::IEQPro()
SetTelescopeCapability(TELESCOPE_CAN_PARK | TELESCOPE_CAN_SYNC | TELESCOPE_CAN_GOTO | TELESCOPE_CAN_ABORT |
TELESCOPE_HAS_TIME | TELESCOPE_HAS_LOCATION | TELESCOPE_HAS_TRACK_MODE | TELESCOPE_CAN_CONTROL_TRACK |
TELESCOPE_HAS_TRACK_RATE,
9);
9,
HOME_FIND | HOME_GO | HOME_SET
);
}

const char *IEQPro::getDefaultName()
Expand Down Expand Up @@ -127,13 +129,6 @@ bool IEQPro::initProperties()
IUFillSwitchVector(&HemisphereSP, HemisphereS, 2, getDeviceName(), "HEMISPHERE", "Hemisphere", MOUNTINFO_TAB, IP_RO,
ISR_1OFMANY, 0, IPS_IDLE);

/* Home */
IUFillSwitch(&HomeS[IEQ_SET_HOME], "IEQ_SET_HOME", "Set current as Home", ISS_OFF);
IUFillSwitch(&HomeS[IEQ_GOTO_HOME], "IEQ_GOTO_HOME", "Go to Home", ISS_OFF);
IUFillSwitch(&HomeS[IEQ_FIND_HOME], "IEQ_FIND_HOME", "Find Home", ISS_OFF);
IUFillSwitchVector(&HomeSP, HomeS, 3, getDeviceName(), "HOME", "Home", MAIN_CONTROL_TAB, IP_RW, ISR_ATMOST1, 0,
IPS_IDLE);

/* How fast do we guide compared to sidereal rate */
IUFillNumber(&GuideRateN[RA_AXIS], "RA_GUIDE_RATE", "RA", "%.2f", 0.01, 0.9, 0.1, 0.5);
IUFillNumber(&GuideRateN[DEC_AXIS], "DE_GUIDE_RATE", "DE", "%.2f", 0.1, 0.99, 0.1, 0.5);
Expand Down Expand Up @@ -170,12 +165,6 @@ bool IEQPro::updateProperties()

INDI::Telescope::updateProperties();

// Remove find home if we do not support it.
if (!canFindHome)
HomeSP.nsp = 2;

defineProperty(&HomeSP);

defineProperty(&GuideNSNP);
defineProperty(&GuideWENP);

Expand All @@ -191,9 +180,6 @@ bool IEQPro::updateProperties()
{
INDI::Telescope::updateProperties();

HomeSP.nsp = 3;
deleteProperty(HomeSP.name);

deleteProperty(GuideNSNP.name);
deleteProperty(GuideWENP.name);

Expand Down Expand Up @@ -347,80 +333,10 @@ bool IEQPro::ISNewNumber(const char *dev, const char *name, double values[], cha
return INDI::Telescope::ISNewNumber(dev, name, values, names, n);
}

bool IEQPro::ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
{
if (!strcmp(getDeviceName(), dev))
{
if (!strcmp(name, HomeSP.name))
{
IUUpdateSwitch(&HomeSP, states, names, n);

HomeOperation operation = static_cast<HomeOperation>(IUFindOnSwitchIndex(&HomeSP));

IUResetSwitch(&HomeSP);

switch (operation)
{
case IEQ_SET_HOME:
if (driver->setCurrentHome() == false)
{
HomeSP.s = IPS_ALERT;
IDSetSwitch(&HomeSP, nullptr);
return false;
}

HomeSP.s = IPS_OK;
IDSetSwitch(&HomeSP, nullptr);
LOG_INFO("Home position set to current coordinates.");
return true;

case IEQ_GOTO_HOME:
if (TrackState == SCOPE_PARKED)
{
LOG_ERROR("Please unpark the mount before issuing any motion commands.");
return false;
}

if (driver->gotoHome() == false)
{
HomeSP.s = IPS_ALERT;
IDSetSwitch(&HomeSP, nullptr);
return false;
}

HomeSP.s = IPS_OK;
IDSetSwitch(&HomeSP, nullptr);
LOG_INFO("Slewing to home position...");
return true;

case IEQ_FIND_HOME:
if (driver->findHome() == false)
{
HomeSP.s = IPS_ALERT;
IDSetSwitch(&HomeSP, nullptr);
return false;
}

HomeSP.s = IPS_OK;
IDSetSwitch(&HomeSP, nullptr);
LOG_INFO("Searching for home position...");
return true;
}

return true;
}
}

return INDI::Telescope::ISNewSwitch(dev, name, states, names, n);
}

bool IEQPro::ReadScopeStatus()
{
iEQ::Base::Info newInfo;

// if (isSimulation())
// mountSim();

bool rc = driver->getStatus(&newInfo);

if (rc)
Expand Down Expand Up @@ -1071,3 +987,51 @@ bool IEQPro::SetTrackEnabled(bool enabled)

return driver->setTrackEnabled(enabled);
}

IPState IEQPro::ExecuteHomeAction(TelescopeHomeAction action)
{
switch (action)
{
case HOME_FIND:
if (!canFindHome && (firmwareInfo.Model.find("CEM") == std::string::npos &&
firmwareInfo.Model.find("GEM45") == std::string::npos &&
firmwareInfo.Model.find("HAE") == std::string::npos &&
firmwareInfo.Model.find("HAZ") == std::string::npos &&
firmwareInfo.Model.find("HEM") == std::string::npos))
{
LOG_WARN("Home search is not supported in this model.");
return IPS_ALERT;
}

if (driver->findHome() == false)
{
return IPS_ALERT;
}

LOG_INFO("Searching for home position...");
return IPS_BUSY;

case HOME_SET:
if (driver->setCurrentHome() == false)
{
return IPS_ALERT;
}

LOG_INFO("Home position set to current coordinates.");
return IPS_OK;

case HOME_GO:
if (driver->gotoHome() == false)
{
return IPS_ALERT;
}

LOG_INFO("Slewing to home position...");
return IPS_BUSY;

default:
return IPS_ALERT;
}

return IPS_ALERT;
}
8 changes: 5 additions & 3 deletions drivers/telescope/ieqpro.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class IEQPro : public INDI::Telescope, public INDI::GuiderInterface
IEQPro();

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;

protected:
virtual const char *getDefaultName() override;
Expand Down Expand Up @@ -78,6 +77,9 @@ class IEQPro : public INDI::Telescope, public INDI::GuiderInterface
// Slew Rate
virtual bool SetSlewRate(int index) override;

// Homing
virtual IPState ExecuteHomeAction(TelescopeHomeAction action) override;

// Sim
//void mountSim();

Expand Down Expand Up @@ -118,8 +120,8 @@ class IEQPro : public INDI::Telescope, public INDI::GuiderInterface
ISwitchVectorProperty HemisphereSP;

/* Home Control */
ISwitch HomeS[3];
ISwitchVectorProperty HomeSP;
// ISwitch HomeS[3];
// ISwitchVectorProperty HomeSP;

/* Guide Rate */
INumber GuideRateN[2];
Expand Down
Loading
Loading