diff --git a/.gitignore b/.gitignore index f176f96..eb98eb9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ BionxControl.pro.user build/ +bcvalue.cpp.autosave diff --git a/bc.h b/bc.h index 41eb7aa..cc5cbf6 100644 --- a/bc.h +++ b/bc.h @@ -742,5 +742,18 @@ public: Q_ENUM(ID) }; +using namespace Qt::Literals::StringLiterals; // Für _L1 + +namespace BCTags +{ + inline constexpr auto Device = "Device"_L1; + inline constexpr auto ID = "ID"_L1; + inline constexpr auto Default = "Default"_L1; + inline constexpr auto Current = "Current"_L1; + inline constexpr auto UnitType = "UnitType"_L1; + inline constexpr auto Min = "Min"_L1; + inline constexpr auto Max = "Max"_L1; + inline constexpr auto Factor = "Factor"_L1; +} #endif // BC_H diff --git a/bcvalue.cpp b/bcvalue.cpp index ac788c5..e9324d3 100644 --- a/bcvalue.cpp +++ b/bcvalue.cpp @@ -29,3 +29,28 @@ #include + + +BCValue::BCValue(BCDevice::ID deviceID_, BC::ID targetID_) + : deviceID{deviceID_}, targetID{targetID_} +{ +} + +void BCValue::setLongValue( uint8_t value) +{ + +} + +uint8_t BCValue::getLongValue() +{ + return 0; +} + + +BCValue* BCValue::makeValue(BCDevice::ID deviceI, const BCValueParams& params ) +{ + + + + return nullptr; +} diff --git a/bcvalue.h b/bcvalue.h index 51efa80..072c387 100644 --- a/bcvalue.h +++ b/bcvalue.h @@ -38,6 +38,21 @@ #include +struct BCValueParams +{ + BCDevice::ID DeviceID{BCDevice::ID::Invalid}; + BC::ID ID{BC::ID::Invalid}; + QString IDString; + QString Default; + QString Current; + QString Enabled; + QString UnitType; + QString Min; + QString Max; + QString Factor; +}; + + struct BCUnit { enum class ID @@ -61,7 +76,11 @@ public: QString label; BCDevice::ID deviceID{BCDevice::ID::Invalid}; BC::ID targetID{BC::ID::Invalid}; - double _value{-1}; + + double value{-1}; + + static BCValue* makeValue( const BCValueParams& params ); + }; // abbreviations: diff --git a/bcvaluemanager.cpp b/bcvaluemanager.cpp index 69c0c48..90fc2b4 100644 --- a/bcvaluemanager.cpp +++ b/bcvaluemanager.cpp @@ -145,12 +145,10 @@ void BCValueManager::readDevice() //while (!_xml.atEnd() && !_xml.hasError()) while( _xml.readNextStartElement() ) { - const char* key = _xml.attributes().value("I##D"_L1).toLatin1().constData(); - qDebug() << " --- blub: " << _xml.name() << " : " << key << ":" <<_xml.attributes().value("ID"_L1); - if(key) + if( _xml.attributes().hasAttribute(BCTags::ID) ) + { makeValue(parsedValues); - else - qDebug() << " --- fitz"; + } //printAttrs (_xml); _xml.skipCurrentElement(); @@ -177,12 +175,24 @@ void BCValueManager::readDevice() void BCValueManager::makeValue(BCValueList& parsedValues) { - // ID='Cons_Stat_Dist_Hi' Default='' Current='' Enabled='true' UnitType='mm' Factor='0.1' Min Max - const char* ID = _xml.attributes().value("firz"_L1).toLatin1().constData(); - auto enumVal = _bcValueEnum.keyToValue64( ID); - if( enumVal.has_value() ) - { + const char* IDKey = _xml.attributes().value(BCTags::ID).toLatin1().constData(); + qDebug() << " --- found: " << _xml.name() << " : " << IDKey; + auto IDVal = _bcValueEnum.keyToValue64( IDKey ); + if( IDVal.has_value() ) + { + BCValueParams params + { + .DeviceID = _currentDeviceID, + .ID = BC::ID( IDVal.value() ), + .Default = _xml.attributes().value(BCTags::Default).toString(), + .Current = _xml.attributes().value(BCTags::Current).toString(), + .UnitType = _xml.attributes().value(BCTags::UnitType).toString(), + .Min = _xml.attributes().value(BCTags::Min).toString(), + .Max = _xml.attributes().value(BCTags::Max).toString(), + .Factor = _xml.attributes().value(BCTags::Factor).toString() + }; + parsedValues.push_back( BCValue::makeValue( params ) ); } } diff --git a/main.cpp b/main.cpp index 2d01ec3..92908c8 100644 --- a/main.cpp +++ b/main.cpp @@ -100,7 +100,7 @@ int main(int argc, char *argv[]) qDebug() << " nice: " << metaEnum.enumName() << " : " <className(); BCValueManager myMgr; - myMgr.loadXml(); + //myMgr.loadXml(); return app.exec();