48 lines
943 B
C++
48 lines
943 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
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit BCTransmitter(QObject *parent = nullptr);
|
|
|
|
public slots:
|
|
|
|
void onToggleConnectionState( bool connect );
|
|
void enqueueValueCommand(BC::OpID opID, const BCValue& value);
|
|
void processValueCommand(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<std::reference_wrapper<const BCValue>>;
|
|
|
|
BCValueQueue _valueQueue;
|
|
QMutex _mutex;
|
|
std::atomic<bool> _isBusy{ false };
|
|
|
|
BCCanDriverTinyCan _canDriver;
|
|
};
|
|
|
|
|
|
#endif // BCTRANSMITTER_H
|