33#include <cvb/opcua/server.hpp>
34#include <cvb/opcua/client.hpp>
36#if defined _WIN32 && defined(UNICODE)
37#define STDOUT std::wcout
39#define STDOUT std::cout
49 auto nodeName = CVB_LIT(
"TestFloatNode");
61 auto nsIndex = server->AddNameSpace(
"My Custom Namespace");
70 server->AddNode(*folder);
76 server->AddNode(*node);
79 auto callbackCookieWrite = node->RegisterWriteCallback([&node]()
81 STDOUT << CVB_LIT(
"write to ") << node->DisplayName() << std::endl;
98 node->UnregisterCallback(callbackCookieWrite);
135 auto result = obj->Browse(*bf);
138 for (
const auto & element : result)
145 auto ns = node->NodeID()->ExpandedText();
146 std::cout << ns <<
" " << name << std::endl;
159 auto tmp = fnode->
Value();
160 std::cout <<
"node value before change " << tmp << std::endl;
161 fnode->SetValue(tmp + 1.1);
162 std::cout <<
"node value after change" << fnode->Value() << std::endl;
173 std::cout <<
"client: " << e1.what() << std::endl;
178 std::cout <<
"client: " << ex.what() << std::endl;
An OPCUA BaseNode. This is the base for all other node classes. For instantiation of a specific node ...
Definition: decl_base_node.hpp:35
String DisplayName() const
Returns the humanreadable name of a node.
Definition: decl_base_node.hpp:91
static BrowseFilterPtr Create()
Creates an even simpler BrowseFilter for browsing the OPCUA client.
Definition: browse_filter.hpp:76
static OpcUa::ClientPtr Create(const Cvb::String &Url)
Creates an OPCUA Client object. And connect it to a given server. There is no disconnect/connect func...
Definition: detail_client.hpp:24
A FloatNode object provides an interface for storage and manipulation of floating point numbers.
Definition: float_node.hpp:24
static FloatNodePtr Create(std::uint16_t namespaceIndex, const Cvb::String &name, const OpcUa::NodeID &parentNodeID, double value)
Creates an OPCUA Variable with the specified parameter, data type and set its value as double.
Definition: float_node.hpp:45
double Value() const
Returns the saved value of the node.
Definition: float_node.hpp:66
static NodeIDPtr Create(Namespace0NodeID id)
Creates an id based on a predefined Namespace0 node id.
Definition: node_id.hpp:48
static ObjectNodePtr CreateFromType(const std::uint16_t NameSpaceIndex, const Cvb::String &Name, const OpcUa::NodeID &Parent, const OpcUa::NodeID &TypeDefinition)
Creates a OPCUA object node with a given type definition.
Definition: object_node.hpp:49
Special runtime exception to carry a native error code.
Definition: exception.hpp:25
int ErrorCode()
Retuns the error code. See Cvb::ErrorCodes.
Definition: exception.hpp:50
static ServerPtr Create(const std::uint16_t port)
Creates an OPCUA server with the specified port number.
Definition: detail_server.hpp:23
An OPCUA VariableNode object. It handles the data modeling acording to the OPCUA specification.
Definition: variable_node.hpp:26
@ Variable
Variable BaseNode Class.
@ Float
single precision floating point number
@ Double
double precision floating point number