ATTENTION

This FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices.


flexsim.com

Go Back   FlexSim Community Forum > FlexSim Software > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 09-11-2007
Tom David's Avatar
Tom David Tom David is offline
Flexsim User
 
Join Date: Aug 2007
Location: Schwaebisch Gmuend, Germany
Posts: 430
Downloads: 157
Uploads: 47
Thanks: 486
Thanked 450 Times in 233 Posts
Rep Power: 520
Tom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant future
Default Start Flexsim and model from externally via a batch file

During the distributor training Anthony Johnson showed an example how to start Flexsim from externally.
I thought this might be interesting for the whole community so I made an example for myself with a batch file and some documentation. The other way to start Flexsim externally could be to use *.vbs. which Anthony showed at the training.
Maybe someone else is in the mood to explain or make an example for this.

Because I got once a Blue Screen during my testing I like to mention that I am not responsible for anything what will happen if you try this stuff. I know this is already clear because this is a forum post but I like to say it at least once .



The Batch file I use (StartFlexsimAndModelViaBatchFile_TD.bat) looks like this:
"C:\Program Files\Flexsim4\program\flexsimrunner.exe" "C:\Program Files\Flexsim4\userprojects\ StartFlexsimAndModelViaBatchFile_TD.fsm"
To execute code while loading the StartupRT.txt is used (found in the /program directory).
I recommend to make a backup of this file.
The general idea is to execute a node function of a node in the model.
In my example the node is under /Tools and called StartupRTtxt.

The following code was modified and added to the StartupRT.txt at the end:

if(openingmodel)
nodefunction(node("MAIN:/project/exec/globals/nodefunctions/openmodelcode"));
if(objectexists(node("/Tools/StartupRTtxt",model())))
{
nodefunction(node("/Tools/StartupRTtxt",model()));
}
if(openinglibrary)
loaduserlibrary(openfile,0,1);
repaintall();

Be aware that there is already code and I just added the bold text.

Create the node StartupRTtxt and toggle the node as Flexscript and Build Flexscript.

Following files are in the zip archive (StartFlexsimAndModelViaBatchFile_TD.zip):
/userprojects/Logo_FlexsimD.bmp
/userprocjets/StartFlexsimAndModelViaBatchFile_TD.bat
/userprocjets/StartFlexsimAndModelViaBatchFile_TD.fsm
/program/startupRT_TD.txt (which has to be renamed to startupRT.txt)

I did not add the paths into the archive because I do not want that by accident someone overwrites his startupRT.txt. So you need to put these files in the above described directories by yourself.

I am sure this gives the community an idea how to do the external start.
Because all Flexscript can be used in the node you can do whatever you want.
In combination with cmdcompile() and the ModelStartupCode I see some more scenario which could be build.

Hopefully my little post will start a discussion about this subject, because I am ready to learn more about it. I appreciate every comment and every new idea.

Thanks in advance
tom the (A)tom
Attached Files
File Type: zip StartFlexsimAndModelViaBatchFile_TD.zip (84.4 KB, 402 views)
The Following User Says Thank You to Tom David For This Useful Post:
cedric molthoff (03-10-2010)
  #2  
Old 09-11-2007
AlanZhang's Avatar
AlanZhang AlanZhang is offline
Flexsim Super Moderator
 
Join Date: Aug 2007
Location: CA
Posts: 289
Downloads: 64
Uploads: 0
Thanks: 88
Thanked 91 Times in 47 Posts
Rep Power: 225
AlanZhang is a jewel in the roughAlanZhang is a jewel in the roughAlanZhang is a jewel in the rough
Default

Hi Tom,

I have tried similar ideas before. There is an post in old Flexsim user forum on this subject. Some explanation there made by Anthony and Cliff would be helpful. Search " After loading model, compile, reset and run by himself?" and you will see it.

Alan
  #3  
Old 09-12-2007
Tom David's Avatar
Tom David Tom David is offline
Flexsim User
 
Join Date: Aug 2007
Location: Schwaebisch Gmuend, Germany
Posts: 430
Downloads: 157
Uploads: 47
Thanks: 486
Thanked 450 Times in 233 Posts
Rep Power: 520
Tom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant future
Default

Alan,

I read the thread in the old forum and there were some helpful information. But what I did not like, that there was no working example.
This is why I took the time to prepare an example which works. Hopefully I save nerves and time of some people .
Yes, it would be nice to have a summary of the thread in the old forum you mentioned, but to be honest I am not in the mood to prepare this.
I still hope, that maybe someone else prepares a working example for *.vbs. Or maybe someone likes go give some further information.
Than this thread here could be so much better than the one in the old forum .
This was my general idea to start this thread here and hopefully with some more value because of the example which works .

Thanks for your reply.
tom the (A)tom
  #4  
Old 09-12-2007
AlanZhang's Avatar
AlanZhang AlanZhang is offline
Flexsim Super Moderator
 
Join Date: Aug 2007
Location: CA
Posts: 289
Downloads: 64
Uploads: 0
Thanks: 88
Thanked 91 Times in 47 Posts
Rep Power: 225
AlanZhang is a jewel in the roughAlanZhang is a jewel in the roughAlanZhang is a jewel in the rough
Default

Hi Tom,

This is great. I like working examples.

Just a few comments. If you want it run and then stop at certain time, use the following command in the StartupRTtxt node:
<code>
resetmodel();
stoptime(100);
runspeed(20);
go();
</code>

Note the stoptime() command has to be used even if you use Expreimenter to set a stop time. And if you want Flexsim exit after the simulation is finished, add following code in the End of experiment trigger:
<code>
cmdexit();
</code>

Combining these, we can actually run multiple simulation model files using batch files.

Thanks.
Alan



All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.