1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-30 08:24:11 +01:00

Ground/Logging: Change replay state at end of replay file to stop lock up

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1715 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
peabody124 2010-09-22 01:04:24 +00:00 committed by peabody124
parent 674ee88f6d
commit 5771769acf
4 changed files with 55 additions and 22 deletions

View File

@ -63,14 +63,37 @@ void LogFile::timerFired()
{
qint64 dataSize;
if(file.bytesAvailable() > 4)
{
// TODO: going back in time will be a problem
while ((myTime.elapsed() - timeOffset) * playbackSpeed > lastTimeStamp) {
if(file.bytesAvailable() < 4) {
stopReplay();
return;
}
file.read((char *) &dataSize, sizeof(dataSize));
if(file.bytesAvailable() < dataSize) {
stopReplay();
return;
}
dataBuffer.append(file.read(dataSize));
emit readyRead();
if(file.bytesAvailable() < 4) {
stopReplay();
return;
}
file.read((char *) &lastTimeStamp,sizeof(lastTimeStamp));
}
} else {
stopReplay();
}
}
bool LogFile::startReplay() {
@ -86,6 +109,7 @@ bool LogFile::startReplay() {
bool LogFile::stopReplay() {
timer.stop();
emit replayFinished();
return true;
}

View File

@ -35,6 +35,7 @@ protected slots:
signals:
void readReady();
void replayFinished();
protected:
QByteArray dataBuffer;

View File

@ -171,6 +171,9 @@ bool LoggingPlugin::initialize(const QStringList& args, QString *errMsg)
mf = new LoggingGadgetFactory(this);
addAutoReleasedObject(mf);
// Map signal from end of replay to replay stopped
connect(&logFile,SIGNAL(replayFinished()), this, SLOT(replayStopped()));
return true;
}
@ -210,7 +213,7 @@ void LoggingPlugin::toggleReplay()
}
else if(state == REPLAY)
{
stopReplay();
logFile.stopReplay();
}
}
@ -269,20 +272,6 @@ void LoggingPlugin::stopLogging()
}
/**
* Send the stop replay signal to the ReplayThread
*/
void LoggingPlugin::stopReplay()
{
logFile.stopReplay();
logFile.close();
delete(uavTalk);
uavTalk = 0;
state = IDLE;
emit stateChanged("IDLE");
}
/**
* Receive the logging stopped signal from the LoggingThread
* and change status to not logging
@ -298,6 +287,25 @@ void LoggingPlugin::loggingStopped()
loggingThread = NULL;
}
/**
* Received the replay stoppedsignal from the LogFile
*/
void LoggingPlugin::replayStopped()
{
Q_ASSERT(state == REPLAY);
if(uavTalk)
delete(uavTalk);
logFile.close();
uavTalk = 0;
state = IDLE;
emit stateChanged("IDLE");
}
void LoggingPlugin::extensionsInitialized()
{
// Do nothing

View File

@ -91,8 +91,8 @@ private slots:
void startLogging(QString file);
void startReplay(QString file);
void stopLogging();
void stopReplay();
void loggingStopped();
void replayStopped();
private:
LoggingGadgetFactory *mf;