This commit is contained in:
2026-01-08 00:25:36 +01:00
parent 23695bc7ef
commit c40f288aaa
9 changed files with 110 additions and 196 deletions

View File

@@ -60,7 +60,6 @@ void BCXmlLoader::loadXmlBikeData( const QString& fileName )
qDebug().noquote() << parts.join(" ");
};
QMetaEnum bcDeviceEnum{QMetaEnum::fromType<BCDevice::ID>()};
QFile file(fileName);
@@ -88,22 +87,31 @@ void BCXmlLoader::loadXmlBikeData( const QString& fileName )
if (token == QXmlStreamReader::StartElement)
{
QString deviceType = _xml.attributes().value("Type"_L1).toString();
//printAttrs (_xml);
// Wir wollen die Device-ID aus dem XML Tag ermitteln
const char* deviceKey = _xml.attributes().value("Type"_L1).toLatin1().constData();
bool ok;
auto optDeviceID = bcDeviceEnum.keyToValue(deviceKey,&ok);
//_currentDeviceID = BCDevice::ID( deviceID.value_or( BCDevice::ID::Invalid ) );
//if( optDeviceID.has_value())
if(ok)
{
qDebug() << " --- Device: " << _xml.name() << ": " << deviceType << " : " << optDeviceID;
//BCDevice::ID currentDeviceID = BCDevice::ID( optDeviceID.value() );
BCDevice::ID currentDeviceID = BCDevice::ID( optDeviceID );
loadXmlBikeDeviceData(currentDeviceID);
}
}
qDebug() << " --- FETCH 1: " << deviceType;
// Wir wollen die Device-ID aus dem XML Tag ermitteln
if( deviceType.isEmpty() )
{
printAttrs (_xml);
continue;
}
QByteArray byteArray = deviceType.toUtf8();
const char* deviceKey = byteArray.constData();
bool ok=false;
auto optDeviceID = bcDeviceEnum.keyToValue(deviceKey,&ok);
//_currentDeviceID = BCDevice::ID( deviceID.value_or( BCDevice::ID::Invalid ) );
//if( optDeviceID.has_value())
if(ok)
{
qDebug() << " --- FETCH 2: Device: " << deviceType << " : " << optDeviceID;
//BCDevice::ID currentDeviceID = BCDevice::ID( optDeviceID.value() );
BCDevice::ID currentDeviceID = BCDevice::ID( optDeviceID );
loadXmlBikeDeviceData(currentDeviceID);
}
} // if start element
}
}
@@ -127,7 +135,6 @@ void BCXmlLoader::loadXmlBikeDeviceData(BCDevice::ID deviceID)
printAttrs (_xml);
Q_ASSERT(_xml.isStartElement() && _xml.name() == "Device"_L1);
// temporäre Wertliste für neues Device
BCValueList currentValues;
@@ -135,7 +142,7 @@ void BCXmlLoader::loadXmlBikeDeviceData(BCDevice::ID deviceID)
{
if( _xml.attributes().hasAttribute(BCTags::ID) )
{
//qDebug() << " --- found: " << _xml.name() << " : " << _xml.attributes().value(BCTags::ID);
qDebug() << " --- found: " << _xml.name() << " : " << _xml.attributes().value(BCTags::ID);
// füllen des Parameter packs
BCValueParams params
@@ -205,7 +212,8 @@ std::optional<BCValuePtr> BCXmlLoader::makeValue( BCDevice::ID deviceID, const B
//std::optional<quint64> IDVal = s_bcValueEnum.keyToValue64( params.ID.toLatin1().constData() );
bool ok;
static QMetaEnum s_bcValueEnum{QMetaEnum::fromType<BC::ID>()};
int IDVal = s_bcValueEnum.keyToValue( params.ID.toLatin1().constData(), &ok );
QByteArray byteArray = params.ID.toUtf8();
int IDVal = s_bcValueEnum.keyToValue( byteArray.constData(), &ok );
qDebug() << " --- should create: " << params.Label;
//if( IDVal.has_value() )
if( ok )
@@ -218,25 +226,12 @@ std::optional<BCValuePtr> BCXmlLoader::makeValue( BCDevice::ID deviceID, const B
setIfExists( params.Max, newValue.optMax );
//setIfExists( params.IsWord, newValue.isWord );
newValue.label = params.Label;
newValue.unitLabel = params.UnitLabel;
if( s_valueTypes.contains( params.ValueType ) )
newValue.valueType = s_valueTypes[params.ValueType];
/*
QString ID;
QString Label;
QString UnitLabel;
QString Factor;
QString Min;
QString Max;
QString IsWord;
QString ValueType;
*/
qDebug() << " --- created: " << params.Label;
newValue.dumpValue();