Pull data from a table during an experiment

Pull data from a table during an experiment

jason_botha
Not applicable
12 Views
3 Replies
Message 1 of 4

Pull data from a table during an experiment

jason_botha
Not applicable

[ FlexSim 16.2.0 ]

Hi there,

I want add a row and then write data to a global table when an item leaves a processor (just Name and time as an example) but access this during an experimenter run.

I want to some how get all the data entries in the table and write them to a different table after an experiment replication has finished. So my plan was to put the data in to a table called "Processor Data" as items leave the processor. Then at the end of the experiment replication i want to move that data to a "Master" table that will be available at the end of the experiment but will contain columns for ScenarionNum, ReplicationNum, ProcessorName and Time so i have a reference to the experiment.

I have attached a small model but i am struggling to alter the End Replication to achieve this.

Could you guys maybe give me a hand. I know @phil.bobo and i talk briefly about this during the conference.

Thanksextract-data-from-a-list-using-an-experiment.fsm

0 Likes
Accepted solutions (1)
13 Views
3 Replies
Replies (3)
Message 2 of 4

Ben_WilsonADSK
Community Manager
Community Manager

@Jason Botha, have you checked out this answer? It seems to be pretty close to what you're trying to do.

0 Likes
Message 3 of 4

philboboADSK
Autodesk
Autodesk
Accepted solution

Attached is your model with custom code in the End of Replication trigger that will copy the data from each child replication's "Processor Data" table into the "Master" table on the main process:

/**Copy Processor Data to Master*/
double replication = param(1);
double scenario = param(2);
treenode childexpfolder = param(3);

treenode table = reftable("Processor Data");
string tablename = concat(getname(ownerobject(table)),"S",numtostring(scenario),"R",numtostring(replication));

if (objectexists(childexpfolder)) {  // End of Replication on the main process
	treenode savedtables = node("/savedtables",childexpfolder);
	treenode tablecopy = node(concat("/",tablename),savedtables);
	for (int r = 1; r <= gettablerows(tablecopy); r++) {
		addtablerow("Master");
		settablenum("Master", gettablerows("Master"), 1, scenario);
		settablenum("Master", gettablerows("Master"), 2, replication);
		settablestr("Master", gettablerows("Master"), 3, gettablestr(tablecopy, r, 1));
		settablenum("Master", gettablerows("Master"), 4, gettablenum(tablecopy, r, 2));
	}
} else {  // End of Replication on the child process
	treenode savedtables = assertsubnode(node("/Tools/Experimenter",model()),"savedtables");
	createcopy(table,savedtables);
	treenode tablecopy = last(savedtables);
	setname(tablecopy,tablename);
}


Phil BoBo
Sr. Manager, Software Development
0 Likes
Message 4 of 4

jason_botha
Not applicable

Phil,

You are a legend. Thank you very much!

Have a good day further!

0 Likes