2021-01-13 15:51:38 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2021 Jon Beniston, M7RCE //
|
|
|
|
// Copyright (C) 2020 Edouard Griffiths, F4EXB //
|
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
|
|
|
// (at your option) any later version. //
|
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef INCLUDE_FEATURE_STARTRACKERWORKER_H_
|
|
|
|
#define INCLUDE_FEATURE_STARTRACKERWORKER_H_
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QAbstractSocket>
|
|
|
|
|
|
|
|
#include "util/message.h"
|
|
|
|
#include "util/messagequeue.h"
|
|
|
|
#include "util/astronomy.h"
|
|
|
|
|
|
|
|
#include "startrackersettings.h"
|
|
|
|
|
|
|
|
class WebAPIAdapterInterface;
|
|
|
|
class QTcpServer;
|
|
|
|
class QTcpSocket;
|
|
|
|
class StarTracker;
|
|
|
|
class QDateTime;
|
2022-03-29 14:12:15 -04:00
|
|
|
class ObjectPipe;
|
2021-01-13 15:51:38 -05:00
|
|
|
|
|
|
|
class StarTrackerWorker : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
class MsgConfigureStarTrackerWorker : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
const StarTrackerSettings& getSettings() const { return m_settings; }
|
|
|
|
bool getForce() const { return m_force; }
|
|
|
|
|
|
|
|
static MsgConfigureStarTrackerWorker* create(const StarTrackerSettings& settings, bool force)
|
|
|
|
{
|
|
|
|
return new MsgConfigureStarTrackerWorker(settings, force);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
StarTrackerSettings m_settings;
|
|
|
|
bool m_force;
|
|
|
|
|
|
|
|
MsgConfigureStarTrackerWorker(const StarTrackerSettings& settings, bool force) :
|
|
|
|
Message(),
|
|
|
|
m_settings(settings),
|
|
|
|
m_force(force)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
StarTrackerWorker(StarTracker* starTracker, WebAPIAdapterInterface *webAPIAdapterInterface);
|
|
|
|
~StarTrackerWorker();
|
2022-09-20 06:48:25 -04:00
|
|
|
void startWork();
|
2021-01-13 15:51:38 -05:00
|
|
|
void stopWork();
|
|
|
|
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; }
|
|
|
|
void setMessageQueueToFeature(MessageQueue *messageQueue) { m_msgQueueToFeature = messageQueue; }
|
|
|
|
void setMessageQueueToGUI(MessageQueue *messageQueue) { m_msgQueueToGUI = messageQueue; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
StarTracker* m_starTracker;
|
|
|
|
WebAPIAdapterInterface *m_webAPIAdapterInterface;
|
|
|
|
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
|
|
|
|
MessageQueue *m_msgQueueToFeature; //!< Queue to report channel change to main feature object
|
|
|
|
MessageQueue *m_msgQueueToGUI;
|
|
|
|
StarTrackerSettings m_settings;
|
2022-09-15 15:59:42 -04:00
|
|
|
QRecursiveMutex m_mutex;
|
2021-01-13 15:51:38 -05:00
|
|
|
QTimer m_pollTimer;
|
|
|
|
QTcpServer *m_tcpServer;
|
|
|
|
QTcpSocket *m_clientConnection;
|
2021-10-12 06:07:56 -04:00
|
|
|
float m_solarFlux;
|
2021-01-13 15:51:38 -05:00
|
|
|
|
|
|
|
bool handleMessage(const Message& cmd);
|
|
|
|
void applySettings(const StarTrackerSettings& settings, bool force = false);
|
|
|
|
void restartServer(bool enabled, uint32_t port);
|
|
|
|
MessageQueue *getMessageQueueToGUI() { return m_msgQueueToGUI; }
|
2021-10-12 06:07:56 -04:00
|
|
|
void updateRaDec(RADec rd, QDateTime dt, bool lbTarget);
|
2021-01-13 15:51:38 -05:00
|
|
|
void writeStellariumTarget(double ra, double dec);
|
|
|
|
void removeFromMap(QString id);
|
2022-03-29 14:12:15 -04:00
|
|
|
void sendToMap(
|
|
|
|
const QList<ObjectPipe*>& mapMessagePipes,
|
|
|
|
QString id,
|
|
|
|
QString image,
|
|
|
|
QString text,
|
|
|
|
double lat,
|
|
|
|
double lon,
|
|
|
|
double rotation = 0.0
|
|
|
|
);
|
2021-01-13 15:51:38 -05:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void handleInputMessages();
|
|
|
|
void update();
|
|
|
|
void acceptConnection();
|
|
|
|
void disconnected();
|
|
|
|
void errorOccurred(QAbstractSocket::SocketError socketError);
|
|
|
|
void readStellariumCommand();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INCLUDE_FEATURE_STARTRACKERWORKER_H_
|