question

Patrick Cloutier avatar image
0 Likes"
Patrick Cloutier asked Patrick Cloutier commented

How to have Flexsim run on its own while connected to external database

I understand this is a very broad question but I couldn't find answers in the manual and this is beyond my current knowledge. I need to start somewhere.

I need a Flexsim model to import data from an external database (MES system), make calculations based on rules and on imported information and export a result to that MES system.

That cycle has to be repeated every 5 minutes (approx) whenever a part is ready at a certain equipment. Flexsim calculates where it has to be brought and exports that info to the MES which in turn will tell the AGV.

This runs 24/7 automatically with no user in front Flexsim to make it run.

The company has internal experts to help me with mapping the fields. I know how to build the Flexsim model and its calculation algorithm.

What I'm missing is:

1 - How does the Flexsim model run on its own without human intervention?

2 - How does the external database trigger Flexsim to import data every time a part is ready? Or does it have to be Flexsim that does it every X min.

3 - Does the model run continuously or only when new data is imported to make the new calculation and then reset and wait for the next RUN ? If the import trigger is in Flexsim (point 2) then I assume it needs to run all the time but then it runs for nothing most of the time.

I know these are maybe vague or stupid questions but I need to start somewhere.

Thanks a lot for pointing me in the right direction.

FlexSim 18.2.2
database
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 Hamoen avatar image
1 Like"
Steven Hamoen answered Phil BoBo commented

@Patrick Cloutier Hi Patrick, we have done something similar in the past where we communicated with a scheduler via a database. When we needed to communicate, we set the runspeed to one and created a loop that checked the database and when a field was changed we set the runspeed again and continued. So to answer your questions:

1. Once started it can run quite long on it's own but maybe start it manually every day? Or you have a separate program running that checks the database and starts FlexSim when needed (there are some posts in the forum about this solution)

2. As described above, simply with a wait loop. We used a while loop and the sleep command in C++ (we created a DLL)

3. So if you set the runspeed to very slow when waiting and not extremely high when it is doing something FlexSim can run quite long on it's own. Or you do as in point 1 and have a separate program start FlexSim all the time.

· 4
5 |100000

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

Patrick Cloutier avatar image Patrick Cloutier commented ·

Thanks Steven.

Since its supposed to run all the time, I'll assume Flexsim is always open with the model loaded. And someone could be "watching form a distance" to make sure it runs and restarts it when needed. Most of the time, Flexsim is not running.

Then, do you think I could have a file that is run by the MES system when required and that file would: 1 - tell Flexsim to import the database info, 2- reset and run the model and 3 - Export the result to the database ?

Would that type of file be the .dll you're taking about? or batch file? or .exe? My knowledge of these in non-existant. Should that file be created by their internal IT guy or by me?

Thanks a lot,

0 Likes 0 ·
Steven Hamoen avatar image Steven Hamoen commented ·

@Patrick Cloutier If the MES system is able to run a script file or shell command when it needs FlexSim then that would be a good solution. This post is a very good start: run a flexsim model automatically. The internal IT Guy is probably very useful in helping you with creating the correct batch file and calling it from the MES system.

If the MES system cannot do it, you have to create a simple program in for instance C# or python or any other language, that listens to the database and if something changes starts FlexSim. So than this piece of software should be the trigger.

0 Likes 0 ·
Patrick Cloutier avatar image Patrick Cloutier Steven Hamoen commented ·

I'm being asked this by their IT guy: In a server running Flexsim, will it run as a service (separated from user interface) or we need to auto-start a fake user session?

What do you think?

0 Likes 0 ·
Phil BoBo avatar image Phil BoBo ♦♦ Patrick Cloutier commented ·

FlexSim is an application, not a service. Depending on your Windows version and configuration, it may or may not be able to run without a user session. You would need to test it to find out how it behaves on the target system configuration.

0 Likes 0 ·
Samuel A avatar image
0 Likes"
Samuel A answered Patrick Cloutier commented

Were you able to make any progress with project? My company is switching to a new MES, Ujigami, and I am wanting to do something similar with flexsim. I am also on the lookout for a custom API that could achieve this.

· 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.

Patrick Cloutier avatar image Patrick Cloutier commented ·
The project never went ahead. When I wrote the post, I was preparing a quote for a potential customer but it didn't get accepted.
0 Likes 0 ·
Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered

You could get the system that writes the data saying a part is ready to also submit a JSON job to the webserver to run a simulation - this way it can also poll to see when the job is completed and optionally return have key results available via JSON (as well as writing to the database).

5 |100000

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

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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