CANdevStudio
Development tool for CAN bus simulation
Loading...
Searching...
No Matches
cansignalencodermodel.h
Go to the documentation of this file.
1#ifndef CANSIGNALENCODERMODEL_H
2#define CANSIGNALENCODERMODEL_H
3
4#include "componentmodel.h"
5#include "nodepainter.h"
6#include <QtCore/QObject>
7#include <cansignalencoder.h>
8#include <candbpainter.h>
9#include <readerwriterqueue.h>
10
11using QtNodes::NodeData;
12using QtNodes::NodeDataType;
13using QtNodes::PortIndex;
14using QtNodes::PortType;
15
16enum class Direction;
17class QCanBusFrame;
18
19class CanSignalEncoderModel : public ComponentModel<CanSignalEncoder, CanSignalEncoderModel> {
20 Q_OBJECT
21
22public:
24
25 unsigned int nPorts(PortType portType) const override;
26 NodeDataType dataType(PortType portType, PortIndex portIndex) const override;
27 std::shared_ptr<NodeData> outData(PortIndex port) override;
28 void setInData(std::shared_ptr<NodeData> nodeData, PortIndex port) override;
29 QtNodes::NodePainterDelegate* painterDelegate() const override;
30
31public slots:
32 void rcvFrame(const QCanBusFrame& frame);
33
34signals:
36 void sndSignal(const QString& name, const QVariant& val);
37
38private:
39 std::unique_ptr<CanDbPainter> _painter;
40 // 127 to use 4 blocks, 512 bytes each
41 moodycamel::ReaderWriterQueue<std::shared_ptr<NodeData>> _rxQueue{ 127 };
42};
43
44#endif // CANSIGNALENCODERMODEL_H
Definition cansignalencodermodel.h:19
void setInData(std::shared_ptr< NodeData > nodeData, PortIndex port) override
Definition cansignalencodermodel.cpp:72
unsigned int nPorts(PortType portType) const override
Definition cansignalencodermodel.cpp:44
void sndSignal(const QString &name, const QVariant &val)
NodeDataType dataType(PortType portType, PortIndex portIndex) const override
Definition cansignalencodermodel.cpp:49
QtNodes::NodePainterDelegate * painterDelegate() const override
Definition cansignalencodermodel.cpp:39
CanSignalEncoderModel()
Definition cansignalencodermodel.cpp:26
void rcvFrame(const QCanBusFrame &frame)
Definition cansignalencodermodel.cpp:83
std::shared_ptr< NodeData > outData(PortIndex port) override
Definition cansignalencodermodel.cpp:59
Definition componentmodel.h:37
virtual QString name() const override
Used to identify model by data model name.
Definition componentmodel.h:115
Direction
The enum class describing frame direction.
Definition datadirection.h:7