How to browse through a global table ?

How to browse through a global table ?

leah_r
Not applicable
36 Views
2 Replies
Message 1 of 3

How to browse through a global table ?

leah_r
Not applicable

[ FlexSim 21.1.1 ]

Hi everyone,

I want to import my Arrivals Source from Excel into my Flexsim model.

One constraint is that each patient uses specific staff resources. Thus, I need to transform the string “Surgeon1” from my Excel file to the pointer “/Surgeon1” in my Flexsim source.

I have thus decided to proceed as follow:

  1. Import the Excel file in a Global Table G1
  2. Build a table G2 where the string values related to staff are transformed into pointers thank to Model.find() and the rest is just copied and pasted.

38918-1619701136871.png


For now, my code looks like that :

/**Custom Code*/

Object current = param(1); 
Object patient = current;
treenode activity = param(2);
Token token = param(3);
treenode processFlow = ownerobject(activity);

Table G1 = Table("ImportExcel");
Table G2 = Table("SourceFlexsim");

int nb_rows_max = G1.numRows;         
int nb_columns_max = G1.numCols;    


int index_col_G1 =1;
int index_row_G1 =1;


for (int index_col_G1 =1; index_col_G1 <= nb_columns_max; index_col_G1+=1);
{    
    for (int index_row_G1; index_row_G1 <=nb_rows_max; index_row_G1+=1);
    {
        G2[index_row_G1][index_col_G1] = G1[index_row_G1][index_col_G1];
    }
};


However, only the first cell G1[1][1] is being copied in G2. Could you help me find a solution?

Also, will the model.find() method work in your opinion ?


Thanks in advance,

Leah

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

clair_augsburgerZGWRZ
Collaborator
Collaborator
Accepted solution

Hi Leah,

One easier way would be to get rid of surgeon names, and just use a number to identify which surgeon you want to pick.

In the attached example 2020-04-29 SurgeonID.fsm, there is a group of 2 surgeons:

38900-1619702604933.png

In the schedule, I have added a numeric label named SurgeonID.

Here the first patient will meet with surgeon #2 and the second patient with surgeon #1:

38932-1619702635792.png

To acquire the correct staff I use this statement:

38933-1619702790904.png

This means I look in the group of surgeons at the rank of the surgeon ID. Note that SurgeonID #1 will match Surgeon1 if surgeons in the group are in the correct order.

With this method, the arrival schedule don't use pointer labels and I think that it will be easier to import the same table from Excel.

0 Likes
Message 3 of 3

leah_r
Not applicable

Thank you, that's amazing ! I'm going to try that asap !

0 Likes