diff --git a/CLC-qthing/SiliconTorch/NVSExplorer.cpp b/CLC-qthing/SiliconTorch/NVSExplorer.cpp index e6e4ad71f29cf46628dc65247897b795fb512973..56df9c592253aec8f3160df763c3df0041af988b 100644 --- a/CLC-qthing/SiliconTorch/NVSExplorer.cpp +++ b/CLC-qthing/SiliconTorch/NVSExplorer.cpp @@ -2,6 +2,7 @@ // C++ system level #include <set> +#include <cmath> #include <vector> #include <cstring> // memset, memcpy, strncmp // #include <cstdlib> @@ -111,6 +112,42 @@ namespace SiliconTorch { qthing::add_binary_message_callback(requestTopic("rm/+/+"), wrapMessageHandler(rmKey)); + + auto getFloat = [&](std::vector<std::string>& topic, qthing::multipart_message_t msg) { + float value = this->getFloat(topic[1], topic[2]); + + if (!std::isnan(value)) { + + char buffer[64]; + snprintf(buffer, 64, "%f", value); + + qthing::publish_message(responseTopic("get_float", topic[1], topic[2]), std::string(buffer)); + } else { + // publish error…? + } + }; + + qthing::add_binary_message_callback(requestTopic("get_float/+/+"), wrapMessageHandler(getFloat)); + + + + auto getDouble = [&](std::vector<std::string>& topic, qthing::multipart_message_t msg) { + double value = this->getDouble(topic[1], topic[2]); + + if (!std::isnan(value)) { + + char buffer[64]; + snprintf(buffer, 64, "%f", value); + + qthing::publish_message(responseTopic("get_double", topic[1], topic[2]), std::string(buffer)); + } else { + // publish error…? + } + }; + + qthing::add_binary_message_callback(requestTopic("get_double/+/+"), wrapMessageHandler(getDouble)); + + }