#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 << "GetDatapointDescription 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 of dp id 1 ... " << std::endl;
auto dpDescription = connection.getDpDescription(1);
if (dpDescription.has_value())
{
std::cout <<
"DP size: " <<
dpSizeToString(dpDescription->size) << std::endl;
std::cout << "DP flags: " << dpDescription->flags.toString() << std::endl;
std::cout <<
"DPT: " <<
dptToString(dpDescription->dpt) << std::endl;
std::cout << std::endl;
}
std::cout << "Reading dp description of id == 10 ... " << std::endl;
dpDescription = connection.getDpDescription(10);
if (dpDescription.has_value())
{
std::cout <<
"DP size: " <<
dpSizeToString(dpDescription->size) << std::endl;
std::cout << "DP flags: " << dpDescription->flags.toString() << std::endl;
std::cout <<
"DPT: " <<
dptToString(dpDescription->dpt) << std::endl;
std::cout << std::endl;
}
std::cout << "Reading dp descriptions of id == 1 to 1000 ... " << std::endl;
for (const auto& item : descriptions)
{
std::cout << "Datapoint id " << item.first << std::endl;
const DatapointDescription& desc = item.second;
std::cout << "DP flags: " << desc.flags.toString() << std::endl;
std::cout <<
"DPT: " <<
dptToString(desc.dpt) << 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
BAOSLIB_EXPORT std::string dpSizeToString(DatapointSize dpSize)
Convert the enum value to a human readable string.
BAOSLIB_EXPORT std::string dptToString(DPT dpt)
Convert the enum value to a human readable string.
std::map< std::uint16_t, DatapointDescription > DatapointDescriptions
Definition: Defines.h:610
Global BAOS sdk namespace.
Definition: config.h:62
void setBaosLogLevel(wzcpp::LogLevel level)