2020-10-27 12:22:10 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
2023-11-18 07:12:18 -05:00
|
|
|
// Copyright (C) 2019-2020, 2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
|
|
|
|
// Copyright (C) 2020-2023 Jon Beniston, M7RCE <jon@beniston.com> //
|
|
|
|
// Copyright (C) 2020 Vort <vvort@yandex.ru> //
|
|
|
|
// Copyright (C) 2022 Jiří Pinkava <jiri.pinkava@rossum.ai> //
|
2020-10-27 12:22:10 -04:00
|
|
|
// //
|
|
|
|
// 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_GS232CONTROLLERWORKER_H_
|
|
|
|
#define INCLUDE_FEATURE_GS232CONTROLLERWORKER_H_
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QSerialPort>
|
2021-11-23 07:13:24 -05:00
|
|
|
#include <QTcpSocket>
|
2020-10-27 12:22:10 -04:00
|
|
|
|
|
|
|
#include "util/message.h"
|
|
|
|
#include "util/messagequeue.h"
|
|
|
|
|
|
|
|
#include "gs232controllersettings.h"
|
2023-04-03 11:47:13 -04:00
|
|
|
#include "controllerprotocol.h"
|
2020-10-27 12:22:10 -04:00
|
|
|
|
2024-02-14 08:21:26 -05:00
|
|
|
class GS232Controller;
|
|
|
|
|
2020-10-27 12:22:10 -04:00
|
|
|
class GS232ControllerWorker : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
class MsgConfigureGS232ControllerWorker : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
const GS232ControllerSettings& getSettings() const { return m_settings; }
|
2022-11-24 10:40:36 -05:00
|
|
|
const QList<QString>& getSettingsKeys() const { return m_settingsKeys; }
|
2020-10-27 12:22:10 -04:00
|
|
|
bool getForce() const { return m_force; }
|
|
|
|
|
2022-11-24 10:40:36 -05:00
|
|
|
static MsgConfigureGS232ControllerWorker* create(const GS232ControllerSettings& settings, const QList<QString>& settingsKeys, bool force)
|
2020-10-27 12:22:10 -04:00
|
|
|
{
|
2022-11-24 10:40:36 -05:00
|
|
|
return new MsgConfigureGS232ControllerWorker(settings, settingsKeys, force);
|
2020-10-27 12:22:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
GS232ControllerSettings m_settings;
|
2022-11-24 10:40:36 -05:00
|
|
|
QList<QString> m_settingsKeys;
|
2020-10-27 12:22:10 -04:00
|
|
|
bool m_force;
|
|
|
|
|
2022-11-24 10:40:36 -05:00
|
|
|
MsgConfigureGS232ControllerWorker(const GS232ControllerSettings& settings, const QList<QString>& settingsKeys, bool force) :
|
2020-10-27 12:22:10 -04:00
|
|
|
Message(),
|
|
|
|
m_settings(settings),
|
2022-11-24 10:40:36 -05:00
|
|
|
m_settingsKeys(settingsKeys),
|
2020-10-27 12:22:10 -04:00
|
|
|
m_force(force)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2024-02-14 08:21:26 -05:00
|
|
|
GS232ControllerWorker(GS232Controller *controller);
|
2020-10-27 12:22:10 -04:00
|
|
|
~GS232ControllerWorker();
|
2022-09-18 11:47:06 -04:00
|
|
|
void startWork();
|
2020-10-27 12:22:10 -04:00
|
|
|
void stopWork();
|
|
|
|
bool isRunning() const { return m_running; }
|
|
|
|
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; }
|
|
|
|
void setMessageQueueToFeature(MessageQueue *messageQueue) { m_msgQueueToFeature = messageQueue; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2024-02-14 08:21:26 -05:00
|
|
|
GS232Controller *m_controller;
|
2020-10-27 12:22:10 -04:00
|
|
|
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
|
|
|
|
MessageQueue *m_msgQueueToFeature; //!< Queue to report channel change to main feature object
|
|
|
|
GS232ControllerSettings m_settings;
|
|
|
|
bool m_running;
|
2021-11-23 07:13:24 -05:00
|
|
|
QIODevice *m_device;
|
2020-10-27 12:22:10 -04:00
|
|
|
QSerialPort m_serialPort;
|
2021-11-23 07:13:24 -05:00
|
|
|
QTcpSocket m_socket;
|
2020-10-27 12:22:10 -04:00
|
|
|
QTimer m_pollTimer;
|
|
|
|
|
2021-05-30 07:38:07 -04:00
|
|
|
float m_lastAzimuth;
|
|
|
|
float m_lastElevation;
|
|
|
|
|
2023-04-03 11:47:13 -04:00
|
|
|
ControllerProtocol *m_controllerProtocol;
|
2021-11-23 07:13:24 -05:00
|
|
|
|
2020-10-27 12:22:10 -04:00
|
|
|
bool handleMessage(const Message& cmd);
|
2022-11-24 10:40:36 -05:00
|
|
|
void applySettings(const GS232ControllerSettings& settings, const QList<QString>& settingsKeys, bool force = false);
|
2021-11-23 07:13:24 -05:00
|
|
|
QIODevice *openSerialPort(const GS232ControllerSettings& settings);
|
|
|
|
QIODevice *openSocket(const GS232ControllerSettings& settings);
|
2021-05-30 07:38:07 -04:00
|
|
|
void setAzimuth(float azimuth);
|
|
|
|
void setAzimuthElevation(float azimuth, float elevation);
|
2024-02-14 08:21:26 -05:00
|
|
|
void sendToSkyMap(float azimuth, float elevation);
|
2020-10-27 12:22:10 -04:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void handleInputMessages();
|
2021-11-23 07:13:24 -05:00
|
|
|
void readData();
|
2020-10-27 12:22:10 -04:00
|
|
|
void update();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INCLUDE_FEATURE_GS232CONTROLLERWORKER_H_
|
2023-04-03 11:47:13 -04:00
|
|
|
|