#include <iostream>
) override {
std::cout << "Time before read: " << timeOld.format("%Y-%m-%d %H:%M:%S") << std::endl;
std::cout <<
"Set current time: " << timeNow.
format(
"%Y-%m-%d %H:%M:%S") << std::endl;
}
) override {}
};
int main() {
.addVariable(currentTimeId, "CurrentTime")
.writeDisplayName({"en-US", "Current time"})
.writeDataType<opcua::DateTime>()
CurrentTimeCallback currentTimeCallback;
}
UA_DataValue wrapper class.
Variant & value() &noexcept
Get value.
UA_DateTime wrapper class.
String format(std::string_view format, bool localtime=false) const
Convert to string with given format (same format codes as strftime).
static DateTime now() noexcept
Get current DateTime.
High-level node class to access node attribute, browse and populate address space.
UA_NumericRange wrapper class.
void run()
Run the server's main loop. This method will block until Server::stop is called.
void setVariableNodeValueCallback(const NodeId &id, ValueCallbackBase &callback)
Set value callback for variable node.
High-level session class to manage client sessions.
Server & connection() noexcept
Get the server instance.
Value callback base class for variable nodes.
virtual void onRead(Session &session, const NodeId &id, const NumericRange *range, const DataValue &value)=0
Called before the value attribute is read.
virtual void onWrite(Session &session, const NodeId &id, const NumericRange *range, const DataValue &value)=0
Called after writing the value attribute.
UA_Variant wrapper class.
T & scalar() &
Get scalar value with given template type (only native or wrapper types).
StatusCode writeDescription(T &connection, const NodeId &id, const LocalizedText &description) noexcept
Write the AttributeId::Description attribute of a node.