Compiles again, without BCValueType.

This commit is contained in:
2026-01-03 02:50:28 +01:00
parent 6032abb35c
commit c5dc84179b
14 changed files with 353 additions and 568 deletions

113
bcvalue.h
View File

@@ -38,6 +38,7 @@
#include <QList>
#include <QVariant>
#include <expected>
#include <bc.h>
@@ -57,14 +58,30 @@
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 )>;
struct BCValueType;
class BCValue
{
public:
// Aus dem Type ergibt sich
// später der Editor
enum class ValueType : uint8_t
{
Plain,
Bool,
Float,
Mookoo
};
enum class State : uint8_t
{
NoState = 0x00,
@@ -78,16 +95,22 @@ public:
};
Q_DECLARE_FLAGS(States, State )
BCValue( const BCValueType* valueType_, BCDevice::ID deviceID_, BC::ID registerID_ );
mutable States state{BCValue::State::NoState};
const BCValueType* valueType{};
BCDevice::ID deviceID{BCDevice::ID::Invalid};
BC::ID registerID{BC::ID::Invalid};
int indexRow{-1};
QString label;
mutable QString visibleValue;
BCValue( BCDevice::ID deviceID_, BC::ID registerID_ );
QString formatValue( uint32_t value ) const;
mutable States state{BCValue::State::ReadOnly};
BCDevice::ID deviceID{BCDevice::ID::Invalid};
BC::ID registerID{BC::ID::Invalid};
ValueType valueType{ValueType::Plain};
int indexRow{-1};
QString label;
mutable QString visibleValue;
bool isWord{false};
QString unitLabel;
double factor{1};
OptDouble min;
OptDouble max;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(BCValue::States)
@@ -103,71 +126,25 @@ using BCValueList = QList<BCValuePtr>;
Q_DECLARE_METATYPE(const BCValuePtr)
/*
class BCValueList : public QList<BCValue>
Q_DECLARE_METATYPE(BCValueList)
/**
* @brief BCAbstractTransmitter ist das abstrakte Basisinterface für die eigentliche
* Datenübertragung auf Treiberebene.
*/
class BCAbstractTransmitter
{
public:
BCValueList()
{
qDebug() << "BC Construct: " << this;
}
BCValueList(const BCValueList& other)
: QList<BCValue>(other)
{
qDebug() << "BC: Copy from: " << &other << "to" << this;
}
BCValueList(BCValueList&& other) noexcept
: QList<BCValue>( other )
{
qDebug() << "Move from: " << &other << "to" << this;
}
// Copy Assignment Operator
BCValueList& operator=(const BCValueList& other)
{
qDebug() << "BC copy assignment: " << this;
QList<BCValue>::operator=( other );
return *this;
}
// Move Assignment Operator
BCValueList& operator=(BCValueList&& other) noexcept
{
qDebug() << "BC move assignment: " << this;
QList<BCValue>::operator=( other );
return *this;
}
~BCValueList()
{
qDebug() << "Destruct: " << this;
}
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;
};
*/
Q_DECLARE_METATYPE(BCValueList)
// abbreviations:
// SOC = State Of Charge
// LMD = Last Measured Discharge
// NIP = ?
/*
Needed ?
#include <type_traits>
template <typename E>
constexpr auto to_u(E e) noexcept {
return static_cast<std::underlying_type_t<E>>(e);
}
*/