This sample shows how to read and write datapoint values via the device API.
It simulates an application of a basic 2-fold switching actuator. It is helpful when in the KNX installation a push button e.g. weinzierl 420 exists.
#include "Helper.h"
#include <exception>
#include <iostream>
#include <memory>
#include <thread>
using namespace wz::baos::ip;
namespace
{
enum Datapoints
{
};
{
std::cout << "Read datapoint configuration and validate it ... " << std::endl;
if (
config.size != DatapointSize::BITS_1)
{
throw std::runtime_error("Datapoint Ch_A_Switch: Unexpected datapoint size");
}
{
throw std::runtime_error("Datapoint Ch_A_Switch: Unexpected datapoint type");
}
if (
config.size != DatapointSize::BITS_1)
{
throw std::runtime_error("Datapoint Ch_A_State: Unexpected datapoint size");
}
{
throw std::runtime_error("Datapoint Ch_A_State: Unexpected datapoint type");
}
if (
config.size != DatapointSize::BITS_1)
{
throw std::runtime_error("Datapoint Ch_B_Switch: Unexpected datapoint size");
}
{
throw std::runtime_error("Datapoint Ch_B_Switch: Unexpected datapoint type");
}
if (
config.size != DatapointSize::BITS_1)
{
throw std::runtime_error("Datapoint Ch_B_State: Unexpected datapoint size");
}
{
throw std::runtime_error("Datapoint Ch_B_State: Unexpected datapoint type");
}
}
{
}
{
std::cout << "Received switch -> set state " << std::endl;
}
}
{
try
{
std::cout << "******************************************" << std::endl;
std::cout << "07_SwitchingActuator sample" << std::endl;
std::cout << "******************************************" << std::endl;
std::cout << std::endl;
setBaosLogLevel(wz::baos::LogLevel::warn);
options.setDurationOptionSupported(
true);
{
return 0;
}
std::cout <<
" Connection requested for " <<
ipAddress << std::endl;
bool value = false;
std::cout << "Channel A: Current state: " << value << std::endl;
std::cout << "Channel B: Current state: " << value << std::endl;
{
{
std::uint16_t
id =
item.first;
std::cout << "Received datapoint value indication for id " << id << std::endl;
switch (id)
{
case Datapoints::Ch_A_Switch:
break;
case Datapoints::Ch_B_Switch:
break;
default:
std::cout << "Nothing to do" << std::endl;
}
}
});
{
std::cout << "Press [Enter] to exit the application ..." << std::endl;
std::getchar();
}
else
{
std::cout <<
"Listening for indications for " <<
durationSeconds <<
" seconds ..." << 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 protocol defines and types.
Global BAOS SDK function and options.
void setDpValue(std::uint16_t dpId, protocol::DatapointChangeValue &&dpValue)
Send a SetDatapointValue request to the BAOS device for one datapoint.
A specialization for (connection oriented) connection to the BAOS device via a TCP connection.
Definition BaosTcpConnection.h:182
Represents a BAOS IP4 device with an underlying TCP connection (with BAOS unsecure connection-less)
Definition BaosIpv4Device.h:55
Groups BAOS binary protocol specific types , defines and classes for Indications, Responses etc.
Definition Defines.h:33
std::map< std::uint16_t, DatapointValue > DatapointValues
A map with datapoint ids as keys and DatapointValue as values.
Definition Defines.h:36
wz::baos::Buffer DatapointValue
An type for the DatapointValues.
Definition Defines.h:34
Global BAOS sdk namespace.
Definition config.h:69
std::vector< std::uint8_t > Buffer
An alias type for a byte buffer.
Definition config.h:71
BAOSLIB_EXPORT void setBaosLogLevel(wz::baos::LogLevel level)
std::map< std::uint16_t, DatapointConfig > DatapointConfigurations
Definition BaosDeviceDataTypes.h:212
Information about a datapoint object.
Definition BaosDeviceDataTypes.h:201