![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Version FC
Dependencies: DmTftLibrary eeprom SX1280Lib filesystem mbed
Fork of MSNV2-Terminal_V1-5 by
Diff: Service.cpp
- Revision:
- 21:8524d815c587
- Parent:
- 20:b0281e8a375a
- Child:
- 22:a5929d3668b6
--- a/Service.cpp Sun Sep 02 22:24:14 2018 +0000 +++ b/Service.cpp Tue Sep 04 13:34:36 2018 +0000 @@ -37,69 +37,15 @@ } -std::string Service::getValueAsString(GENERIC_VALUE& value) { - std::ostringstream stringStream; - - switch (value.type) { - case Service::NOT_SET: - break; - - case Service::BOOLEAN: - stringStream << (this->current_value.value.bool_value ? "true" : "false"); - break; - - case Service::CHAR: - stringStream << this->current_value.value.char_value; - break; - - case Service::UINT8_T: -#ifdef TEST_ENVIRONMENT - stringStream << std::to_string(this->current_value.value.uint8_value); -#else - stringStream << this->current_value.value.uint8_value; -#endif - break; - - case Service::INT8_T: -#ifdef TEST_ENVIRONMENT - stringStream << std::to_string(this->current_value.value.int8_value); -#else - stringStream << this->current_value.value.int8_value; -#endif - break; +bool Service::valueToBeSentToGateway() { + if (this->up_mode == Service::BY_RANGE) { + return ((this->low_threshold_limit.compareTo(this->current_value) > 0) + || (this->current_value.compareTo(this->high_threshold_limit) > 0)); + } - case Service::UINT16_T: - stringStream << this->current_value.value.uint16_value; - break; - - case Service::INT16_T: - stringStream << this->current_value.value.int16_value; - break; - - case Service::UINT32_T: - stringStream << this->current_value.value.uint32_value; - break; - - case Service::INT32_T: - stringStream << this->current_value.value.int32_value; - break; + if (this->up_mode == Service::BY_DELTA) { + return this->current_value.isAbsoluteDifferenceValueGreatherThanDelta(this->previous_value, this->delta_threshold); + } - case Service::FLOAT: - stringStream << this->current_value.value.float_value; - break; - - case Service::DOUBLE: - stringStream << this->current_value.value.double_value; - break; - - case Service::TIME: - stringStream << this->current_value.value.time_value; - break; - - default: - stringStream << "Value not set !"; - break; - } - - return stringStream.str(); + return (this->current_value.isDifferentFrom(this->previous_value)); }