question

Joerg Vogel avatar image
0 Likes"
Joerg Vogel asked Joerg Vogel commented

Convert rack bays treenode to tables

The dimensions were for the rack object in previous versions of FlexSim 19 built as tables. In FlexSim 19 the structure has been integrated into the node "bays". I would like to extract by table queries the old tables for content, size and location from this new structure.

treenode-bays-rack.fsm

FlexSim 19.1.0
rackattributesconvert tree to tablequery rack
· 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.

Joerg Vogel avatar image Joerg Vogel commented ·

I can rebuild the tables with the command forobjecttreeunder like:

treenode bays = Model.find("Rack1>variables/bays");
Table result = Table("dump1").setSize(1,1,DATATYPE_OBJECT,0);
int row = 1;
treenode rackCell;
forobjecttreeunder(bays)
{
if (a.find("/loc")){
rackCell = a.find("/loc").up;
if( rackCell.up.name == "bays") continue; // erase next bay node
result.cell(row,1).value = a.find("/loc").up); // collect only cells
result.addRow();
row++;
}
}
result.deleteRow(row);

The table "dump1" contains all cell nodes. From here I can build the content table, size table, and location table.

0 Likes 0 ·

1 Answer

Joerg Vogel avatar image
1 Like"
Joerg Vogel answered Joerg Vogel commented

I can get the cell reference by flattening the structure

treenode Bays = getvarnode(Model.find("Rack1"), "bays");
Table newt = Table.query("SELECT $3 AS Cell FROM $1x$2 ORDER BY Cell ASC",
       /*$1*/ Bays,
       /*$2*/ $iter(1).find("cells"),
       /*$3*/ $iter(2).subnodes["loc"].up 
       );
newt.cloneTo(Table("dump"));

IMPORTANT: I must set a ORDER BY clause after the flattening otherwise the query returns as result <No Data> for all cells.

Flexsim 19.2:

treenode Bays = getvarnode(Model.find("Rack1"), "bays");
Table newt = Table.query("SELECT $4 AS Slot FROM $1x$2x$3 ORDER BY Slot ASC",
	/*$1*/ Bays,  
	/*$2*/ $iter(1).find("levels"),
	/*$3*/ $iter(2).find("slots"),
	/*$4*/ $iter(3).subnodes["loc"].up );
newt.cloneTo(Table("dump"));

The global table "dump" contains references of every slot in a rack. You can get access by evaluating the Variant of a table cell of "dump" for deeper nodes by the method find(string path) and with the property up for higher nodes.

Storage System all racks since 19.2:

treenode qnode = Model.find("Tools/StorageSystem>variables/storageObjects");
Table t1 = Table.query("SELECT $5 AS Node, $6 AS Slot, $7 AS Level, $8 AS Bay, $9 AS Rack FROM $1x$2x$3x$4"
                 ,qnode                      
                 ,getvarnode(ownerobject(Model.find($iter(1).value.getPath(model()))),"bays") 
                 ,$iter(2).find("levels")
                 ,$iter(3).find("slots") 
/*$5 slot node*/ ,$iter(4).subnodes["loc"].up 
/*$6 slot  num*/ ,$iter(4).subnodes["loc"].up.rank 
/*$7 level num*/ ,$iter(3).rank 
/*$8 bay   num*/ ,$iter(2).rank 
/*$9 rack node*/ ,ownerobject($iter(2))                    
                 ); 
t1.cloneTo(Table("dump"));  
· 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.

Joerg Vogel avatar image Joerg Vogel commented ·

If someone knows how to evaluate a coupling node in a query better than over a string path, you are welcome to share

getvarnode(ownerobject .. "bays") // here a shorter code line
0 Likes 0 ·
Joerg Vogel avatar image Joerg Vogel commented ·

an Example for FlexSim 19.0 Warehouse19.fsm

0 Likes 0 ·
warehouse19.fsm (24.4 KiB)