Added BCValueType

This commit is contained in:
2025-12-17 17:50:24 +01:00
parent 09ff2f00bb
commit 35112ba334
5 changed files with 123 additions and 67 deletions

101
bcvalue.h
View File

@@ -28,39 +28,81 @@
***************************************************************************/
#ifndef BCRawValue_H
#define BCRawValue_H
#ifndef BCVALUE_H
#define BCVALUE_H
#include <QObject>
#include <QString>
#include <QList>
#include <QVariant>
#include <bc.h>
/*
Das ist natürlich annalog zu den ItemTypes:
- ein Value hat einen ValueType, der bestimmt folgendes:
- long or short
- unit (mm, km/h, odo ... )
-
*/
using optDouble = std::optional<double>;
struct BCValueParams
struct BCValueType
{
QString ID;
QString Label;
QString Default;
QString Current;
QString Enabled;
QString UnitType;
QString Min;
QString Max;
QString Factor;
};
Q_GADGET
public:
struct BCUnit
{
enum class ID
enum class TypeID : uint8_t
{
Invalid = 0x0,
};
Q_ENUM(TypeID)
enum class UnitID : uint8_t
{
Invalid = 0x0,
Text,
Number,
Float,
Percent,
KWh,
Km,
Mm,
Sec,
SOC,
Date
};
Q_ENUM(UnitID)
static QString getUnitName( UnitID unitID)
{
static QMap<UnitID,QString> s_unitNames
{
{UnitID::Invalid, "" },
{UnitID::Text, ""},
{UnitID::Number, ""},
{UnitID::Float, "" },
{UnitID::Percent, "%"},
{UnitID::KWh, "kWh" },
{UnitID::Km, "km"},
{UnitID::Mm, "mm"},
{UnitID::Sec, "s"},
{UnitID::SOC, "%"},
{UnitID::Date, ""}
};
return s_unitNames[unitID];
}
UnitID ID;
optDouble min;
optDouble max;
optDouble factor;
};
class BCValue
@@ -79,19 +121,30 @@ public:
BCDevice::ID deviceID{BCDevice::ID::Invalid};
BC::ID targetID{BC::ID::Invalid};
optDouble min;
optDouble max;
optDouble factor;
//BCValueType::ID typeID{BCValueType::ID::Invalid};
BCValueType::TypeID firz;
QVariant defaultValue;
QVariant value;
static BCValue makeValue(BCDevice::ID deviceID, const BCValueParams& params );
};
// Damit QVariant dieses Struct transportieren kann:
Q_DECLARE_METATYPE(BCValue)
struct BCValueParams
{
QString ID;
QString Label;
QString Default;
QString Current;
QString Enabled;
QString UnitType;
QString Min;
QString Max;
QString Factor;
};
// abbreviations:
// SOC = State Of Charge
// LMD = Last Measured Discharge
@@ -111,4 +164,4 @@ constexpr auto to_u(E e) noexcept {
using BCValueList = QVector<BCValue>;
#endif // BCRawValue_H
#endif // BCVALUE_H