15 changed files with 484 additions and 4 deletions
@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
|
||||
/****************************************************************************
|
||||
* |
||||
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
|
||||
* |
||||
* QGroundControl is licensed according to the terms in the file |
||||
* COPYING.md in the root of the source code directory. |
||||
* |
||||
****************************************************************************/ |
||||
|
||||
|
||||
#include "SyslinkComponent.h" |
||||
#include "AutoPilotPlugin.h" |
||||
|
||||
SyslinkComponent::SyslinkComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) |
||||
: VehicleComponent(vehicle, autopilot, parent) |
||||
, _name(tr("Syslink")) |
||||
{ |
||||
|
||||
} |
||||
|
||||
QString SyslinkComponent::name(void) const |
||||
{ |
||||
return _name; |
||||
} |
||||
|
||||
QString SyslinkComponent::description(void) const |
||||
{ |
||||
return tr("The Syslink Component is used to setup the radio connection on Crazyflies."); |
||||
} |
||||
|
||||
QString SyslinkComponent::iconResource(void) const |
||||
{ |
||||
return "/qmlimages/wifi.svg"; |
||||
} |
||||
|
||||
bool SyslinkComponent::requiresSetup(void) const |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
bool SyslinkComponent::setupComplete(void) const |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
QStringList SyslinkComponent::setupCompleteChangedTriggerList(void) const |
||||
{ |
||||
return QStringList(); |
||||
} |
||||
|
||||
QUrl SyslinkComponent::setupSource(void) const |
||||
{ |
||||
return QUrl::fromUserInput("qrc:/qml/SyslinkComponent.qml"); |
||||
} |
||||
|
||||
QUrl SyslinkComponent::summaryQmlSource(void) const |
||||
{ |
||||
return QUrl(); |
||||
} |
||||
|
||||
QString SyslinkComponent::prerequisiteSetup(void) const |
||||
{ |
||||
return QString(); |
||||
} |
@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
/****************************************************************************
|
||||
* |
||||
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
|
||||
* |
||||
* QGroundControl is licensed according to the terms in the file |
||||
* COPYING.md in the root of the source code directory. |
||||
* |
||||
****************************************************************************/ |
||||
|
||||
|
||||
#ifndef SyslinkComponent_H |
||||
#define SyslinkComponent_H |
||||
|
||||
#include "VehicleComponent.h" |
||||
|
||||
class SyslinkComponent : public VehicleComponent |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
SyslinkComponent (Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL); |
||||
|
||||
// Virtuals from VehicleComponent
|
||||
QStringList setupCompleteChangedTriggerList() const; |
||||
|
||||
// Virtuals from VehicleComponent
|
||||
QString name () const; |
||||
QString description () const; |
||||
QString iconResource () const; |
||||
bool requiresSetup () const; |
||||
bool setupComplete () const; |
||||
QUrl setupSource () const; |
||||
QUrl summaryQmlSource () const; |
||||
QString prerequisiteSetup () const; |
||||
|
||||
private: |
||||
const QString _name; |
||||
QVariantList _summaryItems; |
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,140 @@
@@ -0,0 +1,140 @@
|
||||
/**************************************************************************** |
||||
* |
||||
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org> |
||||
* |
||||
* QGroundControl is licensed according to the terms in the file |
||||
* COPYING.md in the root of the source code directory. |
||||
* |
||||
****************************************************************************/ |
||||
|
||||
|
||||
|
||||
import QtQuick 2.2 |
||||
import QtQuick.Controls 1.2 |
||||
import QtQuick.Dialogs 1.2 |
||||
import QtQuick.Layouts 1.2 |
||||
|
||||
import QGroundControl.FactSystem 1.0 |
||||
import QGroundControl.FactControls 1.0 |
||||
import QGroundControl.Controls 1.0 |
||||
import QGroundControl.ScreenTools 1.0 |
||||
import QGroundControl.Controllers 1.0 |
||||
|
||||
SetupPage { |
||||
id: syslinkPage |
||||
pageComponent: pageComponent |
||||
|
||||
Component { |
||||
id: pageComponent |
||||
|
||||
Column { |
||||
id: innerColumn |
||||
width: availableWidth |
||||
spacing: ScreenTools.defaultFontPixelHeight * 0.5 |
||||
|
||||
property int textEditWidth: ScreenTools.defaultFontPixelWidth * 12 |
||||
|
||||
|
||||
SyslinkComponentController { |
||||
id: controller |
||||
factPanel: syslinkPage.viewPanel |
||||
} |
||||
|
||||
QGCLabel { |
||||
text: qsTr("Radio Settings") |
||||
font.family: ScreenTools.demiboldFontFamily |
||||
} |
||||
|
||||
Rectangle { |
||||
width: parent.width |
||||
height: radioGrid.height + ScreenTools.defaultFontPixelHeight |
||||
color: qgcPal.windowShade |
||||
|
||||
GridLayout { |
||||
id: radioGrid |
||||
anchors.margins: ScreenTools.defaultFontPixelHeight / 2 |
||||
anchors.left: parent.left |
||||
anchors.top: parent.top |
||||
columns: 2 |
||||
columnSpacing: ScreenTools.defaultFontPixelWidth |
||||
|
||||
QGCLabel { |
||||
text: qsTr("Channel") |
||||
} |
||||
|
||||
QGCTextField { |
||||
id: channelField |
||||
width: textEditWidth |
||||
text: controller.radioChannel |
||||
validator: IntValidator {bottom: 0; top: 125;} |
||||
inputMethodHints: Qt.ImhDigitsOnly |
||||
onEditingFinished: { |
||||
controller.radioChannel = text |
||||
} |
||||
} |
||||
|
||||
QGCLabel { |
||||
id: channelHelp |
||||
Layout.columnSpan: radioGrid.columns |
||||
Layout.fillWidth: true |
||||
font.pointSize: ScreenTools.smallFontPointSize |
||||
wrapMode: Text.WordWrap |
||||
text: "Channel can be between 0 and 125" |
||||
} |
||||
|
||||
QGCLabel { |
||||
id: addressLabel |
||||
text: qsTr("Address") |
||||
} |
||||
|
||||
QGCTextField { |
||||
id: addressField |
||||
width: textEditWidth |
||||
text: controller.radioAddress |
||||
maximumLength: 10 |
||||
validator: RegExpValidator { regExp: /^[0-9A-Fa-f]*$/ } |
||||
onEditingFinished: { |
||||
controller.radioAddress = text |
||||
} |
||||
} |
||||
|
||||
QGCLabel { |
||||
id: addressHelp |
||||
Layout.columnSpan: radioGrid.columns |
||||
Layout.fillWidth: true |
||||
font.pointSize: ScreenTools.smallFontPointSize |
||||
wrapMode: Text.WordWrap |
||||
text: "Address in hex. Default is E7E7E7E7E7." |
||||
} |
||||
|
||||
|
||||
QGCLabel { |
||||
id: rateLabel |
||||
text: qsTr("Data Rate") |
||||
} |
||||
|
||||
QGCComboBox { |
||||
id: rateField |
||||
Layout.fillWidth: true |
||||
model: controller.radioRates |
||||
currentIndex: controller.radioRate |
||||
onActivated: { |
||||
controller.radioRate = index |
||||
} |
||||
} |
||||
|
||||
QGCButton { |
||||
text: "Restore Defaults" |
||||
width: textEditWidth |
||||
onClicked: { |
||||
controller.resetDefaults() |
||||
} |
||||
} |
||||
|
||||
} // Grid |
||||
} // Rectangle - Radio Settings |
||||
|
||||
|
||||
} |
||||
} |
||||
} |
@ -0,0 +1,137 @@
@@ -0,0 +1,137 @@
|
||||
/****************************************************************************
|
||||
* |
||||
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
|
||||
* |
||||
* QGroundControl is licensed according to the terms in the file |
||||
* COPYING.md in the root of the source code directory. |
||||
* |
||||
****************************************************************************/ |
||||
|
||||
#include "SyslinkComponentController.h" |
||||
#include "QGCApplication.h" |
||||
#include "UAS.h" |
||||
#include "ParameterManager.h" |
||||
|
||||
#include <QHostAddress> |
||||
#include <QtEndian> |
||||
|
||||
QGC_LOGGING_CATEGORY(SyslinkComponentControllerLog, "SyslinkComponentControllerLog") |
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
SyslinkComponentController::SyslinkComponentController() |
||||
{ |
||||
_dataRates.append("750Kb/s"); |
||||
_dataRates.append("1Mb/s"); |
||||
_dataRates.append("2Mb/s"); |
||||
|
||||
Fact* chan = getParameterFact(_vehicle->id(), "SLNK_RADIO_CHAN"); |
||||
connect(chan, &Fact::valueChanged, this, &SyslinkComponentController::_channelChanged); |
||||
Fact* rate = getParameterFact(_vehicle->id(), "SLNK_RADIO_RATE"); |
||||
connect(rate, &Fact::valueChanged, this, &SyslinkComponentController::_rateChanged); |
||||
Fact* addr1 = getParameterFact(_vehicle->id(), "SLNK_RADIO_ADDR1"); |
||||
connect(addr1, &Fact::valueChanged, this, &SyslinkComponentController::_addressChanged); |
||||
Fact* addr2 = getParameterFact(_vehicle->id(), "SLNK_RADIO_ADDR2"); |
||||
connect(addr2, &Fact::valueChanged, this, &SyslinkComponentController::_addressChanged); |
||||
} |
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
SyslinkComponentController::~SyslinkComponentController() |
||||
{ |
||||
|
||||
} |
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int |
||||
SyslinkComponentController::radioChannel() |
||||
{ |
||||
return getParameterFact(_vehicle->id(), "SLNK_RADIO_CHAN")->rawValue().toUInt(); |
||||
} |
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void |
||||
SyslinkComponentController::setRadioChannel(int num) |
||||
{ |
||||
Fact* f = getParameterFact(_vehicle->id(), "SLNK_RADIO_CHAN"); |
||||
f->setRawValue(QVariant(num)); |
||||
} |
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
QString |
||||
SyslinkComponentController::radioAddress() |
||||
{ |
||||
uint32_t val_uh = getParameterFact(_vehicle->id(), "SLNK_RADIO_ADDR1")->rawValue().toUInt(); |
||||
uint32_t val_lh = getParameterFact(_vehicle->id(), "SLNK_RADIO_ADDR2")->rawValue().toUInt(); |
||||
uint64_t val = (((uint64_t) val_uh) << 32) | ((uint64_t) val_lh); |
||||
|
||||
return QString().number(val, 16); |
||||
} |
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void |
||||
SyslinkComponentController::setRadioAddress(QString str) |
||||
{ |
||||
Fact *uh = getParameterFact(_vehicle->id(), "SLNK_RADIO_ADDR1"); |
||||
Fact *lh = getParameterFact(_vehicle->id(), "SLNK_RADIO_ADDR2"); |
||||
|
||||
uint64_t val = str.toULongLong(0, 16); |
||||
|
||||
uint32_t val_uh = val >> 32; |
||||
uint32_t val_lh = val & 0xFFFFFFFF; |
||||
|
||||
uh->setRawValue(QVariant(val_uh)); |
||||
lh->setRawValue(QVariant(val_lh)); |
||||
} |
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int |
||||
SyslinkComponentController::radioRate() |
||||
{ |
||||
return getParameterFact(_vehicle->id(), "SLNK_RADIO_RATE")->rawValue().toInt(); |
||||
} |
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void |
||||
SyslinkComponentController::setRadioRate(int idx) |
||||
{ |
||||
if(idx >= 0 && idx <= 2 && idx != radioRate()) { |
||||
Fact* r = getParameterFact(_vehicle->id(), "SLNK_RADIO_RATE"); |
||||
r->setRawValue(idx); |
||||
} |
||||
} |
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void |
||||
SyslinkComponentController::resetDefaults() |
||||
{ |
||||
Fact* chan = getParameterFact(_vehicle->id(), "SLNK_RADIO_CHAN"); |
||||
Fact* rate = getParameterFact(_vehicle->id(), "SLNK_RADIO_RATE"); |
||||
Fact* addr1 = getParameterFact(_vehicle->id(), "SLNK_RADIO_ADDR1"); |
||||
Fact* addr2 = getParameterFact(_vehicle->id(), "SLNK_RADIO_ADDR2"); |
||||
|
||||
chan->setRawValue(chan->rawDefaultValue()); |
||||
rate->setRawValue(rate->rawDefaultValue()); |
||||
addr1->setRawValue(addr1->rawDefaultValue()); |
||||
addr2->setRawValue(addr2->rawDefaultValue()); |
||||
} |
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void |
||||
SyslinkComponentController::_channelChanged(QVariant) |
||||
{ |
||||
emit radioChannelChanged(); |
||||
} |
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void |
||||
SyslinkComponentController::_addressChanged(QVariant) |
||||
{ |
||||
emit radioAddressChanged(); |
||||
} |
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void |
||||
SyslinkComponentController::_rateChanged(QVariant) |
||||
{ |
||||
emit radioRateChanged(); |
||||
} |
||||
|
@ -0,0 +1,66 @@
@@ -0,0 +1,66 @@
|
||||
/****************************************************************************
|
||||
* |
||||
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
|
||||
* |
||||
* QGroundControl is licensed according to the terms in the file |
||||
* COPYING.md in the root of the source code directory. |
||||
* |
||||
****************************************************************************/ |
||||
|
||||
#ifndef SyslinkComponentController_H |
||||
#define SyslinkComponentController_H |
||||
|
||||
#include "FactPanelController.h" |
||||
#include "UASInterface.h" |
||||
#include "QGCLoggingCategory.h" |
||||
#include "AutoPilotPlugin.h" |
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(SyslinkComponentControllerLog) |
||||
|
||||
namespace Ui { |
||||
class SyslinkComponentController; |
||||
} |
||||
|
||||
class SyslinkComponentController : public FactPanelController |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
SyslinkComponentController (); |
||||
~SyslinkComponentController (); |
||||
|
||||
Q_PROPERTY(int radioChannel READ radioChannel WRITE setRadioChannel NOTIFY radioChannelChanged) |
||||
Q_PROPERTY(QString radioAddress READ radioAddress WRITE setRadioAddress NOTIFY radioAddressChanged) |
||||
Q_PROPERTY(int radioRate READ radioRate WRITE setRadioRate NOTIFY radioRateChanged) |
||||
Q_PROPERTY(QStringList radioRates READ radioRates CONSTANT) |
||||
Q_PROPERTY(Vehicle* vehicle READ vehicle CONSTANT) |
||||
|
||||
Q_INVOKABLE void resetDefaults(); |
||||
|
||||
int radioChannel (); |
||||
QString radioAddress (); |
||||
int radioRate (); |
||||
QStringList radioRates () { return _dataRates; } |
||||
Vehicle* vehicle () { return _vehicle; } |
||||
|
||||
void setRadioChannel (int num); |
||||
void setRadioAddress (QString str); |
||||
void setRadioRate (int idx); |
||||
|
||||
|
||||
signals: |
||||
void radioChannelChanged (); |
||||
void radioAddressChanged (); |
||||
void radioRateChanged (); |
||||
|
||||
private slots: |
||||
void _channelChanged (QVariant value); |
||||
void _addressChanged (QVariant value); |
||||
void _rateChanged (QVariant value); |
||||
|
||||
private: |
||||
QStringList _dataRates; |
||||
|
||||
}; |
||||
|
||||
#endif // SyslinkComponentController_H
|
Loading…
Reference in new issue