OPC UA (CVOpcUa.dll) 14.0
OpcUa Client Functions

Typedefs

typedef void * CVOPCCLT
 Handle of an OPCUA Client object. It handles the client side of the OPCUA client/server interaction. More...
 

Functions

CVOPCCLT CreateCVOPCClient ()
 Creates an OPCUA Client object. More...
 
cvbres_t CVOPCClientAddMonitoredItem (CVOPCCLT Client, CVOPCNODE Variable, size_t SubscriptionIndex, pfCVOpcV Callback, void *pPrivate, size_t &CallbackId)
 Adds a monitored item to an existing subscription. More...
 
cvbres_t CVOPCClientConnect (CVOPCCLT Client, const char *DiscoveryURL)
 Connects an OPCUA Client with an OPCUA Server which can be found under the given DiscoveryURL. More...
 
cvbres_t CVOPCClientConnectW (CVOPCCLT Client, const wchar_t *DiscoveryURL)
 Connects an OPCUA Client with an OPCUA Server which can be found under the given DiscoveryURL. More...
 
cvbres_t CVOPCClientCreateSubscription (CVOPCCLT Client, size_t &SubscriptionIndex)
 Creates an OPCUA Subscription for an OPCUA Client, where monitored items could be added to (receive updates if variable data changes). More...
 
cvbres_t CVOPCClientDeleteMonitoredItem (CVOPCCLT Client, size_t SubscriptionIndex, size_t CallbackId)
 Deletes an OPCUA Monitored Item which is identified by the unique CallbackId. More...
 
cvbres_t CVOPCClientDeleteSubscription (CVOPCCLT Client, size_t SubscriptionIndex)
 Creates the OPCUA Subscription for an OPCUA Client. More...
 
cvbres_t CVOPCClientDisconnect (CVOPCCLT Client)
 Disconnects an OPCUA Client that is connected to an OPCUA Server. More...
 
cvbres_t CVOPCClientGetNode (CVOPCCLT Client, CVOPCNODEID NodeId, CVOPCNODE &Node)
 Accesses a Node of the OPCUA Server, given a Client which is connected with that Server and given the NodeId of the Node. More...
 
cvbres_t CVOPCClientGetState (CVOPCCLT Client, TCVOPCClientState &ClientState)
 Gets the current state of an OPCUA Client. More...
 
cvbbool_t IsCVOPCClient (CVOPCCLT Client)
 Tries to check whether the given Client handle is a valid object. More...
 

Detailed Description

Functions to create OPCUA Client objects that support the services Discovery, Read, Write, and Subscription.

Typedef Documentation

◆ CVOPCCLT

Handle of an OPCUA Client object. It handles the client side of the OPCUA client/server interaction.

Note
For details also refer to the OPCUA specification Part 1:
https://opcfoundation.org/developer-tools/specifications-unified-architecture/part-1-overview-and-concepts/

CVOPCCLT objects are reference counted. If one is not needed anymore call the ReleaseObject function of the CVCImg.dll. It is recommended to call the ShareObject function in a program unit (like a class or function) when a handle is set and call ReleaseObject when the handle is not needed anymore.

Function Documentation

◆ CreateCVOPCClient()

CVOPCCLT CreateCVOPCClient ( )

Creates an OPCUA Client object.

Attention
Release the returned object handle with ReleaseObject if not needed anymore.
Returns

◆ CVOPCClientAddMonitoredItem()

cvbres_t CVOPCClientAddMonitoredItem ( CVOPCCLT  Client,
CVOPCNODE  Variable,
size_t  SubscriptionIndex,
pfCVOpcV  Callback,
void *  pPrivate,
size_t &  CallbackId 
)

Adds a monitored item to an existing subscription.

Note
This function is specialized to monitor the value of OPCUA Variables.
Parameters
[in]ClientOPCUA Client handle.
[in]NodeOPCUA Variable that should be monitored.
[in]CallbackCallback function pointer that is called when the value of the OPCUA Monitored Item changes.
[in]pPrivateUser data pointer to be given into Callback function.
[out]CallbackIdUnique CallbackId that refers to the callback of the OPCUA Monitored Item.
Returns
  • #CVC_ERROR (#CVC_E_OK) on success.
  • #CVC_ERROR (#CVC_E_WRONGOBJECT) if either Client or Variable are not a valid objects.
  • Smaller than zero on error (Use CVOPCGetLastErrorString function for a human readable error description).

◆ CVOPCClientConnect()

cvbres_t CVOPCClientConnect ( CVOPCCLT  Client,
const char *  DiscoveryURL 
)

Connects an OPCUA Client with an OPCUA Server which can be found under the given DiscoveryURL.

Attention
Always use initialized variables and initialize unused handles with nullptr.
Parameters
[in]ClientOPCUA Client object.
[in]DiscoveryURLURL of the OPCUA Server to be connected with. String must be 0 terminated.
Returns
  • #CVC_ERROR (#CVC_E_OK) on success.the given OPCUA Client
  • #CVC_ERROR (#CVC_E_WRONGOBJECT) if Client is not a valid object.
  • Smaller than zero on error (Use CVOPCGetLastErrorString function for a human readable error description).

◆ CVOPCClientConnectW()

cvbres_t CVOPCClientConnectW ( CVOPCCLT  Client,
const wchar_t *  DiscoveryURL 
)

Connects an OPCUA Client with an OPCUA Server which can be found under the given DiscoveryURL.

Attention
Always use initialized variables and initialize unused handles with nullptr.
Parameters
[in]ClientOPCUA Client object.
[in]DiscoveryURLURL of the OPCUA Server to be connected with. This wide string must be 0 terminated.
Returns
  • #CVC_ERROR (#CVC_E_OK) on success.
  • #CVC_ERROR (#CVC_E_WRONGOBJECT) if Client is not a valid object.
  • Smaller than zero on error (Use CVOPCGetLastErrorString function for a human readable error description).

◆ CVOPCClientCreateSubscription()

cvbres_t CVOPCClientCreateSubscription ( CVOPCCLT  Client,
size_t &  SubscriptionIndex 
)

Creates an OPCUA Subscription for an OPCUA Client, where monitored items could be added to (receive updates if variable data changes).

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

◆ CVOPCClientDeleteMonitoredItem()

cvbres_t CVOPCClientDeleteMonitoredItem ( CVOPCCLT  Client,
size_t  SubscriptionIndex,
size_t  CallbackId 
)

Deletes an OPCUA Monitored Item which is identified by the unique CallbackId.

Parameters
[in]ClientOPCUA Client handle.
[in]NodeIdOPCUA Variable that is
[out]NodeOPCUA Variable that is
[in]CallbackCallback function pointer that is called when the value of the OPCUA Monitored Item changes.
[in]pPrivateUser data pointer to be given into Callback function.
[out]CallbackIdUnique CallbackId that refers to the callback of the OPCUA Monitored Item.
Returns
  • #CVC_ERROR (#CVC_E_OK) on success.
  • #CVC_ERROR (#CVC_E_WRONGOBJECT) if Client is not a valid object.
  • Smaller than zero on error (Use CVOPCGetLastErrorString function for a human readable error description).

◆ CVOPCClientDeleteSubscription()

cvbres_t CVOPCClientDeleteSubscription ( CVOPCCLT  Client,
size_t  SubscriptionIndex 
)

Creates the OPCUA Subscription for an OPCUA Client.

Note
All monitored items that are part of the given subscription will be deleted as well.
Parameters
[in]ClientOPCUA Client handle.
Returns
  • #CVC_ERROR (#CVC_E_OK) on success.
  • #CVC_ERROR (#CVC_E_WRONGOBJECT) if Client is not a valid object.
  • Smaller than zero on error (Use CVOPCGetLastErrorString function for a human readable error description).

◆ CVOPCClientDisconnect()

cvbres_t CVOPCClientDisconnect ( CVOPCCLT  Client)

Disconnects an OPCUA Client that is connected to an OPCUA Server.

Note
OPCUA Client must be connected to an OPCUA Server so that the function returns with success. If the OPCUA Client was not connected before calling the function returns with an error code.
Attention
Always use initialized variables and initialize unused handles with nullptr.
Parameters
[in]ClientOPCUA Client object to be disconnected.
Returns
  • #CVC_ERROR (#CVC_E_OK) on success.
  • #CVC_ERROR (#CVC_E_WRONGOBJECT) if Client is not a valid object.
  • Smaller than zero on error (Use CVOPCGetLastErrorString function for a human readable error description).

◆ CVOPCClientGetNode()

cvbres_t CVOPCClientGetNode ( CVOPCCLT  Client,
CVOPCNODEID  NodeId,
CVOPCNODE Node 
)

Accesses a Node of the OPCUA Server, given a Client which is connected with that Server and given the NodeId of the Node.

Note
The OPCUA Client must be connected to an OPCUA Server to succeed. The OPCUA NodeId must refer to an OPCUA Node present in the address space of the OPCUA Server.
Attention
Always use initialized variables and initialize unused handles with nullptr.
Parameters
[in]ClientOPCUA Client object to be disconnected.
[in]NodeIdOPCUA NodeId which identifies the node to be retrieved.
[out]NodeOPCUA Node object to be filled with the content of the OPCUA Node of the server's address space.
Returns
  • #CVC_ERROR (#CVC_E_OK) on success.
  • #CVC_ERROR (#CVC_E_WRONGOBJECT) if either Client or NodeId are not a valid objects.
  • Smaller than zero on error (Use CVOPCGetLastErrorString function for a human readable error description).

◆ CVOPCClientGetState()

cvbres_t CVOPCClientGetState ( CVOPCCLT  Client,
TCVOPCClientState &  ClientState 
)

Gets the current state of an OPCUA Client.

Attention
Always use initialized variables and initialize unused handles with nullptr.
Parameters
[in]ClientOPCUA Client object.
[out]Clientstate enum.
Returns
  • #CVC_ERROR (#CVC_E_OK) on success.the given OPCUA Client
  • #CVC_ERROR (#CVC_E_WRONGOBJECT) if Client is not a valid object.
  • Smaller than zero on error (Use CVOPCGetLastErrorString function for a human readable error description).

◆ IsCVOPCClient()

cvbbool_t IsCVOPCClient ( CVOPCCLT  Client)

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

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