#include <iostream>
int main() {
auto currentTimeNode =
.addVariable(currentTimeId, "CurrentTime")
.writeDisplayName({"en-US", "Current time"})
.writeDescription({"en-US", "Current time"})
.writeDataType<opcua::DateTime>()
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;
currentTimeNode.writeValueScalar(timeNow);
};
}
UA_DataValue wrapper class.
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).
void run()
Run the server's main loop. This method will block until Server::stop is called.
void setVariableNodeValueCallback(const NodeId &id, ValueCallback callback)
Set value callbacks to execute before every read and after every write operation.
Value callbacks for variable nodes.
std::function< void(const DataValue &value)> onBeforeRead
Called before the value attribute is read.