Added BCValueType
This commit is contained in:
58
bcvalue.h
58
bcvalue.h
@@ -40,30 +40,29 @@
|
||||
|
||||
|
||||
/*
|
||||
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
|
||||
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,
|
||||
Teilen sich jedoch die Einheit '%'.
|
||||
|
||||
Das ist natürlich annalog zu den ItemTypes:
|
||||
- ein Value hat einen ValueType, der bestimmt folgendes:
|
||||
- long or short or quad
|
||||
- unit (mm, km/h, odo ... )
|
||||
-
|
||||
|
||||
|
||||
*/
|
||||
|
||||
using optDouble = std::optional<double>;
|
||||
|
||||
struct BCValueType
|
||||
{
|
||||
|
||||
Q_GADGET
|
||||
|
||||
public:
|
||||
|
||||
enum class TypeID : uint8_t
|
||||
{
|
||||
Invalid = 0x0,
|
||||
};
|
||||
Q_ENUM(TypeID)
|
||||
|
||||
enum class UnitID : uint8_t
|
||||
{
|
||||
Invalid = 0x0,
|
||||
Text,
|
||||
@@ -71,39 +70,27 @@ public:
|
||||
Float,
|
||||
Percent,
|
||||
KWh,
|
||||
Watt,
|
||||
Km,
|
||||
Kmh,
|
||||
Mm,
|
||||
Sec,
|
||||
SoC,
|
||||
Odo,
|
||||
Assist,
|
||||
AssistFac,
|
||||
Date
|
||||
};
|
||||
Q_ENUM(UnitID)
|
||||
Q_ENUM(TypeID)
|
||||
|
||||
BCValueType( TypeID ID_, QString unitLabel_="", optDouble factor_=std::nullopt, optDouble min_=std::nullopt, optDouble max_= std::nullopt );
|
||||
|
||||
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;
|
||||
TypeID ID;
|
||||
QString unitLabel;
|
||||
optDouble factor;
|
||||
optDouble min;
|
||||
optDouble max;
|
||||
optDouble factor;
|
||||
|
||||
};
|
||||
|
||||
class BCValue
|
||||
@@ -114,18 +101,19 @@ public:
|
||||
BCValue() = default;
|
||||
BCValue( BCDevice::ID deviceID, BC::ID targetID );
|
||||
|
||||
void setLongValue( uint8_t value);
|
||||
uint8_t getLongValue();
|
||||
|
||||
QString label;
|
||||
void setLongValue( uint8_t value);
|
||||
uint8_t getLongValue();
|
||||
|
||||
BCDevice::ID deviceID{BCDevice::ID::Invalid};
|
||||
BC::ID targetID{BC::ID::Invalid};
|
||||
|
||||
BCValueType::TypeID typeID{BCValueType::TypeID::Invalid};;
|
||||
|
||||
QVariant defaultValue;
|
||||
QString label;
|
||||
QVariant value;
|
||||
QVariant defaultValue;
|
||||
bool inSync{false};
|
||||
bool readOnly{false};
|
||||
|
||||
};
|
||||
// Damit QVariant dieses Struct transportieren kann:
|
||||
|
||||
Reference in New Issue
Block a user