2

I have a OPCua server that consists of an array[1000] of objects (4 x reals, 2 x int, 2 x Enumerators).

I am trying to subscribe to Object[104].real2

I can subscribe currently to object and receive all 1000 objects every time there is an update. But this is way to much information.

I would happily settle for a subscription to object[104] if I could find a easy way to receive the data directly into my own class. Currently all data comes back as a series of bytes.

  • I wasn't able to do so on Machine Expert, so as a workaround we defined all elements of the array separately in a Global Variable List and changed the array to be an array of Pointers to access those elements in the PLC code. With OPC we exposed those variables (now no longer in an array), thus we were able to separately select which of them to subscribe to. Hope this helpes in case you are unable to find another solutions. PS. We'd written a py script to generate the code. Wouldn't want to write all 1000 by hand :P – Guiorgy Nov 25 '21 at 17:47

1 Answers1

0

One thing you could try (it works under our environment) is to leave the elements in your array (i.e. not have an array of pointers), declare a variable as a reference, make it available under OPC-UA, and set that reference to point to your variable.

VAR
  ref_to_real: REFERENCE TO REAL;
END_VAR

Then, one line of code to be executed once when your application starts :

ref_re_real REF= Object[104].real2;
Fred
  • 6,590
  • 9
  • 20