question

Aleksey S avatar image
1 Like"
Aleksey S asked Jason Lightfoot edited

How to change rack slot size according to global table

Hello.

I want to update rack dimensions from the table. I do not want to change the size of each slot manually, because data about the slot size are updateable, and from simulation to simulation can be changed (its main parameter of research). So I created a rack with a maximal quantity of slot and slots size. And after the simulation start, I want to change the sizes of each slot according to table data. Please see a model by the link below.

Test.fsm

FlexSim 20.2.3
flexsim 20.2.3rack storageslotdimensionsset rack sizetable by code
test.fsm (76.6 KiB)
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
1 Like"
Jason Lightfoot answered anthony.johnson commented

Here's a user command where you can pass in the rack and the reference of the table like this:

configureRackFromTable(Model.find("DK_1"),reftable("WH_MAP"));

The code for it is:

/**Custom Code*/
Object rack=param(1);
Table table =param(2);
Array loc=[1,1,1];
Array selection = [loc];
function_s(rack, "setNumBays", 1);
function_s(rack, "setNumSlots", 1); //, selection);
function_s(rack, "setNumLevels", 1); //, selection);

int numrows=table.numRows;
//SET COLUMN IDX FOR SPEED
#define BAY 2
#define BAY_WIDTH 3
#define LEVEL 4
#define LEVEL_HEIGHT 5
#define NUMSLOTS 6
function_s(rack, "setNumBays", (table[numrows][BAY]+1)/2);


for (int n=1;n<=numrows;n++) {
    double  baywidth=table[n][BAY_WIDTH];
    int bay=(table[n][BAY]+1)/2;
    selection=[[bay,1,1]];
    function_s(rack, "setBaySize", baywidth,selection);
    int level=table[n][LEVEL];
    selection=[[bay,level,1]];
    function_s(rack, "setNumLevels", level,selection);
    function_s(rack, "setLevelSize",table[n][LEVEL_HEIGHT], selection);
    int numslots=table[n][NUMSLOTS];
    if (numslots==0)
            function_s(rack, "setSlotStorable",0, selection);
    else{
        function_s(rack, "setSlotStorable",1, selection);
        function_s(rack, "setNumSlots",numslots, selection);
        function_s(rack, "setSlotSize",baywidth/numslots, selection);
    }
    
}

Model attached.test_setRackSizeFromTable_jl.fsm


· 2
5 |100000

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

Aleksey S avatar image Aleksey S commented ·

jason.lightfoot, you made magic. It was what I do not know and could not find here. I hope your answer and my question will be useful for other peoples.

0 Likes 0 ·
anthony.johnson avatar image anthony.johnson ♦♦ commented ·

Jason's answer is correct and the best answer, for now. I'd like to add something to property tables that allows you to do this essentially through property tables or the Object.setProperty() API, deprecating this solution. I am just not so excited about users calling function_s() directly, because these are not technically forward-compatible solutions. If at some point in the future we change the way things work under the hood, these functions may not work going forward.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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