Rework driver code, again.
This commit is contained in:
22
bcdriver.h
22
bcdriver.h
@@ -34,7 +34,7 @@
|
||||
#define BCDRIVER_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <expected>
|
||||
#include <bc.h>
|
||||
|
||||
/*
|
||||
@@ -75,7 +75,7 @@ class BCDriverStatus;
|
||||
* @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.
|
||||
* über den TinyCAN Adapter oder ggf. über einen ELM327 Stecker.
|
||||
*
|
||||
* Die hier relevante Implementierung über das TinyCan System
|
||||
* findet sich in der Unterklasse 'BCDriverTinyCan'.
|
||||
@@ -90,6 +90,9 @@ class BCDriver : public QObject
|
||||
|
||||
public:
|
||||
|
||||
// Die möglichen Zustände beim Laden
|
||||
// des CAN-Bus Treibers.
|
||||
|
||||
enum class DriverState
|
||||
{
|
||||
NotPresent,
|
||||
@@ -97,17 +100,22 @@ public:
|
||||
Loaded,
|
||||
Initialized,
|
||||
Opened, // bis hierher: dll vorhanden, Treiber geladen
|
||||
Ready // hier: devices connectable
|
||||
DeviceReady // hier: devices connectable
|
||||
};
|
||||
Q_ENUM(DriverState)
|
||||
|
||||
// Enthält den Treiberzustand oder einen Fehlerstring
|
||||
using DriverStateResult = std::expected<DriverState,QString>;
|
||||
// Enthält den gelesenen Wert oder einen Fehlerstring
|
||||
using TransmitResult = std::expected<uint8_t,QString>;
|
||||
|
||||
explicit BCDriver( QObject* parent = nullptr );
|
||||
virtual ~BCDriver() = default;
|
||||
|
||||
DriverState getState() const;
|
||||
|
||||
virtual uint32_t readRawByte( uint32_t deviceID, uint8_t registerID ) const = 0;
|
||||
virtual void writeRawByte( uint32_t deviceID, uint8_t registerID, uint8_t value ) const = 0;
|
||||
virtual TransmitResult readRawByte( uint32_t deviceID, uint8_t registerID ) const = 0;
|
||||
virtual TransmitResult writeRawByte(uint32_t deviceID, uint8_t registerID, uint8_t value ) const = 0;
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -132,8 +140,8 @@ public:
|
||||
|
||||
explicit BCDriverDummy( QObject* parent = nullptr );
|
||||
|
||||
uint32_t readRawByte( uint32_t deviceID, uint8_t registerID ) const override;
|
||||
void writeRawByte( uint32_t deviceID, uint8_t registerID, uint8_t value ) const override;
|
||||
TransmitResult readRawByte( uint32_t deviceID, uint8_t registerID ) const override;
|
||||
TransmitResult writeRawByte( uint32_t deviceID, uint8_t registerID, uint8_t value ) const override;
|
||||
|
||||
public slots:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user