Fixing button locking, part I

This commit is contained in:
2026-01-06 18:47:08 +01:00
parent 221e0bc8c2
commit a8a947ff0b
8 changed files with 50 additions and 27 deletions

View File

@@ -53,11 +53,37 @@ QString BCValue::formatValues( uint32_t value ) const
return QString::number(result, 'f', 2);
}
double BCValue::calcRatio() const
{
return 0.33;
double ratio = 0;
if( optMin.has_value() && optMax.has_value() )
{
double min = optMin.value();
double max = optMax.value();
double range = max - min;
// Safety: Division durch Null verhindern (wenn min == max)
if (std::abs(range) < 1e-9)
return ratio;
// Die eigentliche Formel
ratio = ((rawValue - min) / range);
//ratio = (int) qBound( min,ratio, max);
}
return ratio;
}
void BCValue::dumpValue() const
{
qDebug() << "DeviceID: " << deviceID << " Register: " << registerID << " state:" " << state << " << " label: " << label;
qDebug() << "visibleValue: " << visibleValue << " min: " << min << " max: " << max << " factor: " << factor << " ValueType: " << (char)valueType << " ";
qDebug() << "visibleValue: " << visibleValue << " min: " << optMin << " max: " << optMax << " factor: " << factor << " ValueType: " << (char)valueType << " ";
qDebug() << "indexRow: " << indexRow << " isWord: " << isWord;
qDebug();