Added some Motor tags, changed back to some qt 6.0 methods.
This commit is contained in:
3
bc.h
3
bc.h
@@ -712,10 +712,7 @@ public:
|
|||||||
Motor_Assist_Regen_Inflex = 0xd2, // Speed From Which Regen Is Not Attenuated [Unit:Rpm, Range:5..?, Factor:9.091]
|
Motor_Assist_Regen_Inflex = 0xd2, // Speed From Which Regen Is Not Attenuated [Unit:Rpm, Range:5..?, Factor:9.091]
|
||||||
|
|
||||||
Motor_Assist_Maxspeed_Derate_Delta = 0xd3, // Speed Before Maxspeed To Start Derating [Unit:Rpm, Factor:9.091]
|
Motor_Assist_Maxspeed_Derate_Delta = 0xd3, // Speed Before Maxspeed To Start Derating [Unit:Rpm, Factor:9.091]
|
||||||
//{%Endregion}
|
|
||||||
|
|
||||||
|
|
||||||
//{%Region Sensor}
|
|
||||||
ID_Sensor = 0x68,
|
ID_Sensor = 0x68,
|
||||||
Reg_Sensor_Config_Gauge_Gain_Hi = 0x10,
|
Reg_Sensor_Config_Gauge_Gain_Hi = 0x10,
|
||||||
Reg_Sensor_Config_Gauge_Gain_Lo = 0x11,
|
Reg_Sensor_Config_Gauge_Gain_Lo = 0x11,
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ void BCDataManager::loadXmlBikeData( const QString& fileName )
|
|||||||
printAttrs (_xml);
|
printAttrs (_xml);
|
||||||
// Wir wollen die Device-ID aus dem XML Tag ermitteln
|
// Wir wollen die Device-ID aus dem XML Tag ermitteln
|
||||||
const char* deviceKey = _xml.attributes().value("Type"_L1).toLatin1().constData();
|
const char* deviceKey = _xml.attributes().value("Type"_L1).toLatin1().constData();
|
||||||
auto optDeviceID = _bcDeviceEnum.keyToValue64(deviceKey);
|
auto optDeviceID = _bcDeviceEnum.keysToValue64(deviceKey);
|
||||||
//_currentDeviceID = BCDevice::ID( deviceID.value_or( BCDevice::ID::Invalid ) );
|
//_currentDeviceID = BCDevice::ID( deviceID.value_or( BCDevice::ID::Invalid ) );
|
||||||
if( optDeviceID.has_value())
|
if( optDeviceID.has_value())
|
||||||
{
|
{
|
||||||
@@ -204,41 +204,6 @@ std::optional<BCValue> BCDataManager::makeDataValue( BCDevice::ID deviceID, cons
|
|||||||
|
|
||||||
static QMetaEnum s_bcValueEnum{QMetaEnum::fromType<BC::ID>()};
|
static QMetaEnum s_bcValueEnum{QMetaEnum::fromType<BC::ID>()};
|
||||||
|
|
||||||
static BCValueTypeMap s_bcDataTypes
|
|
||||||
{
|
|
||||||
{ "Byte", new BCValueTypeWord( "", 1.5625F) },
|
|
||||||
{ "Word", new BCValueTypeWord( "", 1.5625F) },
|
|
||||||
|
|
||||||
{ "Float", new BCValueTypeWord( "", 1.5625F) },
|
|
||||||
{ "Percent",new BCValueTypeWord( "%", 1.5625 ) },
|
|
||||||
{ "KWh", new BCValueTypeWord( "kwh", 1.5625 ) },
|
|
||||||
{ "Watt", new BCValueTypeWord( "w", 1.5625 ) },
|
|
||||||
{ "Km", new BCValueTypeWord( "km", 1.5625 ) },
|
|
||||||
{ "Kmh", new BCValueTypeWord( "km/h", 0.1 ) },
|
|
||||||
{ "Mm", new BCValueTypeWord( "mm", 1.5625 ) },
|
|
||||||
{ "Sec", new BCValueTypeWord( "s", 1.5625 ) },
|
|
||||||
{ "SoC", new BCValueTypeWord( "%", 1.5625 ) },
|
|
||||||
{ "Odo", new BCValueTypeWord( "km", 1.5625 ) },
|
|
||||||
{ "Assist", new BCValueTypeWord( "", 0 ,4 ) },
|
|
||||||
{ "Assist", new BCValueTypeWord( "%" ) },
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
_dataTypes.insert( "Float", new Fitz{{ "", 1.5625F}} );
|
|
||||||
_dataTypes.insert( "Percent",new Fatz{{ "%", 1.5625 }} );
|
|
||||||
_dataTypes.insert( "KWh", new Fatz{{ "kwh", 1.5625 }} );
|
|
||||||
_dataTypes.insert( "Watt", new Long{{ "w", 1.5625 }} );
|
|
||||||
_dataTypes.insert( "Km", new BCValueTypeWord{{ "km", 1.5625 }} );
|
|
||||||
_dataTypes.insert( "Kmh", new BCValueTypeWord{{ "km/h", 0.1 }} );
|
|
||||||
_dataTypes.insert( "Mm", new BCValueTypeWord{{ "mm", 1.5625 }} );
|
|
||||||
_dataTypes.insert( "Sec", new BCValueTypeWord{{ "s", 1.5625 }} );
|
|
||||||
_dataTypes.insert( "SoC", new Long{{ "%", 1.5625 }} );
|
|
||||||
_dataTypes.insert( "Odo", new Fitz{{ "km", 1.5625 }} );
|
|
||||||
_dataTypes.insert( "Assist", new Fatz{{ "", 0 ,4 }} );
|
|
||||||
_dataTypes.insert( "Assist", new Fatz{{ "%" }} );
|
|
||||||
//_dataTypes.insert( "Date", { BCValueType::TypeID::Date } );
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Wir brauchen:
|
Wir brauchen:
|
||||||
@@ -249,16 +214,14 @@ std::optional<BCValue> BCDataManager::makeDataValue( BCDevice::ID deviceID, cons
|
|||||||
|
|
||||||
std::optional<BCValue> newValue;
|
std::optional<BCValue> newValue;
|
||||||
|
|
||||||
std::optional<quint64> IDVal = s_bcValueEnum.keyToValue64( params.ID.toLatin1().constData() );
|
std::optional<quint64> IDVal = s_bcValueEnum.keysToValue64( params.ID.toLatin1().constData() );
|
||||||
qDebug() << " --- should create: " << params.Label << ": " << params.UnitType;
|
qDebug() << " --- should create: " << params.Label << ": " << params.UnitType;
|
||||||
if( IDVal.has_value() )
|
if( IDVal.has_value() )
|
||||||
{
|
{
|
||||||
|
auto valueType = BCValueType::fetchValueType(params.UnitType);
|
||||||
if( s_bcDataTypes.contains( params.UnitType ) )
|
if( valueType.has_value() )
|
||||||
{
|
{
|
||||||
|
newValue = BCValue( *valueType, deviceID, static_cast<BC::ID>(IDVal.value()) );
|
||||||
const BCValueType* valueType = s_bcDataTypes[params.UnitType];
|
|
||||||
newValue = BCValue( valueType, deviceID, static_cast<BC::ID>(IDVal.value()) );
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
setIfExists( params.Factor, newValue.factor );
|
setIfExists( params.Factor, newValue.factor );
|
||||||
@@ -269,7 +232,6 @@ std::optional<BCValue> BCDataManager::makeDataValue( BCDevice::ID deviceID, cons
|
|||||||
newValue->defaultValue = params.Default;
|
newValue->defaultValue = params.Default;
|
||||||
|
|
||||||
qDebug() << " --- created: " << params.Label;
|
qDebug() << " --- created: " << params.Label;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,8 +79,6 @@ protected:
|
|||||||
|
|
||||||
std::optional<BCValue> makeDataValue( BCDevice::ID deviceID, const BCDataParams& params );
|
std::optional<BCValue> makeDataValue( BCDevice::ID deviceID, const BCDataParams& params );
|
||||||
|
|
||||||
using BCValueTypeMap = QHash<QString,BCValueType*>;
|
|
||||||
|
|
||||||
QXmlStreamReader _xml;
|
QXmlStreamReader _xml;
|
||||||
QMetaEnum _bcDeviceEnum{QMetaEnum::fromType<BCDevice::ID>()};
|
QMetaEnum _bcDeviceEnum{QMetaEnum::fromType<BCDevice::ID>()};
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,51 @@ QString BCValueType::formatValue( uint32_t value ) const
|
|||||||
double result = value * factor;
|
double result = value * factor;
|
||||||
return QString::number(result, 'f', 2);
|
return QString::number(result, 'f', 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
_dataTypes.insert( "Float", new Fitz{{ "", 1.5625F}} );
|
||||||
|
_dataTypes.insert( "Percent",new Fatz{{ "%", 1.5625 }} );
|
||||||
|
_dataTypes.insert( "KWh", new Fatz{{ "kwh", 1.5625 }} );
|
||||||
|
_dataTypes.insert( "Watt", new Long{{ "w", 1.5625 }} );
|
||||||
|
_dataTypes.insert( "Km", new BCValueTypeWord{{ "km", 1.5625 }} );
|
||||||
|
_dataTypes.insert( "Kmh", new BCValueTypeWord{{ "km/h", 0.1 }} );
|
||||||
|
_dataTypes.insert( "Mm", new BCValueTypeWord{{ "mm", 1.5625 }} );
|
||||||
|
_dataTypes.insert( "Sec", new BCValueTypeWord{{ "s", 1.5625 }} );
|
||||||
|
_dataTypes.insert( "SoC", new Long{{ "%", 1.5625 }} );
|
||||||
|
_dataTypes.insert( "Odo", new Fitz{{ "km", 1.5625 }} );
|
||||||
|
_dataTypes.insert( "Assist", new Fatz{{ "", 0 ,4 }} );
|
||||||
|
_dataTypes.insert( "Assist", new Fatz{{ "%" }} );
|
||||||
|
//_dataTypes.insert( "Date", { BCValueType::TypeID::Date } );
|
||||||
|
*/
|
||||||
|
std::optional<BCValueType*> BCValueType::fetchValueType( const QString& unitTypeKey )
|
||||||
|
{
|
||||||
|
static QHash<QString,BCValueType*> s_bcDataTypes
|
||||||
|
{
|
||||||
|
{ "Byte", new BCValueTypeWord( "", 1.5625F) },
|
||||||
|
{ "Word", new BCValueTypeWord( "", 1.5625F) },
|
||||||
|
|
||||||
|
{ "Float", new BCValueTypeWord( "", 1.5625F) },
|
||||||
|
{ "Percent",new BCValueTypeWord( "%", 1.5625 ) },
|
||||||
|
{ "KWh", new BCValueTypeWord( "kwh", 1.5625 ) },
|
||||||
|
{ "Watt", new BCValueTypeWord( "w", 1.5625 ) },
|
||||||
|
{ "Km", new BCValueTypeWord( "km", 1.5625 ) },
|
||||||
|
{ "Kmh", new BCValueTypeWord( "km/h", 0.1 ) },
|
||||||
|
{ "Mm", new BCValueTypeWord( "mm", 1.5625 ) },
|
||||||
|
{ "Sec", new BCValueTypeWord( "s", 1.5625 ) },
|
||||||
|
{ "Degree", new BCValueTypeByte( "°C", 1.0 ) },
|
||||||
|
{ "SoC", new BCValueTypeWord( "%", 1.5625 ) },
|
||||||
|
{ "Odo", new BCValueTypeWord( "km", 1.5625 ) },
|
||||||
|
{ "Assist", new BCValueTypeWord( "", 0 ,4 ) },
|
||||||
|
{ "Assist", new BCValueTypeWord( "%" ) },
|
||||||
|
};
|
||||||
|
|
||||||
|
if( !s_bcDataTypes.contains( unitTypeKey ) )
|
||||||
|
return std::nullopt;
|
||||||
|
|
||||||
|
return s_bcDataTypes[unitTypeKey];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/// ----
|
/// ----
|
||||||
|
|
||||||
BCValueTypeByte::BCValueTypeByte( QString unitLabel_, double factor_, optDouble min_, optDouble max_ )
|
BCValueTypeByte::BCValueTypeByte( QString unitLabel_, double factor_, optDouble min_, optDouble max_ )
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ public:
|
|||||||
|
|
||||||
virtual QString formatValue( uint32_t value ) const;
|
virtual QString formatValue( uint32_t value ) const;
|
||||||
|
|
||||||
|
static std::optional<BCValueType*> fetchValueType( const QString& unitTypeKey );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -29,13 +29,25 @@
|
|||||||
|
|
||||||
</Device>
|
</Device>
|
||||||
|
|
||||||
<Device Type="Battery">
|
|
||||||
</Device>
|
|
||||||
<Device Type="Motor">
|
<Device Type="Motor">
|
||||||
|
<Value ID='Motor_Rev_Hw' Label='Hardware Version' Default='' UnitType='Byte' />
|
||||||
|
<Value ID='Motor_Rev_Sw' Label='Software Version' Default='' UnitType='Byte' />
|
||||||
|
<Value ID='Motor_Status_Temperature' Label='Motor Temperature' Default='' UnitType='Degree'/>
|
||||||
|
<Value ID='Motor_Assist_Maxspeed' Label='Motor max. Speed' Default='' UnitType='Kmh' />
|
||||||
|
<Value ID='Motor_Sn_Item_Hi' Label='Motor Part Number' Default='' UnitType='Word'/>
|
||||||
|
<Value ID='Motor_Sn_Item_Hi' Label='Motor Serial Number' Default='' UnitType='Word' />
|
||||||
|
<Value ID='Motor_Geometry_Circ_Hi' Label='Motor Gemetry' Default='' UnitType='Mm' />
|
||||||
</Device>
|
</Device>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<Device Type="Sensor">
|
<Device Type="Sensor">
|
||||||
</Device>
|
</Device>
|
||||||
|
|
||||||
|
<Device Type="Battery">
|
||||||
|
</Device>
|
||||||
|
|
||||||
|
|
||||||
</Bike>
|
</Bike>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
|||||||
Reference in New Issue
Block a user