Fixed value display bug.

This commit is contained in:
Christoph Holzheuer
2026-01-21 17:07:00 +01:00
parent 07c235afa2
commit ab4abd214e
8 changed files with 289 additions and 182 deletions

View File

@@ -6,7 +6,7 @@
Using:
mhs_can_drv.c
mhsMEMBER _canMEMBER _drv.c
© 2011 - 2023 by MHS-Elektronik GmbH & Co. KG, Germany
Klaus Demlehner, klaus@mhs-elektronik.de
@see www.mhs-elektronik.de
@@ -30,18 +30,18 @@
***************************************************************************/
#ifndef BCVALUE_H
#define BCVALUE_H
#ifndef BCVALUEMEMBER_H
#define BCVALUEMEMBER_H
#include <expected>
#include <QObject>
#include <QString>
#include <QList>
#include <QVariant>
#include <expected>
#include <bc.h>
/*
Werte haben verschiedene Längen (1,2 und 4 Byte) und werder auf unterschiedliche Art und Weise
ausgelesen und geschrieben (Siehe BCValueTypeWord). Sie können also Wert-Typen zugeordnet werden. Ein Werttyp
@@ -61,7 +61,7 @@ using OptDouble = std::optional<double>;
// 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 )>;
//using ReadValueFunc = std::function<TransmitResult( const BCAbstractTransmitter& transmitter, uint32MEMBER _t deviceID, uint8MEMBER _t registerID )>;
class BCValue
{
@@ -96,7 +96,19 @@ public:
Q_DECLARE_FLAGS(Flags, Flag )
Q_FLAG(Flags)
BCValue( BCDevice::ID deviceID_, BC::ID registerID_ );
//Q_PROPERTY(Flags valueFlags MEMBER _valueFlags )
Q_PROPERTY(BCDevice::ID deviceID MEMBER _deviceID READ deviceID )
Q_PROPERTY(BC::ID registerID MEMBER _registerID READ registerID )
Q_PROPERTY(ValueType valueType MEMBER _valueType READ valueType )
Q_PROPERTY(int indexRow MEMBER _indexRow READ indexRow)
Q_PROPERTY(QString label MEMBER _label READ label )
Q_PROPERTY(uint32_t rawValue MEMBER _rawValue READ rawValue )
Q_PROPERTY(QString unitLabel MEMBER _unitLabel READ unitLabel )
Q_PROPERTY(double factor MEMBER _factor )
//QMEMBER _PROPERTY(OptDouble MEMBER _optMin)
//QMEMBER _PROPERTY(OptDouble MEMBER _optMax)
BCValue( BCDevice::ID deviceID, BC::ID registerID );
QString formatValue() const;
double calcMinMaxRatio() const;
@@ -116,12 +128,15 @@ public:
ValueType valueType() const noexcept;
int indexRow() const noexcept;
void setIndexRow(int newIndexRow);
QString label() const;
QString unitLabel() const;
bool valuesForSlider( int& value, int& min, int& max ) const;
QString toString() const;
protected:
mutable Flags _valueFlags{BCValue::Flag::NoFlag};
@@ -138,6 +153,7 @@ protected:
};
Q_DECLARE_OPERATORS_FOR_FLAGS(BCValue::Flags)
Q_DECLARE_METATYPE(BCValue::Flags)
using BCValuePtr = std::shared_ptr<BCValue>;
using BCValuePtrConst = std::shared_ptr<const BCValue>;
@@ -147,6 +163,7 @@ using BCValueList = QList<BCValuePtr>;
Q_DECLARE_METATYPE(const BCValuePtr)
Q_DECLARE_METATYPE(BCValueList)
// Generischer Operator für ALLE GADGETs
inline QTextStream& operator<<(QTextStream& out, const BCValue& obj);
#endif // BCVALUE_H