summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasem Mutlaq <mutlaqja@ikarustech.com>2016-10-09 10:51:09 (GMT)
committerJasem Mutlaq <mutlaqja@ikarustech.com>2016-10-09 10:51:09 (GMT)
commit22b6eadd58c0cf18541e247c656bbcb4d8528c95 (patch)
tree1a688f81a49bc3a62dc94751cfcc082a1f48e531
parent90c09b9dba0b1f007e81e63c1613cc49e660464a (diff)
More progress on linguider. small fix in phd2
-rw-r--r--kstars/ekos/guide/externalguide/linguider.cpp490
-rw-r--r--kstars/ekos/guide/externalguide/linguider.h31
-rw-r--r--kstars/ekos/guide/externalguide/phd2.cpp8
-rw-r--r--kstars/ekos/guide/guide.cpp17
-rw-r--r--kstars/ekos/guide/opsguide.cpp15
-rw-r--r--kstars/ekos/guide/opsguide.h4
6 files changed, 110 insertions, 455 deletions
diff --git a/kstars/ekos/guide/externalguide/linguider.cpp b/kstars/ekos/guide/externalguide/linguider.cpp
index 105037c..7534098 100644
--- a/kstars/ekos/guide/externalguide/linguider.cpp
+++ b/kstars/ekos/guide/externalguide/linguider.cpp
@@ -12,10 +12,7 @@
#include <QUrl>
#include <QVariantMap>
#include <QDebug>
-#include <QHttpMultiPart>
#include <QFile>
-#include <QJsonObject>
-#include <QJsonDocument>
#include <KMessageBox>
#include <KLocalizedString>
@@ -34,36 +31,10 @@ LinGuider::LinGuider()
connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(readLinGuider()));
connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError)));
- connect(tcpSocket, SIGNAL(connected()), this, SIGNAL(connected()));
- connect(tcpSocket, SIGNAL(disconnected()), this, SIGNAL(disconnected()));
+ connect(tcpSocket, SIGNAL(connected()), this, SLOT(onConnected()));
- methodID=1;
- state = STOPPED;
+ state = IDLE;
connection = DISCONNECTED;
- event = Alert;
-
- events["Version"] = Version;
- events["LockPositionSet"] = LockPositionSet;
- events["CalibrationComplete"] = CalibrationComplete;
- events["StarSelected"] = StarSelected;
- events["StartGuiding"] = StartGuiding;
- events["Paused"] = Paused;
- events["StartCalibration"] = StartCalibration;
- events["AppState"] = AppState;
- events["CalibrationFailed"] = CalibrationFailed;
- events["CalibrationDataFlipped"] = CalibrationDataFlipped;
- events["LoopingExposures"] = LoopingExposures;
- events["LoopingExposuresStopped"] = LoopingExposuresStopped;
- events["Settling"] = Settling;
- events["SettleDone"] = SettleDone;
- events["StarLost"] = StarLost;
- events["GuidingStopped"] = GuidingStopped;
- events["Resumed"] = Resumed;
- events["GuideStep"] = GuideStep;
- events["GuidingDithered"] = GuidingDithered;
- events["LockPositionLost"] = LockPositionLost;
- events["Alert"] = Alert;
-
}
LinGuider::~LinGuider()
@@ -80,22 +51,19 @@ bool LinGuider::Connect()
}
// Already connected, let's connect equipment
else
- setEquipmentConnected(true);
+ emit newStatus(GUIDE_CONNECTED);
return true;
}
bool LinGuider::Disconnect()
-{
- if (connection == EQUIPMENT_CONNECTED)
- setEquipmentConnected(false);
-
- connection = DISCONNECTED;
- tcpSocket->disconnectFromHost();
+{
+ connection = DISCONNECTED;
+ tcpSocket->disconnectFromHost();
- emit newStatus(GUIDE_DISCONNECTED);
+ emit newStatus(GUIDE_DISCONNECTED);
- return true;
+ return true;
}
void LinGuider::displayError(QAbstractSocket::SocketError socketError)
@@ -124,8 +92,6 @@ void LinGuider::readLinGuider()
{
QTextStream stream(tcpSocket);
- QJsonParseError qjsonError;
-
while (stream.atEnd() == false)
{
QString rawString = stream.readLine();
@@ -133,408 +99,140 @@ void LinGuider::readLinGuider()
if (rawString.isEmpty())
continue;
- QJsonDocument jdoc = QJsonDocument::fromJson(rawString.toLatin1(), &qjsonError);
-
- if (qjsonError.error != QJsonParseError::NoError)
- {
+ if (Options::verboseLogging())
emit newLog(rawString);
- emit newLog(qjsonError.errorString());
- continue;
- }
-
- emit newLog(rawString);
-
- processJSON(jdoc.object());
- }
-
-}
-
-void LinGuider::processJSON(const QJsonObject &jsonObj)
-{
- LinGuiderMessageType messageType = LINGUIDER_UNKNOWN;
- bool result = false;
- if (jsonObj.contains("Event"))
- {
- messageType = LINGUIDER_EVENT;
- processLinGuiderEvent(jsonObj);
-
- if (event == Alert)
- return;
- }
- else if (jsonObj.contains("error"))
- {
- messageType = LINGUIDER_ERROR;
- result = false;
- processLinGuiderError(jsonObj);
- }
- else if (jsonObj.contains("result"))
- {
- messageType = LINGUIDER_RESULT;
- result = true;
- }
-
- switch (connection)
- {
- case CONNECTING:
- if (event == Version)
- connection = CONNECTED;
- return;
-
- case CONNECTED:
- // If initial state is STOPPED, let us connect equipment
- if (state == STOPPED)
- setEquipmentConnected(true);
- else if (state == GUIDING)
+ qint16 magicNumber = *(reinterpret_cast<qint16*>(rawString.toLatin1().data()));
+ if (magicNumber != 0x02)
{
- connection = EQUIPMENT_CONNECTED;
- emit newStatus(Ekos::GUIDE_CONNECTED);
+ emit newLog(i18n("Invalid response."));
+ continue;
}
- return;
-
- case DISCONNECTED:
- emit newStatus(Ekos::GUIDE_DISCONNECTED);
- break;
- case EQUIPMENT_CONNECTING:
- if (messageType == LINGUIDER_RESULT)
+ qint16 command = *(reinterpret_cast<qint16*>(rawString.toLatin1().data()+2));
+ if (command < GET_VER || command > GET_RA_DEC_DRIFT)
{
- if (result)
- {
- connection = EQUIPMENT_CONNECTED;
- emit newStatus(Ekos::GUIDE_CONNECTED);
- }
- else
- {
- connection = EQUIPMENT_DISCONNECTED;
- emit newStatus(Ekos::GUIDE_DISCONNECTED);
- }
+ emit newLog(i18n("Invalid response."));
+ continue;
}
- return;
-
- case EQUIPMENT_CONNECTED:
- case EQUIPMENT_DISCONNECTED:
- break;
-
- case EQUIPMENT_DISCONNECTING:
- connection = EQUIPMENT_DISCONNECTED;
- //emit disconnected();
- return;
- }
- switch (state)
- {
- case GUIDING:
- break;
+ QString reply = rawString.mid(8);
- case PAUSED:
- break;
-
- case STOPPED:
- break;
-
- default:
- break;
+ processResponse(static_cast<LinGuiderCommand>(command), reply);
}
}
-void LinGuider::processLinGuiderEvent(const QJsonObject &jsonEvent)
+void LinGuider::processResponse(LinGuiderCommand command, const QString &reply)
{
- QString eventName = jsonEvent["Event"].toString();
-
- if (events.contains(eventName) == false)
+ switch (command)
{
- emit newLog(i18n("Unknown LinGuider event: %1", eventName));
- return;
- }
-
- event = events.value(eventName);
-
- switch (event)
- {
- case Version:
- emit newLog(i18n("LinGuider: Version %1", jsonEvent["PHDVersion"].toString()));
- break;
-
- case CalibrationComplete:
- //state = CALIBRATION_SUCCESSFUL;
- // It goes immediately to guiding until PHD implements a calibration-only method
- state = GUIDING;
- emit newLog(i18n("LinGuider: Calibration Complete."));
- //emit guideReady();
- emit newStatus(Ekos::GUIDE_CALIBRATION_SUCESS);
- break;
-
- case StartGuiding:
- state = GUIDING;
- if (connection != EQUIPMENT_CONNECTED)
+ case GET_VER:
+ emit newLog(i18n("Connected to LinGuider %1", reply));
+ if (reply < "v.4.1.0")
{
- connection = EQUIPMENT_CONNECTED;
- emit newStatus(Ekos::GUIDE_CONNECTED);
+ emit newLog(i18n("Only LinGuider v4.1.0 or higher is supported. Please upgrade LinGuider and try again."));
+ Disconnect();
}
- emit newLog(i18n("LinGuider: Guiding Started."));
- emit newStatus(Ekos::GUIDE_GUIDING);
break;
- case Paused:
- state = PAUSED;
- emit newLog(i18n("LinGuider: Guiding Paused."));
- emit newStatus(Ekos::GUIDE_SUSPENDED);
- break;
-
- case StartCalibration:
- state = CALIBRATING;
- emit newLog(i18n("LinGuider: Calibration Started."));
- emit newStatus(Ekos::GUIDE_CALIBRATING);
- break;
-
- case AppState:
- processLinGuiderState(jsonEvent["State"].toString());
- break;
-
- case CalibrationFailed:
- state = CALIBRATION_FAILED;
- emit newLog(i18n("LinGuider: Calibration Failed (%1).", jsonEvent["Reason"].toString()));
- emit newStatus(Ekos::GUIDE_CALIBRATION_ERROR);
- break;
-
- case CalibrationDataFlipped:
- emit newLog(i18n("Calibration Data Flipped."));
- break;
-
- case LoopingExposures:
- //emit newLog(i18n("LinGuider: Looping Exposures."));
- break;
-
- case LoopingExposuresStopped:
- emit newLog(i18n("LinGuider: Looping Exposures Stopped."));
- break;
-
- case Settling:
- break;
-
- case SettleDone:
+ case FIND_STAR:
{
- bool error=false;
-
- if (jsonEvent["Status"].toInt() != 0)
+ emit newLog(i18n("Auto star selected %1", reply));
+ QStringList pos = reply.split(' ');
+ if (pos.count() == 2)
{
- error = true;
- emit newLog(i18n("LinGuider: Settling failed (%1).", jsonEvent["Error"].toString()));
+ starCenter = reply;
+ sendCommand(SET_GUIDER_RETICLE_POS, reply);
}
-
- if (state == GUIDING)
- {
- if (error)
- state = STOPPED;
- }
- else if (state == DITHERING)
+ else
{
- if (error)
- {
- state = DITHER_FAILED;
- //emit ditherFailed();
- emit newStatus(GUIDE_DITHERING_ERROR);
- }
- else
- {
- state = DITHER_SUCCESSFUL;
- emit newStatus(Ekos::GUIDE_DITHERING_SUCCESS);
- }
+ emit newLog(i18n("Failed to process star position."));
+ emit newStatus(GUIDE_CALIBRATION_ERROR);
}
}
- break;
-
- case StarSelected:
- emit newLog(i18n("LinGuider: Star Selected."));
- break;
-
- case StarLost:
- emit newLog(i18n("LinGuider: Star Lost."));
- emit newStatus(Ekos::GUIDE_ABORTED);
- break;
-
- case GuidingStopped:
- emit newLog(i18n("LinGuider: Guiding Stopped."));
- //emit autoGuidingToggled(false);
- emit newStatus(Ekos::GUIDE_IDLE);
- break;
-
- case Resumed:
- emit newLog(i18n("LinGuider: Guiding Resumed."));
- emit newStatus(Ekos::GUIDE_GUIDING);
- state = GUIDING;
- break;
-
- case GuideStep:
- {
- 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_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);
- }
- break;
-
- case GuidingDithered:
- emit newLog(i18n("LinGuider: Guide Dithering."));
- emit newStatus(Ekos::GUIDE_DITHERING);
- break;
-
- case LockPositionSet:
- emit newLog(i18n("LinGuider: Lock Position Set."));
break;
- case LockPositionLost:
- emit newLog(i18n("LinGuider: Lock Position Lost."));
- emit newStatus(Ekos::GUIDE_CALIBRATION_ERROR);
+ case SET_GUIDER_RETICLE_POS:
+ if (reply == "OK")
+ {
+ sendCommand(SET_GUIDER_OVLS_POS, starCenter);
+ }
+ else
+ {
+ emit newLog(i18n("Failed to set guider reticle position."));
+ emit newStatus(GUIDE_CALIBRATION_ERROR);
+ }
break;
-
- case Alert:
- emit newLog(i18n("LinGuider %1: %2", jsonEvent["Type"].toString(), jsonEvent["Msg"].toString()));
+ default:
break;
-
}
}
-void LinGuider::processLinGuiderState(const QString &LinGuiderState)
-{
- if (LinGuiderState == "Stopped")
- state = STOPPED;
- else if (LinGuiderState == "Selected")
- state = SELECTED;
- else if (LinGuiderState == "Calibrating")
- state = CALIBRATING;
- else if (LinGuiderState == "GUIDING")
- state = GUIDING;
- else if (LinGuiderState == "LostLock")
- state = LOSTLOCK;
- else if (LinGuiderState == "Paused")
- state = PAUSED;
- else if (LinGuiderState == "Looping")
- state = LOOPING;
-}
-
-void LinGuider::processLinGuiderError(const QJsonObject &jsonError)
+void LinGuider::onConnected()
{
- QJsonObject jsonErrorObject = jsonError["error"].toObject();
-
- emit newLog(i18n("LinGuider Error: %1", jsonErrorObject["message"].toString()));
-
- /* switch (connection)
- {
- case CONNECTING:
- case CONNECTED:
- emit disconnected();
- break;
+ emit newStatus(GUIDE_CONNECTED);
+ // Get version
- default:
- break;
- }*/
+ sendCommand(GET_VER);
}
-void LinGuider::sendJSONRPCRequest(const QString & method, const QJsonArray args)
-{
+void LinGuider::sendCommand(LinGuiderCommand command, const QString &args)
+{
+ //emit newLog(json_doc.toJson(QJsonDocument::Compact));
- QJsonObject jsonRPC;
+ //tcpSocket->write(json_doc.toJson(QJsonDocument::Compact));
- jsonRPC.insert("jsonrpc", "2.0");
- jsonRPC.insert("method", method);
+ // Command format: Magic Number (0x00 0x02), cmd (2 bytes), len_of_param (4 bytes), param (ascii)
- if (args.empty() == false)
- jsonRPC.insert("params", args);
+ int size = 8 + args.size();
- jsonRPC.insert("id", methodID++);
+ QByteArray cmd(size, 0);
- QJsonDocument json_doc(jsonRPC);
+ // Magic number
+ cmd[0] = 0x02;
+ cmd[1] = 0x00;
- emit newLog(json_doc.toJson(QJsonDocument::Compact));
+ // Command
+ cmd[2] = command;
+ cmd[3] = 0x00;
- tcpSocket->write(json_doc.toJson(QJsonDocument::Compact));
- tcpSocket->write("\r\n");
-}
+ // Len
+ qint32 len = args.size();
+ memcpy(cmd.data()+4, &len, 4);
-void LinGuider::setEquipmentConnected(bool enable)
-{
- if ( (connection == EQUIPMENT_CONNECTED && enable == true) || (connection == EQUIPMENT_DISCONNECTED && enable == false) )
- return;
-
- if (enable)
- connection = EQUIPMENT_CONNECTING;
- else
- connection = EQUIPMENT_DISCONNECTING;
+ // Params
+ if (args.isEmpty() == false)
+ memcpy(cmd.data()+8, args.toLatin1().data(), args.size());
- QJsonArray args;
-
- // connected = enable
- args << enable;
-
- sendJSONRPCRequest("set_connected", args);
+ tcpSocket->write(cmd);
}
bool LinGuider::calibrate()
{
- // We don't explicitly do calibration since it is done in the guide step by LinGuider anyway
- emit newStatus(Ekos::GUIDE_CALIBRATION_SUCESS);
+ // Let's start calibraiton. It is already calibrated but in this step we auto-select and star and set the square
+ emit newStatus(Ekos::GUIDE_CALIBRATING);
+
+ sendCommand(FIND_STAR);
+
return true;
}
bool LinGuider::guide()
{
- if (connection != EQUIPMENT_CONNECTED)
- {
- emit newLog(i18n("LinGuider Error: Equipment not connected."));
- return false;
- }
-
- QJsonArray args;
- QJsonObject settle;
-
- settle.insert("pixels", 1.5);
- settle.insert("time", 8);
- settle.insert("timeout", 45);
- // Settle param
- args << settle;
- // Recalibrate param
- args << false;
-
- sendJSONRPCRequest("guide", args);
+ //
return true;
}
bool LinGuider::abort()
{
- if (connection != EQUIPMENT_CONNECTED)
- {
- emit newLog(i18n("LinGuider Error: Equipment not connected."));
- return false;
- }
- sendJSONRPCRequest("stop_capture");
- return true;
+ return true;
}
bool LinGuider::suspend()
{
- if (connection != EQUIPMENT_CONNECTED)
- {
- emit newLog(i18n("LinGuider Error: Equipment not connected."));
- return false;
- }
-
- QJsonArray args;
-
- // Paused param
- args << true;
- // FULL param
- args << "full";
-
- sendJSONRPCRequest("set_paused", args);
return true;
@@ -542,18 +240,6 @@ bool LinGuider::suspend()
bool LinGuider::resume()
{
- if (connection != EQUIPMENT_CONNECTED)
- {
- emit newLog(i18n("LinGuider Error: Equipment not connected."));
- return false;
- }
-
- QJsonArray args;
-
- // Paused param
- args << false;
-
- sendJSONRPCRequest("set_paused", args);
return true;
@@ -561,29 +247,7 @@ bool LinGuider::resume()
bool LinGuider::dither(double pixels)
{
- if (connection != EQUIPMENT_CONNECTED)
- {
- emit newLog(i18n("LinGuider Error: Equipment not connected."));
- return false;
- }
-
- QJsonArray args;
- QJsonObject settle;
-
- settle.insert("pixels", 1.5);
- settle.insert("time", 8);
- settle.insert("timeout", 45);
-
- // Pixels
- args << pixels;
- // RA Only?
- args << false;
- // Settle
- args << settle;
-
- state = DITHERING;
- sendJSONRPCRequest("dither", args);
return true;
}
diff --git a/kstars/ekos/guide/externalguide/linguider.h b/kstars/ekos/guide/externalguide/linguider.h
index ca3eda4..64fa068 100644
--- a/kstars/ekos/guide/externalguide/linguider.h
+++ b/kstars/ekos/guide/externalguide/linguider.h
@@ -11,7 +11,7 @@
#define LinGuider_H
#include <QAbstractSocket>
-#include <QJsonArray>
+#include <QTimer>
#include "../guideinterface.h"
@@ -25,7 +25,7 @@ namespace Ekos
* Uses external LinGuider for guiding.
*
* @author Jasem Mutlaq
- * @version 1.1
+ * @version 1.0
*/
class LinGuider : public GuideInterface
{
@@ -33,11 +33,10 @@ class LinGuider : public GuideInterface
public:
- typedef enum { Version, LockPositionSet, CalibrationComplete, StarSelected, StartGuiding, Paused, StartCalibration, AppState, CalibrationFailed, CalibrationDataFlipped, LoopingExposures,
- LoopingExposuresStopped, Settling, SettleDone, StarLost, GuidingStopped, Resumed, GuideStep, GuidingDithered, LockPositionLost, Alert } LinGuiderEvent;
- typedef enum { STOPPED, SELECTED, LOSTLOCK, PAUSED, LOOPING, CALIBRATING, CALIBRATION_FAILED, CALIBRATION_SUCCESSFUL, GUIDING, DITHERING, DITHER_FAILED, DITHER_SUCCESSFUL } LinGuiderState;
- typedef enum { DISCONNECTED, CONNECTING, CONNECTED, EQUIPMENT_DISCONNECTING, EQUIPMENT_DISCONNECTED, EQUIPMENT_CONNECTING, EQUIPMENT_CONNECTED } LinGuiderConnection;
- typedef enum { LINGUIDER_UNKNOWN, LINGUIDER_RESULT, LINGUIDER_EVENT, LINGUIDER_ERROR } LinGuiderMessageType;
+ typedef enum { GET_VER = 1, SET_GUIDER_SQUARE_POS, SAVE_FRAME, DITHER, DITHER_NO_WAIT_XY, GET_DISTANCE, SAVE_FRAME_DECORATED,
+ GUIDER, GET_GUIDER_STATE, SET_GUIDER_OVLS_POS, SET_GUIDER_RETICLE_POS, FIND_STAR, SET_DITHERING_RANGE, GET_RA_DEC_DRIFT} LinGuiderCommand;
+ typedef enum { IDLE, GUIDING} LinGuiderState;
+ typedef enum { DISCONNECTED, CONNECTING, CONNECTED} LinGuiderConnection;
LinGuider();
~LinGuider();
@@ -55,27 +54,21 @@ public:
private slots:
void readLinGuider();
+ void onConnected();
void displayError(QAbstractSocket::SocketError socketError);
private:
-
- void setEquipmentConnected(bool enable);
-
- void sendJSONRPCRequest(const QString & method, const QJsonArray args = QJsonArray());
- void processJSON(const QJsonObject &jsonObj);
-
- void processLinGuiderEvent(const QJsonObject &jsonEvent);
- void processLinGuiderState(const QString &LinGuiderState);
- void processLinGuiderError(const QJsonObject &jsonError);
+ void sendCommand(LinGuiderCommand command, const QString &args = QString());
+ void processResponse(LinGuiderCommand command, const QString &reply);
QTcpSocket *tcpSocket;
- qint64 methodID;
- QHash<QString, LinGuiderEvent> events;
LinGuiderState state;
LinGuiderConnection connection;
- LinGuiderEvent event;
+
+ QTimer deviationTimer;
+ QString starCenter;
};
}
diff --git a/kstars/ekos/guide/externalguide/phd2.cpp b/kstars/ekos/guide/externalguide/phd2.cpp
index f76bb15..dfe430a 100644
--- a/kstars/ekos/guide/externalguide/phd2.cpp
+++ b/kstars/ekos/guide/externalguide/phd2.cpp
@@ -32,10 +32,7 @@ PHD2::PHD2()
tcpSocket = new QTcpSocket(this);
connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(readPHD2()));
- connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError)));
-
- connect(tcpSocket, SIGNAL(connected()), this, SIGNAL(connected()));
- connect(tcpSocket, SIGNAL(disconnected()), this, SIGNAL(disconnected()));
+ connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError)));
methodID=1;
state = STOPPED;
@@ -142,7 +139,8 @@ void PHD2::readPHD2()
continue;
}
- emit newLog(rawString);
+ if (Options::verboseLogging())
+ emit newLog(rawString);
processJSON(jdoc.object());
}
diff --git a/kstars/ekos/guide/guide.cpp b/kstars/ekos/guide/guide.cpp
index 3241167..2045d6d 100644
--- a/kstars/ekos/guide/guide.cpp
+++ b/kstars/ekos/guide/guide.cpp
@@ -240,7 +240,7 @@ Guide::Guide() : QWidget()
opsGuide = new OpsGuide();
dialog->addPage(opsGuide, i18n("Guide Settings"));
connect(guideOptionsB, SIGNAL(clicked()), dialog, SLOT(show()));
- connect(opsGuide, SIGNAL(guiderTypeChanged(Guide::GuiderType)), this, SLOT(setGuiderType(int)));
+ connect(opsGuide, SIGNAL(guiderTypeChanged(int)), this, SLOT(setGuiderType(int)));
internalGuider->setGuideView(guideView);
@@ -689,12 +689,15 @@ void Guide::setBusy(bool enable)
{
if (guiderType == GUIDE_INTERNAL)
{
- calibrateB->setEnabled(true);
captureB->setEnabled(true);
darkFrameCheck->setEnabled(true);
subFrameCheck->setEnabled(true);
}
+ // All can calibrate except for PHD2
+ if (guiderType != GUIDE_PHD2)
+ calibrateB->setEnabled(true);
+
if (state >= GUIDE_CALIBRATION_SUCESS || guiderType != GUIDE_INTERNAL)
guideB->setEnabled(true);
@@ -1310,7 +1313,7 @@ bool Guide::setGuiderType(int type)
currentCCD->getDriverInfo()->getClientManager()->setBLOBMode(B_NEVER, currentCCD->getDeviceName(), useGuideHead ? "CCD2" : "CCD1");
}
- calibrateB->setEnabled(false);
+ calibrateB->setEnabled(true);
captureB->setEnabled(false);
darkFrameCheck->setEnabled(false);
subFrameCheck->setEnabled(false);
@@ -1768,7 +1771,7 @@ void Guide::buildOperationStack(GuideState operation)
case GUIDE_CALIBRATING:
operationStack.push(GUIDE_CALIBRATING);
- if (starCenter.isNull() || (Options::guideAutoStarEnabled()))
+ if (guiderType == GUIDE_INTERNAL && (starCenter.isNull() || (Options::guideAutoStarEnabled())))
{
if (Options::guideDarkFrameEnabled())
operationStack.push(GUIDE_DARK);
@@ -1821,10 +1824,12 @@ bool Guide::executeOperationStack()
break;
case GUIDE_CALIBRATING:
- guider->setStarPosition(starCenter);
+ if (guiderType == GUIDE_INTERNAL)
+ guider->setStarPosition(starCenter);
if (guider->calibrate())
{
- disconnect(guideView, SIGNAL(trackingStarSelected(int,int)), this, SLOT(setTrackingStar(int,int)));
+ if (guiderType == GUIDE_INTERNAL)
+ disconnect(guideView, SIGNAL(trackingStarSelected(int,int)), this, SLOT(setTrackingStar(int,int)));
setBusy(true);
}
else
diff --git a/kstars/ekos/guide/opsguide.cpp b/kstars/ekos/guide/opsguide.cpp
index 56fcbb6..8aad3a1 100644
--- a/kstars/ekos/guide/opsguide.cpp
+++ b/kstars/ekos/guide/opsguide.cpp
@@ -49,9 +49,9 @@ void OpsGuide::showEvent(QShowEvent *)
slotLoadSettings(static_cast<Guide::GuiderType>(Options::guiderType()));
}
-void OpsGuide::slotLoadSettings(Guide::GuiderType guiderType)
+void OpsGuide::slotLoadSettings(int guiderType)
{
- switch (guiderType)
+ switch (static_cast<Guide::GuiderType>(guiderType))
{
case Guide::GUIDE_INTERNAL:
internalGuideR->setChecked(true);
@@ -76,36 +76,31 @@ void OpsGuide::slotLoadSettings(Guide::GuiderType guiderType)
externalHost->setText(Options::linGuiderHost());
externalPort->setText(QString::number(Options::linGuiderPort()));
break;
- }
+ }
}
void OpsGuide::slotApply()
-{
- Guide::GuiderType type;
-
+{
switch (guiderTypeButtonGroup->checkedId())
{
case Guide::GUIDE_INTERNAL:
- type = Guide::GUIDE_INTERNAL;
Options::setGuiderType(Guide::GUIDE_INTERNAL);
break;
case Guide::GUIDE_PHD2:
- type = Guide::GUIDE_PHD2;
Options::setGuiderType(Guide::GUIDE_PHD2);
Options::setPHD2Host(externalHost->text());
Options::setPHD2Port(externalPort->text().toInt());
break;
case Guide::GUIDE_LINGUIDER:
- type = Guide::GUIDE_LINGUIDER;
Options::setGuiderType(Guide::GUIDE_LINGUIDER);
Options::setLinGuiderHost(externalHost->text());
Options::setLinGuiderPort(externalPort->text().toInt());
break;
}
- emit guiderTypeChanged(type);
+ emit guiderTypeChanged(guiderTypeButtonGroup->checkedId());
}
}
diff --git a/kstars/ekos/guide/opsguide.h b/kstars/ekos/guide/opsguide.h
index 0799afe..f166fc0 100644
--- a/kstars/ekos/guide/opsguide.h
+++ b/kstars/ekos/guide/opsguide.h
@@ -39,10 +39,10 @@ protected:
private slots:
void slotApply();
- void slotLoadSettings(Guide::GuiderType guiderType);
+ void slotLoadSettings(int guiderType);
signals:
- void guiderTypeChanged(Guide::GuiderType guiderType);
+ void guiderTypeChanged(int guiderType);
private:
KConfigDialog *m_ConfigDialog;