Skip to content

Commit ba0869c

Browse files
committed
LP-597 Don't disable playback when the end of the logfile has been reached.
- instead, do the same as the user pressing the stop button.
1 parent 684849f commit ba0869c

4 files changed

Lines changed: 73 additions & 21 deletions

File tree

ground/gcs/src/libs/utils/logfile.cpp

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ void LogFile::timerFired()
182182
qint64 dataSize;
183183
if (m_file.bytesAvailable() < (qint64)sizeof(dataSize)) {
184184
qDebug() << "LogFile replay - end of log file reached";
185-
stopReplay();
185+
resetReplay();
186186
return;
187187
}
188188
m_file.read((char *)&dataSize, sizeof(dataSize));
@@ -197,7 +197,7 @@ void LogFile::timerFired()
197197
// read data
198198
if (m_file.bytesAvailable() < dataSize) {
199199
qDebug() << "LogFile replay - end of log file reached";
200-
stopReplay();
200+
resetReplay();
201201
return;
202202
}
203203
QByteArray data = m_file.read(dataSize);
@@ -216,7 +216,7 @@ void LogFile::timerFired()
216216
// read next timestamp
217217
if (m_file.bytesAvailable() < (qint64)sizeof(m_nextTimeStamp)) {
218218
qDebug() << "LogFile replay - end of log file reached";
219-
stopReplay();
219+
resetReplay();
220220
return;
221221
}
222222
m_previousTimeStamp = m_nextTimeStamp;
@@ -235,7 +235,7 @@ void LogFile::timerFired()
235235
}
236236
} else {
237237
qDebug() << "LogFile replay - end of log file reached";
238-
stopReplay();
238+
resetReplay();
239239
}
240240
}
241241

@@ -319,6 +319,31 @@ bool LogFile::stopReplay()
319319
return true;
320320
}
321321

322+
/**
323+
* FUNCTION: resetReplay()
324+
*
325+
* Stops replaying the logfile.
326+
* Stops the timer: m_timer
327+
* Resets playback position to the start of the logfile
328+
* through the emission of a replayCompleted signal.
329+
*
330+
*/
331+
bool LogFile::resetReplay()
332+
{
333+
if (!m_file.isOpen()) {
334+
return false;
335+
}
336+
if (m_timer.isActive()) {
337+
m_timer.stop();
338+
}
339+
340+
qDebug() << "LogFile - resetReplay";
341+
m_replayState = STOPPED;
342+
343+
emit replayCompleted();
344+
return true;
345+
}
346+
322347
/**
323348
* SLOT: resumeReplay()
324349
*

ground/gcs/src/libs/utils/logfile.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ protected slots:
9797

9898
signals:
9999
void replayStarted();
100-
void replayFinished();
100+
void replayFinished(); // Emitted on error during replay or when logfile disconnected
101+
void replayCompleted(); // Emitted at the end of normal logfile playback
101102
void setPlaybackPosition(quint32);
102103
void setBeginAndEndTimes(quint32, quint32);
103104

@@ -127,6 +128,7 @@ protected slots:
127128
QVector<qint64> m_timeStampPositions;
128129

129130
bool buildIndex();
131+
bool resetReplay();
130132
};
131133

132134
#endif // LOGFILE_H

ground/gcs/src/plugins/logging/logging.ui

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@
3232
<number>3</number>
3333
</property>
3434
<item>
35-
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,2,0,0,2,0,0">
35+
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0,2,0,0,2,0,0">
36+
<property name="spacing">
37+
<number>4</number>
38+
</property>
3639
<property name="sizeConstraint">
3740
<enum>QLayout::SetNoConstraint</enum>
3841
</property>
@@ -50,13 +53,13 @@
5053
<property name="minimumSize">
5154
<size>
5255
<width>39</width>
53-
<height>38</height>
56+
<height>30</height>
5457
</size>
5558
</property>
56-
<property name="baseSize">
59+
<property name="maximumSize">
5760
<size>
5861
<width>39</width>
59-
<height>38</height>
62+
<height>30</height>
6063
</size>
6164
</property>
6265
<property name="focusPolicy">
@@ -88,7 +91,13 @@
8891
<property name="minimumSize">
8992
<size>
9093
<width>39</width>
91-
<height>38</height>
94+
<height>30</height>
95+
</size>
96+
</property>
97+
<property name="maximumSize">
98+
<size>
99+
<width>39</width>
100+
<height>30</height>
92101
</size>
93102
</property>
94103
<property name="icon">
@@ -103,6 +112,22 @@
103112
</property>
104113
</widget>
105114
</item>
115+
<item>
116+
<spacer name="horizontalSpacer_5">
117+
<property name="orientation">
118+
<enum>Qt::Horizontal</enum>
119+
</property>
120+
<property name="sizeType">
121+
<enum>QSizePolicy::Fixed</enum>
122+
</property>
123+
<property name="sizeHint" stdset="0">
124+
<size>
125+
<width>4</width>
126+
<height>20</height>
127+
</size>
128+
</property>
129+
</spacer>
130+
</item>
106131
<item>
107132
<widget class="QPushButton" name="stopButton">
108133
<property name="sizePolicy">
@@ -114,7 +139,13 @@
114139
<property name="minimumSize">
115140
<size>
116141
<width>39</width>
117-
<height>38</height>
142+
<height>30</height>
143+
</size>
144+
</property>
145+
<property name="maximumSize">
146+
<size>
147+
<width>39</width>
148+
<height>30</height>
118149
</size>
119150
</property>
120151
<property name="icon">

ground/gcs/src/plugins/logging/logginggadgetwidget.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ void LoggingGadgetWidget::setPlugin(LoggingPlugin *p)
8585
connect(logFile, &LogFile::setPlaybackPosition, this, &LoggingGadgetWidget::setPlaybackPosition);
8686
connect(logFile, &LogFile::replayStarted, this, &LoggingGadgetWidget::enableWidgets);
8787
connect(logFile, &LogFile::replayFinished, this, &LoggingGadgetWidget::disableWidgets);
88+
connect(logFile, &LogFile::replayCompleted, this, &LoggingGadgetWidget::stopButtonAction);
8889

8990
// Feedback from logfile to scope
9091
connect(logFile, &LogFile::replayFinished, scpPlugin, &ScopeGadgetFactory::stopPlotting);
@@ -123,22 +124,15 @@ void LoggingGadgetWidget::pauseButtonAction()
123124

124125
void LoggingGadgetWidget::stopButtonAction()
125126
{
126-
ReplayState replayState = (loggingPlugin->getLogfile())->getReplayState();
127-
128-
if (replayState != STOPPED) {
129-
emit pauseReplayAndResetPosition();
130-
}
127+
emit pauseReplayAndResetPosition();
131128

132129
m_logging->playButton->setVisible(true);
133130
m_logging->pauseButton->setVisible(false);
134131
m_logging->stopButton->setEnabled(false);
135132

136-
// Block signals while setting the slider to the start position
137-
m_logging->playbackPosition->blockSignals(true);
138-
m_logging->playbackPosition->setValue(m_logging->playbackPosition->minimum());
139-
m_logging->playbackPosition->blockSignals(false);
133+
setPlaybackPosition(0);
140134

141-
m_logging->statusLabel->setText(tr("Paused"));
135+
m_logging->statusLabel->setText(tr("Stopped"));
142136
}
143137

144138
void LoggingGadgetWidget::stateChanged(LoggingPlugin::State state)

0 commit comments

Comments
 (0)