question

benjamin.h avatar image
0 Likes"
benjamin.h asked Brandon Peterson commented

Define a specific location in a rack according to the item type

Hi,

I have about 38 references, each having a specific item type. I would like to define the location of the cell (of the rack) for each of my items.

So far I created a global table named 'location" with 3 columns (itemtype, bay, level)

In the rack option, i have put code in :

Place in Bay :

  1. gettablecell("location",getitemtype(item),1)

Place in level :

  1. gettablecell("location",getitemtype(item),2)

Nonetheless, FlexSim tells me that I have an error somewhere with this syntax. However, I don't know another way to do it.

Any help would be welcome :D

FlexSim 16.0.1
global tablerackcodeflowitem
· 1
5 |100000

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

benjamin.h avatar image
2 Likes"
benjamin.h answered Ben Wilson edited

I found a solution

For Place in Bay :

  1. treenode item = param(1);
  2. treenode current = ownerobject(c);
  3. /**By Global Table Lookup*/
  4. /** \nTable: */
  5. string tablename = /**/"Placement"/**/;
  6. /** \nRow: */
  7. int row = /**/1/**/;
  8. for(row; row <= gettablerows(tablename); row++) {
  9. if(gettablenum(tablename,row,1) == getitemtype(item)) {
  10. break;
  11. }
  12. }
  13. /** \nColumn: */
  14. int col = /**/2/**/; // column of the Output port from the globaltable
  15. return gettablenum(tablename,row,col);

For Place in level :

  1. treenode item = param(1);
  2. treenode current = ownerobject(c);
  3. double baynumber = param(2);
  4. /**By Global Table Lookup*/
  5. /** \nTable: */
  6. string tablename = /**/"Placement"/**/;
  7. /** \nRow: */
  8. int row = /**/1/**/;
  9. for(row; row <= gettablerows(tablename); row++) {
  10. if(gettablenum(tablename,row,1) == getitemtype(item)) {
  11. break;
  12. }
  13. }
  14. /** \nColumn: */
  15. int col = /**/3/**/; // column of the Output port from the globaltable
  16. return gettablenum(tablename,row,col);

The problem was that my itemtypes weren't part of the global table, but of the legend of it.

· 1
5 |100000

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

Marco Baccalaro avatar image
1 Like"
Marco Baccalaro answered benjamin.h commented

Hello, You have these problems:

  • you have to use gettablenum instead of gettablecell (otherwise you have a reference to the cell of the table instead of the number contained in it)
  • you have to search the bay and level in columns 2 and 3
  • finally you have to use an ordered table into the rows from 1 to n: the itemtype must correspond to the row number (otherwise you have to search the right row using an SQL query)
· 1
5 |100000

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