ANSI C Based OPC UA Client/Server/PubSub SDK
1.9.4.474
|
Application merging Server and Client functionality together needs to initialize UA Stack in Startup sequence and cleanup UA Stack in Shutdown sequence only once.
The application should either use one configuration file and one UaBase_Settings for both Server and Client or set bProxyStubInitialized and bTraceInitialized if both are handled independent of each other. This is to ensure that ProxyStub and Trace configuration is initialized only once based on one configuration file.
Application that uses two configuration files should set bProxyStubInitialized and bTraceInitialized in the UaBase_Settings instance that it uses later as shown in the example below:
Two UaBase_Settings instances:
Server Startup:
Client Startup with bProxyStubInitialized and bTraceInitialized set to OpcUa_True:
If custom structure DataTypes are registered for automatic encoding/decoding by the stack, the registration must be done after ProxyStub initialized but before any OPC UA communication is initiated on client or server side.
After UaServer_StartUp and UaClient_StartUp application should execute the main loop by calling UaBase_DoCom cyclically until it returns an error or the application should be shut down. Also, it should use UaServer_Shutdown in the Shutdown sequence instead of registering for shutdown keystroke if the main loop uses keystrokes like in example below.