Made float have the correct number of decimal places
This commit is contained in:
parent
30a39aff3e
commit
d3d203842a
1 changed files with 5 additions and 1 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <sstream>
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
#include "modbus.h"
|
#include "modbus.h"
|
||||||
|
|
||||||
|
|
@ -61,7 +63,9 @@ void PortParameterFloat::setValueFromRegisters(uint16_t *readArray, int register
|
||||||
|
|
||||||
std::string PortParameterFloat::getOutputValue() {
|
std::string PortParameterFloat::getOutputValue() {
|
||||||
std::string separator{"_age"};
|
std::string separator{"_age"};
|
||||||
return std::to_string(this->value.f).append(separator.append(std::to_string(this->age)));
|
std::stringstream valueStringStream;
|
||||||
|
valueStringStream << std::fixed << std::setprecision(this->decimalPlaces) << this->value.f;
|
||||||
|
return valueStringStream.str().append(separator.append(std::to_string(this->age)));
|
||||||
}
|
}
|
||||||
|
|
||||||
PortParameterInt::PortParameterInt(std::string name, uint16_t parameterAddressOffset, int registerSize) : PortParameter(name, parameterAddressOffset, registerSize) {
|
PortParameterInt::PortParameterInt(std::string name, uint16_t parameterAddressOffset, int registerSize) : PortParameter(name, parameterAddressOffset, registerSize) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue