Skip to content

Commit

Permalink
Fix getting coordinates from mount
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-w committed Nov 9, 2024
1 parent 6fcfd37 commit 1d4daca
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
18 changes: 9 additions & 9 deletions plugins/TelescopeControl/src/INDI/INDIConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ INDIConnection::INDIConnection(QObject *parent) : QObject(parent)
INDIConnection::Coordinates INDIConnection::position() const
{
std::lock_guard<std::mutex> lock(mMutex);

Coordinates mCoordinates;
auto property = mTelescope.getNumber("EQUATORIAL_EOD_COORD");
mCoordinates.RA = property.getNumber()->np[0].value;
mCoordinates.DEC = property.getNumber()->np[1].value;

return mCoordinates;
}

Expand Down Expand Up @@ -78,7 +84,7 @@ void INDIConnection::setPosition(INDIConnection::Coordinates coords)

property[0].setValue(coords.RA);
property[1].setValue(coords.DEC);
sendNewNumber(property);
sendNewNumber(property);
}

void INDIConnection::syncPosition(INDIConnection::Coordinates coords)
Expand Down Expand Up @@ -328,7 +334,7 @@ void INDIConnection::newDevice(INDI::BaseDevice dp)

QString name(dp.getDeviceName());

qDebug() << "INDIConnection::newDevice| New Device... " << name;
qDebug().noquote() << "INDIConnection::newDevice| New Device... " << name;

mDevices.append(name);
mTelescope = dp;
Expand Down Expand Up @@ -362,13 +368,7 @@ void INDIConnection::newProperty(INDI::Property property)

QString name(property.getName());

qDebug() << "INDIConnection::newProperty| " << name;

if (name == "EQUATORIAL_EOD_COORD")
{
mCoordinates.RA = property.getNumber()->np[0].value;
mCoordinates.DEC = property.getNumber()->np[1].value;
}
qDebug().noquote() << "INDIConnection::newProperty| " << name;

if (!mTelescope.isConnected())
{
Expand Down
1 change: 0 additions & 1 deletion plugins/TelescopeControl/src/INDI/INDIConnection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ class INDIConnection final : public QObject, public INDI::BaseClient

mutable std::mutex mMutex;
INDI::BaseDevice mTelescope;
Coordinates mCoordinates;
QStringList mDevices;

public: // from INDI::BaseClient
Expand Down
8 changes: 2 additions & 6 deletions plugins/TelescopeControl/src/INDI/TelescopeClientINDI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ TelescopeClientINDI::~TelescopeClientINDI()
mConnection.disconnectServer();
}

Vec3d TelescopeClientINDI::getJ2000EquatorialPos(const StelCore*) const
Vec3d TelescopeClientINDI::getJ2000EquatorialPos(const StelCore* core) const
{
INDIConnection::Coordinates positionJNow = mConnection.position();

Expand All @@ -63,9 +63,7 @@ Vec3d TelescopeClientINDI::getJ2000EquatorialPos(const StelCore*) const

Vec3d posJNow;
StelUtils::spheToRect(longitudeRad, latitudeRad, posJNow);
const StelCore* core = StelApp::getInstance().getCore();
Vec3d posJ2000 = core->equinoxEquToJ2000(posJNow, StelCore::RefractionOff);
return posJ2000;
return core->equinoxEquToJ2000(posJNow, StelCore::RefractionOff);
}

void TelescopeClientINDI::telescopeGoto(const Vec3d &positionJ2000, StelObjectP selectObject)
Expand All @@ -82,7 +80,6 @@ void TelescopeClientINDI::telescopeGoto(const Vec3d &positionJ2000, StelObjectP
double longitudeRad = posJ2000[0] * 12.0 / M_PI;
double latitudeRad = posJ2000[1] * 180.0 / M_PI;


INDIConnection::Coordinates positionJNow = mConnection.position();
positionJNow.RA = longitudeRad;
positionJNow.DEC = latitudeRad;
Expand All @@ -107,7 +104,6 @@ void TelescopeClientINDI::telescopeSync(const Vec3d &positionJ2000, StelObjectP
double longitudeRad = posJ2000[0] * 12.0 / M_PI;
double latitudeRad = posJ2000[1] * 180.0 / M_PI;


INDIConnection::Coordinates positionJNow = mConnection.position();
positionJNow.RA = longitudeRad;
positionJNow.DEC = latitudeRad;
Expand Down

0 comments on commit 1d4daca

Please sign in to comment.