#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() {
.writeDataType<opcua::DateTime>()
CurrentTimeCallback currentTimeCallback;
}
UA_DataValue wrapper class.
Variant & value() &noexcept
Get value.
UA_DateTime wrapper class.
static DateTime now() noexcept
Get current DateTime.
std::string format(std::string_view format, bool localtime=false) const
Convert to string with given format (same format codes as strftime).
High-level node class to access node attribute, browse and populate address space.
Node & writeValueScalar(const T &value)
Write scalar to variable node.
Node & writeDisplayName(const LocalizedText &displayName)
Write the AttributeId::DisplayName attribute of a node.
Node addVariable(const NodeId &id, std::string_view browseName, const VariableAttributes &attributes={}, const NodeId &variableType=VariableTypeId::BaseDataVariableType, const NodeId &referenceType=ReferenceTypeId::HasComponent)
Add variable.
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 callbacks to execute before every read and after every write operation.
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.
T & scalar() &
Get reference to 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.