Unverified Commit d22f4886 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #7415 from DonLakeFlyer/LogReplay

Log replay changes
parents 2d8ae582 afe39436
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <QFileInfo> #include <QFileInfo>
#include <QtEndian> #include <QtEndian>
#include <QSignalSpy>
const char* LogReplayLinkConfiguration::_logFilenameKey = "logFilename"; const char* LogReplayLinkConfiguration::_logFilenameKey = "logFilename";
...@@ -368,7 +369,7 @@ void LogReplayLink::_readNextLogEntry(void) ...@@ -368,7 +369,7 @@ void LogReplayLink::_readNextLogEntry(void)
timeToNextExecutionMSecs = desiredPacedTimeMSecs - currentTimeMSecs; timeToNextExecutionMSecs = desiredPacedTimeMSecs - currentTimeMSecs;
} }
emit currentLogTimeSecs((_logCurrentTimeUSecs - _logStartTimeUSecs) / 1000000); _signalCurrentLogTimeSecs();
// And schedule the next execution of this function. // And schedule the next execution of this function.
_readTickTimer.start(timeToNextExecutionMSecs); _readTickTimer.start(timeToNextExecutionMSecs);
...@@ -450,8 +451,12 @@ void LogReplayLink::_resetPlaybackToBeginning(void) ...@@ -450,8 +451,12 @@ void LogReplayLink::_resetPlaybackToBeginning(void)
void LogReplayLink::movePlayhead(int percentComplete) void LogReplayLink::movePlayhead(int percentComplete)
{ {
if (isPlaying()) { if (isPlaying()) {
qWarning() << "Should not move playhead while playing, pause first"; _pauseOnThread();
return; QSignalSpy waitForPause(this, SIGNAL(playbackPaused));
waitForPause.wait();
if (_readTickTimer.isActive()) {
return;
}
} }
if (percentComplete < 0 || percentComplete > 100) { if (percentComplete < 0 || percentComplete > 100) {
...@@ -495,7 +500,8 @@ void LogReplayLink::movePlayhead(int percentComplete) ...@@ -495,7 +500,8 @@ void LogReplayLink::movePlayhead(int percentComplete)
// And scan until we reach the start of a MAVLink message. We make sure to record this timestamp for // And scan until we reach the start of a MAVLink message. We make sure to record this timestamp for
// smooth jumping around the file. // smooth jumping around the file.
_logCurrentTimeUSecs = _seekToNextMavlinkMessage(&dummy); _logCurrentTimeUSecs = _seekToNextMavlinkMessage(&dummy);
_signalCurrentLogTimeSecs();
// Now update the UI with our actual final position. // Now update the UI with our actual final position.
newRelativeTimeUSecs = (float)(_logCurrentTimeUSecs - _logStartTimeUSecs); newRelativeTimeUSecs = (float)(_logCurrentTimeUSecs - _logStartTimeUSecs);
percentComplete = (newRelativeTimeUSecs / _logDurationUSecs) * 100; percentComplete = (newRelativeTimeUSecs / _logDurationUSecs) * 100;
...@@ -561,3 +567,8 @@ void LogReplayLink::_playbackError(void) ...@@ -561,3 +567,8 @@ void LogReplayLink::_playbackError(void)
_logFile.close(); _logFile.close();
emit playbackError(); emit playbackError();
} }
void LogReplayLink::_signalCurrentLogTimeSecs(void)
{
emit currentLogTimeSecs((_logCurrentTimeUSecs - _logStartTimeUSecs) / 1000000);
}
...@@ -120,6 +120,7 @@ private: ...@@ -120,6 +120,7 @@ private:
void _finishPlayback(void); void _finishPlayback(void);
void _playbackError(void); void _playbackError(void);
void _resetPlaybackToBeginning(void); void _resetPlaybackToBeginning(void);
void _signalCurrentLogTimeSecs(void);
// Virtuals from LinkInterface // Virtuals from LinkInterface
virtual bool _connect(void); virtual bool _connect(void);
......
...@@ -271,7 +271,7 @@ void MainWindow::_buildCommonWidgets(void) ...@@ -271,7 +271,7 @@ void MainWindow::_buildCommonWidgets(void)
// Log player // Log player
// TODO: Make this optional with a preferences setting or under a "View" menu // TODO: Make this optional with a preferences setting or under a "View" menu
logPlayer = new QGCMAVLinkLogPlayer(statusBar()); logPlayer = new QGCMAVLinkLogPlayer(statusBar());
statusBar()->addPermanentWidget(logPlayer); statusBar()->addPermanentWidget(logPlayer, 1);
// Populate widget menu // Populate widget menu
for (int i = 0, end = ARRAY_SIZE(rgDockWidgetNames); i < end; i++) { for (int i = 0, end = ARRAY_SIZE(rgDockWidgetNames); i < end; i++) {
......
...@@ -142,7 +142,6 @@ void QGCMAVLinkLogPlayer::_playbackStarted(void) ...@@ -142,7 +142,6 @@ void QGCMAVLinkLogPlayer::_playbackStarted(void)
_enablePlaybackControls(true); _enablePlaybackControls(true);
_ui->playButton->setChecked(true); _ui->playButton->setChecked(true);
_ui->playButton->setIcon(QIcon(":/res/Pause")); _ui->playButton->setIcon(QIcon(":/res/Pause"));
_ui->positionSlider->setEnabled(false);
} }
/// Signalled from LogReplayLink when replay is paused /// Signalled from LogReplayLink when replay is paused
...@@ -150,7 +149,6 @@ void QGCMAVLinkLogPlayer::_playbackPaused(void) ...@@ -150,7 +149,6 @@ void QGCMAVLinkLogPlayer::_playbackPaused(void)
{ {
_ui->playButton->setIcon(QIcon(":/res/Play")); _ui->playButton->setIcon(QIcon(":/res/Play"));
_ui->playButton->setChecked(false); _ui->playButton->setChecked(false);
_ui->positionSlider->setEnabled(true);
} }
void QGCMAVLinkLogPlayer::_playbackPercentCompleteChanged(int percentComplete) void QGCMAVLinkLogPlayer::_playbackPercentCompleteChanged(int percentComplete)
......
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
<number>100</number> <number>100</number>
</property> </property>
<property name="tracking"> <property name="tracking">
<bool>false</bool> <bool>true</bool>
</property> </property>
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
......
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