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 03-23-2010
juan alberto juan alberto is offline
Flexsim User
 
Join Date: May 2009
Location: Valencia, Spain
Posts: 74
Downloads: 14
Uploads: 0
Thanks: 19
Thanked 3 Times in 2 Posts
Rep Power: 138
juan alberto is on a distinguished road
Default using a dll

Hi all,

How Can I load a external dll ( the dll is in c++ ) in flexsim ?

Thanks !!
  #2  
Old 03-23-2010
Steven Hamoen's Avatar
Steven Hamoen Steven Hamoen is offline
Talumis, Flexsim Distributor, The Netherlands
 
Join Date: Aug 2007
Location: Soest, NL
Posts: 854
Downloads: 43
Uploads: 0
Thanks: 391
Thanked 661 Times in 379 Posts
Rep Power: 684
Steven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond repute
Default

Juan,

Check out the article in the Wiki section of this forum about attaching a DLL to Flexsim

http://www.flexsim.com/community/for...read.php?t=382

Steven

PS I removed your other post. No double posting please!

Last edited by Steven Hamoen; 03-23-2010 at 07:12 AM.
The Following 2 Users Say Thank You to Steven Hamoen For This Useful Post:
RalfGruber (03-23-2010)
  #3  
Old 03-24-2010
juan alberto juan alberto is offline
Flexsim User
 
Join Date: May 2009
Location: Valencia, Spain
Posts: 74
Downloads: 14
Uploads: 0
Thanks: 19
Thanked 3 Times in 2 Posts
Rep Power: 138
juan alberto is on a distinguished road
Default

Hello,
I have read the post and I know how to create the dll.

However, I don't know how to load the dll in flexsim. I mean, How can I open/load the dll in flexsim? And How I can use the functions of the dll when I'm programming in flexsim?

Thanks.



Quote:
Originally Posted by Steven Hamoen View Post
Juan,

Check out the article in the Wiki section of this forum about attaching a DLL to Flexsim

http://www.flexsim.com/community/for...read.php?t=382

Steven

PS I removed your other post. No double posting please!
  #4  
Old 03-24-2010
Steven Hamoen's Avatar
Steven Hamoen Steven Hamoen is offline
Talumis, Flexsim Distributor, The Netherlands
 
Join Date: Aug 2007
Location: Soest, NL
Posts: 854
Downloads: 43
Uploads: 0
Thanks: 391
Thanked 661 Times in 379 Posts
Rep Power: 684
Steven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond repute
Default

Are you sure you read throught the article?

Quote:
Once you've defined the function on the dll side, you need to go into Flexsim and define how the node connects to the dll. If you, for example, want to have a message trigger call a dll function, go to the code field of that trigger and press the "DLL" radio button at the bottom of the code field. You should get a message saying something like "Would you like to format the code for dll linking." Click OK. This will toggle the trigger for dll connection and change the code to be the a default format. When Flexsim executes a dll toggled node, it looks for two quote-enclosed texts, and ignores the rest of the field. This lets you define template code with the /** and /**/ syntax, so that the template window will give useful information, while still letting you define the dll-linking information properly.

The first quote-enclosed text should be the path to the dll. This can be an absolute path, such as "C:\Documents and Settings\Anthony Johnson\My Documents\dllname.dll", or it can be a relative path. If it is a relative path, then there are two options. Either you can have the relative path be relative to the Flexsim4\program directory, such as, if you put your dll in the Flexsim4\libraries directory, the path could be "..\libraries\dllname.dll". Also, if the dll is specifically used for a model (instead of for a user library), you can have the dll path be relative to the model path. For example, if the dll is in the same directory as the model, the path can simply be "dllname.dll".

The second quote-enclosed text should be the name of the function that the trigger calls. In the example provided in DLL Maker, the name should be "mydllfunction1".

Once you have built the dll and have toggled the right triggers as "DLL" and specified the proper information in Flexsim's triggers, you should be able to run the model, and whenever one of your DLL toggled triggers is fired, Flexsim will call the appropriate function from the dll.
So to put it very simple:
Change your node to DLL (either in the code editor or via the tree )
Change the code to let it point to the right DLL and the right function in your DLL

If you want to use a function from the DLL in Flexscript the easiest way is to create a usercommand that is toggled as DLL and call's the DLL function or you could use the nodefunction command to call the node directly
The Following 2 Users Say Thank You to Steven Hamoen For This Useful Post:
Tom David (03-24-2010)
  #5  
Old 03-24-2010
juan alberto juan alberto is offline
Flexsim User
 
Join Date: May 2009
Location: Valencia, Spain
Posts: 74
Downloads: 14
Uploads: 0
Thanks: 19
Thanked 3 Times in 2 Posts
Rep Power: 138
juan alberto is on a distinguished road
Default

Hello again,
I have more problems with this topic. How can I get a value that my dll function returns? For example:

int NumeroAleatorio()

This functions returns a random number, and I want to get it when I use it in flexsim. I'm sorry for my questions, but I'm new in this topic.

Thank you!

Quote:
Originally Posted by Steven Hamoen View Post
Are you sure you read throught the article?

So to put it very simple:
Change your node to DLL (either in the code editor or via the tree )
Change the code to let it point to the right DLL and the right function in your DLL

If you want to use a function from the DLL in Flexscript the easiest way is to create a usercommand that is toggled as DLL and call's the DLL function or you could use the nodefunction command to call the node directly
  #6  
Old 03-24-2010
Lars-Olof Leven Lars-Olof Leven is offline
Flexsim Distributor
 
Join Date: Aug 2007
Location: Sweden, Borlnge
Posts: 312
Downloads: 278
Uploads: 2
Thanks: 300
Thanked 256 Times in 139 Posts
Rep Power: 330
Lars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to behold
Default

Hi,

Create a User Command that wraps your dll call, switch the user command as dll.
Then call the user command as normally you do.

Example:
Create a use command called Test: dll:"../libraries/thedll.dll" name:"NumeroAleatorio"
Call user command like: int number=Test();

Do not forget to add return in your int NumeroAleatorio() code.

Lars-Olof
The Following 4 Users Say Thank You to Lars-Olof Leven For This Useful Post:
Tom David (03-24-2010)
  #7  
Old 10-22-2014
Paulo Lopes
Guest
 
Posts: n/a
Downloads: 9
Uploads: 0
Default

Hello there, I have been trying to attach the dll of the wiki example to any of a simple model in flexsim but I keep getting an error throwing Windows Error Code: 193. I feel it might have to do with compability issues? And the debugging in VS says it cannot start the program because the dll is not in the path defined... Can someone shed a light on this, please?
  #8  
Old 10-23-2014
Anthony Johnson's Avatar
Anthony Johnson Anthony Johnson is offline
Manager of Product Development
 
Join Date: Jul 2007
Posts: 440
Downloads: 86
Uploads: 4
Thanks: 171
Thanked 899 Times in 288 Posts
Rep Power: 735
Anthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond repute
Default

Make sure you're building against the same platform as your FlexSim installer, i.e. if you installed the 64-bit version of FlexSim, you need to build your dll using the x64 Platform, and for 32-bit FlexSim you need to build your dll using the Win32 Platform. You can set the build platform in the toolbar of Visual Studio.
The Following 4 Users Say Thank You to Anthony Johnson For This Useful Post:
Paulo Lopes (10-27-2014)



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.