CVB++ 14.0
Server Class Reference

An OPCUA server object. More...

#include <cvb/opcua/server.hpp>

Inherits enable_shared_from_this< Server >.

Public Member Functions

void * Handle () const noexcept
 Returns C-API style handle to the server. More...
 
std::uint16_t AddNameSpace (const Cvb::String &name) const
 Adds a new name space defined as a string to the server. The name space index of this name space will be returned. More...
 
Cvb::String DiscoveryURL () const
 Returns the URL of an OPCUA server as string. More...
 
void DeleteNode (const NodeID &id)
 Removes an OPCUA node from the OPCUA server. More...
 
template<class T >
std::shared_ptr< T > Node (const OpcUa::NodeID &id) const
 Returns a node (typed). Valid types are BaseNode and all derivatives. More...
 
BaseNodePtr Node (const OpcUa::NodeID &id) const
 Returns a node (without type). More...
 
void AddNode (const OpcUa::BaseNode &node)
 Adds a OPCUA node to the server. More...
 
void Start () const
 Starts the OPCUA server. More...
 
void Stop () const
 Stops the OPCUA server. More...
 

Static Public Member Functions

static ServerPtr Create (const std::uint16_t port)
 Creates an OPCUA server with the specified port number. More...
 

Detailed Description

An OPCUA server object.

It handles the server side of the OPCUA client/server interaction.

Note
Unlike the OpcUa::Client, the server has start and stop operations.
Primary tool for OpcUa modeling is the OpcUa::Server::AddNode methods. See OpcUa::BaseNode for details.
for details also refer to the OPCUA specification Part 1:
https://opcfoundation.org/developer-tools/specifications-unified-architecture/part-1-overview-and-concepts/

Member Function Documentation

◆ AddNameSpace()

std::uint16_t AddNameSpace ( const Cvb::String name) const
inline

Adds a new name space defined as a string to the server. The name space index of this name space will be returned.

Note
The namespace index of the new assigned namespace is always assigned by the OPCUA server.
Parameters
[in]nameNew name of the namespace to be added to the server.
Returns
Numeric index of new namespace name which is assigned by the OPCUA Server.
Exceptions
Anyexception derived from std::exception including CvbException and OpcUaException.

◆ AddNode()

void AddNode ( const OpcUa::BaseNode node)
inline

Adds a OPCUA node to the server.

Note
See OpcUa::BaseNode on node creation
Parameters
[in]nodeThe node to be added

◆ Create()

ServerPtr Create ( const std::uint16_t  port)
inlinestatic

Creates an OPCUA server with the specified port number.

Parameters
[in]portMust be a valid positive integer number. 4840 and 4843 are reserved for the OpcUA TCP protocol. They are usually used to connect to a LDS server If you want to define a different number, please use a number between 1024 and 65535 to avoid conflicts with well known ports, that are registered by the Internet Assigned Numbers Authority (IANA)
Returns
Pointer of the OPCUA server object.
Exceptions
Anyexception derived from std::exception including CvbException and OpcUaException.
Examples
OpcUa/BareboneServer, and OpcUa/ServerClientInteraction.

◆ DeleteNode()

void DeleteNode ( const NodeID id)
inline

Removes an OPCUA node from the OPCUA server.

Parameters
[in]idOPCUA NodeID of the node to be removed form the server.
Exceptions
Anyexception derived from std::exception including CvbException and OpcUaException.

◆ DiscoveryURL()

Cvb::String DiscoveryURL ( ) const
inline

Returns the URL of an OPCUA server as string.

Note
The OPCUA server must be running the retrieve the URL.
Returns
String representation of URL.
Exceptions
Anyexception derived from std::exception including CvbException and OpcUaException.

◆ Handle()

void * Handle ( ) const
inlinenoexcept

Returns C-API style handle to the server.

Returns
C-API handle

◆ Node() [1/2]

std::shared_ptr< T > Node ( const OpcUa::NodeID id) const
inline

Returns a node (typed). Valid types are BaseNode and all derivatives.

Exceptions
Anyexception derived from std::exception including CvbException and OpcUaException.

◆ Node() [2/2]

BaseNodePtr Node ( const OpcUa::NodeID id) const
inline

Returns a node (without type).

Note
Please use this method only if you don't know the type of the node. Otherwise use Server::Node<Type>(...).
Parameters
[in]idOPCUA NodeID identifing the requested node.
Exceptions
Anyexception derived from std::exception including CvbException and OpcUaException.

◆ Start()

void Start ( ) const
inline

Starts the OPCUA server.

Exceptions
Anyexception derived from std::exception including CvbException and OpcUaException.

◆ Stop()

void Stop ( ) const
inline

Stops the OPCUA server.

Exceptions
Anyexception derived from std::exception including CvbException and OpcUaException.