dataload_ulog.cpp
Go to the documentation of this file.
00001 #include "dataload_ulog.h"
00002 #include <QTextStream>
00003 #include <QFile>
00004 #include <QMessageBox>
00005 #include <QDebug>
00006 #include <QWidget>
00007 #include <QSettings>
00008 #include <QProgressDialog>
00009 #include <QMainWindow>
00010 #include "selectlistdialog.h"
00011 #include "ulog_parser.h"
00012 #include "ulog_parameters_dialog.h"
00013 
00014 DataLoadULog::DataLoadULog(): _main_win(nullptr)
00015 {
00016     for(QWidget *widget: qApp->topLevelWidgets())
00017     {
00018         if(widget->inherits("QMainWindow"))
00019         {
00020             _main_win = widget;
00021             break;
00022         }
00023     }
00024 }
00025 
00026 const std::vector<const char*> &DataLoadULog::compatibleFileExtensions() const
00027 {
00028     static  std::vector<const char*> extensions = { "ulg" };
00029     return extensions;
00030 }
00031 
00032 bool DataLoadULog::readDataFromFile(FileLoadInfo* fileload_info, PlotDataMapRef& plot_data)
00033 {
00034     const auto& filename = fileload_info->filename;
00035 
00036     ULogParser parser( filename.toStdString() );
00037 
00038     const auto& timeseries_map = parser.getTimeseriesMap();
00039 
00040     for( const auto& it: timeseries_map)
00041     {
00042         const std::string& sucsctiption_name =  it.first;
00043         const ULogParser::Timeseries& timeseries = it.second;
00044 
00045         for (const auto& data: timeseries.data )
00046         {
00047             std::string series_name = sucsctiption_name + data.first;
00048 
00049             auto series = plot_data.addNumeric( series_name );
00050 
00051             for( size_t i=0; i < data.second.size(); i++ )
00052             {
00053                 double msg_time = static_cast<double>(timeseries.timestamps[i]) * 0.000001;
00054                 PlotData::Point point( msg_time, data.second[i] );
00055                 series->second.pushBack( point );
00056             }
00057         }
00058     }
00059 
00060     ULogParametersDialog* dialog = new ULogParametersDialog( parser, _main_win );
00061     dialog->setWindowTitle( QString("ULog file %1").arg(filename) );
00062     dialog->setAttribute(Qt::WA_DeleteOnClose);
00063     dialog->restoreSettings();
00064     dialog->show();
00065 
00066     return true;
00067 }
00068 
00069 DataLoadULog::~DataLoadULog()
00070 {
00071 
00072 }
00073 
00074 bool DataLoadULog::xmlSaveState(QDomDocument &doc, QDomElement &parent_element) const
00075 {
00076     return true;
00077 }
00078 
00079 bool DataLoadULog::xmlLoadState(const QDomElement &)
00080 {
00081     return true;
00082 }
00083 


plotjuggler
Author(s): Davide Faconti
autogenerated on Wed Jul 3 2019 19:28:04