Create an experiment using flexscript

Create an experiment using flexscript

royjuventus29
Enthusiast Enthusiast
298 Views
3 Replies
Message 1 of 4

Create an experiment using flexscript

royjuventus29
Enthusiast
Enthusiast

Hi, there! I am using flexscript to create an experiment module in flexsim. The function I used is "Object experimenterObj = Object.create("Experimenter");" It works but it is created directly under the "model" treenode. In this case, it cannot be found in the toolbox since it is not under the "tool" folder. Is it possible to make it under the "tool" folder by flexscript?

question.png

 

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

hbg4857MXY4
Enthusiast
Enthusiast

It is possible to create various tools using this function, but it seems that the "Experimenter" does not support it.

 

 

TEST.PNG

 

0 Likes
Message 3 of 4

FelixMoehlmann
Mentor
Mentor
Accepted solution

When the Experimenter is opened from the menu the respective GUI is created with the Experimenter as the focus object. As part of the PreOpen code of the window a check is made whether an experimenter actually exists in the model. If not, it creates one with the following code.

Object experimenter = createinstance(library().find("Experimenter"), node("Tools", model()));
experimenter.name = "Experimenter";

// This makes sure that the db connection is created
treenode dbNode = function_s(experimenter, "getDBNode");
// And that its default path has "Experiment" in it
setsdtvalue(dbNode, "defaultStem", "Experiment");

// And ID any default jobs
var jobList = getvarnode(experimenter, "jobs").subnodes;
for (int i = 1; i <= jobList.length; i++) {
	function_s(experimenter, "getJobID", jobList[i]);
}

The second block (lines 4-7) is supposed to set the default database name to "Experiment". That doesn't actually work though, because the "dbNode" is only initialized properly as part of the ID assignation in line 12.

If you don't intend to keep the default experiment job you only need the first two rows. But then also run the following to initialize the "dbNode".

function_s(experimenter, "getDBConnection");

That's what I could find, digging around in the view and main tree, anyway.

Message 4 of 4

royjuventus29
Enthusiast
Enthusiast

Thank you, the "Experimenter" is created under the Toolbox now. Very good suggestion!

0 Likes