Cleanups.
This commit is contained in:
@@ -37,24 +37,49 @@
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include <QVariant>
|
||||
#include <expected>
|
||||
|
||||
#include <bc.h>
|
||||
|
||||
class BCAbstractTransmitter;
|
||||
class BCValue;
|
||||
class BCAbstractTransmitter;
|
||||
|
||||
using optDouble = std::optional<double>;
|
||||
using ReadValueFunc = std::function<uint32_t( const BCAbstractTransmitter& transmitter, uint32_t deviceID, uint8_t registerID )>;
|
||||
|
||||
// Enthält den gelesenen Wert oder einen Fehlerstring
|
||||
using TransmitResult = std::expected<uint32_t,QString>;
|
||||
// Funktionsobject, um Werte aus der Transmitterschicht zu holden
|
||||
using ReadValueFunc = std::function<TransmitResult( const BCAbstractTransmitter& transmitter, uint32_t deviceID, uint8_t registerID )>;
|
||||
|
||||
|
||||
/**
|
||||
* @brief BCAbstractTransmitter ist das abstrakte Basisinterface für die eigentliche
|
||||
* Datenübertragung auf Treiberebene.
|
||||
*/
|
||||
|
||||
class BCAbstractTransmitter
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
virtual TransmitResult readByte ( uint32_t deviceID, uint8_t registerID ) const = 0;
|
||||
virtual TransmitResult writeByte( uint32_t deviceID, uint8_t registerID, uint8_t value_ ) const = 0;
|
||||
};
|
||||
|
||||
|
||||
struct BCValueType
|
||||
{
|
||||
|
||||
Q_GADGET
|
||||
|
||||
public:
|
||||
|
||||
BCValueType();
|
||||
BCValueType( QString unitLabel_, double factor_= 1.0, optDouble min_=std::nullopt, optDouble max_= std::nullopt );
|
||||
BCValueType( QString unitKey_, QString unitLabel_, double factor_= 1.0, optDouble min_=std::nullopt, optDouble max_= std::nullopt );
|
||||
|
||||
QString readRawValueX ( const BCAbstractTransmitter& transmitter, const BCValue& value ) const;
|
||||
void writeRawValueX( const BCAbstractTransmitter& transmitter, const BCValue& value ) const;
|
||||
|
||||
virtual QString formatValue( uint32_t value ) const;
|
||||
|
||||
QString unitLabel;
|
||||
double factor;
|
||||
@@ -62,8 +87,6 @@ public:
|
||||
optDouble max;
|
||||
ReadValueFunc readValueFunc;
|
||||
|
||||
virtual QString formatValue( uint32_t value ) const;
|
||||
|
||||
static std::optional<BCValueType*> fetchValueType( const QString& unitTypeKey );
|
||||
static std::optional<ReadValueFunc> fetchReadValueFunction( const QString& unitTypeKey );
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user