OPC UA (CVOpcUa.dll) 14.0
OPCUA Server Functions

Functions

CVOPCSRV CreateCVOPCServer (cvbuint16_t PortNumber)
 Creates an Server OPCUA Server with the specified PortNumber. More...
 
cvbres_t CVOPCNodeDeregisterMethodCallback (CVOPCNODE Method, size_t CallbackId)
 Unregisters the Callback referring to an OPCUA Method given an unique CallbackId. More...
 
cvbres_t CVOPCNodeDeregisterVariableCallback (CVOPCNODE Variable, size_t CallbackId)
 Unregisters the Callback referring to an OPCUA Variable given an unique CallbackId. More...
 
cvbres_t CVOPCNodeRegisterMethodCallback (CVOPCNODE Method, pfCVOpcM Callback, void *pPrivate, size_t &CallbackId)
 Registers callbacks of a OPCUA Method that has been already added to a server so that the Method is connected to the API. More...
 
cvbres_t CVOPCNodeRegisterVariableCallback (CVOPCNODE Variable, pfCVOpcV CallbackRead, pfCVOpcV CallbackWrite, void *pPrivate, size_t &CallbackId)
 Registers callbacks of a OPCUA Variable that has been already added to server so that the Variable is connected to the API. More...
 
cvbres_t CVOPCServerAddNameSpace (CVOPCSRV Server, const char *NameSpaceName, cvbuint16_t &NameSpaceIndex)
 Adds a new NameSpace defined as a C string to the Server. The NameSpaceIndex of this NameSpace will be returned. More...
 
cvbres_t CVOPCServerAddNameSpaceW (CVOPCSRV Server, const wchar_t *NameSpaceName, cvbuint16_t &NameSpaceIndex)
 Adds a new NameSpace defined as a wide C string to the Server. The NameSpaceIndex of this NameSpace will be returned. More...
 
cvbres_t CVOPCServerAddNode (CVOPCSRV Server, CVOPCNODE Node)
 Adds a OPCUA Node to the server. More...
 
cvbres_t CVOPCServerDeleteNode (CVOPCSRV Server, CVOPCNODEID NodeOrId)
 Removes an OPCUA Node Attribute from OPCUA Server. More...
 
cvbres_t CVOPCServerDeleteNodeEx (CVOPCSRV Server, CVOPCNODE Node)
 Removes an OPCUA Node Attribute from OPCUA Server. More...
 
cvbres_t CVOPCServerDeregisterAll (CVOPCSRV Server)
 Unregisters all method and variable callbacks. More...
 
cvbres_t CVOPCServerGetDisoveryURL (CVOPCSRV Server, char *URL, size_t &URLSize)
 Gets the URL of an Server OPCUA Server as an C string. More...
 
cvbres_t CVOPCServerGetDisoveryURLW (CVOPCSRV Server, wchar_t *URL, size_t &URLSize)
 Gets the URL of an Server OPCUA Server as a wide C string. More...
 
cvbres_t CVOPCServerGetNode (CVOPCSRV server, CVOPCNODEID NodeId, CVOPCNODE &Node)
 Gets a OPCUA NodeOrId to the server which is identified by an OPCUA NodeId. More...
 
cvbres_t CVOPCServerGetState (CVOPCSRV Server, TCVOPCServerState &ServerState)
 Returns the current state of the OPCUA server. More...
 
cvbres_t CVOPCServerStart (CVOPCSRV Server)
 Starts an OPCUA Server. More...
 
cvbres_t CVOPCServerStop (CVOPCSRV Server)
 Stops an OPCUA Server. More...
 
cvbbool_t IsCVOPCServer (CVOPCSRV Server)
 Tries to check whether the given Server handle is a valid object. More...
 

Detailed Description

Functions to create OPCUA Server objects, create OPCUA NameSpaces on the Server, add OPCUA Node objects to the Server's address space, register callbacks for OPCUA Variables and OPCUA Methods.

Function Documentation

◆ CreateCVOPCServer()

CVOPCSRV CreateCVOPCServer ( cvbuint16_t  PortNumber)

Creates an Server OPCUA Server with the specified PortNumber.

Parameters
[in]PortNumbermust have 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 in between 1024 and 65535 to avoid conflict with well known ports that are registered by the Internet Assigned Numbers Authority (IANA)
Returns
  • #OPCSRV handle of Server OPCUA Server object;nullptr on error (Use CVOPCGetLastErrorString function for a human readable error description).

◆ CVOPCNodeDeregisterMethodCallback()

cvbres_t CVOPCNodeDeregisterMethodCallback ( CVOPCNODE  Method,
size_t  CallbackId 
)

Unregisters the Callback referring to an OPCUA Method given an unique CallbackId.

Parameters
[in]MethodOPCUA node handle.
[in]CallbackIdUnique callback ID that refers to OPCUA variable for which the callback should be removed.
Returns
  • #CVC_ERROR (#CVC_E_OK) on success.
  • #CVC_ERROR (#CVC_E_WRONGOBJECT) if node id is not a valid object
  • Smaller than zero on error (Use CVOPCGetLastErrorString function for a human readable error description).

◆ CVOPCNodeDeregisterVariableCallback()

cvbres_t CVOPCNodeDeregisterVariableCallback ( CVOPCNODE  Variable,
size_t  CallbackId 
)

Unregisters the Callback referring to an OPCUA Variable given an unique CallbackId.

Parameters
[in]VariableOPCUA node handle.
[in]CallbackIdUnique callback ID that refers to OPCUA variable for which the callback should be removed.
Returns
  • #CVC_ERROR (#CVC_E_OK) on success.
  • #CVC_ERROR (#CVC_E_WRONGOBJECT) if node id is not a valid object
  • Smaller than zero on error (Use CVOPCGetLastErrorString function for a human readable error description).

◆ CVOPCNodeRegisterMethodCallback()

cvbres_t CVOPCNodeRegisterMethodCallback ( CVOPCNODE  Method,
pfCVOpcM  Callback,
void *  pPrivate,
size_t &  CallbackId 
)

Registers callbacks of a OPCUA Method that has been already added to a server so that the Method is connected to the API.

Note
Callbacks are used to perform the operation of the OPCUA Method, given the OPCUA Input Arguments. The result of the Operation is provided to the OPCUA Client as a OPCUA Output Arguments.
Parameters
[in]NodeOPCUA Node handle.
[in]CallbackReadCallback function pointer of function being called when an OPCUA Client calls the method.
[in]pPrivateUser data pointer to be given into Callback function.
[out]CallbackIdUnique callback ID that refers the callback of the added method. Use this ID to unregister the Callback.
Returns
  • #CVC_ERROR (#CVC_E_OK) on success.
  • #CVC_ERROR (#CVC_E_WRONGOBJECT) if node id is not a valid object
  • Smaller than zero on error (Use CVOPCGetLastErrorString function for a human readable error description).

◆ CVOPCNodeRegisterVariableCallback()

cvbres_t CVOPCNodeRegisterVariableCallback ( CVOPCNODE  Variable,
pfCVOpcV  CallbackRead,
pfCVOpcV  CallbackWrite,
void *  pPrivate,
size_t &  CallbackId 
)

Registers callbacks of a OPCUA Variable that has been already added to server so that the Variable is connected to the API.

Note
Updates the Value of the OPCUA Variable Node which has been added to the OPCUA Server by local variables which are assigned inside callbacks to the variable. There are two categories of variable callbacks. CallbackRead is invoked when a OPCUA Client reads the variable. CallbackWrite is invoked when a OPCUA Client calls the write service to write another value into the variable.
Parameters
[in]NodeOPCUA Node handle.
[in]CallbackReadCallback function pointer of function being called when an OPCUA Client reads the variable.
[in]CallbackWriteCallback function pointer of function being called when an OPCUA Client writes the variable.
[in]pPrivateUser data pointer to be given into Callback function.
[out]CallbackIdUnique callback ID that refers the callback of the added variable. Use this ID to unregister the Callback.
Returns
  • #CVC_ERROR (#CVC_E_OK) on success.
  • #CVC_ERROR (#CVC_E_WRONGOBJECT) if node id is not a valid object
  • Smaller than zero on error (Use CVOPCGetLastErrorString function for a human readable error description).

◆ CVOPCServerAddNameSpace()

cvbres_t CVOPCServerAddNameSpace ( CVOPCSRV  Server,
const char *  NameSpaceName,
cvbuint16_t &  NameSpaceIndex 
)

Adds a new NameSpace defined as a C string to the Server. The NameSpaceIndex of this NameSpace will be returned.

Note
the NameSpaceIndex of the new assigned NameSpace is always assigned by the OPCUA Server.
Parameters
[in]ServerOPCUA Server handle to be initialized.
[in]NameSpaceNameNew Name of the NameSpace to be added to the server. String must be 0 terminated.
[out]NameSpaceIndexNumeric index of new namespace name which is assigned by the OPCUA Server.
Returns
  • #CVC_ERROR (#CVC_E_OK) on success.
  • #CVC_ERROR (#CVC_E_WRONGOBJECT) if node id is not a valid object
  • Smaller than zero on error (Use CVOPCGetLastErrorString function for a human readable error description).

◆ CVOPCServerAddNameSpaceW()

cvbres_t CVOPCServerAddNameSpaceW ( CVOPCSRV  Server,
const wchar_t *  NameSpaceName,
cvbuint16_t &  NameSpaceIndex 
)

Adds a new NameSpace defined as a wide C string to the Server. The NameSpaceIndex of this NameSpace will be returned.

Note
the NameSpaceIndex of the new assigned NameSpace is always assigned by the OPCUA Server.
Parameters
[in]ServerOPCUA Server handle to be initialized.
[in]NameSpaceNameNew Name of the NameSpace to be added to the server. This wide string must be 0 terminated.
[out]NameSpaceIndexNumeric index of new namespace name which is assigned by the OPCUA Server.
Returns
  • #CVC_ERROR (#CVC_E_OK) on success.
  • #CVC_ERROR (#CVC_E_WRONGOBJECT) if node id is not a valid object
  • Smaller than zero on error (Use CVOPCGetLastErrorString function for a human readable error description).

◆ CVOPCServerAddNode()

cvbres_t CVOPCServerAddNode ( CVOPCSRV  Server,
CVOPCNODE  Node 
)

Adds a OPCUA Node to the server.

Parameters
[in]ServerOPCUA Server handle.
[in]NodeOrIdOPCUA NodeOrId handle.
Returns
  • #CVC_ERROR (#CVC_E_OK) on success.
  • #CVC_ERROR (#CVC_E_WRONGOBJECT) if node id is not a valid object
  • Smaller than zero on error (Use CVOPCGetLastErrorString function for a human readable error description).

◆ CVOPCServerDeleteNode()

cvbres_t CVOPCServerDeleteNode ( CVOPCSRV  Server,
CVOPCNODEID  NodeOrId 
)

Removes an OPCUA Node Attribute from OPCUA Server.

Parameters
[in]ServerOPCUA Server handle.
[in]NodeOrIdOPCUA NodeOrId handle or NodeId of the node to be removed form the server.
Returns
  • #CVC_ERROR (#CVC_E_OK) on success.
  • #CVC_ERROR (#CVC_E_WRONGOBJECT) if node id is not a valid object
  • Smaller than zero on error (Use CVOPCGetLastErrorString function for a human readable error description).

◆ CVOPCServerDeleteNodeEx()

cvbres_t CVOPCServerDeleteNodeEx ( CVOPCSRV  Server,
CVOPCNODE  Node 
)

Removes an OPCUA Node Attribute from OPCUA Server.

Parameters
[in]ServerOPCUA Server handle.
[in]NodeOrIdOPCUA NodeOrId handle or NodeId of the node to be removed form the server.
Returns
  • #CVC_ERROR (#CVC_E_OK) on success.
  • #CVC_ERROR (#CVC_E_WRONGOBJECT) if node id is not a valid object
  • Smaller than zero on error (Use CVOPCGetLastErrorString function for a human readable error description).

◆ CVOPCServerDeregisterAll()

cvbres_t CVOPCServerDeregisterAll ( CVOPCSRV  Server)

Unregisters all method and variable callbacks.

Parameters
[in]ServerOPCUA Server handle.
Returns
  • #CVC_ERROR (#CVC_E_OK) on success.
  • #CVC_ERROR (#CVC_E_WRONGOBJECT) if node id is not a valid object
  • Smaller than zero on error (Use CVOPCGetLastErrorString function for a human readable error description).

◆ CVOPCServerGetDisoveryURL()

cvbres_t CVOPCServerGetDisoveryURL ( CVOPCSRV  Server,
char *  URL,
size_t &  URLSize 
)

Gets the URL of an Server OPCUA Server as an C string.

Note
The OPCUA Server must be running the retrieve the URL.
Attention
Server needs at least 200ms after performing start server until all elements are fully created.
Server OPCUA Server must be running to get a meaningfully Discovery URL
Parameters
[in]ServerOPCUA server handle
[out]URLPointer of char array to contain c-string representation of URL.
[in,out]URLSizeLength Number of bytes allocated in URL string if it is unequal nullptr. Receives minimal number of bytes needed for full string representation including zero-termination.
Returns
  • #CVC_ERROR (#CVC_E_OK) on success.
  • #CVC_ERROR (#CVC_E_WRONGOBJECT) if node id is not a valid object
  • Smaller than zero on error (Use CVOPCGetLastErrorString function for a human readable error description).

◆ CVOPCServerGetDisoveryURLW()

cvbres_t CVOPCServerGetDisoveryURLW ( CVOPCSRV  Server,
wchar_t *  URL,
size_t &  URLSize 
)

Gets the URL of an Server OPCUA Server as a wide C string.

Note
The OPCUA Server must be running the retrieve the URL
Attention
Server OPCUA Server must be running to get a meaningfully Discovery URL
Parameters
[in]ServerOPCUA server handle
[out]URLPointer of wide char array to contain wide C string representation of URL.
[in,out]URLSizeLength Number of bytes allocated in URL string if it is unequal nullptr. Receives minimal number of bytes needed for full string representation including zero-termination.
Returns
  • #CVC_ERROR (#CVC_E_OK) on success.
  • #CVC_ERROR (#CVC_E_WRONGOBJECT) if node id is not a valid object
  • Smaller than zero on error (Use CVOPCGetLastErrorString function for a human readable error description).

◆ CVOPCServerGetNode()

cvbres_t CVOPCServerGetNode ( CVOPCSRV  server,
CVOPCNODEID  NodeId,
CVOPCNODE Node 
)

Gets a OPCUA NodeOrId to the server which is identified by an OPCUA NodeId.

Parameters
[in]ServerOPCUA Server handle.
[in]NodeIdOPCUA NodeId handle.
[out]NodeOrIdOPCUA NodeOrId handle.
Returns
  • #CVC_ERROR (#CVC_E_OK) on success.
  • #CVC_ERROR (#CVC_E_WRONGOBJECT) if node id is not a valid object
  • Smaller than zero on error (Use CVOPCGetLastErrorString function for a human readable error description).

◆ CVOPCServerGetState()

cvbres_t CVOPCServerGetState ( CVOPCSRV  Server,
TCVOPCServerState &  ServerState 
)

Returns the current state of the OPCUA server.

Parameters
[in]ServerOPCUA Server handle.
[out]CurrentOPCUA Server State to be returned.
Returns
  • #CVC_ERROR (#CVC_E_OK) on success.
  • #CVC_ERROR (#CVC_E_WRONGOBJECT) if node id is not a valid object
  • Smaller than zero on error (Use CVOPCGetLastErrorString function for a human readable error description).

◆ CVOPCServerStart()

cvbres_t CVOPCServerStart ( CVOPCSRV  Server)

Starts an OPCUA Server.

Attention
Server OPCUA Server must be initialized first.
Parameters
[in]ServerOPCUA Server handle.
Returns
  • #CVC_ERROR (#CVC_E_OK) on success.
  • #CVC_ERROR (#CVC_E_WRONGOBJECT) if node id is not a valid object
  • Smaller than zero on error (Use CVOPCGetLastErrorString function for a human readable error description).

◆ CVOPCServerStop()

cvbres_t CVOPCServerStop ( CVOPCSRV  Server)

Stops an OPCUA Server.

Parameters
[in]ServerOPCUA Server handle.
Returns
  • #CVC_ERROR (#CVC_E_OK) on success.
  • #CVC_ERROR (#CVC_E_WRONGOBJECT) if node id is not a valid object
  • Smaller than zero on error (Use CVOPCGetLastErrorString function for a human readable error description).

◆ IsCVOPCServer()

cvbbool_t IsCVOPCServer ( CVOPCSRV  Server)

Tries to check whether the given Server handle is a valid object.

Attention
Always use initialized variables and initialize unused handles with nullptr.
Parameters
[in]ServerOPCUA Server handle to check.
Returns
TRUE if it is a valid object, FALSE otherwise.