File indexing completed on 2024-06-16 03:42:44

0001 /*
0002     File                 : VectorBLFFilter.h
0003     Project              : LabPlot
0004     Description          : Vector BLF I/O-filter
0005     --------------------------------------------------------------------
0006     SPDX-FileCopyrightText: 2023 Martin Marmsoler <martin.marmsoler@gmail.com>
0007     SPDX-License-Identifier: GPL-3.0-or-later
0008 */
0009 #ifndef CANFILTER_H
0010 #define CANFILTER_H
0011 
0012 #include "backend/datasources/filters/AbstractFileFilter.h"
0013 
0014 class CANFilterPrivate;
0015 
0016 /*!
0017     \class CANFilter
0018     \brief Manages the import/export of data which are using dbc files for parsing the log files
0019 
0020     \ingroup datasources
0021 */
0022 class CANFilter : public AbstractFileFilter {
0023     Q_OBJECT
0024 
0025 public:
0026     CANFilter(FileType type, CANFilterPrivate*);
0027     ~CANFilter() override;
0028 
0029     /*!
0030      * \brief fileInfoString
0031      * Information about the file content
0032      * \return
0033      */
0034     static QString fileInfoString(const QString&);
0035     QVector<QStringList> preview(const QString& filename, int lines);
0036 
0037     void
0038     readDataFromFile(const QString& fileName, AbstractDataSource* = nullptr, AbstractFileFilter::ImportMode = AbstractFileFilter::ImportMode::Replace) override;
0039     void write(const QString& fileName, AbstractDataSource*) override;
0040 
0041     virtual QStringList lastErrors() override;
0042 
0043     QStringList vectorNames() const;
0044     const QVector<AbstractColumn::ColumnMode> columnModes() const;
0045 
0046     enum class TimeHandling {
0047         Separate, // separate timestamp for every message id
0048         ConcatNAN, // common timestamp vector for all messages, but NAN if the current value is not available
0049         ConcatPrevious // common timestamp vector for all messages, but use the previous value if available, otherwise 0
0050     };
0051 
0052     void setConvertTimeToSeconds(bool);
0053     void setTimeHandlingMode(TimeHandling);
0054 
0055     /*!
0056      * \brief setDBCFile
0057      * Sets dbc file which is used to decode the messages
0058      * \param file
0059      * \return
0060      */
0061     bool setDBCFile(const QString& file);
0062 
0063     void save(QXmlStreamWriter*) const override;
0064     bool load(XmlStreamReader*) override;
0065 
0066 private:
0067     std::unique_ptr<CANFilterPrivate> const d;
0068 
0069     std::vector<void*> dataContainer() const;
0070 
0071     friend class BLFFilterTest;
0072 };
0073 
0074 #endif // CANFILTER_H