question

tr-simulation avatar image
0 Likes"
tr-simulation asked tr-simulation commented

Limiting the data exported in the experimenter?

In my attached model, I go to the experimenter > view results > statistics table > select from drop down "duration of procedure phases". How do I export ONLY this table to excel? When I export, there is do much data with so many tabs...how do I limit what is exported to only this table?V4_20230207.fsm

FlexSim 22.2.2
flexsim healthcare
v4-20230207.fsm (14.9 MiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered tr-simulation commented

You can read the table into a global table and export from there:

treenode experimenter = Model.find("Tools/Experimenter");
Database.Connection db = function_s(experimenter, "getDBConnection");
int disconnect = 0;
if (!db.isConnected) {
    if (!db.connect()) {
        return 0;
    }
    disconnect = 1;
}
Database.ResultSet results = db.query("SELECT * FROM [/Duration of Procedure Phases]");
results.cloneTo("DurationOfProcedurePhases");
if (disconnect) {
    db.disconnect();
}

Note that the use of function_s means it may not be supported in the future and you would have to change any code that relied on that function should it cease to function correctly.

· 9
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

tr-simulation avatar image tr-simulation commented ·
Where do I enter this code?
0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ tr-simulation commented ·
Wherever you like but it makes sense in a script window, in a GUI button, a dashboard button, or in the end of experiment trigger.
0 Likes 0 ·
tr-simulation avatar image tr-simulation Jason Lightfoot ♦♦ commented ·

Ok, I went to the "advanced tab" on the experimenter, selected "at end of job" and added a "code snippet" and put the code in there. But the results did not appear in a global table. I get the error, "exception: FlexScript exception: Invalid row number: 1 in <no path> at MODEL:/Tools/Experimenter>variables/onEndOfJob"

0 Likes 0 ·
Show more comments
tr-simulation avatar image tr-simulation commented ·

In addition to my comment below, how is it exported from a global table?

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ tr-simulation commented ·
Felix describes a method of exporting an experimenter table in this post.


You can probably also use a local result table and export that using an exporttable command rather than having loops to fetch each record and write individual cells.


0 Likes 0 ·