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 02-02-2012
Stephan Seidel's Avatar
Stephan Seidel Stephan Seidel is offline
Flexsim User
 
Join Date: Mar 2009
Location: Dresden, Germany
Posts: 36
Downloads: 20
Uploads: 0
Thanks: 26
Thanked 22 Times in 8 Posts
Rep Power: 150
Stephan Seidel will become famous soon enough
Arrow Transfer User Commands to a DLL

Hi All,

I've transfered some user commands from my model into a .cpp file by using this script:
http://http://code.google.com/p/flex...scriptToDLL.fs
which worked very well. Apparently you'll need to change the usercommands treenode, but that is not the reason for my post.
I then tried to compile the .cpp into a DLL. That didnt work because Visual Studio display multiple errors, e.g. that it doesnt know some User Commands I am using within my User Commands.
So what i'd like to know is if there is a solution to put user commands (which call inturn other user commands) into a dll. Or will the transfer of user commands into a dll only work if there is just plain flexscript within the user commands?
The answer might be simple but because I'm not a C++ pro I've got no idea.
Thanks for any help.

Stephan
__________________
---
You can't have it both ways.
  #2  
Old 02-02-2012
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

I'm not sure if you can call another function using the FLEXSIMINTERFACE declaration. For that reason we always work differently. Every call to a FLEXSIMINTERFACE function call a standard C++ function. That function can then easily call another standard C++ function. So for instance


DLL_FuncA( FLEXSIMINTERFACE) {
treenode current = parnode(1);
return FuncA( current );
}

DLL_FuncB( FLEXSIMINTERFACE) {
double Value = parval(1);
return FuncB( Value );
}


FuncB( double Value ) {
do stuff..
return something;
}


FuncA( treenode current ) {
double X =....;
return Z * FuncB( X );
}

You can put the DLL_ functions as some kind of interface in a seperate interface cpp file and the other functions in a different cpp file. Normally you don't have to look into the interface file anymore.

Also remember if you need B in A you need to define B before A
The Following 2 Users Say Thank You to Steven Hamoen For This Useful Post:
Stephan Seidel (02-03-2012)
  #3  
Old 02-03-2012
Stephan Seidel's Avatar
Stephan Seidel Stephan Seidel is offline
Flexsim User
 
Join Date: Mar 2009
Location: Dresden, Germany
Posts: 36
Downloads: 20
Uploads: 0
Thanks: 26
Thanked 22 Times in 8 Posts
Rep Power: 150
Stephan Seidel will become famous soon enough
Post

Thanks Steven,

your idea is good but I'm afraid it won't solve my problem. I'd like to give you you an idea why I'm trying to convert user commands to DLL calls. Right now my model is using around 50 or so user commands. Some of them are just for writing some information to the output console, others are more complex. All user commands are pure flexscript right now. Because I'm not a huge fan of c++ I'd like to keep it that way.
On the other hand the model contains code which I dont want to give away. Therefore the idea of transfering it into a DLL.
But in order to do that I'd like to have an one-click mechanism which transfers the user commands into a cpp and compiling that into a DLL and thats it. I dont want to work with the cpp files and alter code there.
I also tried developing in visual studio once but wasnt able to get the DLL accepting my breakpoints and step thru the code (in other words attaching visual studio to flexsim). So I went back to flexscript.
Any ideas on how to solve that problem are appreciated...

Cheers,
Stephan
__________________
---
You can't have it both ways.
  #4  
Old 02-03-2012
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

Quote:
Originally Posted by Stephan Seidel View Post
Thanks Steven,
Any ideas on how to solve that problem are appreciated...
"That problem" means your original problem ?

What you could do if you call a usercommand from a different usercommand, don't call it with the usercommand name but call it with nodefunction() and the path to the actual flexscript node. That way it will compile and work.

Debugging works like a charm with us. If you are interested in being guided working with visual studio, we can offer a day support/training into using visual studio c++ with Flexsim.
The Following User Says Thank You to Steven Hamoen For This Useful Post:
Stephan Seidel (02-03-2012)
  #5  
Old 02-03-2012
Stephan Seidel's Avatar
Stephan Seidel Stephan Seidel is offline
Flexsim User
 
Join Date: Mar 2009
Location: Dresden, Germany
Posts: 36
Downloads: 20
Uploads: 0
Thanks: 26
Thanked 22 Times in 8 Posts
Rep Power: 150
Stephan Seidel will become famous soon enough
Default

Hi Steven,

Yes, I meant the original problem of porting user commands to a DLL.
Thanks for your offer. I keep that in mind in case the current project (which ends in a few weeks) will be extended. For the time being I'll play around with your suggestions and see whats working best.

Cheers,
Stephan
__________________
---
You can't have it both ways.
The Following User Says Thank You to Stephan Seidel For This Useful Post:
Steven Hamoen (02-03-2012)

Tags
.cpp, dll, user commands


Thread Thread Starter Forum Replies Last Post
groups in user commands Carsten Seehafer Q&A 2 07-08-2011 01:34 AM
Transfer Area John Kim Container Terminal (CT) Library 2 09-15-2009 10:20 AM
Table Commands Library Brandon Peterson User Development 5 09-25-2008 09:25 AM
What about the file read commands? AlanZhang Gripes and Goodies 0 02-08-2008 05:17 PM
New custom commands in Downloads link Cliff King Q&A 0 09-24-2007 05:46 PM


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.