diff --git a/src/gstreamer/gstreamer_android.h b/src/gstreamer/gstreamer_android.h index cd03dfe..e9c55ad 100644 --- a/src/gstreamer/gstreamer_android.h +++ b/src/gstreamer/gstreamer_android.h @@ -1,12 +1,9 @@ -#ifndef GSTREAMER_ANDROID_H -#define GSTREAMER_ANDROID_H +#pragma once #include G_BEGIN_DECLS void gst_android_init(JNIEnv *env, jclass klass, jobject context); G_END_DECLS - -#endif diff --git a/src/gstreamer/gstreamerintegration.h b/src/gstreamer/gstreamerintegration.h index fb4c368..374855a 100644 --- a/src/gstreamer/gstreamerintegration.h +++ b/src/gstreamer/gstreamerintegration.h @@ -1,66 +1,63 @@ /* * Copyright 2019 Eike Hein * * 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; either version 2 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 14 of version 3 of the license. * * 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 for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef KIROGI_GSTREAMER_H -#define KIROGI_GSTREAMER_H +#pragma once #include #include class QQuickWindow; class GStreamerIntegration : public QObject { Q_OBJECT Q_PROPERTY(bool playing READ playing WRITE setPlaying NOTIFY playingChanged) Q_PROPERTY(QString pipeline READ pipeline WRITE setPipeline NOTIFY pipelineChanged) public: explicit GStreamerIntegration(QObject *parent = nullptr); ~GStreamerIntegration(); bool playing() const; void setPlaying(bool playing); QString pipeline() const; void setPipeline(const QString &pipeline); void setWindow(QQuickWindow *window); Q_SIGNALS: void playingChanged() const; void pipelineChanged() const; private: void updateGstPipeline(); bool m_playing; QString m_pipeline; GstElement *m_gstPipeline; bool m_fallback; QQuickWindow *m_window; }; - -#endif diff --git a/src/lib/abstractvehicle.h b/src/lib/abstractvehicle.h index 0784cab..2c5111a 100644 --- a/src/lib/abstractvehicle.h +++ b/src/lib/abstractvehicle.h @@ -1,348 +1,345 @@ /* * 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 KIROGI_ABSTRACTVEHICLE_H -#define KIROGI_ABSTRACTVEHICLE_H +#pragma once #include #include #include #include "kirogicore_export.h" namespace Kirogi { class KIROGI_EXPORT AbstractVehicle : public QObject { Q_OBJECT Q_PROPERTY(int id READ id CONSTANT) Q_PROPERTY(QString name READ name NOTIFY nameChanged) Q_PROPERTY(QString iconName READ iconName NOTIFY iconNameChanged) Q_PROPERTY(VehicleType vehicleType READ vehicleType CONSTANT) Q_PROPERTY(ConnectionState connectionState READ connectionState NOTIFY connectionStateChanged) Q_PROPERTY(FlyingState flyingState READ flyingState NOTIFY flyingStateChanged) Q_PROPERTY(bool connected READ connected NOTIFY connectionStateChanged) Q_PROPERTY(bool ready READ ready NOTIFY connectionStateChanged) Q_PROPERTY(bool flying READ flying NOTIFY flyingStateChanged) Q_PROPERTY(QList supportedActions READ supportedActions CONSTANT) Q_PROPERTY(bool piloting READ piloting WRITE setPiloting NOTIFY pilotingChanged) Q_PROPERTY(int flightTime READ flightTime NOTIFY flightTimeChanged) Q_PROPERTY(PerformanceMode performanceMode READ performanceMode NOTIFY performanceModeChanged) Q_PROPERTY(float maxRollSpeed READ maxRollSpeed NOTIFY maxRollSpeedChanged) Q_PROPERTY(float maxRollSpeedMin READ maxRollSpeedMin NOTIFY maxRollSpeedMinChanged) Q_PROPERTY(float maxRollSpeedMax READ maxRollSpeedMax NOTIFY maxRollSpeedMaxChanged) Q_PROPERTY(float maxPitchSpeed READ maxPitchSpeed NOTIFY maxPitchSpeedChanged) Q_PROPERTY(float maxPitchSpeedMin READ maxPitchSpeedMin NOTIFY maxPitchSpeedMinChanged) Q_PROPERTY(float maxPitchSpeedMax READ maxPitchSpeedMax NOTIFY maxPitchSpeedMaxChanged) Q_PROPERTY(float maxYawSpeed READ maxYawSpeed NOTIFY maxYawSpeedChanged) Q_PROPERTY(float maxYawSpeedMin READ maxYawSpeedMin NOTIFY maxYawSpeedMinChanged) Q_PROPERTY(float maxYawSpeedMax READ maxYawSpeedMax NOTIFY maxYawSpeedMaxChanged) Q_PROPERTY(float maxGazSpeed READ maxGazSpeed NOTIFY maxGazSpeedChanged) Q_PROPERTY(float maxGazSpeedMin READ maxGazSpeedMin NOTIFY maxGazSpeedMinChanged) Q_PROPERTY(float maxGazSpeedMax READ maxGazSpeedMax NOTIFY maxGazSpeedMaxChanged) Q_PROPERTY(float maxTilt READ maxTilt NOTIFY maxTiltChanged) Q_PROPERTY(float maxTiltMin READ maxTiltMin NOTIFY maxTiltMinChanged) Q_PROPERTY(float maxTiltMax READ maxTiltMax NOTIFY maxTiltMaxChanged) Q_PROPERTY(bool bankedTurns READ bankedTurns NOTIFY bankedTurnsChanged) Q_PROPERTY(bool geofence READ geofence NOTIFY geofenceChanged) Q_PROPERTY(float maxAltitude READ maxAltitude NOTIFY maxAltitudeChanged) Q_PROPERTY(float maxAltitudeMin READ maxAltitudeMin NOTIFY maxAltitudeMinChanged) Q_PROPERTY(float maxAltitudeMax READ maxAltitudeMax NOTIFY maxAltitudeMaxChanged) Q_PROPERTY(float maxDistance READ maxDistance NOTIFY maxDistanceChanged) Q_PROPERTY(float maxDistanceMin READ maxDistanceMin NOTIFY maxDistanceMinChanged) Q_PROPERTY(float maxDistanceMax READ maxDistanceMax NOTIFY maxDistanceMaxChanged) Q_PROPERTY(QGeoCoordinate gpsPosition READ gpsPosition NOTIFY gpsPositionChanged) Q_PROPERTY(float distance READ distance NOTIFY distanceChanged) Q_PROPERTY(float altitude READ altitude NOTIFY altitudeChanged) Q_PROPERTY(int speed READ speed NOTIFY speedChanged) Q_PROPERTY(float roll READ roll NOTIFY attitudeChanged) Q_PROPERTY(float pitch READ pitch NOTIFY attitudeChanged) Q_PROPERTY(float yaw READ yaw NOTIFY attitudeChanged) Q_PROPERTY(int signalStrength READ signalStrength NOTIFY signalStrengthChanged) Q_PROPERTY(int batteryLevel READ batteryLevel NOTIFY batteryLevelChanged) Q_PROPERTY(bool gpsSupported READ gpsSupported NOTIFY gpsSupportedChanged) Q_PROPERTY(bool gpsFix READ gpsFix NOTIFY gpsFixChanged) Q_PROPERTY(QString videoSource READ videoSource NOTIFY videoSourceChanged) Q_PROPERTY(bool videoStreamEnabled READ videoStreamEnabled NOTIFY videoStreamEnabledChanged) Q_PROPERTY(bool videoStabilization READ videoStabilization NOTIFY videoStabilizationChanged) Q_PROPERTY(bool canTakePicture READ canTakePicture NOTIFY canTakePictureChanged) Q_PROPERTY(bool isRecordingVideo READ isRecordingVideo NOTIFY isRecordingVideoChanged) Q_PROPERTY(quint16 numberOfFlights READ numberOfFlights NOTIFY numberOfFlightsChanged) Q_PROPERTY(quint16 lastFlightDuration READ lastFlightDuration NOTIFY lastFlightDurationChanged) public: enum VehicleType { UnknownVehicleType = 0, QuadCopter = 1 }; Q_ENUM(VehicleType) enum ConnectionState { Disconnected = 0, Connecting = 1, Connected = 2, Ready = 3 }; Q_ENUM(ConnectionState) enum FlyingState { Unknown = 0, Landed = 1, TakingOff = 2, Hovering = 3, Flying = 4, Landing = 5, // FIXME: (Parrot) Not handled yet. // Emergency = 5, // UserTakeoff = 6, // MotorRamping = 7, // EmergencyLanding = 8 }; Q_ENUM(FlyingState) enum VehicleAction { TakeOff = 1, Land = 2, MoveTo = 3, FlatTrim = 4, FlipForward = 5, FlipBackward = 6, FlipLeft = 7, FlipRight = 8, SwitchPerformanceMode = 9, SetMaxRollSpeed = 10, SetMaxPitchSpeed = 11, SetMaxYawSpeed = 12, SetMaxGazSpeed = 13, SetMaxTilt = 14, ToggleBankedTurns = 15, ToggleGeofence = 16, SetMaxAltitude = 17, SetMaxDistance = 18, ToggleVideoStream = 19, ToggleVideoStabilization = 20, TakePicture = 21, RecordVideo = 22 }; Q_ENUM(VehicleAction) enum PerformanceMode { CustomPerformance = 0, FilmPerformance = 1, SportPerformance = 2 }; Q_ENUM(PerformanceMode) explicit AbstractVehicle(QObject *parent = nullptr); virtual ~AbstractVehicle() override; int id() const; virtual QString name() const = 0; virtual QString iconName() const; virtual VehicleType vehicleType() const; virtual ConnectionState connectionState() const; virtual FlyingState flyingState() const; bool connected() const; bool ready() const; bool flying() const; virtual QList supportedActions() const; Q_INVOKABLE virtual bool isActionSupported(VehicleAction action) const; virtual bool piloting() const; Q_INVOKABLE virtual void setPiloting(bool piloting); Q_INVOKABLE virtual void requestAction(VehicleAction action); Q_INVOKABLE virtual void requestTakeOff(); Q_INVOKABLE virtual void requestLand(); Q_INVOKABLE virtual void pilot(qint8 roll, qint8 pitch, qint8 yaw, qint8 gaz); Q_INVOKABLE virtual void requestMoveTo(QGeoCoordinate destination); virtual int flightTime() const; virtual PerformanceMode performanceMode() const; Q_INVOKABLE virtual void requestPerformanceMode(PerformanceMode mode); virtual float maxRollSpeed() const; Q_INVOKABLE virtual void requestMaxRollSpeed(float speed); virtual float maxRollSpeedMin() const; virtual float maxRollSpeedMax() const; virtual float maxPitchSpeed() const; Q_INVOKABLE virtual void requestMaxPitchSpeed(float speed); virtual float maxPitchSpeedMin() const; virtual float maxPitchSpeedMax() const; virtual float maxYawSpeed() const; Q_INVOKABLE virtual void requestMaxYawSpeed(float speed); virtual float maxYawSpeedMin() const; virtual float maxYawSpeedMax() const; virtual float maxGazSpeed() const; Q_INVOKABLE virtual void requestMaxGazSpeed(float speed); virtual float maxGazSpeedMin() const; virtual float maxGazSpeedMax() const; virtual float maxTilt() const; Q_INVOKABLE virtual void requestMaxTilt(float tilt); virtual float maxTiltMin() const; virtual float maxTiltMax() const; virtual bool bankedTurns() const; Q_INVOKABLE virtual void requestEnableBankedTurns(bool enable); virtual bool geofence() const; Q_INVOKABLE virtual void requestEnableGeofence(bool enable); virtual float maxAltitude() const; Q_INVOKABLE virtual void requestMaxAltitude(float altitude); virtual float maxAltitudeMin() const; virtual float maxAltitudeMax() const; virtual float maxDistance() const; Q_INVOKABLE virtual void requestMaxDistance(float distance); virtual float maxDistanceMin() const; virtual float maxDistanceMax() const; virtual float roll() const; virtual float pitch() const; virtual float yaw() const; virtual int signalStrength() const; virtual int batteryLevel() const; virtual bool gpsSupported() const; virtual bool gpsFix() const; virtual QGeoCoordinate gpsPosition() const; virtual float distance() const; virtual float altitude() const; virtual void setControllerGpsPosition(const QGeoCoordinate &position); Q_INVOKABLE virtual void requestReturnHome(); virtual float speed() const; virtual QString videoSource() const; virtual bool videoStreamEnabled() const; Q_INVOKABLE virtual void requestEnableVideoStream(bool enable); virtual bool videoStabilization() const; Q_INVOKABLE virtual void requestEnableVideoStabilization(bool enable); virtual bool canTakePicture() const; virtual bool isRecordingVideo() const; virtual quint16 numberOfFlights() const; virtual quint16 lastFlightDuration() const; Q_SIGNALS: void nameChanged() const; void iconNameChanged() const; void connectionStateChanged() const; void flyingStateChanged() const; void pilotingChanged() const; void flightTimeChanged() const; void performanceModeChanged() const; void maxRollSpeedChanged() const; void maxRollSpeedMinChanged() const; void maxRollSpeedMaxChanged() const; void maxPitchSpeedChanged() const; void maxPitchSpeedMinChanged() const; void maxPitchSpeedMaxChanged() const; void maxYawSpeedChanged() const; void maxYawSpeedMinChanged() const; void maxYawSpeedMaxChanged() const; void maxGazSpeedChanged() const; void maxGazSpeedMinChanged() const; void maxGazSpeedMaxChanged() const; void maxTiltChanged() const; void maxTiltMinChanged() const; void maxTiltMaxChanged() const; void bankedTurnsChanged() const; void geofenceChanged() const; void maxAltitudeChanged() const; void maxAltitudeMinChanged() const; void maxAltitudeMaxChanged() const; void maxDistanceChanged() const; void maxDistanceMinChanged() const; void maxDistanceMaxChanged() const; void attitudeChanged() const; void rollChanged() const; void pitchChanged() const; void yawChanged() const; void signalStrengthChanged() const; void batteryLevelChanged() const; void gpsSupportedChanged() const; void gpsFixChanged() const; void gpsPositionChanged() const; void distanceChanged() const; void altitudeChanged() const; void speedChanged() const; void videoSourceChanged() const; void videoStreamEnabledChanged() const; void videoStabilizationChanged() const; void canTakePictureChanged() const; void isRecordingVideoChanged() const; void numberOfFlightsChanged() const; void lastFlightDurationChanged() const; protected Q_SLOTS: virtual void setConnectionState(ConnectionState state); virtual void setFlyingState(FlyingState state); private: class Private; QScopedPointer d; }; } - -#endif diff --git a/src/lib/qtquickplugin.h b/src/lib/qtquickplugin.h index 68118b1..c5161b3 100644 --- a/src/lib/qtquickplugin.h +++ b/src/lib/qtquickplugin.h @@ -1,40 +1,37 @@ /* * 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 KIROGI_QTQUICKPLUGIN_H -#define KIROGI_QTQUICKPLUGIN_H +#pragma once #include #include namespace Kirogi { class QtQuickPlugin : public QQmlExtensionPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") public: void registerTypes(const char *uri) override; }; } - -#endif diff --git a/src/lib/vehiclesupportplugin.h b/src/lib/vehiclesupportplugin.h index 6e91eb7..eef0416 100644 --- a/src/lib/vehiclesupportplugin.h +++ b/src/lib/vehiclesupportplugin.h @@ -1,52 +1,49 @@ /* * 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 KIROGI_VEHICLESUPPORT_H -#define KIROGI_VEHICLESUPPORT_H +#pragma once #include #include "abstractvehicle.h" #include "kirogicore_export.h" namespace Kirogi { class KIROGI_EXPORT VehicleSupportPlugin : public QObject { Q_OBJECT public: explicit VehicleSupportPlugin(QObject *parent); virtual ~VehicleSupportPlugin() override; virtual QList vehicles() const = 0; Q_SIGNALS: void vehicleAdded(Kirogi::AbstractVehicle *vehicle) const; void vehicleRemoved(Kirogi::AbstractVehicle *vehicle) const; private: class PluginPrivate *const d; }; } - -#endif diff --git a/src/lib/vehiclesupportpluginmodel.h b/src/lib/vehiclesupportpluginmodel.h index cc86935..a02207c 100644 --- a/src/lib/vehiclesupportpluginmodel.h +++ b/src/lib/vehiclesupportpluginmodel.h @@ -1,69 +1,66 @@ /* * 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 KIROGI_VEHICLESUPPORTPLUGINMODEL_H -#define KIROGI_VEHICLESUPPORTPLUGINMODEL_H +#pragma once #include #include "kirogicore_export.h" namespace Kirogi { class VehicleSupportPlugin; class KIROGI_EXPORT VehicleSupportPluginModel : public QAbstractListModel { Q_OBJECT public: enum AdditionalRoles { Id = Qt::UserRole + 1, Status, Plugin }; Q_ENUM(AdditionalRoles) enum PluginStatus { PluginNotLoaded = 0, PluginLoaded = 1 }; Q_ENUM(PluginStatus) explicit VehicleSupportPluginModel(QObject *parent = nullptr); ~VehicleSupportPluginModel() override; QHash roleNames() const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override; Q_INVOKABLE bool loadPlugin(int row); Q_INVOKABLE bool loadPluginById(const QString &id); Q_INVOKABLE bool unloadPlugin(int row); Q_INVOKABLE bool unloadAllPlugins(); Q_SIGNALS: // FIXME TODO: QObject -> VehicleSupportPlugin void pluginLoaded(const QString &pluginId, const QString &name, QObject *plugin) const; private: class Private; QScopedPointer d; }; } - -#endif diff --git a/src/permissions.h b/src/permissions.h index 9d49569..35b6545 100644 --- a/src/permissions.h +++ b/src/permissions.h @@ -1,48 +1,45 @@ /* * Copyright 2019 Eike Hein * * 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; either version 2 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 14 of version 3 of the license. * * 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 for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef KIROGI_PERMISSIONS_H -#define KIROGI_PERMISSIONS_H +#pragma once #include class Permissions : public QObject { Q_OBJECT Q_PROPERTY(bool granted READ granted NOTIFY grantedChanged) public: explicit Permissions(const QStringList &permissions, QObject *parent = nullptr); ~Permissions(); bool granted() const; Q_INVOKABLE void request(); Q_SIGNALS: void grantedChanged() const; private: QStringList m_permissions; bool m_granted; }; - -#endif diff --git a/src/plugins/parrot/parrotconnection.h b/src/plugins/parrot/parrotconnection.h index fec10d0..56cc5a6 100644 --- a/src/plugins/parrot/parrotconnection.h +++ b/src/plugins/parrot/parrotconnection.h @@ -1,100 +1,97 @@ /* * 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 PARROTCONNECTION_H -#define PARROTCONNECTION_H +#pragma once #include #include "parrotprotocol.h" #include "parrotvehicle.h" #include #include #include #include #include #include #include class ParrotConnection : public QObject { Q_OBJECT public: explicit ParrotConnection(ParrotVehicle::Type type, const QString &vehicleName, const QString &hostName, int port, QObject *parent = nullptr); ~ParrotConnection(); public Q_SLOTS: void handshake(const QString &productSerial = QString()); void reset(); void sendCommand(Parrot::Command command, const QVariantList &arguments, bool retryForever = false); void pilot(qint8 roll, qint8 pitch, qint8 yaw, qint8 gaz); Q_SIGNALS: void stateChanged(Kirogi::AbstractVehicle::ConnectionState state) const; void commandReceived(const ParrotCommand &command) const; private Q_SLOTS: void receiveData(); void pumpC2dAckQueue(); void sendPilotingCommand(); private: void initSockets(); void processIncomingFrame(const ParrotFrame &frame); void sendAck(const ParrotFrame &frame); void sendFrame(const ParrotFrame &frame); void sendData(const QByteArray &data, quint32 size); quint8 makeSeq(quint8 bufferId); ParrotVehicle::Type m_type; QString m_vehicleName; QHostAddress m_hostAddress; int m_port; QPointer m_handshakeSocket; QJsonObject m_handshakeResponse; // c2d = Controller-to-device, i.e. we send here. int m_c2dport; // d2c = Device-to-Controller, i.e. we listen here. int m_d2cPort; QPointer m_d2cSocket; QPointer m_c2dSocket; QHash m_seq; QQueue m_c2dAckQueue; QTimer *m_c2dAckTimer; QTimer *m_pilotingTimer; qint8 m_roll; qint8 m_pitch; qint8 m_yaw; qint8 m_gaz; }; - -#endif diff --git a/src/plugins/parrot/parrotplugin.h b/src/plugins/parrot/parrotplugin.h index f73fa61..e7fdabd 100644 --- a/src/plugins/parrot/parrotplugin.h +++ b/src/plugins/parrot/parrotplugin.h @@ -1,56 +1,53 @@ /* * 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 PARROTPLUGIN_H -#define PARROTPLUGIN_H +#pragma once #include "abstractvehicle.h" #include "vehiclesupportplugin.h" #include class ParrotVehicle; #ifndef Q_OS_ANDROID namespace KDNSSD { class ServiceBrowser; } #endif class ParrotPlugin : public Kirogi::VehicleSupportPlugin { Q_OBJECT public: ParrotPlugin(QObject *parent, const QVariantList &args); ~ParrotPlugin() override; QList vehicles() const override; private: QHash m_vehicles; #ifndef Q_OS_ANDROID KDNSSD::ServiceBrowser *m_bebop2Browser; KDNSSD::ServiceBrowser *m_anafiBrowser; #endif }; - -#endif diff --git a/src/plugins/parrot/parrotprotocol.h b/src/plugins/parrot/parrotprotocol.h index 3bd749d..3fe5ff0 100644 --- a/src/plugins/parrot/parrotprotocol.h +++ b/src/plugins/parrot/parrotprotocol.h @@ -1,315 +1,312 @@ /* * 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 PARROTPROTOCOL_H -#define PARROTPROTOCOL_H +#pragma once #include class Parrot : public QObject { public: Parrot() : QObject() { } ~Parrot() { } enum HeaderSizes { HEADER_COMMAND = 4, HEADER_FRAME = 7 }; Q_ENUM(HeaderSizes) enum DataType { ACK = 1, DATA = 2, LOW_LATENCY_DATA = 3, DATA_WITH_ACK = 4 }; Q_ENUM(DataType) enum BufferId { BUFFER_PING = 0, BUFFER_PONG = 1, BUFFER_C2D_NON_ACK_DATA = 10, BUFFER_C2D_ACK_DATA = 11, BUFFER_C2D_EMERGENCY_DATA = 12, BUFFER_D2C_ACK_DATA = 126, BUFFER_D2C_NON_ACK_DATA = 127, BUFFER_D2C_ACK_FOR_C2D_ACK_DATA = BUFFER_C2D_ACK_DATA + 128 }; Q_ENUM(BufferId) enum ArgumentType { TYPE_U8 = 0, TYPE_I8 = 1, TYPE_U16 = 2, TYPE_I16 = 3, TYPE_U32 = 4, TYPE_I32 = 5, TYPE_U64 = 6, TYPE_I64 = 7, TYPE_FLOAT = 8, TYPE_DOUBLE = 9, TYPE_STRING = 10, TYPE_ENUM = 11 }; Q_ENUM(ArgumentType) enum Command { UnknownCommand = 0, Ardrone3AccessoryStateBattery = 1, Ardrone3AnimationsFlip = 2, Ardrone3AntiflickeringStateelectricFrequencyChanged = 3, Ardrone3AntiflickeringStatemodeChanged = 4, Ardrone3AntiflickeringelectricFrequency = 5, Ardrone3AntiflickeringsetMode = 6, Ardrone3CameraOrientationV2 = 7, Ardrone3CameraStateOrientationV2 = 8, Ardrone3CameraStateVelocityRange = 9, Ardrone3CameraStatedefaultCameraOrientationV2 = 10, Ardrone3CameraVelocity = 11, Ardrone3GPSSettingsHomeType = 12, Ardrone3GPSSettingsReturnHomeDelay = 13, Ardrone3GPSSettingsSendControllerGPS = 14, Ardrone3GPSSettingsStateGPSFixStateChanged = 15, Ardrone3GPSSettingsStateGeofenceCenterChanged = 16, Ardrone3GPSSettingsStateHomeChanged = 17, Ardrone3GPSSettingsStateHomeTypeChanged = 18, Ardrone3GPSSettingsStateReturnHomeDelayChanged = 19, Ardrone3GPSStateHomeTypeAvailabilityChanged = 20, Ardrone3GPSStateHomeTypeChosenChanged = 21, Ardrone3GPSStateNumberOfSatelliteChanged = 22, Ardrone3MediaRecordEventPictureEventChanged = 23, Ardrone3MediaRecordEventVideoEventChanged = 24, Ardrone3MediaRecordPictureV2 = 25, Ardrone3MediaRecordStatePictureStateChangedV2 = 26, Ardrone3MediaRecordStateVideoStateChangedV2 = 27, Ardrone3MediaRecordVideoV2 = 28, Ardrone3MediaStreamingStateVideoEnableChanged = 29, Ardrone3MediaStreamingStateVideoStreamModeChanged = 30, Ardrone3MediaStreamingVideoEnable = 31, Ardrone3MediaStreamingVideoStreamMode = 32, Ardrone3NetworkSettingsStateWifiSelectionChanged = 33, Ardrone3NetworkSettingsStatewifiSecurity = 34, Ardrone3NetworkSettingsWifiSelection = 35, Ardrone3NetworkSettingswifiSecurity = 36, Ardrone3NetworkStateAllWifiAuthChannelChanged = 37, Ardrone3NetworkStateAllWifiScanChanged = 38, Ardrone3NetworkStateWifiAuthChannelListChanged = 39, Ardrone3NetworkStateWifiScanListChanged = 40, Ardrone3NetworkWifiAuthChannel = 41, Ardrone3NetworkWifiScan = 42, Ardrone3PictureSettingsAutoWhiteBalanceSelection = 43, Ardrone3PictureSettingsExpositionSelection = 44, Ardrone3PictureSettingsPictureFormatSelection = 45, Ardrone3PictureSettingsSaturationSelection = 46, Ardrone3PictureSettingsStateAutoWhiteBalanceChanged = 47, Ardrone3PictureSettingsStateExpositionChanged = 48, Ardrone3PictureSettingsStatePictureFormatChanged = 49, Ardrone3PictureSettingsStateSaturationChanged = 50, Ardrone3PictureSettingsStateTimelapseChanged = 51, Ardrone3PictureSettingsStateVideoAutorecordChanged = 52, Ardrone3PictureSettingsStateVideoFramerateChanged = 53, Ardrone3PictureSettingsStateVideoRecordingModeChanged = 54, Ardrone3PictureSettingsStateVideoResolutionsChanged = 55, Ardrone3PictureSettingsStateVideoStabilizationModeChanged = 56, Ardrone3PictureSettingsTimelapseSelection = 57, Ardrone3PictureSettingsVideoAutorecordSelection = 58, Ardrone3PictureSettingsVideoFramerate = 59, Ardrone3PictureSettingsVideoRecordingMode = 60, Ardrone3PictureSettingsVideoResolutions = 61, Ardrone3PictureSettingsVideoStabilizationMode = 62, Ardrone3PilotingCancelMoveTo = 63, Ardrone3PilotingEmergency = 64, Ardrone3PilotingEventmoveByEnd = 65, Ardrone3PilotingFlatTrim = 66, Ardrone3PilotingLanding = 67, Ardrone3PilotingNavigateHome = 68, Ardrone3PilotingPCMD = 69, Ardrone3PilotingSettingsBankedTurn = 70, Ardrone3PilotingSettingsMaxAltitude = 71, Ardrone3PilotingSettingsMaxDistance = 72, Ardrone3PilotingSettingsMaxTilt = 73, Ardrone3PilotingSettingsNoFlyOverMaxDistance = 74, Ardrone3PilotingSettingsSetMotionDetectionMode = 75, Ardrone3PilotingSettingsStateAutonomousFlightMaxHorizontalAcceleration = 76, Ardrone3PilotingSettingsStateAutonomousFlightMaxHorizontalSpeed = 77, Ardrone3PilotingSettingsStateAutonomousFlightMaxRotationSpeed = 78, Ardrone3PilotingSettingsStateAutonomousFlightMaxVerticalAcceleration = 79, Ardrone3PilotingSettingsStateAutonomousFlightMaxVerticalSpeed = 80, Ardrone3PilotingSettingsStateBankedTurnChanged = 81, Ardrone3PilotingSettingsStateMaxAltitudeChanged = 82, Ardrone3PilotingSettingsStateMaxDistanceChanged = 83, Ardrone3PilotingSettingsStateMaxTiltChanged = 84, Ardrone3PilotingSettingsStateMotionDetection = 85, Ardrone3PilotingSettingsStateNoFlyOverMaxDistanceChanged = 86, Ardrone3PilotingSettingssetAutonomousFlightMaxHorizontalAcceleration = 87, Ardrone3PilotingSettingssetAutonomousFlightMaxHorizontalSpeed = 88, Ardrone3PilotingSettingssetAutonomousFlightMaxRotationSpeed = 89, Ardrone3PilotingSettingssetAutonomousFlightMaxVerticalAcceleration = 90, Ardrone3PilotingSettingssetAutonomousFlightMaxVerticalSpeed = 91, Ardrone3PilotingStartPilotedPOI = 92, Ardrone3PilotingStateAlertStateChanged = 93, Ardrone3PilotingStateAltitudeChanged = 94, Ardrone3PilotingStateAttitudeChanged = 95, Ardrone3PilotingStateFlatTrimChanged = 96, Ardrone3PilotingStateFlyingStateChanged = 97, Ardrone3PilotingStateGpsLocationChanged = 98, Ardrone3PilotingStateMotionState = 99, Ardrone3PilotingStateNavigateHomeStateChanged = 100, Ardrone3PilotingStatePilotedPOI = 101, Ardrone3PilotingStatePositionChanged = 102, Ardrone3PilotingStateReturnHomeBatteryCapacity = 103, Ardrone3PilotingStateSpeedChanged = 104, Ardrone3PilotingStatemoveToChanged = 105, Ardrone3PilotingStopPilotedPOI = 106, Ardrone3PilotingTakeOff = 107, Ardrone3PilotingUserTakeOff = 108, Ardrone3PilotingmoveBy = 109, Ardrone3PilotingmoveTo = 110, Ardrone3SettingsStateCPUID = 111, Ardrone3SettingsStateMotorErrorLastErrorChanged = 112, Ardrone3SettingsStateMotorErrorStateChanged = 113, Ardrone3SettingsStateMotorFlightsStatusChanged = 114, Ardrone3SettingsStateProductGPSVersionChanged = 115, Ardrone3SoundStartAlertSound = 116, Ardrone3SoundStateAlertSound = 117, Ardrone3SoundStopAlertSound = 118, Ardrone3SpeedSettingsHullProtection = 119, Ardrone3SpeedSettingsMaxPitchRollRotationSpeed = 120, Ardrone3SpeedSettingsMaxRotationSpeed = 121, Ardrone3SpeedSettingsMaxVerticalSpeed = 122, Ardrone3SpeedSettingsStateHullProtectionChanged = 123, Ardrone3SpeedSettingsStateMaxPitchRollRotationSpeedChanged = 124, Ardrone3SpeedSettingsStateMaxRotationSpeedChanged = 125, Ardrone3SpeedSettingsStateMaxVerticalSpeedChanged = 126, CommonARLibsVersionsStateControllerLibARCommandsVersion = 127, CommonARLibsVersionsStateDeviceLibARCommandsVersion = 128, CommonARLibsVersionsStateSkyControllerLibARCommandsVersion = 129, CommonCalibrationMagnetoCalibration = 130, CommonCalibrationStateMagnetoCalibrationAxisToCalibrateChanged = 131, CommonCalibrationStateMagnetoCalibrationRequiredState = 132, CommonCalibrationStateMagnetoCalibrationStartedChanged = 133, CommonCalibrationStateMagnetoCalibrationStateChanged = 134, CommonCalibrationStatePitotCalibrationStateChanged = 135, CommonCameraSettingsStateCameraSettingsChanged = 136, CommonCommonAllStates = 137, CommonCommonCurrentDate = 138, CommonCommonCurrentTime = 139, CommonCommonReboot = 140, CommonCommonStateAllStatesChanged = 141, CommonCommonStateBatteryStateChanged = 142, CommonCommonStateCurrentDateChanged = 143, CommonCommonStateCurrentTimeChanged = 144, CommonCommonStateMassStorageContent = 145, CommonCommonStateMassStorageContentForCurrentRun = 146, CommonCommonStateMassStorageInfoStateListChanged = 147, CommonCommonStateMassStorageStateListChanged = 148, CommonCommonStateSensorsStatesListChanged = 149, CommonCommonStateVideoRecordingTimestamp = 150, CommonCommonStateWifiSignalChanged = 151, CommonControllerisPiloting = 152, CommonFactoryReset = 153, CommonFlightPlanEventSpeedBridleEvent = 154, CommonFlightPlanEventStartingErrorEvent = 155, CommonFlightPlanSettingsReturnHomeOnDisconnect = 156, CommonFlightPlanSettingsStateReturnHomeOnDisconnectChanged = 157, CommonFlightPlanStateAvailabilityStateChanged = 158, CommonFlightPlanStateComponentStateListChanged = 159, CommonFlightPlanStateLockStateChanged = 160, CommonMavlinkPause = 161, CommonMavlinkStart = 162, CommonMavlinkStateMavlinkFilePlayingStateChanged = 163, CommonMavlinkStateMissionItemExecuted = 164, CommonMavlinkStop = 165, CommonNetworkEventDisconnection = 166, CommonOverHeatStateOverHeatRegulationChanged = 167, CommonRunStateRunIdChanged = 168, CommonSettingsAllSettings = 169, CommonSettingsAutoCountry = 170, CommonSettingsCountry = 171, CommonSettingsProductName = 172, CommonSettingsReset = 173, CommonSettingsStateAllSettingsChanged = 174, CommonSettingsStateAutoCountryChanged = 175, CommonSettingsStateCountryChanged = 176, CommonSettingsStateProductNameChanged = 177, CommonSettingsStateProductSerialHighChanged = 178, CommonSettingsStateProductSerialLowChanged = 179, CommonSettingsStateProductVersionChanged = 180, CommonSettingsStateResetChanged = 181, CommonWifiSettingsOutdoorSetting = 182, CommonWifiSettingsStateoutdoorSettingsChanged = 183, Bla = 184 }; Q_ENUM(Command) }; class ParrotCommand { public: struct Tuple { inline explicit Tuple(quint8 _productId = 0, quint8 _classId = 0, quint16 _commandId = 0) : productId(_productId) , classId(_classId) , commandId(_commandId) { } quint8 productId; quint8 classId; quint16 commandId; inline bool operator==(const Tuple &t) const { return (productId == t.productId && classId == t.classId && commandId == t.commandId); } }; explicit ParrotCommand(Parrot::Command command, const QVariantList &arguments = QVariantList()); explicit ParrotCommand(Parrot::Command command, const QByteArray &arguments = QByteArray()); explicit ParrotCommand(const QByteArray &data); explicit ParrotCommand(); ~ParrotCommand(); QByteArray pack() const; Parrot::Command id() const; Tuple tuple; QByteArray data; private: static Parrot::Command commandForTuple(const Tuple &tuple); static Tuple tupleForCommand(Parrot::Command command); static QHash m_commandForTuple; static QHash m_tupleForCommand; static QHash> m_signatureForCommand; }; Q_DECLARE_METATYPE(ParrotCommand) inline uint qHash(const ParrotCommand::Tuple &t) { return t.productId * t.classId * t.commandId; } class ParrotFrame { public: explicit ParrotFrame(quint8 dataType, quint8 bufferId, quint8 seq, const QByteArray &data = QByteArray()); explicit ParrotFrame(const QByteArray &data, int start); ~ParrotFrame(); QByteArray pack() const; ParrotCommand command() const; quint8 dataType = 0; quint8 bufferId = 0; quint8 seq = 0; quint32 size = 0; QByteArray data; int retry = 0; // NOTE: Setting to -1 before sending means infinite retries. }; - -#endif diff --git a/src/plugins/parrot/parrotvehicle.h b/src/plugins/parrot/parrotvehicle.h index 4bcb5f5..59fad26 100644 --- a/src/plugins/parrot/parrotvehicle.h +++ b/src/plugins/parrot/parrotvehicle.h @@ -1,205 +1,202 @@ /* * 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 PARROTVEHICLE_H -#define PARROTVEHICLE_H +#pragma once #include "abstractvehicle.h" #include "parrotprotocol.h" #include class ParrotConnection; class ParrotVehicle : public Kirogi::AbstractVehicle { Q_OBJECT public: enum Type { Bebop2 = 0, Anafi }; Q_ENUM(Type) explicit ParrotVehicle(Type type, const QString &hostName, int port, const QString &productSerial, QObject *parent = nullptr); ~ParrotVehicle() override; QString name() const override; QString iconName() const override; Kirogi::AbstractVehicle::VehicleType vehicleType() const override; QList supportedActions() const override; bool piloting() const override; Q_INVOKABLE void setPiloting(bool piloting) override; Q_INVOKABLE void requestAction(Kirogi::AbstractVehicle::VehicleAction action) override; Q_INVOKABLE void pilot(qint8 roll, qint8 pitch, qint8 yaw, qint8 gaz) override; Q_INVOKABLE void requestMoveTo(QGeoCoordinate destination) override; Kirogi::AbstractVehicle::PerformanceMode performanceMode() const override; void requestPerformanceMode(Kirogi::AbstractVehicle::PerformanceMode mode) override; float maxRollSpeed() const override; void requestMaxRollSpeed(float speed) override; float maxRollSpeedMin() const override; float maxRollSpeedMax() const override; float maxPitchSpeed() const override; void requestMaxPitchSpeed(float speed) override; float maxPitchSpeedMin() const override; float maxPitchSpeedMax() const override; float maxYawSpeed() const override; void requestMaxYawSpeed(float speed) override; float maxYawSpeedMin() const override; float maxYawSpeedMax() const override; float maxGazSpeed() const override; void requestMaxGazSpeed(float speed) override; float maxGazSpeedMin() const override; float maxGazSpeedMax() const override; float maxTilt() const override; void requestMaxTilt(float tilt) override; float maxTiltMin() const override; float maxTiltMax() const override; bool bankedTurns() const override; void requestEnableBankedTurns(bool bankedTurns) override; bool geofence() const override; void requestEnableGeofence(bool enable) override; float maxAltitude() const override; void requestMaxAltitude(float altitude) override; float maxAltitudeMin() const override; float maxAltitudeMax() const override; float maxDistance() const override; void requestMaxDistance(float distance) override; float maxDistanceMin() const override; float maxDistanceMax() const 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; bool gpsFix() const override; QGeoCoordinate gpsPosition() const override; float altitude() const override; void setControllerGpsPosition(const QGeoCoordinate &position) override; void requestReturnHome() override; float speed() const override; quint16 numberOfFlights() const override; quint16 lastFlightDuration() const override; QString videoSource() const override; bool videoStreamEnabled() const override; Q_INVOKABLE void requestEnableVideoStream(bool enable) override; bool videoStabilization() const override; void requestEnableVideoStabilization(bool enable) override; bool canTakePicture() const override; bool isRecordingVideo() const override; public Q_SLOTS: void connectToVehicle(); private Q_SLOTS: void processIncomingCommand(const ParrotCommand &command); private: void initVehicle(); void sendCommand(Parrot::Command command, const QVariantList &arguments = QVariantList(), bool retryForever = false); Type m_type; QString m_hostName; QString m_productSerial; int m_initialized; bool m_piloting; float m_maxRollPitchSpeed; float m_maxRollPitchSpeedMin; float m_maxRollPitchSpeedMax; float m_maxYawSpeed; float m_maxYawSpeedMin; float m_maxYawSpeedMax; float m_maxGazSpeed; float m_maxGazSpeedMin; float m_maxGazSpeedMax; float m_maxTilt; float m_maxTiltMin; float m_maxTiltMax; bool m_bankedTurns; bool m_geofence; float m_maxAltitude; float m_maxAltitudeMin; float m_maxAltitudeMax; float m_maxDistance; float m_maxDistanceMin; float m_maxDistanceMax; float m_roll; float m_pitch; float m_yaw; float m_defaultCameraOrientationTilt; float m_defaultCameraOrientationPan; qint16 m_signalStrength; int m_batteryLevel; bool m_gpsFix; QGeoCoordinate m_gpsPosition; float m_altitude; float m_speed; bool m_videoStreamEnabled; qint32 m_videoStreamMode; qint32 m_videoStabilizationMode; bool m_canTakePicture; bool m_isRecordingVideo; quint16 m_numberOfFlights; quint16 m_lastFlightDuration; QThread m_connectionThread; ParrotConnection *m_connection; }; - -#endif 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