Commit 0a7a4d87 authored by Jasem Mutlaq's avatar Jasem Mutlaq

PHD2 is mostly working now in the Ekos updated guide module

parent d56d662d
......@@ -189,7 +189,7 @@ if (INDI_FOUND)
#ekos/guide/internalguide/rcalibration.cpp
ekos/guide/internalguide/vect.cpp
# External Guide
#ekos/guide/externalguide/phd2.cpp
ekos/guide/externalguide/phd2.cpp
)
endif(CFITSIO_FOUND)
endif(BUILD_KSTARS_LITE)
......
......@@ -71,7 +71,7 @@ PHD2::~PHD2()
}
void PHD2::Connect()()
bool PHD2::Connect()
{
if (connection == DISCONNECTED)
{
......@@ -81,15 +81,21 @@ void PHD2::Connect()()
// Already connected, let's connect equipment
else
setEquipmentConnected(true);
return true;
}
void PHD2::disconnectPHD2()
bool PHD2::Disconnect()
{
if (connection == EQUIPMENT_CONNECTED)
setEquipmentConnected(false);
connection = DISCONNECTED;
tcpSocket->disconnectFromHost();
emit newStatus(GUIDE_DISCONNECTED);
return true;
}
void PHD2::displayError(QAbstractSocket::SocketError socketError)
......@@ -99,10 +105,12 @@ void PHD2::displayError(QAbstractSocket::SocketError socketError)
case QAbstractSocket::RemoteHostClosedError:
break;
case QAbstractSocket::HostNotFoundError:
emit newLog(i18n("The host was not found. Please check the host name and port settings in Ekos options."));
emit newLog(i18n("The host was not found. Please check the host name and port settings in Guide options."));
emit newStatus(GUIDE_DISCONNECTED);
break;
case QAbstractSocket::ConnectionRefusedError:
emit newLog(i18n("The connection was refused by the peer. Make sure the PHD2 is running, and check that the host name and port settings are correct."));
emit newStatus(GUIDE_DISCONNECTED);
break;
default:
emit newLog(i18n("The following error occurred: %1.", tcpSocket->errorString()));
......@@ -180,11 +188,12 @@ void PHD2::processJSON(const QJsonObject &jsonObj)
else if (state == GUIDING)
{
connection = EQUIPMENT_CONNECTED;
emit connected();
emit newStatus(Ekos::GUIDE_CONNECTED);
}
return;
case DISCONNECTED:
emit newStatus(Ekos::GUIDE_DISCONNECTED);
break;
case EQUIPMENT_CONNECTING:
......@@ -193,12 +202,12 @@ void PHD2::processJSON(const QJsonObject &jsonObj)
if (result)
{
connection = EQUIPMENT_CONNECTED;
emit connected();
emit newStatus(Ekos::GUIDE_CONNECTED);
}
else
{
connection = EQUIPMENT_DISCONNECTED;
emit disconnected();
emit newStatus(Ekos::GUIDE_DISCONNECTED);
}
}
return;
......@@ -261,7 +270,7 @@ void PHD2::processPHD2Event(const QJsonObject &jsonEvent)
if (connection != EQUIPMENT_CONNECTED)
{
connection = EQUIPMENT_CONNECTED;
emit connected();
emit newStatus(Ekos::GUIDE_CONNECTED);
}
emit newLog(i18n("PHD2: Guiding Started."));
emit newStatus(Ekos::GUIDE_GUIDING);
......@@ -361,10 +370,10 @@ void PHD2::processPHD2Event(const QJsonObject &jsonEvent)
{
double diff_ra_pixels, diff_de_pixels, diff_ra_arcsecs, diff_de_arcsecs;
diff_ra_pixels = jsonEvent["RADistanceRaw"].toDouble();
diff_de_pixels = jsonEvent["DecDistanceRaw"].toDouble();
diff_de_pixels = jsonEvent["DECDistanceRaw"].toDouble();
diff_ra_arcsecs = 206264.8062470963552 * diff_ra_pixels * ccd_pixel_width / focal;
diff_de_arcsecs = 206264.8062470963552 * diff_de_pixels * ccd_pixel_height / focal;
diff_ra_arcsecs = 206.26480624709 * diff_ra_pixels * ccdPixelSizeX / mountFocalLength;
diff_de_arcsecs = 206.26480624709 * diff_de_pixels * ccdPixelSizeY / mountFocalLength;
emit newAxisDelta(diff_ra_arcsecs, diff_de_arcsecs);
}
......@@ -466,6 +475,13 @@ void PHD2::setEquipmentConnected(bool enable)
sendJSONRPCRequest("set_connected", args);
}
bool PHD2::calibrate()
{
// We don't explicitly do calibration since it is done in the guide step by PHD2 anyway
emit newStatus(Ekos::GUIDE_CALIBRATION_SUCESS);
return true;
}
bool PHD2::guide()
{
if (connection != EQUIPMENT_CONNECTED)
......@@ -491,7 +507,7 @@ bool PHD2::guide()
return true;
}
bool PHD2::stop()
bool PHD2::abort()
{
if (connection != EQUIPMENT_CONNECTED)
{
......@@ -572,19 +588,6 @@ bool PHD2::dither(double pixels)
return true;
}
bool PHD2::isConnected()
{
return (connection >= CONNECTED);
}
void PHD2::setCCDMountParams(double ccd_pix_w, double ccd_pix_h, double mount_aperture, double mount_focal)
{
ccd_pixel_width = ccd_pix_w/1000.0;
ccd_pixel_height= ccd_pix_h/1000.0;
focal = mount_focal;
aperture = mount_aperture;
}
}
......@@ -75,9 +75,7 @@ private:
PHD2State state;
PHD2Connection connection;
PHD2Event event;
double ccd_pixel_width, ccd_pixel_height, aperture, focal;
PHD2Event event;
};
}
......
This diff is collapsed.
......@@ -164,14 +164,6 @@ public:
*/
Q_SCRIPTABLE Q_NOREPLY void setDitherSettings(bool enable, double value);
/** DBUS interface function.
* Selects which guiding process to utilize for calibration & guiding.
* @param type Type of guider process to use. 0 for internal guider, 1 for external PHD2, 2 for external lin_guider
* @return True if guiding is switched to the new requested type. False otherwise.
*/
Q_SCRIPTABLE Q_NOREPLY bool setGuideType(int type);
/** @}*/
void addCCD(ISD::GDInterface *newCCD);
......@@ -271,6 +263,13 @@ public slots:
*/
Q_SCRIPTABLE Q_NOREPLY void startAutoCalibrateGuide();
/** DBUS interface function.
* Selects which guiding process to utilize for calibration & guiding.
* @param type Type of guider process to use. 0 for internal guider, 1 for external PHD2, 2 for external lin_guider
* @return True if guiding is switched to the new requested type. False otherwise.
*/
Q_SCRIPTABLE bool setGuiderType(int type);
/**
* @brief checkCCD Check all CCD parameters and ensure all variables are updated to reflect the selected CCD
* @param ccdNum CCD index number in the CCD selection combo box
......@@ -367,8 +366,7 @@ protected slots:
void setAxisSigma(double ra, double de);
void setAxisPulse(double ra, double de);
// FIXME
//void onSetDECSwap(bool enable);
void processGuideOptions();
void onControlDirectionChanged(bool enable);
......@@ -487,8 +485,8 @@ private:
// Pointers of guider processes
QPointer<InternalGuider> internalGuider;
// TODO implement those
//QPointer<PHD2> phd2Guider;
QPointer<PHD2> phd2Guider;
// TODO implement those
//QPointer<LinGuider> linGuider;
};
......
......@@ -136,13 +136,19 @@
<property name="verticalSpacing">
<number>5</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<item row="3" column="2">
<widget class="QLabel" name="label_8">
<property name="toolTip">
<string>Apply filter to image after capture to enhance it</string>
</property>
<property name="text">
<string>Guider:</string>
<string>Filters:</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="3">
<widget class="QComboBox" name="ST4Combo"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="toolTip">
......@@ -153,6 +159,19 @@
</property>
</widget>
</item>
<item row="0" column="1" colspan="3">
<widget class="QComboBox" name="guiderCombo"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="toolTip">
<string>Guide star tracking box size. Box size must be set in accordance to the selected star size.</string>
</property>
<property name="text">
<string>Box:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="toolTip">
......@@ -163,14 +182,16 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="exposureIN">
<property name="maximum">
<double>60.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
<item row="2" column="3">
<widget class="QComboBox" name="binningCombo"/>
</item>
<item row="3" column="3">
<widget class="QComboBox" name="filterCombo">
<item>
<property name="text">
<string>--</string>
</property>
</item>
</widget>
</item>
<item row="2" column="2">
......@@ -186,16 +207,20 @@
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QComboBox" name="binningCombo"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="toolTip">
<string>Guide star tracking box size. Box size must be set in accordance to the selected star size.</string>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="exposureIN">
<property name="maximum">
<double>60.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Box:</string>
<string>Guider:</string>
</property>
</widget>
</item>
......@@ -228,31 +253,32 @@
</item>
</widget>
</item>
<item row="3" column="2">
<widget class="QLabel" name="label_8">
<item row="4" column="2" colspan="2">
<widget class="QPushButton" name="externalDisconnectB">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Apply filter to image after capture to enhance it</string>
<string>Disconnect from external guiding application.</string>
</property>
<property name="text">
<string>Filters:</string>
<string>Disconnect</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QComboBox" name="filterCombo">
<item>
<property name="text">
<string>--</string>
</property>
</item>
<item row="4" column="0" colspan="2">
<widget class="QPushButton" name="externalConnectB">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Connect to external guiding application.</string>
</property>
<property name="text">
<string>Connect</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="3">
<widget class="QComboBox" name="guiderCombo"/>
</item>
<item row="1" column="1" colspan="3">
<widget class="QComboBox" name="ST4Combo"/>
</item>
</layout>
</item>
</layout>
......
......@@ -97,7 +97,7 @@
<arg name="value" type="d" direction="in"/>
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
</method>
<method name="setGuideType">
<method name="setGuiderType">
<arg name="guideType" type="i" direction="in"/>
<arg type="b" direction="out"/>
</method>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment