C++ Based OPC UA Client/Server/PubSub SDK  1.7.0.449
Client Cpp Sample – Full Client Example

The client example “Client Cpp Sample” provides a full client example.

The sample code and the referenced functions in the following list can be found in the file client_cpp_sdk.cpp

It provides examples for:

  • Server discovery (method startDiscovery)
  • Certificate and security handling (methods setupSecurity, createCertificates, startDiscovery, connect)
  • Connect to server including namespace handling (method connect)
  • Disconnect from server (method disconnect)
  • Browse server address space (method browse)
  • Read values from server (method read)
  • Write values to server (method write)
  • Register nodes for optimized read / write (method registerNodes)
  • Unregister nodes (method unregisterNodes)
  • Create subscription, data monitored items and event monitored items including event filter handling (method subscribe)
  • Call method in server (method callMethod)
  • Translate a browse path to nodeId (method translate)
  • Transfer a subscription from one session to another session (method transferSubscription)
  • Read historical data on a variable (methods historyReadDataRaw, historyReadDataProcessed, historyReadDataAtTime)
  • Update and delete historical data on a variable (methods historyUpdateData, historyDeleteData)
  • Read event history on an event notifier (method historyReadEvents)
  • Update and delete the event history on an event notifier (methods historyUpdateData, historyDeleteData)
  • Handling of structured data types (method read() in client_cpp_sdk.h and method printGenericStructureValue() in callback.h); see also the utility classes UaStructureDefinition to describe a structured data type and UaGenericStructureValue to serialize and deserialize the data

The callback handling for data changes and events is implemented in callback.h.

The configuration parameters for the client (serverUrl, NodeIds for reading and writing etc.) are loaded from an *.ini file "ClientConfig.ini" and stored in global variables.