Files
BionxControl/bctransmitter.h

48 lines
1003 B
C
Raw Normal View History

2025-12-20 16:33:00 +01:00
#ifndef BCTRANSMITTER_H
#define BCTRANSMITTER_H
#include <QObject>
#include <QQueue>
#include <QMutex>
#include <atomic>
2025-12-23 11:09:26 +01:00
#include <bcdataitem.h>
2025-12-20 16:33:00 +01:00
#include <bccandrivertinycan.h>
2025-12-22 21:27:20 +01:00
// template ...
class BCTransmitter : public QObject, public BCAbstractTransmitter
2025-12-20 16:33:00 +01:00
{
Q_OBJECT
public:
explicit BCTransmitter(QObject *parent = nullptr);
2025-12-21 18:31:16 +01:00
bcdata_t readRawValue( BCDevice::ID deviceID, BC::ID registerID ) const override;
2025-12-21 20:46:16 +01:00
void writeRawValue(BCDevice::ID deviceID, BC::ID registerID, bcdata_t value ) const override;
2025-12-20 16:33:00 +01:00
public slots:
void onToggleConnectionState( bool connect );
2025-12-23 11:09:26 +01:00
void enqueueValueOp(BC::OpID opID, const BCDataItem* value );
void processValueOp(BC::OpID opID);
2025-12-20 16:33:00 +01:00
signals:
void commandFinished(int id, bool success);
void messageLogged(const QString& msg);
private:
2025-12-23 11:09:26 +01:00
using BCDataQueue = QQueue<const BCDataItem*>;
2025-12-20 16:33:00 +01:00
2025-12-22 21:27:20 +01:00
BCDataQueue _valueQueue;
2025-12-20 16:33:00 +01:00
QMutex _mutex;
std::atomic<bool> _isBusy{ false };
BCCanDriverTinyCan _canDriver;
};
#endif // BCTRANSMITTER_H