dataload_ulog.cpp
Go to the documentation of this file.
1 #include "dataload_ulog.h"
2 #include <QTextStream>
3 #include <QFile>
4 #include <QMessageBox>
5 #include <QDebug>
6 #include <QWidget>
7 #include <QSettings>
8 #include <QProgressDialog>
9 #include <QMainWindow>
10 #include "selectlistdialog.h"
11 #include "ulog_parser.h"
12 #include "ulog_parameters_dialog.h"
13 
15 {
16  for (QWidget* widget : qApp->topLevelWidgets())
17  {
18  if (widget->inherits("QMainWindow"))
19  {
20  _main_win = widget;
21  break;
22  }
23  }
24 }
25 
26 const std::vector<const char*>& DataLoadULog::compatibleFileExtensions() const
27 {
28  static std::vector<const char*> extensions = { "ulg" };
29  return extensions;
30 }
31 
33  PlotDataMapRef& plot_data)
34 {
35  const auto& filename = fileload_info->filename;
36 
37  QFile file(filename);
38 
39  if (!file.open(QIODevice::ReadOnly))
40  {
41  throw std::runtime_error("ULog: Failed to open file");
42  }
43  QByteArray file_array = file.readAll();
44  ULogParser::DataStream datastream(file_array.data(), file_array.size());
45 
46  ULogParser parser(datastream);
47 
48  const auto& timeseries_map = parser.getTimeseriesMap();
49 
50  for (const auto& it : timeseries_map)
51  {
52  const std::string& sucsctiption_name = it.first;
53  const ULogParser::Timeseries& timeseries = it.second;
54 
55  for (const auto& data : timeseries.data)
56  {
57  std::string series_name = sucsctiption_name + data.first;
58 
59  auto series = plot_data.addNumeric(series_name);
60 
61  for (size_t i = 0; i < data.second.size(); i++)
62  {
63  double msg_time = static_cast<double>(timeseries.timestamps[i]) * 0.000001;
64  PlotData::Point point(msg_time, data.second[i]);
65  series->second.pushBack(point);
66  }
67  }
68  }
69 
71  dialog->setWindowTitle(QString("ULog file %1").arg(filename));
72  dialog->setAttribute(Qt::WA_DeleteOnClose);
73  dialog->restoreSettings();
74  dialog->show();
75 
76  return true;
77 }
78 
80 {
81 }
82 
83 bool DataLoadULog::xmlSaveState(QDomDocument& doc, QDomElement& parent_element) const
84 {
85  return true;
86 }
87 
88 bool DataLoadULog::xmlLoadState(const QDomElement&)
89 {
90  return true;
91 }
std::vector< uint64_t > timestamps
Definition: ulog_parser.h:109
bool xmlSaveState(QDomDocument &doc, QDomElement &parent_element) const override
Override this method to save the status of the plugin to XML.
#define nullptr
Definition: backward.hpp:386
const std::vector< const char * > & compatibleFileExtensions() const override
Provide a list of file extensions that this plugin can open.
bool xmlLoadState(const QDomElement &parent_element) override
Override this method to load the status of the plugin from XML.
auto arg(const Char *name, const T &arg) -> detail::named_arg< Char, T >
Definition: core.h:1736
QString filename
name of the file to open
~DataLoadULog() override
bool readDataFromFile(PJ::FileLoadInfo *fileload_info, PlotDataMapRef &destination) override
TimeseriesMap::iterator addNumeric(const std::string &name, PlotGroup::Ptr group={})
Definition: plotdata.cpp:51
typename PlotDataBase< double, Value >::Point Point
Definition: timeseries.h:23
QWidget * _main_win
Definition: dataload_ulog.h:37
std::vector< std::pair< std::string, std::vector< double > > > data
Definition: ulog_parser.h:110
Definition: format.h:895


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Jun 19 2023 03:01:01