48 lines
991 B
C++
48 lines
991 B
C++
#ifndef BCTRANSMITTER_H
|
|
#define BCTRANSMITTER_H
|
|
|
|
#include <QObject>
|
|
#include <QQueue>
|
|
#include <QMutex>
|
|
#include <atomic>
|
|
|
|
#include <bcdata.h>
|
|
#include <bccandrivertinycan.h>
|
|
|
|
// template ...
|
|
class BCTransmitter : public QObject, public BCAbstractTransmitter
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit BCTransmitter(QObject *parent = nullptr);
|
|
|
|
bcdata_t readRawValue( BCDevice::ID deviceID, BC::ID registerID ) const override;
|
|
void writeRawValue(BCDevice::ID deviceID, BC::ID registerID, bcdata_t value ) const override;
|
|
|
|
public slots:
|
|
|
|
void onToggleConnectionState( bool connect );
|
|
void enqueueValueOp(BC::OpID opID, const BCData* value );
|
|
void processValueOp(BC::OpID opID);
|
|
|
|
signals:
|
|
|
|
void commandFinished(int id, bool success);
|
|
void messageLogged(const QString& msg);
|
|
|
|
private:
|
|
|
|
using BCDataQueue = QQueue<const BCData*>;
|
|
|
|
BCDataQueue _valueQueue;
|
|
QMutex _mutex;
|
|
std::atomic<bool> _isBusy{ false };
|
|
|
|
BCCanDriverTinyCan _canDriver;
|
|
};
|
|
|
|
|
|
#endif // BCTRANSMITTER_H
|