From a374e26517515fbab68c1d8a15ad0ed235c531c8 Mon Sep 17 00:00:00 2001 From: pixhawk Date: Sat, 29 May 2010 15:52:54 +0200 Subject: [PATCH] Minor cleanups --- src/comm/MAVLinkProtocol.cc | 2 +- src/comm/ProtocolInterface.h | 3 ++- src/comm/UDPLink.cc | 4 +++- src/ui/CameraView.cc | 10 ++++++++-- src/ui/CameraView.h | 2 ++ src/ui/MainWindow.cc | 2 +- src/ui/uas/UASInfoWidget.cc | 10 ++++++++-- src/ui/uas/UASInfoWidget.h | 6 ++++-- 8 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/comm/MAVLinkProtocol.cc b/src/comm/MAVLinkProtocol.cc index 8899424..18e4b83 100644 --- a/src/comm/MAVLinkProtocol.cc +++ b/src/comm/MAVLinkProtocol.cc @@ -227,7 +227,7 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link) // qDebug() << "LOSSCHANGED" << receiveLoss; currLossCounter = 0; currReceiveCounter = 0; - emit receiveLossChanged(receiveLoss); + emit receiveLossChanged(message.sysid, receiveLoss); } // The packet is emitted as a whole, as it is only 255 - 261 bytes short diff --git a/src/comm/ProtocolInterface.h b/src/comm/ProtocolInterface.h index c2e998c..fc84675 100644 --- a/src/comm/ProtocolInterface.h +++ b/src/comm/ProtocolInterface.h @@ -56,7 +56,8 @@ public slots: virtual void receiveBytes(LinkInterface *link) = 0; signals: - void receiveLossChanged(float loss); + /** @brief Update the packet loss from one system */ + void receiveLossChanged(int uasId, float loss); }; diff --git a/src/comm/UDPLink.cc b/src/comm/UDPLink.cc index 3891678..fb94298 100644 --- a/src/comm/UDPLink.cc +++ b/src/comm/UDPLink.cc @@ -67,7 +67,9 @@ void UDPLink::run() void UDPLink::setAddress(QString address) { - // TODO Implement address + Q_UNUSED(address); + // FIXME TODO Implement address + //socket->setLocalAddress(QHostAddress(address)); } void UDPLink::setPort(quint16 port) diff --git a/src/ui/CameraView.cc b/src/ui/CameraView.cc index 1563ede..c19f514 100644 --- a/src/ui/CameraView.cc +++ b/src/ui/CameraView.cc @@ -44,8 +44,9 @@ CameraView::CameraView(int width, int height, int depth, int channels, QWidget* //setImageSize(width, height, depth, channels); receivedWidth = width; receivedHeight = height; - receivedDepth = 8; - receivedChannels = 1; + receivedDepth = depth; + receivedChannels = channels; + imageId = -1; // Fill with black background QImage fill = QImage(width, height, QImage::Format_Indexed8); @@ -139,6 +140,7 @@ void CameraView::setImageSize(int width, int height, int depth, int channels) void CameraView::startImage(int imgid, int width, int height, int depth, int channels) { + this->imageId = imgid; //qDebug() << "CameraView: starting image (" << width << "x" << height << ", " << depth << "bits) with " << channels << "channels"; // Copy previous image to screen if it hasn't been finished properly @@ -208,6 +210,10 @@ void CameraView::saveImage() void CameraView::setPixels(int imgid, const unsigned char* imageData, int length, unsigned int startIndex) { + // FIXME imgid can be used to receive and then display multiple images + // the image buffer should be converted into a n image buffer. + Q_UNUSED(imgid); + // qDebug() << "at" << __FILE__ << __LINE__ << ": Received startindex" << startIndex << "and length" << length << "(" << startIndex+length << "of" << rawExpectedBytes << "bytes)"; if (imageStarted) diff --git a/src/ui/CameraView.h b/src/ui/CameraView.h index db9b1e8..07b6e56 100644 --- a/src/ui/CameraView.h +++ b/src/ui/CameraView.h @@ -71,6 +71,8 @@ protected: int receivedChannels; int receivedWidth; int receivedHeight; + QMap images; ///< Reference to the received images + int imageId; ///< ID of the currently displayed image void commitRawDataToGL(); }; diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index f6c29bf..9e7584b 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -166,7 +166,7 @@ settings() adjustSize(); // - connect(mavlink, SIGNAL(receiveLossChanged(float)), info, SLOT(updateSendLoss(float))); + connect(mavlink, SIGNAL(receiveLossChanged(int, float)), info, SLOT(updateSendLoss(int, float))); } MainWindow::~MainWindow() diff --git a/src/ui/uas/UASInfoWidget.cc b/src/ui/uas/UASInfoWidget.cc index 989be0d..8a0535a 100644 --- a/src/ui/uas/UASInfoWidget.cc +++ b/src/ui/uas/UASInfoWidget.cc @@ -117,13 +117,19 @@ void UASInfoWidget::updateCPULoad(UASInterface* uas, double load) } } -void UASInfoWidget::updateReceiveLoss(float receiveLoss) +void UASInfoWidget::updateReceiveLoss(int uasId, float receiveLoss) { + Q_UNUSED(uasId); this->receiveLoss = this->receiveLoss * 0.8f + receiveLoss * 0.2f; } -void UASInfoWidget::updateSendLoss(float sendLoss) +/** + The send loss is typically calculated on the GCS based on packets + that were received scrambled from the MAV + */ +void UASInfoWidget::updateSendLoss(int uasId, float sendLoss) { + Q_UNUSED(uasId); this->sendLoss = this->sendLoss * 0.8f + sendLoss * 0.2f; } diff --git a/src/ui/uas/UASInfoWidget.h b/src/ui/uas/UASInfoWidget.h index 9eb66d4..065fa9b 100644 --- a/src/ui/uas/UASInfoWidget.h +++ b/src/ui/uas/UASInfoWidget.h @@ -56,8 +56,10 @@ public slots: void updateBattery(UASInterface* uas, double voltage, double percent, int seconds); void updateCPULoad(UASInterface* uas, double load); - void updateReceiveLoss(float receiveLoss); - void updateSendLoss(float sendLoss); + /** @brief Set the loss rate of packets received by the MAV */ + void updateReceiveLoss(int uasId, float receiveLoss); + /** @brief Set the loss rate of packets sent from the MAV */ + void updateSendLoss(int uasId, float sendLoss); void setVoltage(UASInterface* uas, double voltage); void setChargeLevel(UASInterface* uas, double chargeLevel);