#include "Helper.h"
#include <wzcpp/features/utils/Formatter.h>
#include <iostream>
#include <memory>
namespace
{
{
try
{
std::cout << dpDescs.size() << " datapoints configured" << std::endl;
std::cout << dpValues.size() << " valid datapoint values" << std::endl;
std::cout << "Read all parameter bytes: " << std::endl;
std::cout << params.size() << " parameter bytes read" << std::endl;
}
catch (const wzcpp::error::WzBaseException& e)
{
std::cerr << "Wz Exception in main: " << e.msg() << std::endl;
}
}
}
int main(int argc, char* argv[])
{
try
{
std::cout << "******************************************" << std::endl;
std::cout << "10_Class config sample" << std::endl;
std::cout << "******************************************" << std::endl;
std::cout << std::endl;
setBaosLogLevel(wz::baos::LogLevel::warn);
CommandLineOptions options;
options.parse(argc, argv);
if (options.wasHelpdisplayed())
{
return 0;
}
const std::string ipAddress = options.getIpAddress();
std::cout << " Working with device on IP address " << ipAddress << std::endl;
{
std::cout << "------------------ ServerItemReadStrategy::METADATAREADWITHFALLBACK -----------------------"
<< std::endl;
getDeviceInfo(baosDevice);
}
{
std::cout << "------------------ Set meta data manually -----------------------" << std::endl;
baosDevice.setMetaInfo(
DeviceMeta{
"BaosGeneric", 18, 100, 100});
auto hexString = wzcpp::rangeToHex<std::array<std::byte, 5>>(devicegroupid.deviceid);
std::cout << "The DeviceGroupIdentifier for this device is: " << hexString << std::endl;
getDeviceInfo(baosDevice);
}
{
std::cout << "------------------ ServerItemReadStrategy::AllATONCE -----------------------" << std::endl;
baosDevice.setServerItemReadStrategy(ServerItemReadStrategy::ALLATONCE);
bool allAtOnceAvailable{false};
try
{
auto staticInfo = baosDevice.getStaticInfo();
auto connection = baosDevice.getConnection();
auto maxDatapointsItem = connection->getServerItem(protocol::ServerItemId::MaxDatapoints);
auto maxParameterBytesItem = connection->getServerItem(protocol::ServerItemId::MaxParameterBytes);
if (maxDatapointsItem.has_value())
{
std::cout << "Serveritem MaxDatapoints available" << std::endl;
}
if (maxParameterBytesItem.has_value())
{
std::cout << "Serveritem MaxParameterBytes available" << std::endl;
}
if (maxDatapointsItem.has_value() && maxParameterBytesItem.has_value())
{
allAtOnceAvailable = true;
}
}
catch (const wzcpp::error::WzBaseException& e)
{
std::cerr << "Wz Exception in main: " << e.msg() << std::endl;
}
std::cout << "The device with ip " << ipAddress << " can use the all at once strategy: " << std::boolalpha
<< allAtOnceAvailable << std::endl;
}
}
catch (const std::exception& e)
{
std::cerr << "Failed: " << e.what() << std::endl;
return -1;
}
return 0;
}
Specialization for a IP v4 BAOSDevice.
Specialization for a TCP IP v4 BAOSConnection.
Global BAOS SDK function and options.
DeviceStaticInfo getStaticInfo(bool reload=false)
Get the information about a connected BAOS device that is never changed. Like serial number.
protocol::DatapointValues getAllDpValuesRaw(bool reload=false, protocol::DatapointValueFilter filter=protocol::DatapointValueFilter::VALID)
Load all the datapoint values and cache them.
protocol::ParameterBytes getAllParameterBytes(bool reload=false)
Load all the parameter bytes and cache them.
DatapointConfigurations getAllDpConfigurations(bool reload=false)
Load all the datapoint configurations and cache them.
Represents a BAOS IP4 device with an underlying TCP connection (with BAOS unsecure connection-less)
Definition BaosIpv4Device.h:55
Global BAOS sdk namespace.
Definition config.h:69
BAOSLIB_EXPORT void setBaosLogLevel(wz::baos::LogLevel level)
A collection of fields representing those serveritems which may change if the configuration of the de...
Definition BaosDeviceDataTypes.h:94
std::uint8_t applicationVersion
Definition BaosDeviceDataTypes.h:98
std::uint16_t applicationId
Definition BaosDeviceDataTypes.h:96
std::uint16_t manufactureCodeApp
The manufacturer code of the ETS application e.g. 0x00C5 for Weinzierl.
Definition BaosDeviceDataTypes.h:95
Unique identifier for a device.
Definition BaosDevicesMeta.h:44
A collection of fields representing those serveritems which won't ever change in a device.
Definition BaosDeviceDataTypes.h:49