Is that possible to demultiplex the method call request

Questions regarding the use of the ANSI C SDK for Server or Client development or integration into customer products ...

Moderator: uasdkc

Post Reply
dingy
Sr. Member
Sr. Member
Posts: 14
Joined: 28 May 2013, 03:15

Is that possible to demultiplex the method call request

Post by dingy »

Hello, support team:

I'm developing an UA based gateway program. This program will be able to process some method call request which will lead blocking I/O operation, for example, update address space configuration file or access user account data file.

In single thread mode, this kind of request will block the event loop of UA Server until the I/O blocking operation is done.

So, I wonder if it is possible to dispatch this kind of request to anther thread, and this thread will be in charge of processing and responding to the client?

If it is possible, do I need to do some lock job when I send back the responds to UA Stack? At which moment do I need to lock?

Thanks a lot

User avatar
Support Team
Hero Member
Hero Member
Posts: 3072
Joined: 18 Mar 2011, 15:09

Re: Is that possible to demultiplex the method call request

Post by Support Team »

Hello,

you can dispatch all calls to the provider to another thread and process them there.

The only thing to remember is that the according XYZ_WriteComplete-callback needs to be called by the main thread that is calling UaServer_DoCom() in a loop. Hence you will have to create some sort of message queue that is filled with the responses by the worker thread and that is processed by the main thread.

Additionally you can call

Code: Select all

OpcUa_SocketManager_SignalEvent(OpcUa_Null, OPCUA_SOCKET_RENEWLOOP_EVENT, OpcUa_True);
out of the worker thread to signal the stack to return from the UaServer_DoCom() function, so that the new response in your message loop can be handled as soon as possible.

Best regards,
Unified Automation Support Team

dingy
Sr. Member
Sr. Member
Posts: 14
Joined: 28 May 2013, 03:15

Re: Is that possible to demultiplex the method call request

Post by dingy »

Ok, Thanks a lot

User avatar
Support Team
Hero Member
Hero Member
Posts: 3072
Joined: 18 Mar 2011, 15:09

Re: Is that possible to demultiplex the method call request

Post by Support Team »

Hello,

please note that it is important to set the define

Code: Select all

OPCUA_USE_SYNCHRONISATION
in order to use OpcUa_SocketManager_SignalEvent from other threads, otherwise you might run into problems.

If you are using the CMake files provided with the SDK, you can enable the define by setting the CMake option

Code: Select all

BUILD_UASTACK_USE_SYNC
to ON.

Best regards,
Unified Automation Support Team

Post Reply