diff --git a/src/plugins/ryzetello/ryzetelloconnection.h b/src/plugins/ryzetello/ryzetelloconnection.h index 404754a..d548c03 100644 --- a/src/plugins/ryzetello/ryzetelloconnection.h +++ b/src/plugins/ryzetello/ryzetelloconnection.h @@ -1,83 +1,80 @@ /* * Copyright 2019 Eike Hein * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ -#ifndef RYZETELLOCONNECTION_H -#define RYZETELLOCONNECTION_H +#pragma once #include #include "abstractvehicle.h" #include #include #include #include #include struct RyzeTelloCommand { QString text; int retry = 0; // NOTE: Setting to -1 before sending means infinite retries. }; class RyzeTelloConnection : public QObject { Q_OBJECT public: explicit RyzeTelloConnection(const QString &vehicleName, QObject *parent = nullptr); ~RyzeTelloConnection(); public Q_SLOTS: void handshake(); void reset(); void sendCommand(const QString &command, bool retryForever = false); void pilot(qint8 roll, qint8 pitch, qint8 yaw, qint8 gaz); Q_SIGNALS: void stateChanged(Kirogi::AbstractVehicle::ConnectionState state) const; void responseReceived(const QString &response) const; void stateReceived(const QByteArray &state) const; private Q_SLOTS: void receiveData(); void receiveState(); void pumpCommandQueue(); void sendPilotingCommand(); private: void initSockets(); QString m_vehicleName; QHostAddress m_address; QPointer m_controlSocket; QPointer m_stateSocket; QQueue m_commandQueue; QTimer *m_commandQueueTimer; QTimer *m_pilotingTimer; qint8 m_roll; qint8 m_pitch; qint8 m_yaw; qint8 m_gaz; }; - -#endif diff --git a/src/plugins/ryzetello/ryzetelloplugin.h b/src/plugins/ryzetello/ryzetelloplugin.h index 9971b3c..5a24b0b 100644 --- a/src/plugins/ryzetello/ryzetelloplugin.h +++ b/src/plugins/ryzetello/ryzetelloplugin.h @@ -1,45 +1,42 @@ /* * Copyright 2019 Eike Hein * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ -#ifndef RYZETELLOPLUGIN_H -#define RYZETELLOPLUGIN_H +#pragma once #include "abstractvehicle.h" #include "vehiclesupportplugin.h" #include class RyzeTelloVehicle; class RyzeTelloPlugin : public Kirogi::VehicleSupportPlugin { Q_OBJECT public: RyzeTelloPlugin(QObject *parent, const QVariantList &args); ~RyzeTelloPlugin() override; QList vehicles() const override; private: RyzeTelloVehicle *m_vehicle; }; - -#endif diff --git a/src/plugins/ryzetello/ryzetellovehicle.h b/src/plugins/ryzetello/ryzetellovehicle.h index 89f26df..cf32a4c 100644 --- a/src/plugins/ryzetello/ryzetellovehicle.h +++ b/src/plugins/ryzetello/ryzetellovehicle.h @@ -1,103 +1,100 @@ /* * Copyright 2019 Eike Hein * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ -#ifndef RYZETELLOVEHICLE_H -#define RYZETELLOVEHICLE_H +#pragma once #include "abstractvehicle.h" #include class RyzeTelloConnection; class QTimer; class RyzeTelloVehicle : public Kirogi::AbstractVehicle { Q_OBJECT public: explicit RyzeTelloVehicle(QObject *parent = nullptr); ~RyzeTelloVehicle() override; QString name() const override; QString iconName() const override; Kirogi::AbstractVehicle::VehicleType vehicleType() const override; QList supportedActions() const override; Q_INVOKABLE void requestAction(Kirogi::AbstractVehicle::VehicleAction action) override; Q_INVOKABLE void pilot(qint8 roll, qint8 pitch, qint8 yaw, qint8 gaz) override; Kirogi::AbstractVehicle::PerformanceMode performanceMode() const override; void requestPerformanceMode(Kirogi::AbstractVehicle::PerformanceMode mode) override; float roll() const override; float pitch() const override; float yaw() const override; int signalStrength() const override; int batteryLevel() const override; bool gpsSupported() const override; float distance() const override; float altitude() const override; float speed() const override; public Q_SLOTS: void connectToVehicle(); private Q_SLOTS: void processIncomingResponse(const QString &response); void processIncomingState(const QByteArray &state); void pollSignalStrength(); private: void initVehicle(); void sendCommand(const QString &command, bool retryForever = false); int m_stateSeq; int m_motorOnTime; int m_oldMotorOnTime; float m_roll; float m_pitch; float m_yaw; int m_signalStrength; int m_batteryLevel; float m_distance; float m_altitude; float m_speed; QTimer *m_signalStrengthTimer; QTimer *m_disconnectTimer; QThread m_connectionThread; RyzeTelloConnection *m_connection; }; - -#endif