Added BCValue creation, part II.

This commit is contained in:
2025-12-16 21:21:59 +01:00
parent b0d347ef79
commit afb5828a65
6 changed files with 80 additions and 12 deletions

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
BionxControl.pro.user BionxControl.pro.user
build/ build/
bcvalue.cpp.autosave

13
bc.h
View File

@@ -742,5 +742,18 @@ public:
Q_ENUM(ID) 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 #endif // BC_H

View File

@@ -29,3 +29,28 @@
#include <bcvalue.h> #include <bcvalue.h>
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;
}

View File

@@ -38,6 +38,21 @@
#include <bc.h> #include <bc.h>
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 struct BCUnit
{ {
enum class ID enum class ID
@@ -61,7 +76,11 @@ public:
QString label; QString label;
BCDevice::ID deviceID{BCDevice::ID::Invalid}; BCDevice::ID deviceID{BCDevice::ID::Invalid};
BC::ID targetID{BC::ID::Invalid}; BC::ID targetID{BC::ID::Invalid};
double _value{-1};
double value{-1};
static BCValue* makeValue( const BCValueParams& params );
}; };
// abbreviations: // abbreviations:

View File

@@ -145,12 +145,10 @@ void BCValueManager::readDevice()
//while (!_xml.atEnd() && !_xml.hasError()) //while (!_xml.atEnd() && !_xml.hasError())
while( _xml.readNextStartElement() ) while( _xml.readNextStartElement() )
{ {
const char* key = _xml.attributes().value("I##D"_L1).toLatin1().constData(); if( _xml.attributes().hasAttribute(BCTags::ID) )
qDebug() << " --- blub: " << _xml.name() << " : " << key << ":" <<_xml.attributes().value("ID"_L1); {
if(key)
makeValue(parsedValues); makeValue(parsedValues);
else }
qDebug() << " --- fitz";
//printAttrs (_xml); //printAttrs (_xml);
_xml.skipCurrentElement(); _xml.skipCurrentElement();
@@ -177,12 +175,24 @@ void BCValueManager::readDevice()
void BCValueManager::makeValue(BCValueList& parsedValues) void BCValueManager::makeValue(BCValueList& parsedValues)
{ {
// ID='Cons_Stat_Dist_Hi' Default='' Current='' Enabled='true' UnitType='mm' Factor='0.1' Min Max const char* IDKey = _xml.attributes().value(BCTags::ID).toLatin1().constData();
const char* ID = _xml.attributes().value("firz"_L1).toLatin1().constData(); qDebug() << " --- found: " << _xml.name() << " : " << IDKey;
auto enumVal = _bcValueEnum.keyToValue64( ID); auto IDVal = _bcValueEnum.keyToValue64( IDKey );
if( enumVal.has_value() )
{
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 ) );
} }
} }

View File

@@ -100,7 +100,7 @@ int main(int argc, char *argv[])
qDebug() << " nice: " << metaEnum.enumName() << " : " <<metaEnum.name() << ": " << metaEnum.enclosingMetaObject()->className(); qDebug() << " nice: " << metaEnum.enumName() << " : " <<metaEnum.name() << ": " << metaEnum.enclosingMetaObject()->className();
BCValueManager myMgr; BCValueManager myMgr;
myMgr.loadXml(); //myMgr.loadXml();
return app.exec(); return app.exec();