QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
VehicleGPSAggregateFactGroup.h
Go to the documentation of this file.
1/****************************************************************************
2 *
3 * (c) 2009-2024 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 *
5 * QGroundControl is licensed according to the terms in the file
6 * COPYING.md in the root of the source code directory.
7 *
8 ****************************************************************************/
9
10#pragma once
11
12#include "FactGroup.h"
13#include <QtCore/QTimer>
14#include <QtCore/QVector>
15#include <QtCore/QMetaObject>
16
18
20{
21 Q_OBJECT
22 Q_PROPERTY(Fact* spoofingState READ spoofingState CONSTANT)
23 Q_PROPERTY(Fact* jammingState READ jammingState CONSTANT)
24 Q_PROPERTY(Fact* authenticationState READ authenticationState CONSTANT)
25 Q_PROPERTY(Fact* isStale READ isStale CONSTANT)
26public:
27 enum AuthState {
28 AUTH_UNKNOWN = 0,
29 AUTH_INITIALIZING = 1,
30 AUTH_ERROR = 2,
31 AUTH_OK = 3,
32 AUTH_DISABLED = 4,
33 AUTH_INVALID = -1
34 };
35
36 explicit VehicleGPSAggregateFactGroup(QObject *parent = nullptr);
37
38 Fact* spoofingState() { return &_spoofingStateFact; }
39 Fact* jammingState() { return &_jammingStateFact; }
40 Fact* authenticationState() { return &_authenticationStateFact; }
41 Fact* isStale() { return &_isStaleFact; }
42
43 void updateFromGps(VehicleGPSFactGroup* gps1, VehicleGPSFactGroup* gps2);
44 void bindToGps(VehicleGPSFactGroup* gps1, VehicleGPSFactGroup* gps2);
45
46private slots:
47 void _updateAggregates();
48 void _onIntegrityUpdated();
49 void _onStaleTimeout();
50
51private:
52 static constexpr int GNSS_INTEGRITY_STALE_TIMEOUT_MS = 5000;
53
54 static int _mergeWorst(int a, int b);
55 static int _mergeAuthentication(int a, int b);
56 static int _valueOrInvalid(Fact* fact);
57 void _clearConnections();
58
59 VehicleGPSFactGroup* _gps1 = nullptr;
60 VehicleGPSFactGroup* _gps2 = nullptr;
61 QTimer _staleTimer;
62 QVector<QMetaObject::Connection> _connections;
63
64 Fact _spoofingStateFact = Fact(0, QStringLiteral("spoofingState"), FactMetaData::valueTypeUint8);
65 Fact _jammingStateFact = Fact(0, QStringLiteral("jammingState"), FactMetaData::valueTypeUint8);
66 Fact _authenticationStateFact = Fact(0, QStringLiteral("authenticationState"), FactMetaData::valueTypeUint8);
67 Fact _isStaleFact = Fact(0, QStringLiteral("isStale"), FactMetaData::valueTypeBool);
68};
Used to group Facts together into an object hierarachy.
Definition FactGroup.h:19
A Fact is used to hold a single value within the system.
Definition Fact.h:19