#include <iostream>
int main() {
client.
connect(
"opc.tcp://localhost:4840");
opcua::FilterOperator::OfType,
{
}
);
opcua::FilterOperator::LessThan,
{
),
}
);
{
},
filterCombined
);
sub.subscribeEvent(
opcua::ObjectId::Server,
eventFilter,
std::cout
<< "Event notification:\n"
<<
"- attribute id: " <<
static_cast<int>(item.
attributeId()) <<
"\n";
const auto& severity = eventFields.
at(1).scalar<uint16_t>();
std::cout << "Time: " << time.format("%Y-%m-%d %H:%M:%S") << "\n";
std::cout << "Severity: " << severity << "\n";
std::cout <<
"Message: " <<
message.text() <<
"\n";
}
);
}
void connect(std::string_view endpointUrl)
Connect to the selected server.
void run()
Run the client's main loop by. This method will block until Client::stop is called.
UA_DateTime wrapper class.
UA_LocalizedText wrapper class.
High-level monitored item class.
IntegerId subscriptionId() const noexcept
Get the server-assigned identifier of the underlying subscription.
const NodeId & nodeId()
Get the monitored NodeId.
IntegerId monitoredItemId() const noexcept
Get the server-assigned identifier of this monitored item.
AttributeId attributeId()
Get the monitored AttributeId.
std::string toString() const
Encode NodeId as a string like ns=1;s=SomeNode.
View to a contiguous sequence of objects, similar to std::span in C++20.
constexpr reference at(size_t index) const
Access element by index with bounds checking.
High-level subscription class.
UA_ContentFilterElement wrapper class.
UA_ContentFilter wrapper class.
UA_EventFilter wrapper class.
UA_LiteralOperand wrapper class.
UA_SimpleAttributeOperand wrapper class.
uint32_t IntegerId
IntegerId.
@ Value
The most recent value of the variable that the server has.