Commit efb95d00 authored by LM's avatar LM

Fixed log buttons, replay pausing does not work yet properly, but issue / solution is now known

parent c31ba506
...@@ -63,8 +63,10 @@ MAVLinkProtocol::MAVLinkProtocol() : ...@@ -63,8 +63,10 @@ MAVLinkProtocol::MAVLinkProtocol() :
totalLossCounter = 0; totalLossCounter = 0;
currReceiveCounter = 0; currReceiveCounter = 0;
currLossCounter = 0; currLossCounter = 0;
for (int i = 0; i < 256; i++) { for (int i = 0; i < 256; i++)
for (int j = 0; j < 256; j++) { {
for (int j = 0; j < 256; j++)
{
lastIndex[i][j] = -1; lastIndex[i][j] = -1;
} }
} }
...@@ -83,9 +85,12 @@ void MAVLinkProtocol::loadSettings() ...@@ -83,9 +85,12 @@ void MAVLinkProtocol::loadSettings()
enableMultiplexing(settings.value("MULTIPLEXING_ENABLED", m_multiplexingEnabled).toBool()); enableMultiplexing(settings.value("MULTIPLEXING_ENABLED", m_multiplexingEnabled).toBool());
// Only set logfile if there is a name present in settings // Only set logfile if there is a name present in settings
if (settings.contains("LOGFILE_NAME") && m_logfile == NULL) { if (settings.contains("LOGFILE_NAME") && m_logfile == NULL)
{
m_logfile = new QFile(settings.value("LOGFILE_NAME").toString()); m_logfile = new QFile(settings.value("LOGFILE_NAME").toString());
} else if (m_logfile == NULL) { }
else if (m_logfile == NULL)
{
m_logfile = new QFile(QDesktopServices::storageLocation(QDesktopServices::HomeLocation) + "/qgroundcontrol_packetlog.mavlink"); m_logfile = new QFile(QDesktopServices::storageLocation(QDesktopServices::HomeLocation) + "/qgroundcontrol_packetlog.mavlink");
} }
// Enable logging // Enable logging
...@@ -93,7 +98,8 @@ void MAVLinkProtocol::loadSettings() ...@@ -93,7 +98,8 @@ void MAVLinkProtocol::loadSettings()
// Only set system id if it was valid // Only set system id if it was valid
int temp = settings.value("GCS_SYSTEM_ID", systemId).toInt(); int temp = settings.value("GCS_SYSTEM_ID", systemId).toInt();
if (temp > 0 && temp < 256) { if (temp > 0 && temp < 256)
{
systemId = temp; systemId = temp;
} }
...@@ -123,7 +129,8 @@ void MAVLinkProtocol::storeSettings() ...@@ -123,7 +129,8 @@ void MAVLinkProtocol::storeSettings()
settings.setValue("GCS_SYSTEM_ID", systemId); settings.setValue("GCS_SYSTEM_ID", systemId);
settings.setValue("GCS_AUTH_KEY", m_authKey); settings.setValue("GCS_AUTH_KEY", m_authKey);
settings.setValue("GCS_AUTH_ENABLED", m_authEnabled); settings.setValue("GCS_AUTH_ENABLED", m_authEnabled);
if (m_logfile) { if (m_logfile)
{
// Logfile exists, store the name // Logfile exists, store the name
settings.setValue("LOGFILE_NAME", m_logfile->fileName()); settings.setValue("LOGFILE_NAME", m_logfile->fileName());
} }
...@@ -139,20 +146,26 @@ void MAVLinkProtocol::storeSettings() ...@@ -139,20 +146,26 @@ void MAVLinkProtocol::storeSettings()
MAVLinkProtocol::~MAVLinkProtocol() MAVLinkProtocol::~MAVLinkProtocol()
{ {
storeSettings(); storeSettings();
if (m_logfile) { if (m_logfile)
if (m_logfile->isOpen()) { {
if (m_logfile->isOpen())
{
m_logfile->flush(); m_logfile->flush();
m_logfile->close(); m_logfile->close();
} }
delete m_logfile; delete m_logfile;
m_logfile = NULL;
} }
} }
QString MAVLinkProtocol::getLogfileName() QString MAVLinkProtocol::getLogfileName()
{ {
if (m_logfile) { if (m_logfile)
{
return m_logfile->fileName(); return m_logfile->fileName();
} else { }
else
{
return QDesktopServices::storageLocation(QDesktopServices::HomeLocation) + "/qgroundcontrol_packetlog.mavlink"; return QDesktopServices::storageLocation(QDesktopServices::HomeLocation) + "/qgroundcontrol_packetlog.mavlink";
} }
} }
...@@ -174,7 +187,8 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) ...@@ -174,7 +187,8 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
for (int position = 0; position < b.size(); position++) { for (int position = 0; position < b.size(); position++) {
unsigned int decodeState = mavlink_parse_char(link->getId(), (uint8_t)(b.at(position)), &message, &status); unsigned int decodeState = mavlink_parse_char(link->getId(), (uint8_t)(b.at(position)), &message, &status);
if (decodeState == 1) { if (decodeState == 1)
{
//#ifdef MAVLINK_MESSAGE_LENGTHS //#ifdef MAVLINK_MESSAGE_LENGTHS
// const uint8_t message_lengths[] = MAVLINK_MESSAGE_LENGTHS; // const uint8_t message_lengths[] = MAVLINK_MESSAGE_LENGTHS;
// if (message.msgid >= sizeof(message_lengths) || // if (message.msgid >= sizeof(message_lengths) ||
...@@ -216,7 +230,8 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) ...@@ -216,7 +230,8 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
#endif #endif
// Log data // Log data
if (m_loggingEnabled && m_logfile) { if (m_loggingEnabled && m_logfile)
{
const int len = MAVLINK_MAX_PACKET_LEN+sizeof(quint64); const int len = MAVLINK_MAX_PACKET_LEN+sizeof(quint64);
uint8_t buf[len]; uint8_t buf[len];
quint64 time = QGC::groundTimeUsecs(); quint64 time = QGC::groundTimeUsecs();
...@@ -224,7 +239,8 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) ...@@ -224,7 +239,8 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
// Write message to buffer // Write message to buffer
mavlink_msg_to_send_buffer(buf+sizeof(quint64), &message); mavlink_msg_to_send_buffer(buf+sizeof(quint64), &message);
QByteArray b((const char*)buf, len); QByteArray b((const char*)buf, len);
if(m_logfile->write(b) < static_cast<qint64>(MAVLINK_MAX_PACKET_LEN+sizeof(quint64))) { if(m_logfile->write(b) < static_cast<qint64>(MAVLINK_MAX_PACKET_LEN+sizeof(quint64)))
{
emit protocolStatusMessage(tr("MAVLink Logging failed"), tr("Could not write to file %1, disabling logging.").arg(m_logfile->fileName())); emit protocolStatusMessage(tr("MAVLink Logging failed"), tr("Could not write to file %1, disabling logging.").arg(m_logfile->fileName()));
// Stop logging // Stop logging
enableLogging(false); enableLogging(false);
...@@ -238,7 +254,8 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) ...@@ -238,7 +254,8 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
UASInterface* uas = UASManager::instance()->getUASForId(message.sysid); UASInterface* uas = UASManager::instance()->getUASForId(message.sysid);
// Check and (if necessary) create UAS object // Check and (if necessary) create UAS object
if (uas == NULL && message.msgid == MAVLINK_MSG_ID_HEARTBEAT) { if (uas == NULL && message.msgid == MAVLINK_MSG_ID_HEARTBEAT)
{
// ORDER MATTERS HERE! // ORDER MATTERS HERE!
// The UAS object has first to be created and connected, // The UAS object has first to be created and connected,
// only then the rest of the application can be made aware // only then the rest of the application can be made aware
...@@ -246,7 +263,8 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) ...@@ -246,7 +263,8 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
// it's first messages. // it's first messages.
// Check if the UAS has the same id like this system // Check if the UAS has the same id like this system
if (message.sysid == getSystemId()) { if (message.sysid == getSystemId())
{
emit protocolStatusMessage(tr("SYSTEM ID CONFLICT!"), tr("Warning: A second system is using the same system id (%1)").arg(getSystemId())); emit protocolStatusMessage(tr("SYSTEM ID CONFLICT!"), tr("Warning: A second system is using the same system id (%1)").arg(getSystemId()));
} }
...@@ -262,9 +280,11 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) ...@@ -262,9 +280,11 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
mavlink_msg_heartbeat_decode(&message, &heartbeat); mavlink_msg_heartbeat_decode(&message, &heartbeat);
// Check if the UAS has a different protocol version // Check if the UAS has a different protocol version
if (m_enable_version_check && (heartbeat.mavlink_version != MAVLINK_VERSION)) { if (m_enable_version_check && (heartbeat.mavlink_version != MAVLINK_VERSION))
{
// Bring up dialog to inform user // Bring up dialog to inform user
if (!versionMismatchIgnore) { if (!versionMismatchIgnore)
{
emit protocolStatusMessage(tr("The MAVLink protocol version on the MAV and QGroundControl mismatch!"), emit protocolStatusMessage(tr("The MAVLink protocol version on the MAV and QGroundControl mismatch!"),
tr("It is unsafe to use different MAVLink versions. QGroundControl therefore refuses to connect to system %1, which sends MAVLink version %2 (QGroundControl uses version %3).").arg(message.sysid).arg(heartbeat.mavlink_version).arg(MAVLINK_VERSION)); tr("It is unsafe to use different MAVLink versions. QGroundControl therefore refuses to connect to system %1, which sends MAVLink version %2 (QGroundControl uses version %3).").arg(message.sysid).arg(heartbeat.mavlink_version).arg(MAVLINK_VERSION));
versionMismatchIgnore = true; versionMismatchIgnore = true;
...@@ -279,28 +299,39 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) ...@@ -279,28 +299,39 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
} }
// Only count message if UAS exists for this message // Only count message if UAS exists for this message
if (uas != NULL) { if (uas != NULL)
{
// Increase receive counter // Increase receive counter
totalReceiveCounter++; totalReceiveCounter++;
currReceiveCounter++; currReceiveCounter++;
qint64 lastLoss = totalLossCounter; qint64 lastLoss = totalLossCounter;
// Update last packet index // Update last packet index
if (lastIndex[message.sysid][message.compid] == -1) { if (lastIndex[message.sysid][message.compid] == -1)
{
lastIndex[message.sysid][message.compid] = message.seq; lastIndex[message.sysid][message.compid] = message.seq;
} else { }
else
{
// TODO: This if-else block can (should) be greatly simplified // TODO: This if-else block can (should) be greatly simplified
if (lastIndex[message.sysid][message.compid] == 255) { if (lastIndex[message.sysid][message.compid] == 255)
{
lastIndex[message.sysid][message.compid] = 0; lastIndex[message.sysid][message.compid] = 0;
} else { }
else
{
lastIndex[message.sysid][message.compid]++; lastIndex[message.sysid][message.compid]++;
} }
int safeguard = 0; int safeguard = 0;
//qDebug() << "SYSID" << message.sysid << "COMPID" << message.compid << "MSGID" << message.msgid << "LASTINDEX" << lastIndex[message.sysid][message.compid] << "SEQ" << message.seq; //qDebug() << "SYSID" << message.sysid << "COMPID" << message.compid << "MSGID" << message.msgid << "LASTINDEX" << lastIndex[message.sysid][message.compid] << "SEQ" << message.seq;
while(lastIndex[message.sysid][message.compid] != message.seq && safeguard < 255) { while(lastIndex[message.sysid][message.compid] != message.seq && safeguard < 255)
if (lastIndex[message.sysid][message.compid] == 255) { {
if (lastIndex[message.sysid][message.compid] == 255)
{
lastIndex[message.sysid][message.compid] = 0; lastIndex[message.sysid][message.compid] = 0;
} else { }
else
{
lastIndex[message.sysid][message.compid]++; lastIndex[message.sysid][message.compid]++;
} }
totalLossCounter++; totalLossCounter++;
...@@ -317,7 +348,8 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) ...@@ -317,7 +348,8 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
//if () //if ()
// If a new loss was detected or we just hit one 128th packet step // If a new loss was detected or we just hit one 128th packet step
if (lastLoss != totalLossCounter || (totalReceiveCounter % 64 == 0)) { if (lastLoss != totalLossCounter || (totalReceiveCounter % 64 == 0))
{
// Calculate new loss ratio // Calculate new loss ratio
// Receive loss // Receive loss
float receiveLoss = (double)currLossCounter/(double)(currReceiveCounter+currLossCounter); float receiveLoss = (double)currLossCounter/(double)(currReceiveCounter+currLossCounter);
...@@ -335,12 +367,14 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) ...@@ -335,12 +367,14 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
emit messageReceived(link, message); emit messageReceived(link, message);
// Multiplex message if enabled // Multiplex message if enabled
if (m_multiplexingEnabled) { if (m_multiplexingEnabled)
{
// Get all links connected to this unit // Get all links connected to this unit
QList<LinkInterface*> links = LinkManager::instance()->getLinksForProtocol(this); QList<LinkInterface*> links = LinkManager::instance()->getLinksForProtocol(this);
// Emit message on all links that are currently connected // Emit message on all links that are currently connected
foreach (LinkInterface* currLink, links) { foreach (LinkInterface* currLink, links)
{
// Only forward this message to the other links, // Only forward this message to the other links,
// not the link the message was received on // not the link the message was received on
if (currLink != link) sendMessage(currLink, message); if (currLink != link) sendMessage(currLink, message);
...@@ -387,7 +421,8 @@ void MAVLinkProtocol::sendMessage(mavlink_message_t message) ...@@ -387,7 +421,8 @@ void MAVLinkProtocol::sendMessage(mavlink_message_t message)
// Emit message on all links that are currently connected // Emit message on all links that are currently connected
QList<LinkInterface*>::iterator i; QList<LinkInterface*>::iterator i;
for (i = links.begin(); i != links.end(); ++i) { for (i = links.begin(); i != links.end(); ++i)
{
sendMessage(*i, message); sendMessage(*i, message);
//qDebug() << __FILE__ << __LINE__ << "SENT MESSAGE OVER" << ((LinkInterface*)*i)->getName() << "LIST SIZE:" << links.size(); //qDebug() << __FILE__ << __LINE__ << "SENT MESSAGE OVER" << ((LinkInterface*)*i)->getName() << "LIST SIZE:" << links.size();
} }
...@@ -407,7 +442,8 @@ void MAVLinkProtocol::sendMessage(LinkInterface* link, mavlink_message_t message ...@@ -407,7 +442,8 @@ void MAVLinkProtocol::sendMessage(LinkInterface* link, mavlink_message_t message
// Write message into buffer, prepending start sign // Write message into buffer, prepending start sign
int len = mavlink_msg_to_send_buffer(buffer, &message); int len = mavlink_msg_to_send_buffer(buffer, &message);
// If link is connected // If link is connected
if (link->isConnected()) { if (link->isConnected())
{
// Send the portion of the buffer now occupied by the message // Send the portion of the buffer now occupied by the message
link->writeBytes((const char*)buffer, len); link->writeBytes((const char*)buffer, len);
} }
...@@ -506,25 +542,36 @@ void MAVLinkProtocol::enableLogging(bool enabled) ...@@ -506,25 +542,36 @@ void MAVLinkProtocol::enableLogging(bool enabled)
bool changed = false; bool changed = false;
if (enabled != m_loggingEnabled) changed = true; if (enabled != m_loggingEnabled) changed = true;
if (enabled) { if (enabled)
if (m_logfile && m_logfile->isOpen()) { {
if (m_logfile && m_logfile->isOpen())
{
m_logfile->flush(); m_logfile->flush();
m_logfile->close(); m_logfile->close();
} }
if (m_logfile) {
if (!m_logfile->open(QIODevice::WriteOnly | QIODevice::Append)) { if (m_logfile)
{
if (!m_logfile->open(QIODevice::WriteOnly | QIODevice::Append))
{
emit protocolStatusMessage(tr("Opening MAVLink logfile for writing failed"), tr("MAVLink cannot log to the file %1, please choose a different file. Stopping logging.").arg(m_logfile->fileName())); emit protocolStatusMessage(tr("Opening MAVLink logfile for writing failed"), tr("MAVLink cannot log to the file %1, please choose a different file. Stopping logging.").arg(m_logfile->fileName()));
m_loggingEnabled = false; m_loggingEnabled = false;
} }
} }
} else if (!enabled) { else
if (m_logfile) { {
if (m_logfile->isOpen()) { emit protocolStatusMessage(tr("Opening MAVLink logfile for writing failed"), tr("MAVLink cannot start logging, no logfile selected."));
}
}
else if (!enabled)
{
if (m_logfile)
{
if (m_logfile->isOpen())
{
m_logfile->flush(); m_logfile->flush();
m_logfile->close(); m_logfile->close();
} }
delete m_logfile;
m_logfile = NULL;
} }
} }
m_loggingEnabled = enabled; m_loggingEnabled = enabled;
...@@ -533,9 +580,12 @@ void MAVLinkProtocol::enableLogging(bool enabled) ...@@ -533,9 +580,12 @@ void MAVLinkProtocol::enableLogging(bool enabled)
void MAVLinkProtocol::setLogfileName(const QString& filename) void MAVLinkProtocol::setLogfileName(const QString& filename)
{ {
if (!m_logfile) { if (!m_logfile)
{
m_logfile = new QFile(filename); m_logfile = new QFile(filename);
} else { }
else
{
m_logfile->flush(); m_logfile->flush();
m_logfile->close(); m_logfile->close();
} }
......
...@@ -161,12 +161,14 @@ void MAVLinkSettingsWidget::chooseLogfileName() ...@@ -161,12 +161,14 @@ void MAVLinkSettingsWidget::chooseLogfileName()
{ {
QString fileName = QFileDialog::getSaveFileName(this, tr("Specify MAVLink log file name"), QDesktopServices::storageLocation(QDesktopServices::DesktopLocation), tr("MAVLink Logfile (*.mavlink);;")); QString fileName = QFileDialog::getSaveFileName(this, tr("Specify MAVLink log file name"), QDesktopServices::storageLocation(QDesktopServices::DesktopLocation), tr("MAVLink Logfile (*.mavlink);;"));
if (!fileName.endsWith(".mavlink")) { if (!fileName.endsWith(".mavlink"))
{
fileName.append(".mavlink"); fileName.append(".mavlink");
} }
QFileInfo file(fileName); QFileInfo file(fileName);
if (file.exists() && !file.isWritable()) { if (file.exists() && !file.isWritable())
{
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical); msgBox.setIcon(QMessageBox::Critical);
msgBox.setText(tr("The selected logfile is not writable")); msgBox.setText(tr("The selected logfile is not writable"));
...@@ -174,7 +176,9 @@ void MAVLinkSettingsWidget::chooseLogfileName() ...@@ -174,7 +176,9 @@ void MAVLinkSettingsWidget::chooseLogfileName()
msgBox.setStandardButtons(QMessageBox::Ok); msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok); msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec(); msgBox.exec();
} else { }
else
{
updateLogfileName(fileName); updateLogfileName(fileName);
protocol->setLogfileName(fileName); protocol->setLogfileName(fileName);
} }
...@@ -189,12 +193,15 @@ void MAVLinkSettingsWidget::enableDroneOS(bool enable) ...@@ -189,12 +193,15 @@ void MAVLinkSettingsWidget::enableDroneOS(bool enable)
// Delete from all lists first // Delete from all lists first
UDPLink* firstUdp = NULL; UDPLink* firstUdp = NULL;
QList<LinkInterface*> links = LinkManager::instance()->getLinksForProtocol(protocol); QList<LinkInterface*> links = LinkManager::instance()->getLinksForProtocol(protocol);
foreach (LinkInterface* link, links) { foreach (LinkInterface* link, links)
{
UDPLink* udp = dynamic_cast<UDPLink*>(link); UDPLink* udp = dynamic_cast<UDPLink*>(link);
if (udp) { if (udp)
{
if (!firstUdp) firstUdp = udp; if (!firstUdp) firstUdp = udp;
// Remove current hosts // Remove current hosts
for (int i = 0; i < m_ui->droneOSComboBox->count(); ++i) { for (int i = 0; i < m_ui->droneOSComboBox->count(); ++i)
{
QString oldHostString = m_ui->droneOSComboBox->itemText(i); QString oldHostString = m_ui->droneOSComboBox->itemText(i);
oldHostString = hostString.split(":").first(); oldHostString = hostString.split(":").first();
udp->removeHost(oldHostString); udp->removeHost(oldHostString);
...@@ -203,8 +210,10 @@ void MAVLinkSettingsWidget::enableDroneOS(bool enable) ...@@ -203,8 +210,10 @@ void MAVLinkSettingsWidget::enableDroneOS(bool enable)
} }
// Re-add if enabled // Re-add if enabled
if (enable) { if (enable)
if (firstUdp) { {
if (firstUdp)
{
firstUdp->addHost(hostString); firstUdp->addHost(hostString);
} }
// Set key // Set key
......
...@@ -21,6 +21,7 @@ QGCMAVLinkLogPlayer::QGCMAVLinkLogPlayer(MAVLinkProtocol* mavlink, QWidget *pare ...@@ -21,6 +21,7 @@ QGCMAVLinkLogPlayer::QGCMAVLinkLogPlayer(MAVLinkProtocol* mavlink, QWidget *pare
mavlinkLogFormat(true), mavlinkLogFormat(true),
binaryBaudRate(57600), binaryBaudRate(57600),
isPlaying(false), isPlaying(false),
currPacketCount(0),
ui(new Ui::QGCMAVLinkLogPlayer) ui(new Ui::QGCMAVLinkLogPlayer)
{ {
ui->setupUi(this); ui->setupUi(this);
...@@ -102,6 +103,7 @@ void QGCMAVLinkLogPlayer::play() ...@@ -102,6 +103,7 @@ void QGCMAVLinkLogPlayer::play()
loopTimer.start(interval*accelerationFactor); loopTimer.start(interval*accelerationFactor);
} }
isPlaying = true; isPlaying = true;
ui->logStatsLabel->setText(tr("Started playing.."));
ui->playButton->setIcon(QIcon(":images/actions/media-playback-pause.svg")); ui->playButton->setIcon(QIcon(":images/actions/media-playback-pause.svg"));
} }
else else
...@@ -272,7 +274,8 @@ bool QGCMAVLinkLogPlayer::loadLogFile(const QString& file) ...@@ -272,7 +274,8 @@ bool QGCMAVLinkLogPlayer::loadLogFile(const QString& file)
minutes -= 60*hours; minutes -= 60*hours;
QString timelabel = tr("%1h:%2m:%3s").arg(hours, 2).arg(minutes, 2).arg(seconds, 2); QString timelabel = tr("%1h:%2m:%3s").arg(hours, 2).arg(minutes, 2).arg(seconds, 2);
ui->logStatsLabel->setText(tr("%2 MB, %3 packets, %4").arg(logFileInfo.size()/1000000.0f, 0, 'f', 2).arg(logFileInfo.size()/(MAVLINK_MAX_PACKET_LEN+sizeof(quint64))).arg(timelabel)); currPacketCount = logFileInfo.size()/(MAVLINK_MAX_PACKET_LEN+sizeof(quint64));
ui->logStatsLabel->setText(tr("%2 MB, %3 packets, %4").arg(logFileInfo.size()/1000000.0f, 0, 'f', 2).arg(currPacketCount).arg(timelabel));
} }
else else
{ {
...@@ -302,6 +305,10 @@ bool QGCMAVLinkLogPlayer::loadLogFile(const QString& file) ...@@ -302,6 +305,10 @@ bool QGCMAVLinkLogPlayer::loadLogFile(const QString& file)
QString timelabel = tr("%1h:%2m:%3s").arg(hours, 2).arg(minutes, 2).arg(seconds, 2); QString timelabel = tr("%1h:%2m:%3s").arg(hours, 2).arg(minutes, 2).arg(seconds, 2);
ui->logStatsLabel->setText(tr("%2 MB, %4 at %5 KB/s").arg(logFileInfo.size()/1000000.0f, 0, 'f', 2).arg(timelabel).arg(binaryBaudRate/10.0f/1024.0f, 0, 'f', 2)); ui->logStatsLabel->setText(tr("%2 MB, %4 at %5 KB/s").arg(logFileInfo.size()/1000000.0f, 0, 'f', 2).arg(timelabel).arg(binaryBaudRate/10.0f/1024.0f, 0, 'f', 2));
} }
// Reset current state
reset(0);
return true; return true;
} }
} }
...@@ -458,7 +465,7 @@ void QGCMAVLinkLogPlayer::logLoop() ...@@ -458,7 +465,7 @@ void QGCMAVLinkLogPlayer::logLoop()
// Update status label // Update status label
// Update progress bar // Update progress bar
if (loopCounter % 40 == 0) if (loopCounter % 40 == 0 || currPacketCount < 500)
{ {
QFileInfo logFileInfo(logFile); QFileInfo logFileInfo(logFile);
int progress = (ui->positionSlider->maximum()-ui->positionSlider->minimum())*(logFile.pos()/static_cast<float>(logFileInfo.size())); int progress = (ui->positionSlider->maximum()-ui->positionSlider->minimum())*(logFile.pos()/static_cast<float>(logFileInfo.size()));
......
...@@ -78,6 +78,7 @@ protected: ...@@ -78,6 +78,7 @@ protected:
bool mavlinkLogFormat; bool mavlinkLogFormat;
int binaryBaudRate; int binaryBaudRate;
bool isPlaying; bool isPlaying;
unsigned int currPacketCount;
static const int packetLen = MAVLINK_MAX_PACKET_LEN; static const int packetLen = MAVLINK_MAX_PACKET_LEN;
static const int timeLen = sizeof(quint64); static const int timeLen = sizeof(quint64);
void changeEvent(QEvent *e); void changeEvent(QEvent *e);
......
...@@ -45,7 +45,7 @@ QGCToolBar::QGCToolBar(QWidget *parent) : ...@@ -45,7 +45,7 @@ QGCToolBar::QGCToolBar(QWidget *parent) :
toggleLoggingAction = new QAction(QIcon(":"), "Logging", this); toggleLoggingAction = new QAction(QIcon(":"), "Logging", this);
toggleLoggingAction->setCheckable(true); toggleLoggingAction->setCheckable(true);
logReplayAction = new QAction(QIcon(":"), "Replay", this); logReplayAction = new QAction(QIcon(":"), "Replay", this);
logReplayAction->setCheckable(true); logReplayAction->setCheckable(false);
addAction(toggleLoggingAction); addAction(toggleLoggingAction);
addAction(logReplayAction); addAction(logReplayAction);
...@@ -143,7 +143,7 @@ void QGCToolBar::logging(bool enabled) ...@@ -143,7 +143,7 @@ void QGCToolBar::logging(bool enabled)
} }
QFileInfo file(fileName); QFileInfo file(fileName);
if (file.exists() && !file.isWritable()) if ((file.exists() && !file.isWritable()))
{ {
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical); msgBox.setIcon(QMessageBox::Critical);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment