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;
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.
BaosConLessTcpConnection BaosTcpConnection
A specialization for (connection-less) connection to the BAOS device via a TCP connection.
Definition: BaosTcpConnection.h:168
Global BAOS protocol defines and types.
Global BAOS SDK function and options.
void open(const std::string &ip4Address, std::uint16_t port=12004)
Open a connection to physical BAOS device.
Groups BAOS binary protocol specific types , defines and classes for Indications, Responses etc.
Definition: Defines.h:33
std::string DatapointDescriptionString
Strong type for the description string.
Definition: Defines.h:630
std::map< std::uint16_t, DatapointDescriptionString > DatapointDescriptionStrings
Definition: Defines.h:633
Global BAOS sdk namespace.
Definition: config.h:69
BAOSLIB_EXPORT void setBaosLogLevel(wz::baos::LogLevel level)