EasyUaClnt a simplicity wrapper library based on AsOpcUac

Hello Community,

I would like to share with you a library we developed in B&R Spain.

General information

Description
The EasyUaClnt is a simplicity wrapper library based on AsOpcUac. Anyone who has tried to program a functionality (node read, node write, subscription…) with the AsOpcUac library knows that for each functionality, several function block (FUB) calls are required. The idea behind this library is to provide a clear interface to the user and encapsulate each functionality in one function block (FUB).

Minimum tested Automation Runtime versions
AS4

  • For SG4 Intel CPUs: J4.25
  • For SG4 ARM CPUs: A4.34

AS6

  • For SG4 Intel CPUs: 6.0.0
  • For SG4 ARM CPUs: 6.0.0

Functionalities
The functionalities of this library exhibit no constraints when compared with the AsOpcUac library ones. It allows the user to perform the following actions in OPC UA as a client in a easier way:

  • Read
  • ReadList
  • ReadBluk
  • Write
  • WriteList
  • WriteBulk
  • Subscription
  • SubscriptionList
  • MethodCall
  • ConnectionGetStatus

Library help
The library has its own help that comes with samples for each of the functionalities listed before. From AS can be accessed by pressing F1 over the library.

Example

EasyUaRead - Read an OPC UA node
In the following example is shown how an OPC UA node can be read from an OPC UA Server using just 1 FUB. To achieve the same result using AsOpcUac is necessary the usage of 6 FUBs.

  • AsOpcUac: UA_Connect → UA_GetNamespaceIndex → UA_NodeGetHandle → UA_Read → UA_NodeReleaseHandle → UA_Disconnect
  • EasyUaClint: EasyUaRead

The Controller 1 (192.168.0.105) works as OPC UA Client and implements the function EasyUaRead from the library EasyUaClnt. The value of the variable read from the server is copied to the local variable “VarA” of the task “Read”.

The Controller 2 (192.168.0.106) works as OPC UA Server. In the Controller 2 the name of the variable is “VarX” and it is a local variables of the task “ServerTask” and it is Enabled in the OPC UA Default View configuration.

Controller 1 code - Task Read

PROGRAM _INIT
	VarA;
	EasyUaRead_0.ServerEndpointUrl := 'opc.tcp://192.168.0.106:4840';
	EasyUaRead_0.NodeID.NamespaceIndex := 6;
	EasyUaRead_0.NodeID.Identifier := '::ServerTask:VarX';
	EasyUaRead_0.NodeID.IdentifierType := UAIdentifierType_String;
	EasyUaRead_0.Variable := '::Read:VarA';
END_PROGRAM

PROGRAM _CYCLIC
	EasyUaRead_0();
END_PROGRAM

Execution of the FUB

Downloads and links

Last binary library version
Binary lib V1.02.2 for AS4: Click to download
Binary lib V2.00.0 for AS6: Click to download

Source code repository
B&R GitHub source code repository:

New AS6 version

More information about the new in the post: AS6 post with the news

Regards colleagues,

Javier

20 Likes

That’s great ! This could save a lot of our time.

1 Like

Thanks for the feedback Christoph Hilchenbach! The README is already added and the pull request will be done asap.

1 Like

Hello @javier.novella !
Great job. I have problems opening the Help of the imported Library. There is no content. Any idea why?

Hi Filipe

This is probably a Windows Security thing, which can happen for CHM files which were downloaded from the internet. Try right-click on the CHM and open the properties. There should be some kind of unlock checkbox or button if I remember correctly.

3 Likes

It worked with your workaround! Thanks

Thanks for the tip Patrick! :slight_smile:

This link explains why opening chm files sometimes shows no contents:

3 Likes

Receiving this error when trying to utilize ‘EasyUaSubscriptionList’


Properties of EasyUaClnt Library shows version 1.02
And trying to import existing library only gives option for version 1.02, but compiler still produces same error.
(As a new user I can only include one image in my comment)

1 Like

Here is screenshot on library property version
image

1 Like

You have to deploy the EasyUaClnt library to the software configuration (together with some other libraries):

2 Likes

Hi @javier.novella ,
thank you for this library, this currently makes my life much easier - communicating with an external (not B&R and not Pub/Sub capable) OPC/UA Server through standard OPC/UA Block Read & Write Requests.

We are using Block-Reads in a cyclic manner - there your default behaviour is not yet the one I needed, so I did a patch to your internal statemachine for a rapid prototype.
The prototype with the patch is working nicely at high frequency.

May I propose a small modification, that helps, when you really want to do a high frequency block read - without setting up the connection for every single Read Request.
If you are OK, I can propose that through a fork/pull-request

Best
Thomas

2 Likes

Hello Thomas,

Thanks for your message and support! You can fork it for sure as we talked privately.

For your cyclic-reads I understand your use-case but I would recommend you to switch to Subscriptions.

Thanks in advance and best regards!

1 Like

Hello,

I leave here the new minor version of the EasyUaClnt library. It includes the following changes:

Changed

-Improved disconnection procedure for EasyUaWrite, EasyUaWriteList, EasyUaRead, EasyUaReadList, EasyUaMethodCall.

For the newest version refer to the main post.

Source code repository: br-automation-com/easyuaclient-as-project-dev (github.com)

7 Likes

Library version used is 1.02.1.
I have downloaded project using AS 4.2 (AR O4.26 - X20CP1583).
It is always getting to Diag mode with logger entry as Installation Failure for EasyUaclnt with error ID : 8099.

When i tried the same project with AS 4.12 (AR B4.93 with same hardware X20CP1583), It is working fine.

Finally i want to use it with AS 4.2. Any Solution ??

Hello Manishkumar Dholu,

I will try to reproduce this behaviour and I will be back to you as soon as possible,

Thanks for the feedback!

EDIT:
I could reproduce it, It is related to the last compilation.
If you use the Source library from the repository it will work.
In the meanwhile you can take the library with the source code and will I take a look to the last compilation done.

3 Likes

Hello Javier Novella,

I tried with Open Source Library. Now i am able to use this library in AS 4.2.
Thanks for support.

2 Likes

Hello Community!

Firstly, thanks to all the people who is using this library! Is really exciting to see how someone’s work is really valuable for others. Secondly, but not less important, thanks to the people who keeps pushing it and gives feedback that allows us to improve it!

I’m really happy to send to you the new V1.02.1 that improves the compatibility with older AR. I have made also some small changes in the Help to make it more understandable.

This V1.02.1 only applies the people using AR < B4.34, for the rest there is no need to change.

The version 1.02.1 has been re-uploaded. The changes done are:

Changed

-Improved disconnection procedure for EasyUaWrite, EasyUaWriteList, EasyUaRead, EasyUaReadList, EasyUaMethodCall.
-Improved backwards compatibility with old AR.
-Help improved.
-Minimum AR versions updated.

The minimum tested AR versions for the EasyUaClnt now are fixed to:

  • For SG4 Intel CPUs: J4.25
  • For SG4 ARM CPUs: A4.34

For the newest version refer to the main post.

10 Likes

Hello Javier Novella,
thank you for this library

best
rishikesh

3 Likes

When attempting to use this workaround, I get the following popup which then terminates the attempt to unblock:

image

2 Likes