question

Cass Z avatar image
0 Likes"
Cass Z asked Cass Z commented

How do I monitor all the emulation variables by writing codes in Script window?

Hi, guys. I set up an emulation model in my FlexSim, I want to know if there is a way that I can code in the Script to watch my emulation variables, or if there is any way that I can monitor the emulation variables through a global table.

Thank you so much.

emulationvars.png

FlexSim 22.1.1
emulation
emulationvars.png (219.8 KiB)
· 3
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 ·
Hello @Cass Z,

Are you able to attach your model?

Both for the script window and the global table, can you use the dropper to select the node?

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

Hi, @Jeanette F . This is my model. Thank you for your help. newHiredemo_processDemo_autosave.fsm

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

Hi @Cass Z, was Jeanette F's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

Jeanette F avatar image
0 Likes"
Jeanette F answered Cass Z commented

Hello @Cass Z,

I created a way for you to monitor your emulation values both in the script window and a global table.

For thew script window you can use the sampler to select the node and then type value at the end.

1656355856478.png

Model.find("Tools/Emulation>variables/emulationVariables/OPC UA Sensor Variable").value

For the table you will need to create a event triggered source for each node and select the node for the object.

1656355919477.png

Then a custom code will be used to write to the table.

Please let me know if this doesn't work. I didn't have a way to test it out with the values changing. I also only set up the table for the first node.

newhiredemo-processdemo-autosave_1.fsm


· 5
5 |100000

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

Cass Z avatar image Cass Z commented ·

Hi, @Jeanette F I just tested it, the variables in the "GlobalTable1" are not changing. Do you know if there are any ways that I can import my Python code? I wrote a script in Python to connect to my PLC and I can read the values, but I am not sure where to import my Python code.

Thank you!

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

Only the first one would change. I didn't have any of the other values set up. I will reply again to get you the info for the python integration.

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

Hello @Cass Z,

1656361294174.png

Here is the place in our manual that talks about externally linking python code.

0 Likes 0 ·
1656361294174.png (67.7 KiB)
Show more comments