1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

GVS/Scope: Bugfix: Export all known data points into CSV not just one per screen redraw

This commit is contained in:
Corvus Corax 2011-11-26 22:51:20 +01:00 committed by James Cotton
parent 78278683cc
commit 2ce3365861
2 changed files with 47 additions and 33 deletions

View File

@ -447,6 +447,7 @@ void ScopeGadgetWidget::uavObjectReceived(UAVObject* obj)
foreach(PlotData* plotData, m_curvesData.values()) {
if (plotData->append(obj)) m_csvLoggingDataUpdated=1;
}
csvLoggingAddData();
}
void ScopeGadgetWidget::replotNewData()
@ -610,6 +611,7 @@ int ScopeGadgetWidget::csvLoggingStart()
m_csvLoggingStartTime = NOW;
m_csvLoggingHeaderSaved=0;
m_csvLoggingDataSaved=0;
m_csvLoggingBuffer.clear();
QDir PathCheck(m_csvLoggingPath);
if (!PathCheck.exists())
{
@ -677,13 +679,50 @@ int ScopeGadgetWidget::csvLoggingInsertHeader()
return 0;
}
int ScopeGadgetWidget::csvLoggingAddData()
{
if (!m_csvLoggingStarted) return -1;
m_csvLoggingDataValid=0;
QDateTime NOW = QDateTime::currentDateTime();
QString tempString;
QTextStream ss( &tempString );
ss << NOW.toString("yyyy-MM-dd") << ", " << NOW.toString("hh:mm:ss.z") << ", " ;
#if QT_VERSION >= 0x040700
ss <<(NOW.toMSecsSinceEpoch() - m_csvLoggingStartTime.toMSecsSinceEpoch())/1000.00;
#else
ss <<(NOW.toTime_t() - m_csvLoggingStartTime.toTime_t());
#endif
ss << ", " << m_csvLoggingConnected << ", " << m_csvLoggingDataUpdated;
m_csvLoggingDataUpdated=0;
foreach(PlotData* plotData2, m_curvesData.values())
{
ss << ", ";
if (plotData2->xData->isEmpty ())
{
}
else
{
ss << QString().sprintf("%3.6g",plotData2->yDataHistory->last()/pow(10,plotData2->scalePower));
m_csvLoggingDataValid=1;
}
}
ss << endl;
if (m_csvLoggingDataValid)
{
QTextStream ts( &m_csvLoggingBuffer );
ts << tempString;
}
return 0;
}
int ScopeGadgetWidget::csvLoggingInsertData()
{
if (!m_csvLoggingStarted) return -1;
m_csvLoggingDataSaved=1;
m_csvLoggingDataValid=0;
QDateTime NOW = QDateTime::currentDateTime();
QString tempString;
if(m_csvLoggingFile.open(QIODevice::WriteOnly | QIODevice::Append)== FALSE)
{
@ -691,38 +730,11 @@ int ScopeGadgetWidget::csvLoggingInsertData()
}
else
{
QTextStream ss( &tempString );
ss << NOW.toString("yyyy-MM-dd") << ", " << NOW.toString("hh:mm:ss.z") << ", " ;
#if QT_VERSION >= 0x040700
ss <<(NOW.toMSecsSinceEpoch() - m_csvLoggingStartTime.toMSecsSinceEpoch())/1000.00;
#else
ss <<(NOW.toTime_t() - m_csvLoggingStartTime.toTime_t());
#endif
ss << ", " << m_csvLoggingConnected << ", " << m_csvLoggingDataUpdated;
m_csvLoggingDataUpdated=0;
foreach(PlotData* plotData2, m_curvesData.values())
{
ss << ", ";
if (plotData2->xData->isEmpty ())
{
}
else
{
ss << QString().sprintf("%3.6g",plotData2->yDataHistory->last()/pow(10,plotData2->scalePower));
m_csvLoggingDataValid=1;
}
}
ss << endl;
if (m_csvLoggingDataValid)
{
QTextStream ts( &m_csvLoggingFile );
ts << tempString;
}
QTextStream ts( &m_csvLoggingFile );
ts << m_csvLoggingBuffer;
m_csvLoggingFile.close();
}
m_csvLoggingBuffer.clear();
return 0;
}

View File

@ -166,11 +166,13 @@ private:
QString m_csvLoggingName;
QString m_csvLoggingPath;
QString m_csvLoggingBuffer;
QFile m_csvLoggingFile;
QMutex mutex;
int csvLoggingInsertHeader();
int csvLoggingAddData();
int csvLoggingInsertData();
void deleteLegend();