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 05-16-2012
Vadim Fooks's Avatar
Vadim Fooks Vadim Fooks is offline
Flexsim User
 
Join Date: Feb 2012
Posts: 67
Downloads: 26
Uploads: 0
Thanks: 50
Thanked 24 Times in 13 Posts
Rep Power: 118
Vadim Fooks will become famous soon enough
Default Best way to transfer a large volume of data from the dll to flexsim?

Ladies and Gentlemen,

I am trying to move a large volume of data (about 4kb worth) from the function in C++ that generates this data in the dll to the flexsim object that calls this function. The function is called quite frequently and it always produces a new set of data, so prepocessing it and loading it out of the database/excel is impossible.

I got it working using sendmessage in a loop, but I would like to know if there is a better way of doing it because sendmessage'ing so much data in one call seems to put a lot of strain on the simulation.

Is it possible to create some kind of container data structure in memory and pass the pointer to it from the dll to flexsim or something along those lines?


Also, I noticed that in C++ I can pass a lot more parameters to sendmessage than in FlexScript. Is there any way to work around the restriction of at most 3 arguments?


Thank you!
Vadim
  #2  
Old 05-17-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

Have you thought about using a global table to pass the table? Or any treestructure? You can simply pass in the main node and from there fill it in the DLL.

Passing a pointer might also be possible. Look at this post "/threads/thread1302&highlight=pointer

If you would use a nodefunction instead of sendmessage you can use up to 10 parameters. And if you would pass a pointer to treenode structure you can have an unlimited amount of parameters
  #3  
Old 05-17-2012
Vadim Fooks's Avatar
Vadim Fooks Vadim Fooks is offline
Flexsim User
 
Join Date: Feb 2012
Posts: 67
Downloads: 26
Uploads: 0
Thanks: 50
Thanked 24 Times in 13 Posts
Rep Power: 118
Vadim Fooks will become famous soon enough
Default

Steven, thank you for the suggestion for using an array. Do you by any chance know what happens under the hood when I do that? I would like to know what kind of overhead is involved in allocation and deallocation of the array. My big concern is that the bandwidth of the connection between flexsim and the dll may become an issue at higher rates of simulation.
If I speed up the simulation to the desired rate, the aforementioned function will be called about 10000 times per second, which will be ok if communication involves just dereferencing a pointer, but won't work if it will involve any file i/o operations.

Thank you!
Vadim
  #4  
Old 05-18-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

What do you mean with array? Do you mean a C++ array or do you mean a node structure? Anyway neither one involves i/o operations.

Have you also thought about putting your c++ code in Flexsim itself? You can put c++ in flexsim and the compile flexsim. Although it is a bit of a hassle to compile everytime you start up Flexsim you don't have to throw data over a border.
  #5  
Old 05-19-2012
Jason Lightfoot Jason Lightfoot is offline
Flexsim Consultant
 
Join Date: Aug 2007
Location: Somerset, UK
Posts: 719
Downloads: 20
Uploads: 0
Thanks: 123
Thanked 953 Times in 446 Posts
Rep Power: 773
Jason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond repute
Default

Bundle datatypes might be a better option for speed than tables of nodes. Look at the bundle commands.
The Following User Says Thank You to Jason Lightfoot For This Useful Post:
Steven Hamoen (05-20-2012)
  #6  
Old 05-24-2012
LINWEIXU
Guest
 
Posts: n/a
Downloads:
Uploads:
Default

Jason ,can you give us a example how to use Bundle datatype ?
  #7  
Old 05-24-2012
Jason Lightfoot Jason Lightfoot is offline
Flexsim Consultant
 
Join Date: Aug 2007
Location: Somerset, UK
Posts: 719
Downloads: 20
Uploads: 0
Thanks: 123
Thanked 953 Times in 446 Posts
Rep Power: 773
Jason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond repute
Default

It's like a table in a database. Once you've added the bundle datatype to a node you need to setup the field names and types, and then you can start adding records. Search for bundle in the command help for now. I'll see if I can dig out an example at some point. You can see it in action in the tracked variables and statistics data nodes.
  #8  
Old 08-06-2012
Esther Bennett Esther Bennett is offline
Flexsim User
 
Join Date: Mar 2008
Posts: 115
Downloads: 27
Uploads: 0
Thanks: 103
Thanked 116 Times in 50 Posts
Rep Power: 271
Esther Bennett is a name known to allEsther Bennett is a name known to allEsther Bennett is a name known to allEsther Bennett is a name known to allEsther Bennett is a name known to allEsther Bennett is a name known to all
Default

I would like to try the bundle data as an alternative for large tables, but is there a way to add a field entry at a certain location (not at the end), change a field name and delete a field or entry at a certain location?

Esther
  #9  
Old 08-06-2012
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

Unfortunately, with bundles you have to add all of the fields (columns) BEFORE you add any entries (rows). This is for optimal memory usage and speed because it then can calculate the exact memory size needed for an entry and allocate pages/blocks of entries all at once instead of making new memory allocations for each new entry.

This is specifically for module development, but in the next feature release we've added a new data type called "SimpleDataType" (and by "simple" I really mean so simple it's complicated :-)), which is essentially a very lightweight class on a flexsim node's data that can be sub-classed by module developers, allowing for user-definable data types that are properly stored in the tree. That might be another option for passing around lots of data, where you can essentially define your own SimpleDataType wrapper around the data, and then just pass the node holding that wrapper around when needed.
The Following 3 Users Say Thank You to Anthony Johnson For This Useful Post:
Vadim Fooks (08-22-2012)
  #10  
Old 08-06-2012
Esther Bennett Esther Bennett is offline
Flexsim User
 
Join Date: Mar 2008
Posts: 115
Downloads: 27
Uploads: 0
Thanks: 103
Thanked 116 Times in 50 Posts
Rep Power: 271
Esther Bennett is a name known to allEsther Bennett is a name known to allEsther Bennett is a name known to allEsther Bennett is a name known to allEsther Bennett is a name known to allEsther Bennett is a name known to all
Default

Hello Anthony,

I don't mind adding the fields before adding the entries, or removing all entries to be able to change the field entries, but now the only way I seem to be able to change fields is to remove all node data and start all over again.

I am currently developing a model for a client and change my mind about columns I use in a table. With tables I can just change a header or add a column in a location I want, so for me switching to bundle data will in this stage only be worthwhile if I could modify bundle fields in a same way.

Maybe I have to wait for the SimpleDataType and play around with that.

Esther
  #11  
Old 08-06-2012
RalfGruber's Avatar
RalfGruber RalfGruber is offline
FlexSim Software Products
 
Join Date: Jul 2007
Location: Orem, UT, USA
Posts: 195
Downloads: 37
Uploads: 0
Thanks: 518
Thanked 294 Times in 124 Posts
Rep Power: 345
RalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to behold
Default

Hi Esther,

the way I use bundles is to create them OnReset from a global table with one row containing all information for a bundle field. That makes it pretty flexible to rearrange columns.
You just have to make the change in the global table.
And beside that since the fields are called by name, not by number, it doesn't really matter, where the field is located within the record. I guess you won't present a bundle as a result to a customer without any manipulation

Best wishes

Ralf
FlexSim Germany
The Following 2 Users Say Thank You to RalfGruber For This Useful Post:
mgiubilato (08-10-2012)


Thread Thread Starter Forum Replies Last Post
Area/Volume Mapping Naresh Yamani Q&A 2 09-26-2012 05:37 AM
Large aerospace company is looking for a outside contractor Bill Nordgren Job Opportunities 0 02-06-2012 02:10 PM
how can i draw 3d data chart in flexsim? LINWEIXU Q&A 1 09-11-2009 08:21 AM
Loading a large map as a background Kenny Macleod Q&A 6 02-09-2009 03:46 PM
Output high volume data Liu Bin Q&A 8 06-16-2008 09:18 AM


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.