Cleanups.

This commit is contained in:
2026-01-12 23:06:36 +01:00
parent c0ce6a81e3
commit beae1c1b3d
3 changed files with 67 additions and 68 deletions

View File

@@ -39,41 +39,56 @@
BCValue::BCValue( BCDevice::ID deviceID_, BC::ID registerID_)
: deviceID{deviceID_}, registerID{registerID_}
: _deviceID{deviceID_}, _registerID{registerID_}
{
}
QString BCValue::formatValue() const
{
if( factor == 1 )
return QString::number( rawValue );
if( _factor == 1 )
return QString::number( _rawValue );
double result = rawValue * factor;
double result =_rawValue * _factor;
return QString::number(result, 'f', 2);
}
bool BCValue::isWord() const
{
return valueFlags.testFlag(BCValue::Flag::IsWord);
return _valueFlags.testFlag(BCValue::Flag::IsWord);
}
bool BCValue::isReadOnly() const
{
return valueFlags.testFlag(BCValue::Flag::ReadOnly);
return _valueFlags.testFlag(BCValue::Flag::ReadOnly);
}
void BCValue::setFromDouble( double value )
{
if( _optMin.has_value() && _optMax.has_value() )
{
double min = _optMin.value();
double max = _optMax.value();
value = qBound( min,value,max);
}
_rawValue = value / _factor;
}
double BCValue::calcMinMaxRatio() const
{
double ratio = 0;
if( optMin.has_value() && optMax.has_value() )
if( _optMin.has_value() && _optMax.has_value() )
{
double min = optMin.value();
double max = optMax.value();
double min = _optMin.value();
double max = _optMax.value();
double range = max - min;
@@ -82,7 +97,7 @@ double BCValue::calcMinMaxRatio() const
return ratio;
// Die eigentliche Formel
ratio = ((rawValue - min) / range);
ratio = ((_rawValue - min) / range);
//ratio = (int) qBound( min,ratio, max);
}
return ratio;
@@ -91,9 +106,9 @@ double BCValue::calcMinMaxRatio() const
void BCValue::dumpValue() const
{
qDebug() << "DeviceID: " << deviceID << " Register: " << registerID << " state:" " << state << " << " label: " << label;
qDebug() << "formattedValue: " << formatValue() << " min: " << optMin << " max: " << optMax << " factor: " << factor << " ValueType: " << (char)valueType << " ";
qDebug() << "indexRow: " << indexRow << " isWord: " << isWord() << " isRO: " << isReadOnly();
qDebug() << "DeviceID: " << _deviceID << " Register: " << _registerID << " state:" " << state << " << " label: " << _label;
qDebug() << "formattedValue: " << formatValue() << " min: " << _optMin << " max: " << _optMax << " factor: " << _factor << " ValueType: " << (char)_valueType << " ";
qDebug() << "indexRow: " << _indexRow << " isWord: " << isWord() << " isRO: " << isReadOnly();
qDebug();
}