114 lines
3.2 KiB
C++
114 lines
3.2 KiB
C++
#ifndef BCCANDRIVER_H
|
|
#define BCCANDRIVER_H
|
|
|
|
#include <QObject>
|
|
|
|
#include <bc.h>
|
|
|
|
/*
|
|
int32_t CanInitDriver(char *options);
|
|
void CanDownDriver(void);
|
|
int32_t CanSetOptions(char *options);
|
|
int32_t CanDeviceOpen(uint32_t index, char *parameter);
|
|
int32_t CanDeviceClose(uint32_t index);
|
|
|
|
int32_t CanSetMode(uint32_t index, unsigned char can_op_mode, uint16_t can_command);
|
|
|
|
int32_t CanTransmit(uint32_t index, struct TCanMsg *msg, int32_t count);
|
|
void CanTransmitClear(uint32_t index);
|
|
uint32_t CanTransmitGetCount(uint32_t index);
|
|
int32_t CanTransmitSet(uint32_t index, uint16_t cmd, uint32_t time);
|
|
int32_t CanReceive(uint32_t index, struct TCanMsg *msg, int32_t count);
|
|
void CanReceiveClear(uint32_t index);
|
|
uint32_t CanReceiveGetCount(uint32_t index);
|
|
|
|
int32_t CanSetSpeed(uint32_t index, uint16_t speed);
|
|
int32_t CanSetSpeedUser(uint32_t index, uint32_t value);
|
|
char* CanDrvInfo(void);
|
|
char* CanDrvHwInfo(uint32_t index);
|
|
int32_t CanSetFilter(uint32_t index, struct TMsgFilter *msg_filter);
|
|
int32_t CanGetDeviceStatus(uint32_t index, struct TDeviceStatus *status);
|
|
void CanSetPnPEventCallback(void (DRV_CALLBACK_TYPE *event)(uint32_t index, int32_t status));
|
|
void CanSetStatusEventCallback(void (DRV_CALLBACK_TYPE *event) (uint32_t index, struct TDeviceStatus *device_status) );
|
|
void CanSetRxEventCallback(void (DRV_CALLBACK_TYPE *event)(uint32_t index, struct TCanMsg *msg, int32_t count) );
|
|
|
|
void CanSetEvents( uint16_t events );
|
|
uint32_t CanEventStatus(void);
|
|
*/
|
|
|
|
struct CBCItem;
|
|
class BCCanDriverStatus;
|
|
|
|
/**
|
|
* @Abstrakte Basisklasse für alle CAN-Bus Treiber.
|
|
* Das Bionx CAN-Bus System kann auf verschiedenen Wegen
|
|
* angesprochen werden, etwa den über BBI USB2CAN Controller,
|
|
* über den TinyCAN Adapter oder ggf. über einen EL327 Stecker.
|
|
*
|
|
* Die hier relevante Implementierung über das TinyCan System
|
|
* findet sich in der Unterklasse 'BCCanDriverTinyCan'.
|
|
*
|
|
* @see BCCanDriverTinyCan
|
|
*/
|
|
|
|
|
|
class BCCanDriver : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
typedef enum
|
|
{
|
|
sDriverError = 0,
|
|
sIdle,
|
|
sLoaded,
|
|
sReady,
|
|
dStateSize
|
|
} dState;
|
|
|
|
[[maybe_unused]] constexpr static const char* stDriverError = "Error";
|
|
[[maybe_unused]] constexpr static const char* stIdle = "[not loaded]";
|
|
[[maybe_unused]] constexpr static const char* stLoaded = "[not connected]";
|
|
[[maybe_unused]] constexpr static const char* stReady = "Ready";
|
|
|
|
static QString stateLabel( dState state );
|
|
|
|
explicit BCCanDriver( QObject* parent = nullptr );
|
|
virtual ~BCCanDriver() = default;
|
|
|
|
dState getState();
|
|
|
|
virtual BCCanDriver::dState loadDriver() = 0;
|
|
virtual BCCanDriver::dState initDriver() = 0;
|
|
|
|
virtual uint getValue( BCDevice::ID dev, BC::ID reg ) const = 0;
|
|
virtual void setValue( BCDevice::ID dev, BC::ID reg, int value ) const = 0;
|
|
|
|
signals:
|
|
|
|
void errorOccured( const QString& errMsg );
|
|
void statusHint( const QString& msg ) const;
|
|
|
|
void stateChanged( int state );
|
|
void itemReady( const QString& label );
|
|
void itemLoaded( CBCItem& item );
|
|
|
|
public slots:
|
|
|
|
void onStartDriver();
|
|
//void onLoadItem( CBCItem& item );
|
|
|
|
protected:
|
|
|
|
void setState( dState newState );
|
|
|
|
dState _driverState = sIdle;
|
|
|
|
int _retries = 5;
|
|
int _timeOuts = 20;
|
|
|
|
};
|
|
|
|
#endif // BCCANDRIVER_H
|