Convert rack bays treenode to tables

joerg_vogel_HsH
Mentor Mentor
3 Views
4 Replies
Message 1 of 5

Convert rack bays treenode to tables

joerg_vogel_HsH
Mentor
Mentor

[ FlexSim 19.1.0 ]

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.

21074-treenode-bays-rack.jpg

treenode-bays-rack.fsm

0 Likes
Accepted solutions (1)
4 Views
4 Replies
Replies (4)
Message 2 of 5

joerg_vogel_HsH
Mentor
Mentor

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
Message 3 of 5

joerg_vogel_HsH
Mentor
Mentor
Accepted solution

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"));  
Message 4 of 5

joerg_vogel_HsH
Mentor
Mentor

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
Message 5 of 5

joerg_vogel_HsH
Mentor
Mentor

an Example for FlexSim 19.0 Warehouse19.fsm

0 Likes