49 lines
942 B
C++
49 lines
942 B
C++
#ifndef BCTRANSMITTER_H
|
|
#define BCTRANSMITTER_H
|
|
|
|
#include <QObject>
|
|
#include <QQueue>
|
|
#include <QMutex>
|
|
#include <functional>
|
|
#include <atomic>
|
|
|
|
#include <bcvalue.h>
|
|
#include <bccandrivertinycan.h>
|
|
|
|
class BCTransmitter : public QObject, public BCAbstractTransmitter
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit BCTransmitter(QObject *parent = nullptr);
|
|
|
|
|
|
public slots:
|
|
|
|
void onToggleConnectionState( bool connect );
|
|
void enqueueValueOp(BC::OpID opID, const BCValue* value );
|
|
void processValueOp(BC::OpID opID);
|
|
|
|
signals:
|
|
|
|
void commandFinished(int id, bool success);
|
|
void messageLogged(const QString& msg);
|
|
|
|
private:
|
|
|
|
std::optional<uint32_t> executeRead(const BCValue& value);
|
|
std::optional<uint32_t> executeWrite(const BCValue& value);
|
|
|
|
using BCValueQueue = QQueue<const BCValue*>;
|
|
|
|
BCValueQueue _valueQueue;
|
|
QMutex _mutex;
|
|
std::atomic<bool> _isBusy{ false };
|
|
|
|
BCCanDriverTinyCan _canDriver;
|
|
};
|
|
|
|
|
|
#endif // BCTRANSMITTER_H
|