#include <iostream>
int main() {
client.
connect(
"opc.tcp://localhost:4840");
{
}
);
{
),
}
);
{
},
filterCombined
);
sub.subscribeEvent(
eventFilter,
std::cout
<< "Event notification:\n"
<<
"- attribute id: " <<
static_cast<int>(item.
getAttributeId()) <<
"\n";
const auto& severity = eventFields[1].getScalar<uint16_t>();
std::cout << "Time: " << time.format("%Y-%m-%d %H:%M:%S") << "\n";
std::cout << "Severity: " << severity << "\n";
std::cout <<
"Message: " <<
message.getText() <<
"\n";
}
);
}
Subscription< Client > createSubscription()
Create a subscription to monitor data changes and events (default subscription parameters).
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_ContentFilterElement wrapper class.
UA_ContentFilter wrapper class.
UA_DateTime wrapper class.
UA_EventFilter wrapper class.
UA_LiteralOperand wrapper class.
UA_LocalizedText wrapper class.
High-level monitored item class.
uint32_t subscriptionId() const noexcept
Get the server-assigned identifier of the underlying subscription.
uint32_t monitoredItemId() const noexcept
Get the server-assigned identifier of this monitored item.
const NodeId & getNodeId()
Get the monitored NodeId.
AttributeId getAttributeId()
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.
@ Value
The most recent value of the variable that the server has.