Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
When to use OPC UA Variables, Methods, Programs
July 22, 2014
16:31, EEST
Avatar
Allan
Member
Members
Forum Posts: 11
Member Since:
July 22, 2014
sp_UserOfflineSmall Offline

We are looking into using OPC UA with devices, such as motion controllers.

What is the standard way for an OPC UA client to tell the OPC UA server for a motional controller to move?
Would you set an OPC UA variable that is defined for that purpose in the server?
Or would you call an OPC UA method in the server?

As I understand it, both setting variables and calling methods will block the client until the server is done.
Is it standard for the OPC UA server to block until the hardware has completed the action?
Or would the server normally complete the variable setting or method call immediately and send an event when the hardware is ready?

How do you decide when to use an OPC variable and when to use a method?

One feature that I would like to test is how to abort or cancel a command. I know that an OPC UA “ProgramNode” has abort and cancel features.
Is that what you would use if you wanted to be able to abort a command? Are there any examples of this?

What about concurrent access from multiple threads?
Can a UaClient instance be used from multiple threads? Can multiple variable settings or methods be active in the server at one time?
What happens if multiple threads try to set the same variable or call the same method at the same time?
Are these accesses queued up and executed sequentially? Are OPC UA servers multi-threaded?
How would you implement the OPC UA server to allow a latter setting of a variable to cancel the previous one, if it is still in progress?

So many questions…

July 23, 2014
6:50, EEST
Avatar
Otso Palonen
Espoo, Finland
Member
Members
Forum Posts: 32
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

Hello Allan and welcome to the forums!

We are looking into using OPC UA with devices, such as motion controllers.

What is the standard way for an OPC UA client to tell the OPC UA server for a motional controller to move?
Would you set an OPC UA variable that is defined for that purpose in the server?
Or would you call an OPC UA method in the server?

Generally speaking Methods are normally the best way to model actions. Compared to setting variables, they have the advantage of grouping input parameters, output parameters and the explicit action into one neat package.

As I understand it, both setting variables and calling methods will block the client until the server is done.
Is it standard for the OPC UA server to block until the hardware has completed the action?
Or would the server normally complete the variable setting or method call immediately and send an event when the hardware is ready?

How do you decide when to use an OPC variable and when to use a method?

One feature that I would like to test is how to abort or cancel a command. I know that an OPC UA “ProgramNode” has abort and cancel features.
Is that what you would use if you wanted to be able to abort a command? Are there any examples of this?

You can also perform asynchronous calls in our SDK, it all depends on your application and its needs. Method calls will only return when the action is complete, and this is why they shouldn’t be used for long-running actions. Sending an event once the command has been carried out is one option, another is showing the status in a variable. Methods such as those defined in ProgramType can be used to for example cancel commands, but this is application level logic and depends on your system and how it should behave.

What about concurrent access from multiple threads?
Can a UaClient instance be used from multiple threads? Can multiple variable settings or methods be active in the server at one time?
What happens if multiple threads try to set the same variable or call the same method at the same time?
Are these accesses queued up and executed sequentially? Are OPC UA servers multi-threaded?
How would you implement the OPC UA server to allow a latter setting of a variable to cancel the previous one, if it is still in progress?

So many questions…

The server side in our Java SDK is multi-threaded and depending on your system you may need to come up with a concurrency strategy. If you’re just setting the value of a variable, then just doing another Write to overwrite the previous value should be OK. If you have some long-running process which you’ve activated via some method, you could have another method cancelling the process.

July 23, 2014
12:22, EEST
Avatar
Allan
Member
Members
Forum Posts: 11
Member Since:
July 22, 2014
sp_UserOfflineSmall Offline

Thanks for the quick answer, Otso.

Do you have any tips on how to decide whether to use variables or events for reporting on the status once an OPC UA method was called?
Events seem to be more complex to define. Are they a better fit when there are multiple properties to report?

July 23, 2014
12:57, EEST
Avatar
Otso Palonen
Espoo, Finland
Member
Members
Forum Posts: 32
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

It depends on the amount of information you want to provide of the status. If it’s a simple state like in a state machine, a good option is to define a custom Enum type enumerating all the possible states and expose a variable that has the state. If there are multiple properties, an event would be appropiate. You can also use both and leave it up to the client application how it wishes to receive information about state changes.

Of course the method call itself has output parameters, that can be used to convey some information that the server can immediately provide.

UA information models provide guidelines on how to model your system, but in the end the best way depends on the exact requirements of the system. We also provide professional services where we can help you model your application domain into UA Information Models.

July 24, 2014
14:30, EEST
Avatar
Allan
Member
Members
Forum Posts: 11
Member Since:
July 22, 2014
sp_UserOfflineSmall Offline

> “Method calls will only return when the action is complete, and this is why they shouldn’t be used for long-running actions.”

What kind of problems would it cause if a method waited a few seconds until a device completed an action before returning
and why is it better to return right away and later send an event or set a variable?

Would using the “callAsync()” method help here?

By the way, are the OPC UA Java API docs available to non-members (we are still evaluating)?
I need to use a lot of those classes, but only have API docs for the Prosys APIs.

Thanks.

July 25, 2014
5:55, EEST
Avatar
Otso Palonen
Espoo, Finland
Member
Members
Forum Posts: 32
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

A few seconds may not be a problem but at some point there are going to be timeouts and of course many simultaneous calls will take up server resources. Modelling your method calls so they return immediately (of course you may want to check input parameters, check current state etc. and do other things to ensure the validity of the method call) ensures you can use the same style regardless of the actual method execution taking one second or one hour. callAsync can help on the client side, but not with server resource consumption and timeouts.

Evaluation edition only includes documentation for the SDK layer, with the full versions also providing documentation for Java stack. In most cases, you should be fine with the SDK layer docs. Do you have some special case where you’d need information from the stack documentation?

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
29 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Heikki Tahvanainen: 402

hbrackel: 144

rocket science: 88

pramanj: 86

Francesco Zambon: 83

Ibrahim: 78

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

Member Stats:

Guest Posters: 0

Members: 734

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1523

Posts: 6449

Newest Members:

christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettinger, howardkennerley, Thomassnism, biancacraft16, edgardo3518

Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0

Administrators: admin: 1