question

Che-Wei Chou avatar image
0 Likes"
Che-Wei Chou asked Che-Wei Chou commented

Connecting to External Code

Hi,

I've tried to practice this example to connect external python code by the following line:

https://answers.flexsim.com/questions/110833/future-python-and-flexsim-integration.html

However, it seemed to have a bug here.

Could you help to clarify it?

Thanks

Wade


1679783649795.png

TestFlexsimPy.py

Pull_from_Queue.fsm

FlexSim 22.2.0
connect to external code
1679783649795.png (290.9 KiB)
pull-from-queue.fsm (30.1 KiB)
5 |100000

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

1 Answer

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered Che-Wei Chou commented

You defined the code to call python in a user command but in the Pull Strategy code you call a label "CallPython" that does not exist on the processor instead. Either actually use the user command or move the code to call python to the label.

Your python code won't work because:

- you don't pass the jobs array to python when you call "evaluate()".

- options is not defined anywhere in the python code

- you didn't add fields that contain the queue name and item rank to the list, so the entries of the jobs array only contain four elements, not six like the python code assumes in the return value

Also be aware that the Pull Strategy code will not refire automatically. It executes on reset (which will not return a valid item since the queues are all still empty) and when an item leaves the processor. To "kickstart" the processor you will have to execute the code manully when items become available (by evaluating the node the code is defined on in the variables attributes of the processor.

1679903992333.png


1679903992333.png (13.4 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.