#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"
<< "- subscription id: " << item.subscriptionId() << "\n"
<< "- monitored item id: " << item.monitoredItemId() << "\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.
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.
String toString(const NumericRange &range)