MockLinkMissionItemHandler.h 2.13 KB
Newer Older
1
/*=====================================================================
2

3
 QGroundControl Open Source Ground Control Station
4

5
 (c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
6

7
 This file is part of the QGROUNDCONTROL project
8

9 10 11 12
 QGROUNDCONTROL 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 3 of the License, or
 (at your option) any later version.
13

14 15 16 17
 QGROUNDCONTROL 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.
18

19 20
 You should have received a copy of the GNU General Public License
 along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
21

22 23
 ======================================================================*/

Don Gagne's avatar
Don Gagne committed
24 25
#ifndef MockLinkMissionItemHandler_H
#define MockLinkMissionItemHandler_H
26 27

#include <QObject>
Don Gagne's avatar
Don Gagne committed
28
#include <QMap>
29 30

#include "QGCMAVLink.h"
Don Gagne's avatar
Don Gagne committed
31
#include "QGCLoggingCategory.h"
32

Don Gagne's avatar
Don Gagne committed
33 34 35
class MockLink;

Q_DECLARE_LOGGING_CATEGORY(MockLinkMissionItemHandlerLog)
36 37 38 39

class MockLinkMissionItemHandler : public QObject
{
    Q_OBJECT
40

41
public:
Don Gagne's avatar
Don Gagne committed
42
    MockLinkMissionItemHandler(MockLink* mockLink);
43

44 45
    /// @brief Called to handle mission item related messages. All messages should be passed to this method.
    ///         It will handle the appropriate set.
Don Gagne's avatar
Don Gagne committed
46 47
    /// @return true: message handled
    bool handleMessage(const mavlink_message_t& msg);
48

49
private:
Don Gagne's avatar
Don Gagne committed
50 51 52 53 54
    void _handleMissionRequestList(const mavlink_message_t& msg);
    void _handleMissionRequest(const mavlink_message_t& msg);
    void _handleMissionItem(const mavlink_message_t& msg);
    void _handleMissionCount(const mavlink_message_t& msg);
    void _requestNextMissionItem(int sequenceNumber);
55

Don Gagne's avatar
Don Gagne committed
56 57 58 59 60 61 62 63
private:
    MockLink* _mockLink;
    
    int _writeSequenceCount;    ///< Numbers of items about to be written
    int _writeSequenceIndex;    ///< Current index being reqested
    
    typedef QMap<uint16_t, mavlink_mission_item_t>   MissionList_t;
    MissionList_t   _missionItems;
64 65
};

Don Gagne's avatar
Don Gagne committed
66
#endif