QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
SyslinkComponentController.cc
Go to the documentation of this file.
2#include "Vehicle.h"
4
5QGC_LOGGING_CATEGORY(SyslinkComponentControllerLog, "AutoPilotPlugins.SyslinkComponentController")
6
8 : FactPanelController(parent)
9 , _chan(getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_CHAN")))
10 , _rate(getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_RATE")))
11 , _addr1(getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_ADDR1")))
12 , _addr2(getParameterFact(_vehicle->id(), QStringLiteral("SLNK_RADIO_ADDR2")))
13{
14 // qCDebug(SyslinkComponentControllerLog) << Q_FUNC_INFO << this;
15
16 (void) connect(_chan, &Fact::valueChanged, this, &SyslinkComponentController::_channelChanged);
17 (void) connect(_rate, &Fact::valueChanged, this, &SyslinkComponentController::_rateChanged);
18 (void) connect(_addr1, &Fact::valueChanged, this, &SyslinkComponentController::_addressChanged);
19 (void) connect(_addr2, &Fact::valueChanged, this, &SyslinkComponentController::_addressChanged);
20}
21
22SyslinkComponentController::~SyslinkComponentController()
23{
24 // qCDebug(SyslinkComponentControllerLog) << Q_FUNC_INFO << this;
25}
26
27int SyslinkComponentController::radioChannel() const
28{
29 return _chan->rawValue().toUInt();
30}
31
32void SyslinkComponentController::setRadioChannel(int num) const
33{
34 _chan->setRawValue(QVariant(num));
35}
36
37QString SyslinkComponentController::radioAddress() const
38{
39 const uint32_t val_uh = _addr1->rawValue().toUInt();
40 const uint32_t val_lh = _addr2->rawValue().toUInt();
41 const uint64_t val = ((static_cast<uint64_t>(val_uh)) << 32) | static_cast<uint64_t>(val_lh);
42
43 return QString::number(val, 16);
44}
45
46void SyslinkComponentController::setRadioAddress(const QString &str) const
47{
48 const uint64_t val = str.toULongLong(0, 16);
49 const uint32_t val_uh = val >> 32;
50 const uint32_t val_lh = val & 0xFFFFFFFF;
51
52 _addr1->setRawValue(QVariant(val_uh));
53 _addr2->setRawValue(QVariant(val_lh));
54}
55
56int SyslinkComponentController::radioRate() const
57{
58 return _rate->rawValue().toInt();
59}
60
61void SyslinkComponentController::setRadioRate(int idx) const
62{
63 if ((idx >= 0) && (idx <= 2) && (idx != radioRate())) {
64 _rate->setRawValue(idx);
65 }
66}
67
68void SyslinkComponentController::resetDefaults() const
69{
70 _chan->setRawValue(_chan->rawDefaultValue());
71 _rate->setRawValue(_rate->rawDefaultValue());
72 _addr1->setRawValue(_addr1->rawDefaultValue());
73 _addr2->setRawValue(_addr2->rawDefaultValue());
74}
#define QGC_LOGGING_CATEGORY(name, categoryStr)
Used for handling missing Facts from C++ code.
void valueChanged(const QVariant &value)
This signal is only meant for use by the QT property system. It should not be connected to by client ...