Register Service Handler

Questions regarding the use of the High Perfomance SDK for Server development

Moderator: uasdkhpc

Post Reply
Stefan@uaforum
Jr. Member
Jr. Member
Posts: 3
Joined: 11 Jan 2018, 13:01

Register Service Handler

Post by Stefan@uaforum »

Hello,
in the HP SDK Example server_lesson02, the service handler functions are registered in custom_provider.c. The example manual for example accessing asynchronous data says, that "registered service handler functions have changed to the functions that will be implemented in this lesson". But I can not find the place in the example code, where the service handler functions are registered now. So how does the SDK know that custom_provider_read() has to be called in case a OPC UA client sends a read request?

Thank you very much.
Stefan

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

Re: Register Service Handler

Post by Support Team »

Hello,

this is a misunderstanding.

The SDK offers an internal implementation which handles read/write, etc. and then delegates the access of the value attribute to the simplified value_interface.
This callback pointers to call the internal_provider are now pre-filled, so that you don't need to set this anymore.
If you don't want to use provider_internal_read, but you own version you can set this as before in your custom_provider_init function.
Best regards
Unified Automation Support Team

Stefan@uaforum
Jr. Member
Jr. Member
Posts: 3
Joined: 11 Jan 2018, 13:01

Re: Register Service Handler

Post by Stefan@uaforum »

Hello,

why do I need to register the service handlers in the lesson 2 example (e.g.ctx->read = uaprovider_internal_read;)? I understand your reply in that way, that this is done automatically by the SDK, since I have no own implementation of uaprovider_internal_read.

In the example "Accessing Asynchronous Data" there is an own implementation of the uaprovider_internal_read function, but this is not registered and it seems that the example does not work, since the custom_provider_read function is never called if a OPC UA Client makes a read of a node value. The OPC UA Client shows nothing for the value of the node. Could you please take a look at this example? I use the VS2015 Example installation of the HP SDK.

Thank you very much.
Stefan

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

Re: Register Service Handler

Post by Support Team »

Hello Stefan,

you are right, this example does not work anymore. When the initialization was changed to the default settings described above the function pointers have been removed in all examples,
but in this case this was wrong.

The correct initialization would be:

Code: Select all

int custom_provider_init(struct uaprovider *ctx)
{
    ...
    /*! [register_cleanup] */
    ctx->read        = custom_provider_read;
    ctx->write       = custom_provider_write;
    ctx->add_item    = custom_provider_add_item;
    ctx->remove_item = custom_provider_remove_item;
    ctx->modify_item = custom_provider_modify_item;
    ctx->subscribe   = custom_provider_subscribe;
    ctx->cleanup     = custom_provider_cleanup;
    /*! [register_cleanup] */
   ...
}
like it was before.

We have fixed this now in our code and now the example is working again as expected.
Best regards
Unified Automation Support Team

Stefan@uaforum
Jr. Member
Jr. Member
Posts: 3
Joined: 11 Jan 2018, 13:01

Re: Register Service Handler

Post by Stefan@uaforum »

Hello,

did you also update the example on your website (e.g. HP SDK for VS2015) in the download section?

I could not check without uninstalling my current HP SDK.

Best Regards
Stefan

Post Reply