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 :

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

Place in level :

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.

YIMY ALEXANDER AYALA DAZA avatar image YIMY ALEXANDER AYALA DAZA commented ·

Goodnight friend, Could I share your model I tried to set this up and I could not. thanks

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

I found a solution

For Place in Bay :

treenode item = param(1);
treenode current = ownerobject(c);
/**By Global Table Lookup*/
/** \nTable: */
string tablename = /**/"Placement"/**/; 
/** \nRow: */
int row = /**/1/**/; 
for(row; row <= gettablerows(tablename); row++) {
	if(gettablenum(tablename,row,1) == getitemtype(item)) {
		break;
	}
}
/** \nColumn: */
int col = /**/2/**/; // column of the Output port from the globaltable
return gettablenum(tablename,row,col);

For Place in level :

treenode item = param(1);
treenode current = ownerobject(c);
double baynumber = param(2);
/**By Global Table Lookup*/
/** \nTable: */
string tablename = /**/"Placement"/**/; 
/** \nRow: */
int row = /**/1/**/; 
for(row; row <= gettablerows(tablename); row++) {
	if(gettablenum(tablename,row,1) == getitemtype(item)) {
		break;
	}
}
/** \nColumn: */
int col = /**/3/**/; // column of the Output port from the globaltable
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 Marco Baccalaro commented ·

Ah ok, that's why you had cols 1 and 2, itemtype was on the header. That's a good solution using the picklist "by global table lookup".


0 Likes 0 ·
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.

benjamin.h avatar image benjamin.h commented ·

Thanks for your help

0 Likes 0 ·