Commit 2ba6578d authored by Lorenz Meier's avatar Lorenz Meier

Merged in APM config tree

parents 27274cd8 d88d49f6
......@@ -49,7 +49,8 @@ user_config.pri
*.suo
*.uhf.txt
*.opensdf
thirdParty/qserialport-build-desktop/
thirdParty/qserialport/bin/
thirdParty/qserialport/lib/
apmplanner2.xcodeproj/
GeneratedFiles/
This diff is collapsed.
......@@ -20,7 +20,8 @@
# Qt configuration
CONFIG += qt \
thread
thread \
console
# serialport
QT += network \
......@@ -265,7 +266,10 @@ FORMS += src/ui/MainWindow.ui \
src/ui/configuration/ArduRoverPidConfig.ui \
src/ui/QGCConfigView.ui \
src/ui/main/QGCViewModeSelection.ui \
src/ui/main/QGCWelcomeMainWindow.ui
src/ui/main/QGCWelcomeMainWindow.ui \
src/ui/configuration/terminalconsole.ui \
src/ui/configuration/SerialSettingsDialog.ui \
src/ui/configuration/ApmFirmwareConfig.ui
INCLUDEPATH += src \
src/ui \
......@@ -378,14 +382,14 @@ HEADERS += src/MG.h \
src/ui/map/Waypoint2DIcon.h \
src/ui/map/QGCMapTool.h \
src/ui/map/QGCMapToolBar.h \
# libs/qextserialport/qextserialenumerator.h \
src/QGCGeo.h \
src/ui/QGCToolBar.h \
src/ui/QGCStatusBar.h \
src/ui/QGCMAVLinkInspector.h \
src/ui/MAVLinkDecoder.h \
src/ui/WaypointViewOnlyView.h \
src/ui/WaypointEditableView.h \
src/ui/WaypointEditableView.h \
src/ui/UnconnectedUASInfoWidget.h \
src/ui/QGCRGBDView.h \
src/ui/mavlink/QGCMAVLinkMessageSender.h \
src/ui/firmwareupdate/QGCFirmwareUpdateWidget.h \
......@@ -459,7 +463,12 @@ HEADERS += src/MG.h \
src/ui/configuration/ArduRoverPidConfig.h \
src/ui/QGCConfigView.h \
src/ui/main/QGCViewModeSelection.h \
src/ui/main/QGCWelcomeMainWindow.h
src/ui/main/QGCWelcomeMainWindow.h \
src/ui/configuration/console.h \
src/ui/configuration/SerialSettingsDialog.h \
src/ui/configuration/terminalconsole.h \
src/ui/configuration/ApmHighlighter.h \
src/ui/configuration/ApmFirmwareConfig.h
# Google Earth is only supported on Mac OS and Windows with Visual Studio Compiler
macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010|win32-msvc2012::HEADERS += src/ui/map3D/QGCGoogleEarthView.h
......@@ -669,7 +678,12 @@ SOURCES += src/main.cc \
src/ui/configuration/ArduRoverPidConfig.cc \
src/ui/QGCConfigView.cc \
src/ui/main/QGCViewModeSelection.cc \
src/ui/main/QGCWelcomeMainWindow.cc
src/ui/main/QGCWelcomeMainWindow.cc \
src/ui/configuration/terminalconsole.cpp \
src/ui/configuration/console.cpp \
src/ui/configuration/SerialSettingsDialog.cc \
src/ui/configuration/ApmHighlighter.cc \
src/ui/configuration/ApmFirmwareConfig.cc
# Enable Google Earth only on Mac OS and Windows with Visual Studio compiler
macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010|win32-msvc2012::SOURCES += src/ui/map3D/QGCGoogleEarthView.cc
......@@ -806,7 +820,8 @@ unix:!macx:!symbian: LIBS += -losg
OTHER_FILES += \
dongfang_notes.txt \
src/ui/dongfang-scrapyard.txt \
qml/components/DigitalDisplay.qml
qml/components/DigitalDisplay.qml \
qml/components/StatusDisplay.qml
OTHER_FILES += \
qml/ApmToolBar.qml \
......
......@@ -120,6 +120,43 @@
<file>files/images/actions/qgroundcontrol-apm.svg</file>
<file>files/images/actions/qgroundcontrol-ardrone.svg</file>
<file>files/images/actions/qgroundcontrol-wifi.svg</file>
<file>files/images/firmware/apmcopter.png</file>
<file>files/images/firmware/apmplane.png</file>
<file>files/images/firmware/apmrover.png</file>
<file>files/images/firmware/FW icons 2013+logos.ai</file>
<file>files/images/firmware/heli.png</file>
<file>files/images/firmware/heli_off.png</file>
<file>files/images/firmware/heli_on.png</file>
<file>files/images/firmware/hexa_off.png</file>
<file>files/images/firmware/hexa_on.png</file>
<file>files/images/firmware/hexaplus.png</file>
<file>files/images/firmware/hexax.png</file>
<file>files/images/firmware/hexay.png</file>
<file>files/images/firmware/octaplus.png</file>
<file>files/images/firmware/octax.png</file>
<file>files/images/firmware/octo_off.png</file>
<file>files/images/firmware/octo_on.png</file>
<file>files/images/firmware/octx.png</file>
<file>files/images/firmware/plane.png</file>
<file>files/images/firmware/plane_off.png</file>
<file>files/images/firmware/plane_on.png</file>
<file>files/images/firmware/quad_off.png</file>
<file>files/images/firmware/quad_on.png</file>
<file>files/images/firmware/quad_T_off.png</file>
<file>files/images/firmware/quad_T_on.png</file>
<file>files/images/firmware/quadplus.png</file>
<file>files/images/firmware/quadx.png</file>
<file>files/images/firmware/quady.png</file>
<file>files/images/firmware/rover.png</file>
<file>files/images/firmware/rover_off.png</file>
<file>files/images/firmware/rover_on.png</file>
<file>files/images/firmware/Tir_off.png</file>
<file>files/images/firmware/Tir_on.png</file>
<file>files/images/firmware/triy.png</file>
<file>files/images/firmware/X8.png</file>
<file>files/images/firmware/X8_on.png</file>
<file>files/images/firmware/Y6_off.png</file>
<file>files/images/firmware/Y6_on.png</file>
</qresource>
<qresource prefix="/general">
<file alias="vera.ttf">files/styles/Vera.ttf</file>
......
......@@ -9,12 +9,27 @@ Rectangle {
property alias linkNameLabel: linkDevice.label
property alias baudrateLabel: baudrate.label
property bool connected: false
property bool armed: false
property string armedstr: "DISARMED"
width: toolbar.width
height: 72
color: "black"
border.color: "black"
onArmedChanged: {
if (armed) {
statusDisplay.statusText = "ARMED"
statusDisplay.statusTextColor = "red"
statusDisplay.statusBackgroundColor = "#FF880000"
}
else {
statusDisplay.statusText = "DISARMED"
statusDisplay.statusTextColor = "yellow"
statusDisplay.statusBackgroundColor = "black"
}
}
onConnectedChanged: {
if (connected){
console.log("APM Tool BAR QML: connected")
......@@ -44,7 +59,7 @@ Rectangle {
Row {
anchors.left: parent.left
spacing: 2
spacing: 10
Rectangle { // Spacer
width: 5
......@@ -104,6 +119,20 @@ Rectangle {
color: "black"
}
StatusDisplay {
id: statusDisplay
width: 110
statusText: "DISARMED"
statusTextColor: "yellow"
statusBackgroundColor: "black"
}
Rectangle { // Spacer
width: 5
height: parent.height
color: "black"
}
// [BB] Commented out ToolBar Status info work.
// WIP: To be fixed later
// DigitalDisplay { // Information Pane
......
......@@ -5,7 +5,7 @@ Rectangle {
property alias title: displayTitle.text
property string textValue: "none"
width: 100
width: 110
height: parent.height/3
anchors.verticalCenter: parent.verticalCenter
border.color: "white"
......
import QtQuick 1.1
Rectangle {
id: statusDisplay
property alias statusText: armedText.text
property alias statusTextColor: armedText.color
property alias statusBackgroundColor: statusDisplay.color
width: 100
height: parent.height/3
anchors.verticalCenter: parent.verticalCenter
radius: 3
border.color: "white"
border.width: 1
Text {
id: armedText
anchors.centerIn: parent
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.pixelSize: 20
}
}
......@@ -168,7 +168,16 @@ QGCCore::QGCCore(bool firstStart, int &argc, char* argv[]) : QApplication(argc,
// to make sure that all components are initialized when the
// first messages arrive
udpLink = new UDPLink(QHostAddress::Any, 14550);
MainWindow::instance()->addLink(udpLink);
LinkManager::instance()->add(udpLink);
//MainWindow::instance()->addLink(udpLink);
} else if (mainWindow->getCustomMode() == MainWindow::CUSTOM_MODE_PX4) {
udpLink = new UDPLink(QHostAddress::Any, 14550);
LinkManager::instance()->add(udpLink);
SerialLink *slink = new SerialLink();
} else {
// We want to have a default serial link available for "quick" connecting.
SerialLink *slink = new SerialLink();
// MainWindow::instance()->addLink(slink);
}
#ifdef OPAL_RT
......@@ -177,15 +186,12 @@ QGCCore::QGCCore(bool firstStart, int &argc, char* argv[]) : QApplication(argc,
MainWindow::instance()->addLink(opalLink);
#endif
//We want to have a default serial link available for "quick" connecting.
SerialLink *slink = new SerialLink();
MainWindow::instance()->addLink(slink);
// Remove splash screen
splashScreen->finish(mainWindow);
if (upgraded) mainWindow->showInfoMessage(tr("Default Settings Loaded"),
tr("qgroundcontrol has been upgraded from version %1 to version %2. Some of your user preferences have been reset to defaults for safety reasons. Please adjust them where needed.").arg(lastApplicationVersion).arg(QGC_APPLICATION_VERSION));
// Check if link could be connected
if (udpLink && !udpLink->connect())
{
......
......@@ -84,13 +84,13 @@ void LinkManager::addProtocol(LinkInterface* link, ProtocolInterface* protocol)
{
// Connect link to protocol
// the protocol will receive new bytes from the link
if(!link || !protocol) return;
if (!link || !protocol) return;
QList<LinkInterface*> linkList = protocolLinks.values(protocol);
// If protocol has not been added before (list length == 0)
// OR if link has not been added to protocol, add
if ((linkList.length() > 0 && !linkList.contains(link)) || linkList.length() == 0)
if (!linkList.contains(link))
{
// Protocol is new, add
connect(link, SIGNAL(bytesReceived(LinkInterface*, QByteArray)), protocol, SLOT(receiveBytes(LinkInterface*, QByteArray)));
......
......@@ -63,16 +63,6 @@ SerialLink::SerialLink(QString portname, int baudRate, bool hardwareFlowControl,
m_dataBits = dataBits;
m_stopBits = stopBits;
// Set the port name
// if (m_portName == "")
// {
// m_name = tr("Serial Link ") + QString::number(getId());
// }
// else
// {
// m_name = portname.trimmed();
// }
loadSettings();
LinkManager::instance()->add(this);
}
......@@ -92,8 +82,6 @@ SerialLink::~SerialLink()
QList<QString> SerialLink::getCurrentPorts()
{
m_ports.clear();
// Example use QSerialPortInfo
// [TODO] make this thread safe
QList<QSerialPortInfo> portList = QSerialPortInfo::availablePorts();
......@@ -153,6 +141,7 @@ void SerialLink::run()
{
//Need to error out here.
emit communicationError(getName(),"Error connecting: " + m_port->errorString());
disconnect(); // This tidies up and sends the necessary signals
return;
}
......@@ -184,18 +173,18 @@ void SerialLink::run()
}
}
if (m_transmitBuffer.size() > 0) {
// send the data
QMutexLocker lockWrite(&m_writeMutex);
int num_written = m_port->write(m_transmitBuffer.constData());
if (num_written > 0){
m_transmitBuffer = m_transmitBuffer.remove(0,num_written);
}
if (m_transmitBuffer.length() > 0) {
QMutexLocker writeLocker(&m_writeMutex);
int numWritten = m_port->write(m_transmitBuffer);
bool txError = m_port->waitForBytesWritten(-1);
// if ((txError) || (numWritten == -1))
// qDebug() << "TX Error!";
m_transmitBuffer = m_transmitBuffer.remove(0, numWritten);
} else {
// qDebug() << "Wait write response timeout %1" << QTime::currentTime().toString();
}
bool error = m_port->waitForReadyRead(500);
bool error = m_port->waitForReadyRead(10);
if(error) { // Waits for 1/2 second [TODO][BB] lower to SerialLink::poll_interval?
QByteArray readData = m_port->readAll();
......@@ -209,9 +198,9 @@ void SerialLink::run()
m_bitsReceivedTotal += readData.length() * 8;
}
} else {
// qDebug() << "readyReadTime #"<< __LINE__;
// qDebug() << "Wait write response timeout %1" << QTime::currentTime().toString();
}
if (bytes != m_bytesRead) // i.e things are good and data is being read.
{
bytes = m_bytesRead;
......@@ -274,20 +263,17 @@ void SerialLink::writeBytes(const char* data, qint64 size)
if(m_port && m_port->isOpen()) {
// qDebug() << "writeBytes" << m_portName << "attempting to tx " << size << "bytes.";
QByteArray byteArray(data,size);
QByteArray byteArray(data, size);
{
QMutexLocker writeLocker(&m_writeMutex);
m_transmitBuffer.append(byteArray);
}
// qDebug() << "writeBytes " << m_portName << "tx'd" << b << "bytes:";
// Increase write counter
m_bitsSentTotal += size * 8;
// Extra debug logging
// qDebug() << byteArray->toHex();
// delete byteArray;
} else {
disconnect();
// Error occured
......@@ -421,6 +407,8 @@ bool SerialLink::hardwareConnect()
}
QObject::connect(m_port,SIGNAL(aboutToClose()),this,SIGNAL(disconnected()));
QObject::connect(m_port, SIGNAL(error(QSerialPort::SerialPortError)),
this, SLOT(linkError(QSerialPort::SerialPortError)));
// port->setCommTimeouts(QSerialPort::CtScheme_NonBlockingRead);
m_connectionStartTime = MG::TIME::getGroundTimeNow();
......@@ -452,6 +440,11 @@ bool SerialLink::hardwareConnect()
return true; // successful connection
}
void SerialLink::linkError(QSerialPort::SerialPortError error)
{
qDebug() << error;
}
/**
* @brief Check if connection is active.
......
......@@ -142,6 +142,8 @@ public slots:
bool connect();
bool disconnect();
void linkError(QSerialPort::SerialPortError error);
protected:
quint64 m_bytesRead;
QSerialPort* m_port;
......@@ -166,13 +168,13 @@ protected:
quint64 m_connectionStartTime;
QMutex m_statisticsMutex;
QMutex m_dataMutex;
QMutex m_writeMutex;
QList<QString> m_ports;
private:
volatile bool m_stopp;
volatile bool m_reqReset;
QMutex m_stoppMutex;
QMutex m_writeMutex;
QByteArray m_transmitBuffer;
bool hardwareConnect();
......
......@@ -50,6 +50,7 @@ UDPLink::UDPLink(QHostAddress host, quint16 port)
this->name = tr("UDP Link (port:%1)").arg(this->port);
emit nameChanged(this->name);
// LinkManager::instance()->add(this);
qDebug() << "UDP Created " << name;
}
UDPLink::~UDPLink()
......@@ -104,7 +105,7 @@ void UDPLink::setPort(int port)
*/
void UDPLink::addHost(const QString& host)
{
//qDebug() << "UDP:" << "ADDING HOST:" << host;
qDebug() << "UDP:" << "ADDING HOST:" << host;
if (host.contains(":"))
{
//qDebug() << "HOST: " << host.split(":").first();
......
......@@ -11,7 +11,7 @@
#define WITH_TEXT_TO_SPEECH 1
#define QGC_APPLICATION_NAME "QGroundControl"
#define QGC_APPLICATION_VERSION "v. 1.1.0 (beta)"
#define QGC_APPLICATION_VERSION "v. 1.1.1 (beta)"
namespace QGC
......
......@@ -53,11 +53,17 @@ ArduPilotMegaMAV::ArduPilotMegaMAV(MAVLinkProtocol* mavlink, int id) :
void ArduPilotMegaMAV::sendTxRequests()
{
enableExtendedSystemStatusTransmission(2);
QGC::SLEEP::msleep(250);
enablePositionTransmission(3);
QGC::SLEEP::msleep(250);
enableExtra1Transmission(10);
QGC::SLEEP::msleep(250);
enableExtra2Transmission(10);
QGC::SLEEP::msleep(250);
enableExtra3Transmission(2);
QGC::SLEEP::msleep(250);
enableRawSensorDataTransmission(2);
QGC::SLEEP::msleep(250);
enableRCChannelDataTransmission(2);
}
......
......@@ -73,11 +73,18 @@ CommConfigurationWindow::CommConfigurationWindow(LinkInterface* link, ProtocolIn
ui.connectionType->setEnabled(false);
ui.linkType->setEnabled(false);
ui.protocolGroupBox->setVisible(false);
ui.protocolTypeGroupBox->setVisible(false);
// Connect UI element visibility to checkbox
connect(ui.advancedOptionsCheckBox, SIGNAL(clicked(bool)), ui.connectionType, SLOT(setEnabled(bool)));
connect(ui.advancedOptionsCheckBox, SIGNAL(clicked(bool)), ui.linkType, SLOT(setEnabled(bool)));
connect(ui.advancedOptionsCheckBox, SIGNAL(clicked(bool)), ui.protocolGroupBox, SLOT(setVisible(bool)));
//connect(ui.advancedOptionsCheckBox, SIGNAL(clicked(bool)), ui.connectionType, SLOT(setEnabled(bool)));
//connect(ui.advancedOptionsCheckBox, SIGNAL(clicked(bool)), ui.linkType, SLOT(setEnabled(bool)));
//connect(ui.advancedOptionsCheckBox, SIGNAL(clicked(bool)), ui.protocolGroupBox, SLOT(setVisible(bool)));
ui.advancedOptionsCheckBox->setVisible(false);
//connect(ui.advCheckBox,SIGNAL(clicked(bool)),ui.advancedOptionsCheckBox,SLOT(setChecked(bool)));
connect(ui.advCheckBox,SIGNAL(clicked(bool)),ui.protocolTypeGroupBox,SLOT(setVisible(bool)));
connect(ui.advCheckBox, SIGNAL(clicked(bool)), ui.connectionType, SLOT(setEnabled(bool)));
connect(ui.advCheckBox, SIGNAL(clicked(bool)), ui.linkType, SLOT(setEnabled(bool)));
connect(ui.advCheckBox, SIGNAL(clicked(bool)), ui.protocolGroupBox, SLOT(setVisible(bool)));
// add link types
ui.linkType->addItem(tr("Serial"), QGC_LINK_SERIAL);
......
......@@ -6,85 +6,15 @@
<rect>
<x>0</x>
<y>0</y>
<width>413</width>
<height>373</height>
<width>324</width>
<height>415</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_2" rowstretch="1,1,1,100,100,1">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item row="0" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>5</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Link Type</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="linkType"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Protocol</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="connectionType">
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="advancedOptionsCheckBox">
<property name="text">
<string>Advanced Options</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="linkGroupBox">
<property name="title">
<string>Link</string>
......@@ -93,16 +23,7 @@
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
......@@ -115,8 +36,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>391</width>
<height>85</height>
<width>302</width>
<height>69</height>
</rect>
</property>
</widget>
......@@ -125,7 +46,65 @@
</layout>
</widget>
</item>
<item row="4" column="0" colspan="2">
<item>
<widget class="QCheckBox" name="advCheckBox">
<property name="text">
<string>Show Advanced Protocol Options</string>
</property>
</widget>
</item>
<item>