| 1 | // Copyright (C) 2022 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QCANFRAMEPROCESSOR_H |
| 5 | #define QCANFRAMEPROCESSOR_H |
| 6 | |
| 7 | #include <QtCore/QVariantMap> |
| 8 | |
| 9 | #include <QtSerialBus/qcancommondefinitions.h> |
| 10 | #include <QtSerialBus/qtserialbusglobal.h> |
| 11 | |
| 12 | #include <memory> |
| 13 | |
| 14 | QT_BEGIN_NAMESPACE |
| 15 | |
| 16 | class QCanBusFrame; |
| 17 | class QCanMessageDescription; |
| 18 | class QCanUniqueIdDescription; |
| 19 | class QCanFrameProcessorPrivate; |
| 20 | |
| 21 | class QCanFrameProcessor |
| 22 | { |
| 23 | public: |
| 24 | enum class Error : quint8 { |
| 25 | None = 0, |
| 26 | InvalidFrame, |
| 27 | UnsupportedFrameFormat, |
| 28 | Decoding, |
| 29 | Encoding, |
| 30 | }; |
| 31 | |
| 32 | struct ParseResult { |
| 33 | QtCanBus::UniqueId uniqueId = QtCanBus::UniqueId{0}; |
| 34 | QVariantMap signalValues; |
| 35 | }; |
| 36 | |
| 37 | Q_SERIALBUS_EXPORT QCanFrameProcessor(); |
| 38 | Q_SERIALBUS_EXPORT ~QCanFrameProcessor(); |
| 39 | |
| 40 | Q_SERIALBUS_EXPORT QCanBusFrame prepareFrame(QtCanBus::UniqueId uniqueId, |
| 41 | const QVariantMap &signalValues); |
| 42 | Q_SERIALBUS_EXPORT ParseResult parseFrame(const QCanBusFrame &frame); |
| 43 | |
| 44 | Q_SERIALBUS_EXPORT Error error() const; |
| 45 | Q_SERIALBUS_EXPORT QString errorString() const; |
| 46 | Q_SERIALBUS_EXPORT QStringList warnings() const; |
| 47 | |
| 48 | Q_SERIALBUS_EXPORT QList<QCanMessageDescription> messageDescriptions() const; |
| 49 | Q_SERIALBUS_EXPORT |
| 50 | void addMessageDescriptions(const QList<QCanMessageDescription> &descriptions); |
| 51 | Q_SERIALBUS_EXPORT |
| 52 | void setMessageDescriptions(const QList<QCanMessageDescription> &descriptions); |
| 53 | Q_SERIALBUS_EXPORT void clearMessageDescriptions(); |
| 54 | |
| 55 | Q_SERIALBUS_EXPORT QCanUniqueIdDescription uniqueIdDescription() const; |
| 56 | Q_SERIALBUS_EXPORT void setUniqueIdDescription(const QCanUniqueIdDescription &description); |
| 57 | |
| 58 | private: |
| 59 | std::unique_ptr<QCanFrameProcessorPrivate> d; |
| 60 | friend class QCanFrameProcessorPrivate; |
| 61 | |
| 62 | Q_DISABLE_COPY_MOVE(QCanFrameProcessor) |
| 63 | }; |
| 64 | |
| 65 | QT_END_NAMESPACE |
| 66 | |
| 67 | #endif // QCANFRAMEPROCESSOR_H |
| 68 |
