This sample shows how to read datapoint description strings via the connection API
#include "Helper.h"
#include <wzcpp/features/utils.h>
#include <iostream>
#include <memory>
using namespace wz::baos::ip;
int main(int argc, char* argv[])
{
try
{
std::cout << "******************************************" << std::endl;
std::cout << "GetDatapointDescriptionString sample" << std::endl;
std::cout << "******************************************" << std::endl;
std::cout << std::endl;
CommandLineOptions options;
options.parse(argc, argv);
if (options.wasHelpdisplayed())
{
return 0;
}
const std::string ipAddress = options.getIpAddress();
std::cout << " Connection requested for " << ipAddress << std::endl;
BaosTcpConnection connection;
connection.open(ipAddress);
std::cout << "Reading description string from dp id 1 ... " << std::endl;
auto desc = connection.getDpDescriptionString(1);
if (desc.has_value())
{
std::cout << "DP 1: " << *desc << std::endl;
}
std::cout << std::endl;
std::cout << "Reading description string from dp id 10 ... " << std::endl;
desc = connection.getDpDescriptionString(10);
if (desc.has_value())
{
std::cout << "DP 10: " << *desc << std::endl;
}
std::cout << std::endl;
std::cout << "Reading description string from dp id 1 to 50 ... " << std::endl;
for (const auto& item : descriptions)
{
std::cout << "Datapoint id " << item.first;
std::cout << ", Description string: " << desc << std::endl;
}
std::cout << std::endl;
}
catch (const std::exception& e)
{
std::cerr << "Failed: " << e.what() << std::endl;
return -1;
}
return 0;
}
Specialization for a TCP IP v4 BAOSConnection.
Global BAOS protocol defines and types.
Global BAOS SDK function and options.
Groups BAOS binary protocol specific types , defines and classes for Indications, Responses etc.
Definition: Defines.h:32
std::string DatapointDescriptionString
Strong type for the description string.
Definition: Defines.h:611
std::map< std::uint16_t, DatapointDescriptionString > DatapointDescriptionStrings
Definition: Defines.h:614
Global BAOS sdk namespace.
Definition: config.h:62
void setBaosLogLevel(wzcpp::LogLevel level)