From 50f1e15f544c9a22b727252ec63de1bcf905c246 Mon Sep 17 00:00:00 2001 From: elafargue Date: Sun, 15 May 2011 22:48:18 +0200 Subject: [PATCH] Aditional artwork for GCS (artwork directory), plus show basic board info when connected on the uploader gadget. --- artwork/GCS Icons/README.txt | 1 + artwork/GCS Icons/application-certificate.svg | 443 ++++++++++++++++++ artwork/GCS Icons/icon-checkbox.svg | 91 ++++ artwork/GCS Icons/icon-gears.svg | 390 +++++++++++++++ artwork/GCS Icons/icon-info.svg | 131 ++++++ artwork/GCS Icons/icon-refresh.svg | 230 +++++++++ artwork/GCS Icons/icon-stop.svg | 130 +++++ .../uavobjectutil/uavobjectutilmanager.cpp | 30 ++ .../uavobjectutil/uavobjectutilmanager.h | 1 + .../src/plugins/uploader/Uploader.pluginspec | 1 + .../images/application-certificate.svg | 443 ++++++++++++++++++ .../plugins/uploader/runningdevicewidget.cpp | 131 ++++++ .../plugins/uploader/runningdevicewidget.h | 69 +++ .../plugins/uploader/runningdevicewidget.ui | 91 ++++ .../src/plugins/uploader/uploader.pro | 10 +- .../src/plugins/uploader/uploader.qrc | 1 + .../plugins/uploader/uploadergadgetwidget.cpp | 12 + .../plugins/uploader/uploadergadgetwidget.h | 1 + 18 files changed, 2203 insertions(+), 3 deletions(-) create mode 100644 artwork/GCS Icons/README.txt create mode 100644 artwork/GCS Icons/application-certificate.svg create mode 100644 artwork/GCS Icons/icon-checkbox.svg create mode 100644 artwork/GCS Icons/icon-gears.svg create mode 100644 artwork/GCS Icons/icon-info.svg create mode 100644 artwork/GCS Icons/icon-refresh.svg create mode 100644 artwork/GCS Icons/icon-stop.svg create mode 100644 ground/openpilotgcs/src/plugins/uploader/images/application-certificate.svg create mode 100644 ground/openpilotgcs/src/plugins/uploader/runningdevicewidget.cpp create mode 100644 ground/openpilotgcs/src/plugins/uploader/runningdevicewidget.h create mode 100644 ground/openpilotgcs/src/plugins/uploader/runningdevicewidget.ui diff --git a/artwork/GCS Icons/README.txt b/artwork/GCS Icons/README.txt new file mode 100644 index 000000000..5c290233f --- /dev/null +++ b/artwork/GCS Icons/README.txt @@ -0,0 +1 @@ +Those icons come from the Tango set and are used in the GCS. diff --git a/artwork/GCS Icons/application-certificate.svg b/artwork/GCS Icons/application-certificate.svg new file mode 100644 index 000000000..077f741d8 --- /dev/null +++ b/artwork/GCS Icons/application-certificate.svg @@ -0,0 +1,443 @@ + + + + + + image/svg+xml + + + + + + CertificateJakub Steinercertificate + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/artwork/GCS Icons/icon-checkbox.svg b/artwork/GCS Icons/icon-checkbox.svg new file mode 100644 index 000000000..185dfc615 --- /dev/null +++ b/artwork/GCS Icons/icon-checkbox.svg @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/artwork/GCS Icons/icon-gears.svg b/artwork/GCS Icons/icon-gears.svg new file mode 100644 index 000000000..8e2572fce --- /dev/null +++ b/artwork/GCS Icons/icon-gears.svg @@ -0,0 +1,390 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/artwork/GCS Icons/icon-info.svg b/artwork/GCS Icons/icon-info.svg new file mode 100644 index 000000000..62c2cecd6 --- /dev/null +++ b/artwork/GCS Icons/icon-info.svg @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/artwork/GCS Icons/icon-refresh.svg b/artwork/GCS Icons/icon-refresh.svg new file mode 100644 index 000000000..3d0cc562d --- /dev/null +++ b/artwork/GCS Icons/icon-refresh.svg @@ -0,0 +1,230 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/artwork/GCS Icons/icon-stop.svg b/artwork/GCS Icons/icon-stop.svg new file mode 100644 index 000000000..8955e4375 --- /dev/null +++ b/artwork/GCS Icons/icon-stop.svg @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ground/openpilotgcs/src/plugins/uavobjectutil/uavobjectutilmanager.cpp b/ground/openpilotgcs/src/plugins/uavobjectutil/uavobjectutilmanager.cpp index 856fc6159..47ad9a8ae 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectutil/uavobjectutilmanager.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectutil/uavobjectutilmanager.cpp @@ -143,6 +143,36 @@ int UAVObjectUtilManager::getBoardModel() return boardType; } +/** + * Get the UAV Board CPU Serial Number, for anyone interested. Return format is a byte array + */ +QByteArray UAVObjectUtilManager::getBoardCPUSerial() +{ + QByteArray cpuSerial; + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + if (!pm) + return 0; + UAVObjectManager *om = pm->getObject(); + if (!om) + return 0; + + UAVDataObject *obj = dynamic_cast(om->getObject(QString("FirmwareIAPObj"))); + // The code below will ask for the object update and wait for the updated to be received, + // or the timeout of the timer, set to 1 second. + QEventLoop loop; + connect(obj, SIGNAL(objectUpdated(UAVObject*)), &loop, SLOT(quit())); + QTimer::singleShot(1000, &loop, SLOT(quit())); // Create a timeout + obj->requestUpdate(); + loop.exec(); + + UAVObjectField* cpuField = obj->getField("CPUSerial"); + for (int i = 0; i < cpuField->getNumElements(); ++i) { + cpuSerial.append(cpuField->getValue(i).toUInt()); + } + return cpuSerial; +} + + // ****************************** // HomeLocation diff --git a/ground/openpilotgcs/src/plugins/uavobjectutil/uavobjectutilmanager.h b/ground/openpilotgcs/src/plugins/uavobjectutil/uavobjectutilmanager.h index 8a97b60dd..f97f969d8 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectutil/uavobjectutilmanager.h +++ b/ground/openpilotgcs/src/plugins/uavobjectutil/uavobjectutilmanager.h @@ -61,6 +61,7 @@ public: int getTelemetrySerialPortSpeeds(QComboBox *comboBox); int getBoardModel(); + QByteArray getBoardCPUSerial(); private: QMutex *mutex; diff --git a/ground/openpilotgcs/src/plugins/uploader/Uploader.pluginspec b/ground/openpilotgcs/src/plugins/uploader/Uploader.pluginspec index b2c9a8777..6b24fe1e7 100755 --- a/ground/openpilotgcs/src/plugins/uploader/Uploader.pluginspec +++ b/ground/openpilotgcs/src/plugins/uploader/Uploader.pluginspec @@ -9,5 +9,6 @@ + diff --git a/ground/openpilotgcs/src/plugins/uploader/images/application-certificate.svg b/ground/openpilotgcs/src/plugins/uploader/images/application-certificate.svg new file mode 100644 index 000000000..077f741d8 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uploader/images/application-certificate.svg @@ -0,0 +1,443 @@ + + + + + + image/svg+xml + + + + + + CertificateJakub Steinercertificate + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/uploader/runningdevicewidget.cpp b/ground/openpilotgcs/src/plugins/uploader/runningdevicewidget.cpp new file mode 100644 index 000000000..7e9b1889b --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uploader/runningdevicewidget.cpp @@ -0,0 +1,131 @@ +/** + ****************************************************************************** + * + * @file runningdevicewidget.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup Uploader Serial and USB Uploader Plugin + * @{ + * @brief The USB and Serial protocol uploader plugin + *****************************************************************************/ +/* + * This program 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. + * + * This program 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. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include "runningdevicewidget.h" + +runningDeviceWidget::runningDeviceWidget(QWidget *parent) : + QWidget(parent) +{ + myDevice = new Ui_runningDeviceWidget(); + myDevice->setupUi(this); + devicePic = NULL; // Initialize pointer to null + + // Initialization of the Device icon display + myDevice->devicePicture->setScene(new QGraphicsScene(this)); + + QPixmap pix = QPixmap(QString(":uploader/images/view-refresh.svg")); + myDevice->statusIcon->setPixmap(pix); +} + + +void runningDeviceWidget::showEvent(QShowEvent *event) +{ + Q_UNUSED(event) + // Thit fitInView method should only be called now, once the + // widget is shown, otherwise it cannot compute its values and + // the result is usually a ahrsbargraph that is way too small. + if (devicePic) + myDevice->devicePicture->fitInView(devicePic,Qt::KeepAspectRatio); +} + +void runningDeviceWidget::resizeEvent(QResizeEvent* event) +{ + Q_UNUSED(event); + if (devicePic) + myDevice->devicePicture->fitInView(devicePic, Qt::KeepAspectRatio); +} + +/** + Fills the various fields for the device + */ +void runningDeviceWidget::populate() +{ + + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + UAVObjectUtilManager* utilMngr = pm->getObject(); + int id = utilMngr->getBoardModel(); + + myDevice->deviceID->setText(QString("Device ID: ") + QString::number(id, 16)); + + // DeviceID tells us what sort of HW we have detected: + // display a nice icon: + myDevice->devicePicture->scene()->clear(); + if (devicePic) + delete devicePic; + devicePic = new QGraphicsSvgItem(); + devicePic->setSharedRenderer(new QSvgRenderer()); + + switch (id) { + case 0x0101: + devicePic->renderer()->load(QString(":/uploader/images/deviceID-0101.svg")); + break; + case 0x0301: + devicePic->renderer()->load(QString(":/uploader/images/deviceID-0301.svg")); + break; + case 0x0401: + devicePic->renderer()->load(QString(":/uploader/images/deviceID-0401.svg")); + break; + case 0x0201: + devicePic->renderer()->load(QString(":/uploader/images/deviceID-0201.svg")); + break; + default: + break; + } + devicePic->setElementId("device"); + myDevice->devicePicture->scene()->addItem(devicePic); + myDevice->devicePicture->setSceneRect(devicePic->boundingRect()); + myDevice->devicePicture->fitInView(devicePic,Qt::KeepAspectRatio); + + QString serial = utilMngr->getBoardCPUSerial().toHex(); + myDevice->cpuSerial->setText(serial); + + status("Ready...", STATUSICON_INFO); + +} + + +/** + Updates status message + */ +void runningDeviceWidget::status(QString str, StatusIcon ic) +{ + QPixmap px; + myDevice->statusLabel->setText(str); + switch (ic) { + case STATUSICON_RUNNING: + px.load(QString(":/uploader/images/system-run.svg")); + break; + case STATUSICON_OK: + px.load(QString(":/uploader/images/dialog-apply.svg")); + break; + case STATUSICON_FAIL: + px.load(QString(":/uploader/images/process-stop.svg")); + break; + default: + px.load(QString(":/uploader/images/gtk-info.svg")); + } + myDevice->statusIcon->setPixmap(px); +} diff --git a/ground/openpilotgcs/src/plugins/uploader/runningdevicewidget.h b/ground/openpilotgcs/src/plugins/uploader/runningdevicewidget.h new file mode 100644 index 000000000..413a406fd --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uploader/runningdevicewidget.h @@ -0,0 +1,69 @@ +/** + ****************************************************************************** + * + * @file devicewidget.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup YModemUploader YModem Serial Uploader Plugin + * @{ + * @brief The YModem protocol serial uploader plugin + *****************************************************************************/ +/* + * This program 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. + * + * This program 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. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef RUNNINGDEVICEWIDGET_H +#define RUNNINGDEVICEWIDGET_H + +#include "ui_runningdevicewidget.h" +#include "uploadergadgetwidget.h" +#include +#include +#include +#include +#include "uavtalk/telemetrymanager.h" +#include "extensionsystem/pluginmanager.h" +#include "uavobjectmanager.h" +#include "uavobject.h" +#include "uavobjectutilmanager.h" + +class runningDeviceWidget : public QWidget +{ + Q_OBJECT +public: + runningDeviceWidget( QWidget *parent = 0); + void populate(); + void freeze(); + QString setOpenFileName(); + QString setSaveFileName(); + typedef enum { STATUSICON_OK, STATUSICON_RUNNING, STATUSICON_FAIL, STATUSICON_INFO} StatusIcon; + +private: + Ui_runningDeviceWidget *myDevice; + int deviceID; + QGraphicsSvgItem *devicePic; + void status(QString str, StatusIcon ic); + + +signals: + +protected: + void showEvent(QShowEvent *event); + void resizeEvent(QResizeEvent *event); + +}; + +#endif // RUNNINGDEVICEWIDGET_H diff --git a/ground/openpilotgcs/src/plugins/uploader/runningdevicewidget.ui b/ground/openpilotgcs/src/plugins/uploader/runningdevicewidget.ui new file mode 100644 index 000000000..105a385c7 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uploader/runningdevicewidget.ui @@ -0,0 +1,91 @@ + + + runningDeviceWidget + + + + 0 + 0 + 516 + 253 + + + + Form + + + + + + + + + + ic + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Status + + + + + + + + + DeviceID + + + + + + + CPU Serial: + + + + + + + + 160 + 160 + + + + background: transparent + + + QFrame::NoFrame + + + + + + + + + + + + + + + + diff --git a/ground/openpilotgcs/src/plugins/uploader/uploader.pro b/ground/openpilotgcs/src/plugins/uploader/uploader.pro index fac544066..05742868d 100755 --- a/ground/openpilotgcs/src/plugins/uploader/uploader.pro +++ b/ground/openpilotgcs/src/plugins/uploader/uploader.pro @@ -6,6 +6,7 @@ include(../../plugins/coreplugin/coreplugin.pri) include(../../plugins/uavobjects/uavobjects.pri) include(../../plugins/uavtalk/uavtalk.pri) include(../../plugins/rawhid/rawhid.pri) +include(../../plugins/uavobjectutil/uavobjectutil.pri) INCLUDEPATH += ../../libs/qextserialport/src HEADERS += uploadergadget.h \ @@ -20,7 +21,8 @@ HEADERS += uploadergadget.h \ SSP/port.h \ SSP/qssp.h \ SSP/qsspt.h \ - SSP/common.h + SSP/common.h \ + runningdevicewidget.h SOURCES += uploadergadget.cpp \ uploadergadgetconfiguration.cpp \ uploadergadgetfactory.cpp \ @@ -32,12 +34,14 @@ SOURCES += uploadergadget.cpp \ devicewidget.cpp \ SSP/port.cpp \ SSP/qssp.cpp \ - SSP/qsspt.cpp + SSP/qsspt.cpp \ + runningdevicewidget.cpp OTHER_FILES += Uploader.pluginspec FORMS += \ uploader.ui \ - devicewidget.ui + devicewidget.ui \ + runningdevicewidget.ui RESOURCES += \ uploader.qrc diff --git a/ground/openpilotgcs/src/plugins/uploader/uploader.qrc b/ground/openpilotgcs/src/plugins/uploader/uploader.qrc index c4dd1b347..1008ef3ba 100644 --- a/ground/openpilotgcs/src/plugins/uploader/uploader.qrc +++ b/ground/openpilotgcs/src/plugins/uploader/uploader.qrc @@ -9,5 +9,6 @@ images/deviceID-0301.svg images/deviceID-0201.svg images/deviceID-0101.svg + images/application-certificate.svg diff --git a/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.cpp b/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.cpp index dcbbb8fbd..8163d3968 100755 --- a/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.cpp @@ -115,6 +115,18 @@ void UploaderGadgetWidget::onAutopilotConnect(){ m_config->bootButton->setEnabled(false); m_config->rescueButton->setEnabled(false); m_config->telemetryLink->setEnabled(false); + + // Add a very simple widget with Board model & serial number + // Delete all previous tabs: + while (m_config->systemElements->count()) { + QWidget *qw = m_config->systemElements->widget(0); + m_config->systemElements->removeTab(0); + delete qw; + } + runningDeviceWidget* dw = new runningDeviceWidget(this); + dw->populate(); + m_config->systemElements->addTab(dw, QString("Connected Device")); + } /** diff --git a/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.h b/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.h index c0274668b..7c7bae19e 100755 --- a/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.h +++ b/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.h @@ -31,6 +31,7 @@ #include "ui_uploader.h" #include "delay.h" #include "devicewidget.h" +#include "runningdevicewidget.h" #include "op_dfu.h" #include #include