Added BCValue creation, part II.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
BionxControl.pro.user
|
||||
build/
|
||||
bcvalue.cpp.autosave
|
||||
|
||||
13
bc.h
13
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
|
||||
|
||||
25
bcvalue.cpp
25
bcvalue.cpp
@@ -29,3 +29,28 @@
|
||||
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
21
bcvalue.h
21
bcvalue.h
@@ -38,6 +38,21 @@
|
||||
#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
|
||||
{
|
||||
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:
|
||||
|
||||
@@ -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 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user