add getStep() method
This commit is contained in:
@@ -1098,7 +1098,7 @@ void MqttHandler::run() {
|
||||
values.set("max", ostr.str());
|
||||
ostr.str("");
|
||||
}
|
||||
if (dt->readFromRawValue(1, g_publishFormat, &ostr) != RESULT_OK) {
|
||||
if (dt->getStep(g_publishFormat, &ostr) != RESULT_OK) {
|
||||
// fallback method, when smallest number didn't work
|
||||
int divisor = dt->getDivisor();
|
||||
float step = 1.0f;
|
||||
|
||||
@@ -735,6 +735,10 @@ result_t NumberDataType::getMinMax(bool getMax, const OutputFormat outputFormat,
|
||||
return readFromRawValue(getMax ? m_maxValue : m_minValue, outputFormat, output);
|
||||
}
|
||||
|
||||
result_t NumberDataType::getStep(const OutputFormat outputFormat, ostream* output) const {
|
||||
return readFromRawValue(hasFlag(EXP) ? floatToUint(1.0f) : 1, outputFormat, output);
|
||||
}
|
||||
|
||||
result_t NumberDataType::readRawValue(size_t offset, size_t length, const SymbolString& input,
|
||||
unsigned int* value) const {
|
||||
size_t start = 0, count = length;
|
||||
|
||||
@@ -517,6 +517,14 @@ class NumberDataType : public DataType {
|
||||
*/
|
||||
result_t getMinMax(bool getMax, const OutputFormat outputFormat, ostream* output) const;
|
||||
|
||||
/**
|
||||
* Get the smallest step value for increment/decrement.
|
||||
* @param outputFormat the @a OutputFormat options to use.
|
||||
* @param output the ostream to append the formatted value to.
|
||||
* @return @a RESULT_OK on success, or an error code.
|
||||
*/
|
||||
result_t getStep(const OutputFormat outputFormat, ostream* output) const;
|
||||
|
||||
/**
|
||||
* @return the divisor (negative for reciprocal).
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user