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

View File

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

View File

@ -171,6 +171,9 @@ bool LoggingPlugin::initialize(const QStringList& args, QString *errMsg)
mf = new LoggingGadgetFactory(this); mf = new LoggingGadgetFactory(this);
addAutoReleasedObject(mf); addAutoReleasedObject(mf);
// Map signal from end of replay to replay stopped
connect(&logFile,SIGNAL(replayFinished()), this, SLOT(replayStopped()));
return true; return true;
} }
@ -210,7 +213,7 @@ void LoggingPlugin::toggleReplay()
} }
else if(state == REPLAY) 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 * Receive the logging stopped signal from the LoggingThread
* and change status to not logging * and change status to not logging
@ -298,6 +287,25 @@ void LoggingPlugin::loggingStopped()
loggingThread = NULL; 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() void LoggingPlugin::extensionsInitialized()
{ {
// Do nothing // Do nothing

View File

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