FlexSim Community Forum

FlexSim Community Forum (https://archive.flexsim.com/index.php)
-   Q&A (https://archive.flexsim.com/forumdisplay.php?f=66)
-   -   On Model Open after set make all code C++ ?? (https://archive.flexsim.com/showthread.php?t=887)

ankus d 03-04-2009 03:08 AM

On Model Open after set make all code C++ ??
 
1 Attachment(s)
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

tobias.biemueller 03-04-2009 04:06 AM

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

ankus d 03-04-2009 04:33 AM

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

Steven Hamoen 03-04-2009 04:45 AM

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

Jason Lightfoot 03-04-2009 06:56 AM

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
}

If you change the C++ code in you model you will of course still need to recompile. Don't forget you can also have a mixture of C++ and Flexscript toggled nodes in a model, so only the time critical ones might have to be toggled C++ or indeed DLL.

Jason

ankus d 03-05-2009 05:22 AM

Jason..

Could you mind, give me a simple example model ?
Thanks..

ankus d 03-05-2009 06:55 AM

1 Attachment(s)
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...:confused: Hope someone can help me..

Jason Lightfoot 03-05-2009 08:07 AM

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

ankus d 03-05-2009 10:06 PM

Thanks Jason...:)


All times are GMT -6. The time now is 03:59 PM.

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