Changed setRaw Value
This commit is contained in:
22
bcvalue.cpp
22
bcvalue.cpp
@@ -90,9 +90,29 @@ uint32_t BCValue::getRawValue() const noexcept
|
||||
return _rawValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Speichert einen via CAN-Bus gelesenen Wert in
|
||||
* der BCValue Struktur.
|
||||
*/
|
||||
|
||||
void BCValue::setRawValue(uint32_t newRawValue) const
|
||||
{
|
||||
_rawValue = newRawValue;
|
||||
// die per Zufallsgenerator erzeugten Werte des Dummy-Treibers
|
||||
// können beliebigen Unsinn enthalten, also müssen wir sie
|
||||
// auch skalieren.
|
||||
|
||||
double value = newRawValue * _factor;
|
||||
|
||||
if( _optMin.has_value() && _optMax.has_value() )
|
||||
{
|
||||
|
||||
double min = _optMin.value();
|
||||
double max = _optMax.value();
|
||||
|
||||
value = (int) qBound( min,value, max);
|
||||
}
|
||||
|
||||
_rawValue = value / _factor;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user