Reworked value reading.
This commit is contained in:
117
bcdatavalue.h
117
bcdatavalue.h
@@ -28,8 +28,8 @@
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef BCDATAITEM_H
|
||||
#define BCDATAITEM_H
|
||||
#ifndef BCDATAVALUE_H
|
||||
#define BCDATAVALUE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
@@ -41,9 +41,9 @@
|
||||
|
||||
/*
|
||||
Werte haben verschiedene Längen (1,2 und 4 Byte) und werder auf unterschiedliche Art und Weise
|
||||
ausgelesen und geschrieben (Siehe ODO). Sin können also Wert-Typen zugeordnet werden. Ein Werttyp
|
||||
ausgelesen und geschrieben (Siehe BCValueTypeWord). Sin können also Wert-Typen zugeordnet werden. Ein Werttyp
|
||||
lässet über eine ID identifizieren, die mit der phyikalische Einheit des Wertes überschneiden kann,
|
||||
aber nicht muss: : Km/h, kWh, ODO ... bilden eigene Typen, SoC, Assistence Level sind auch eigene Typen,
|
||||
aber nicht muss: : Km/h, kWh, BCValueTypeWord ... bilden eigene Typen, SoC, Assistence Level sind auch eigene Typen,
|
||||
Teilen sich jedoch die Einheit '%'.
|
||||
|
||||
Das ist natürlich annalog zu den ItemTypes:
|
||||
@@ -60,115 +60,46 @@ class BCAbstractTransmitter
|
||||
|
||||
public:
|
||||
|
||||
//
|
||||
virtual uint32_t readRawValue( BCDevice::ID deviceID_, BC::ID registerID_ ) const = 0;
|
||||
virtual void writeRawValue( BCDevice::ID deviceID_, BC::ID registerID_, uint8_t value_ ) const = 0;
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
class BCDataItem;
|
||||
class BCValueType;
|
||||
|
||||
using optDouble = std::optional<double>;
|
||||
|
||||
struct BCDataType
|
||||
{
|
||||
|
||||
Q_GADGET
|
||||
|
||||
public:
|
||||
|
||||
BCDataType();
|
||||
BCDataType( QString unitLabel_, double factor_= 1.0, optDouble min_=std::nullopt, optDouble max_= std::nullopt );
|
||||
|
||||
QString unitLabel;
|
||||
double factor;
|
||||
optDouble min;
|
||||
optDouble max;
|
||||
|
||||
virtual double readValue( const BCAbstractTransmitter& transmitter ) = 0;
|
||||
virtual void writeValue( const BCAbstractTransmitter& transmitter ) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct BCDataTypeByte : public BCDataType
|
||||
{
|
||||
/*
|
||||
double readValue( const BCAbstractTransmitter& transmitter, const BCDA ) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void writeValue( const BCAbstractTransmitter& transmitter ) override;
|
||||
{
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
};
|
||||
|
||||
struct ODO : public BCDataType
|
||||
{
|
||||
double readValue( const BCAbstractTransmitter& transmitter ) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void writeValue( const BCAbstractTransmitter& transmitter ) override;
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
struct Long : public BCDataType
|
||||
{};
|
||||
|
||||
struct Fitz : public BCDataType
|
||||
{};
|
||||
|
||||
struct Fatz : public BCDataType
|
||||
{};
|
||||
|
||||
using BCTypeVariant = std::variant<BCDataType,ODO,Long,Fitz,Fatz>;
|
||||
|
||||
// really needed?
|
||||
//using BCDataTypeCRef = std::optional<std::reference_wrapper<const BCTypeVariant>>;
|
||||
|
||||
|
||||
class BCDataItem
|
||||
class BCDataValue
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
BCDataItem( const BCDataType* valueType_, BCDevice::ID deviceID_, BC::ID registerID_ );
|
||||
BCDataValue( const BCValueType* valueType_, BCDevice::ID deviceID_, BC::ID registerID_ );
|
||||
|
||||
void readRawValueX( const BCAbstractTransmitter& transmitter ) const;
|
||||
void writeRawValueX( const BCAbstractTransmitter& transmitter ) const;
|
||||
// void reset()
|
||||
|
||||
//const BCDataType& valueType;
|
||||
//BCDataTypeCRef valueType;
|
||||
const BCDataType* valueType{};
|
||||
BCDevice::ID deviceID{BCDevice::ID::Invalid};
|
||||
BC::ID registerID{BC::ID::Invalid};
|
||||
int rowInModel{-1};
|
||||
QString label;
|
||||
QVariant value;
|
||||
QVariant defaultValue;
|
||||
//const BCValueType& valueType;
|
||||
//BCValueTypeCRef valueType;
|
||||
const BCValueType* valueType{};
|
||||
BCDevice::ID deviceID{BCDevice::ID::Invalid};
|
||||
BC::ID registerID{BC::ID::Invalid};
|
||||
int rowInModel{-1};
|
||||
QString label;
|
||||
mutable QString visibleValue;
|
||||
QVariant defaultValue;
|
||||
|
||||
bool inSync{false};
|
||||
bool readOnly{false};
|
||||
bool inSync{false};
|
||||
bool readOnly{false};
|
||||
|
||||
mutable std::optional<uint32_t> rawValue;
|
||||
//mutable std::optional<uint32_t> rawValue;
|
||||
|
||||
|
||||
|
||||
};
|
||||
Q_DECLARE_METATYPE(BCDataItem*)
|
||||
Q_DECLARE_METATYPE(BCDataValue*)
|
||||
|
||||
|
||||
using BCDataList = QVector<BCDataItem>;
|
||||
using BCDataList = QVector<BCDataValue>;
|
||||
|
||||
|
||||
|
||||
@@ -192,4 +123,4 @@ constexpr auto to_u(E e) noexcept {
|
||||
|
||||
|
||||
|
||||
#endif // BCDATAITEM_H
|
||||
#endif // BCDATAVALUE_H
|
||||
|
||||
Reference in New Issue
Block a user