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 |
|
Downloads |
Q&A Using Flexsim and building models |
#1
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
|||
|
|||
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) |
#7
|
|||
|
|||
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
|
|||
|
|||
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
|
||||
|
||||
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
|
|||
|
|||
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
|
||||
|
||||
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 |