External Program

99 views
Skip to first unread message

Elio Obeid

unread,
Nov 23, 2019, 5:24:11 AM11/23/19
to Jaamsim Users Discussion Group
Hello Harry,

I wanted to ask you about the new ExternalProgram Object since the documentation hasn't been set up yet.

How do I redirect the output of a program to Jaamsim?
Can I use my Jaamsim variables defined in a DisplayEntity in my code?
What is the expected return type of my code? 

Regards,
Elio OBEID.

Harry King

unread,
Nov 23, 2019, 2:32:39 PM11/23/19
to Jaamsim Users Discussion Group
Elio,

The attached example will help you get started with the ExternalProgram object. The external program in the example is a Python program 'JSP_IO_test.py' that accept two numerical values as command line inputs and returns the sum of the two values.

The DataSource input provides two expressions, { this.Value(1) } { 1 },  that return the values passed to be passed to the Python program. The output 'Value' returns the result of the calculation that was performed for the last entity received by the ExternalProgram object. With these inputs, the Value output is increased by one each time the ExternaProgram object receives an entity.

Note that you will need to modify the ProgramFile input to point to the Python interpreter on your computer. For my system, the input is '/C:/ProgramData/Anaconda3/python.exe'.

Harry
ExternalProgram Example.cfg
JSP_IO_test.py
Reply all
Reply to author
Forward
0 new messages