question

Gilles avatar image
0 Likes"
Gilles asked Jeanette F commented

How to open a .fsl fine on C++?

Hello,

I have am building a C++ code. in that code, I need some outputs from a flexsim model. the C++ model needs to pass some parameters to flexsim model and flexsim model needs to provide some outputs back to the c++ code. this process will repeat multiple time in on run of the C++ code. this the approach I am taking:

1. from C++ code, create csv file containing parameter value

2. open the model from C++ code

3. once the model is opened, it should should read the csv file and trigger the run

4. at the end of the simulation, flexsim create and output file for c++

5. c++ read the outfile and run some additional code and create new parameter for flexsim

6. go back to step 1


here is my concern:

how to do step 2? how can I open a flexsim model in c++?

in addition, how to make sure that C++ wait results of simulation before continuing to the next execution?

FlexSim 23.2.0
c++open modelcontrolling
· 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.

Jeanette F avatar image Jeanette F ♦♦ commented ·

Hi @Gilles , was Logan Gold'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 comment back to reopen your question.

0 Likes 0 ·

1 Answer

Logan Gold avatar image
0 Likes"
Logan Gold answered

Hi @Gilles, you should be able to use C++ to run Windows Command Prompt commands. Here is a post that goes over what Command Prompt commands you can use to open FlexSim and run a model:

https://answers.flexsim.com/questions/21116/automatically-configure-and-run-a-flexsim-model.html

You'll need to figure out how to run Command Prompt commands with however you're implementing your C++ code. Since that is a C++ question, we won't be able to help you with those specifics.

There may be a way to determine from within your C++ application when an application closes when it's opened with Command Prompt commands, but again, that is a C++ question that we won't be able to help you with.

You can create a file from within FlexSim by using the fileopen() and fileclose() commands. From within FlexSim, if you go through the Help menu and choose Command Help, you can search for those commands to see how they can be used. You could also try something like exporttable() to export data from a table to a CSV file. Once you have the file created/modified, you should be able to detect when those files are changed with your C++ code.

5 |100000

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