Files
BionxControl/bcvalue.h
2025-12-18 09:30:43 +01:00

168 lines
3.0 KiB
C++

/***************************************************************************
BionxControl
Copyright © 2025 christoph holzheuer
christoph.holzheuer@gmail.com
Using:
BigXionFlasher USB V 0.2.4 rev. 97
© 2011-2013 by Thomas Koenig <info@bigxionflasher.org>
@see www.bigxionflasher.org
Bionx Bike Info
© 2018 Thorsten Schmidt (tschmidt@ts-soft.de)
@see www.ts-soft.de
mhs_can_drv.c 3.00
© 2011 - 2015 by MHS-Elektronik GmbH & Co. KG, Germany
Demlehner Klaus, info@mhs-elektronik.de
@see www.mhs-elektronik.de
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
@see https://github.com/bikemike/bionx-bikeinfo
***************************************************************************/
#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 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,
Number,
Float,
Percent,
KWh,
Km,
Mm,
Sec,
SoC,
Odo,
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
{
public:
BCValue() = default;
BCValue( BCDevice::ID deviceID, BC::ID targetID );
void setLongValue( uint8_t value);
uint8_t getLongValue();
QString label;
BCDevice::ID deviceID{BCDevice::ID::Invalid};
BC::ID targetID{BC::ID::Invalid};
BCValueType::TypeID typeID{BCValueType::TypeID::Invalid};;
QVariant defaultValue;
QVariant value;
};
// 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
// NIP = ?
/*
Needed ?
#include <type_traits>
template <typename E>
constexpr auto to_u(E e) noexcept {
return static_cast<std::underlying_type_t<E>>(e);
}
*/
using BCValueList = QVector<BCValue>;
#endif // BCVALUE_H