question

Steven Chen avatar image
0 Likes"
Steven Chen asked Luciano Cavallero answered

OPC UA instance specifier to access single value of array

Hello,

I would like to re-open this topic: Using OPC UA to connect Fanuc robot - FlexSim Community

In conclusion, build-in Emulation GUI tool doesn't support specifying array index, we need to use internal Emulation in Process Flow.

So we can set node id to following format, where the %s is array index.

ns=2;s=Model;DiscreteInput[%s]


But it fails to read correct value of array, which is always zero.

I use OPC UA ANSI C Demo Server (Windows) as OPC UA server for testing.

UaExpert to modify node value, I set all boolean values to true.

Could you find out what is wrong in my model?

opcua_instance_v22.2.fsm

01.png



FlexSim 22.2.4
emulationopcua
01.png (37.5 KiB)
· 12
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jeanette F avatar image Jeanette F ♦♦ commented ·

@Luciano Cavallero, @Tancredi Canonico, @Fiorenzo A, can you please take a look at this emulation-related question?

0 Likes 0 ·
Luciano Cavallero avatar image Luciano Cavallero commented ·

Some OPC UA Server doesn't support direct access to a single element of an array ( the 'index range' functionality is not supported): please check if your server support this feature.

To avoid problem, if possible, transform your array of boolean into a set of single bool variables.

NOTE: the UaExpert client read and write all the array elements at once.

0 Likes 0 ·
Steven Chen avatar image Steven Chen Luciano Cavallero commented ·

I believe there is nothing to do at server side, because I am able to use Python to specify array index. I use UserCommand to run this Python code.

from opcua import Client

def read(url, node_id, array_index):
    client = Client(url)
    client.connect()
    value = client.get_node(node_id).get_value()[int(array_index)]    
    return value   


My goal is to do the same thing with emulation tool or internal emulation in process flow.

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Steven Chen commented ·

That expression seems to be reading the whole array from the server and not the element which would be the part of the node_id expression (in FlexSim including the %s parameter).

0 Likes 0 ·
Show more comments
Jason Lightfoot avatar image Jason Lightfoot ♦♦ commented ·

Hi @Steven Chen,

We haven't heard back from you. Were you able to solve your problem? If so, please add and accept an answer to let others know the solution. Or please respond to the previous comment so that we can continue to help you.

If we don't hear back in the next 3 business days, we'll assume you were able to solve your problem and we'll close this case in our tracker.

0 Likes 0 ·
Jeanette F avatar image Jeanette F ♦♦ commented ·

Hi @Steven Chen,

We haven't heard back from you. Were you able to solve your problem? If so, please add and accept an answer to let others know the solution. Or please respond to the previous comment so that we can continue to help you.

If we don't hear back in the next 3 business days, we'll assume you were able to solve your problem and we'll close this case in our tracker. You can always comment back at any time to reopen your question.

0 Likes 0 ·

1 Answer

Luciano Cavallero avatar image
0 Likes"
Luciano Cavallero answered

@Steven Chen : alredy in the dev list.

· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Steven Chen avatar image Steven Chen commented ·
Thank you.
0 Likes 0 ·