Reworked value handling.
This commit is contained in:
@@ -44,6 +44,7 @@ class BCAbstractTransmitter;
|
||||
class BCValue;
|
||||
|
||||
using optDouble = std::optional<double>;
|
||||
using ReadValueFunc = std::function<uint32_t( const BCAbstractTransmitter& transmitter, uint32_t deviceID, uint8_t registerID )>;
|
||||
|
||||
struct BCValueType
|
||||
{
|
||||
@@ -59,46 +60,16 @@ public:
|
||||
double factor;
|
||||
optDouble min;
|
||||
optDouble max;
|
||||
|
||||
virtual QString createStringValue( const BCAbstractTransmitter& transmitter, uint32_t deviceID, uint8_t registerID ) const = 0;
|
||||
//virtual void writeValue( const BCAbstractTransmitter& transmitter, BCValue& value ) = 0;
|
||||
ReadValueFunc readValueFunc;
|
||||
|
||||
virtual QString formatValue( uint32_t value ) const;
|
||||
|
||||
static std::optional<BCValueType*> fetchValueType( const QString& unitTypeKey );
|
||||
static std::optional<BCValueType*> fetchValueType( const QString& unitTypeKey );
|
||||
static std::optional<ReadValueFunc> fetchReadValueFunction( const QString& unitTypeKey );
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct BCValueTypeByte : BCValueType
|
||||
{
|
||||
BCValueTypeByte( QString unitLabel_, double factor_= 1.0, optDouble min_=std::nullopt, optDouble max_= std::nullopt );
|
||||
|
||||
QString createStringValue( const BCAbstractTransmitter& transmitter, uint32_t deviceID, uint8_t registerID ) const override;
|
||||
};
|
||||
|
||||
struct BCValueTypeWord : public BCValueType
|
||||
{
|
||||
BCValueTypeWord( QString unitLabel_, double factor_= 1.0, optDouble min_=std::nullopt, optDouble max_= std::nullopt );
|
||||
|
||||
QString createStringValue( const BCAbstractTransmitter& transmitter, uint32_t deviceID, uint8_t registerID ) const override;
|
||||
};
|
||||
|
||||
struct BCValueTypeODO : public BCValueType
|
||||
{
|
||||
BCValueTypeODO( QString unitLabel_, double factor_= 1.0, optDouble min_=std::nullopt, optDouble max_= std::nullopt );
|
||||
|
||||
QString createStringValue( const BCAbstractTransmitter& transmitter, uint32_t deviceID, uint8_t registerID ) const override;
|
||||
};
|
||||
|
||||
/*
|
||||
struct BCValueTypeVolt : public BCValueType
|
||||
{
|
||||
BCValueTypeODO( QString unitLabel_, double factor_= 1.0, optDouble min_=std::nullopt, optDouble max_= std::nullopt );
|
||||
|
||||
QString createStringValue( const BCAbstractTransmitter& transmitter, uint32_t deviceID, uint8_t registerID ) override;
|
||||
};
|
||||
*/
|
||||
|
||||
//using BCTypeVariant = std::variant<BCValueType,BCValueTypeWord,Long,Fitz,Fatz>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user