ATTENTIONThis 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 |
#1
|
|||
|
|||
On Model Open after set make all code C++ ??
Hi all ...
I have problem with my model. I built a bit large model. and to run it in "On Open model" i wrote command. because very slow....then i set my model "Make all code c++", after that my model run faster than before. But, after i wrote code in "On Open model", and then open model..flexsim gave me warning to compile first.. The problem of my model can be seen on the attached file. How to handle this and avoid compile when i open model..? any ideas? Thanks in advance Ankus |
#2
|
|||
|
|||
Hi Ankus,
if you choose the option "Make all code c++" then its necessary to compile. There is no possibility to avoid this with c++. After each programming you have to compile first, before you can run the model. If you dont want to compile, then you must turn all into flexscript. Hope i understand it right and it helps you a little bit Best regards Tobias |
#3
|
|||
|
|||
The problem is if i turn into flexscript, the run of my model is very very slow, compare with C++ ( very fast).
Moreover, i will run my model several times, so the speed is very important. So, i wonder if there is a way to run model in C++ but we no need to compile first..? |
#4
|
||||
|
||||
He Ankus,
There is a way around it by putting your C++ code in a DLL. Then you don't have to compile but you have your code in C++. Check out the wiki articles Forum about Creating DLL's that attach to Flexsim. Steven |
#5
|
|||
|
|||
If you don't want to go the DLL route you can just automate the compile stage when the model loads - rather than avoid it. To do this you need to keep the OnModelLoad node as Flexscript and locate your C++ code in another node - maybe in a userfunction toggled as C++. Then have the following as the OnModelLoad code text:
Code:
if (getnodenum(node("MAIN:/1/1/13"))){ cmdcompile(); } else{ myOnModelLoadUserfunction(); //containing your C++ code } Jason |
The Following 5 Users Say Thank You to Jason Lightfoot For This Useful Post: | ||
Steven Hamoen (03-04-2009) |
#7
|
|||
|
|||
I tried as Jason said..
when i open model, compiling project is executed automatically, but after that, nothing happen. My function in user command(named "myOnModelLoadUser") to run model did'nt executed. I dont know is it right or not.. Need help... Hope someone can help me.. |
#8
|
|||
|
|||
Ankus, I'm sorry it looks like OnModelOpen only fires once when the model is opened. This is unlike the OnLoad nodes we've used in the past (before this version of model triggers were made available) which also fired when the model had compiled. This is my mistake. If you put the user command call into the OnPost-Compile part of the Model Triggers instead, it will work as you intended.
Sorry for the confusion. Jason Last edited by Jason Lightfoot; 03-05-2009 at 08:39 AM. |
The Following 2 Users Say Thank You to Jason Lightfoot For This Useful Post: | ||
Phil BoBo (03-05-2009) |
Thread | Thread Starter | Forum | Replies | Last Post |
error:Unable to open storage set. make sure the file exists. | qin tian | Q&A | 3 | 11-17-2008 01:05 PM |
Working model not saved when we "Open" model | David Chan | Gripes and Goodies | 0 | 08-21-2008 03:10 AM |
Make sure you stop model with the stop button before collecting state based statistics | Paul Dowling | Tips and Tricks | 2 | 06-10-2008 08:10 AM |
How to get a full path of the current open Flexsim model file. | Regan Blackett | Tips and Tricks | 7 | 04-17-2008 10:39 AM |
Model Startup Code | Lolke Koopmans | Q&A | 4 | 12-14-2007 09:51 AM |