Added BCValueType
This commit is contained in:
38
bcvalue.cpp
38
bcvalue.cpp
@@ -47,41 +47,3 @@ uint8_t BCValue::getLongValue()
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
BCValue BCValue::makeValue( BCDevice::ID deviceID, const BCValueParams& params )
|
||||
{
|
||||
|
||||
auto setIfExists = [&]( QStringView source, optDouble& target )
|
||||
{
|
||||
if( !source.isEmpty() )
|
||||
{
|
||||
bool ok;
|
||||
double testVal = source.toDouble(&ok);
|
||||
if (ok)
|
||||
target = testVal;
|
||||
}
|
||||
};
|
||||
|
||||
static QMetaEnum s_bcValueEnum{QMetaEnum::fromType<BC::ID>()};
|
||||
|
||||
/*
|
||||
Wir brauchen:
|
||||
- eine gültige ID
|
||||
|
||||
*/
|
||||
BCValue newValue{};
|
||||
|
||||
auto IDVal = s_bcValueEnum.keyToValue64( params.ID.toLatin1().constData() );
|
||||
if( IDVal.has_value() )
|
||||
{
|
||||
newValue = BCValue( deviceID, BC::ID( IDVal.value() ) );
|
||||
setIfExists( params.Factor, newValue.factor );
|
||||
setIfExists( params.Min, newValue.min );
|
||||
setIfExists( params.Max, newValue.max );
|
||||
newValue.defaultValue.setValue( params.Label );
|
||||
newValue.value.setValue( params.Current );
|
||||
newValue.label = params.Label;
|
||||
}
|
||||
|
||||
return newValue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user