AGV Max Allocations through code

AGV Max Allocations through code

sudheer_r
Not applicable
34 Views
10 Replies
Message 1 of 11

AGV Max Allocations through code

sudheer_r
Not applicable

[ FlexSim 20.1.2 ]

In global table I have control points, Max allocations and Deallocation type, I am trying using this global table how to update this in the model through code.

AGVCP.fsm

29437-controlpoint.png

0 Likes
Accepted solutions (1)
35 Views
10 Replies
Replies (10)
Message 2 of 11

bo_wang
Not applicable
Accepted solution
Message 3 of 11

sudheer_r
Not applicable


@Bob.Wang

Thanks for your code. Could you please give feedback on understanding the code of yours for following questions

I'm trying to understand In Table.query command what is Gt1.ROW_Number. What this does actually.

And if(res.numRows<=0) continue; What is this code for ?

res.cloneTo(Table("GlobalTable2")); why are you cloning to Global Table2?

Object agvnetwork = Model.find("AGVNetwork");
treenode an_cPs= agvnetwork.find(">?controlPoints");
treenode an_daT= agvnetwork.find(">?deallocationTypes");
Table gt1 = Table("GlobalTable1");
for(int i = 1; i <= an_cPs.subnodes.length; i++)
{
    Object cpi_obj = ownerobject(tonode(an_cPs.subnodes.value));
    Table res = Table.query("select *,Gt1.ROW_NUMBER as RN from $1 as Gt1 WHERE [Col 1] = $2 ", gt1, cpi_obj.name);
    if(res.numRows <= 0)
        continue;
    res.cloneTo(Table("GlobalTable2"));
    treenode maxAllocations = cpi_obj.find(">?maxAllocations");
    treenode deallocationTypeRank = cpi_obj.find(">?deallocationTypeRank");
    int gt1Row = res[1]["RN"];
    cpi_obj.find(">?maxAllocations").value = gt1[gt1Row][2].as(string).toNum();
    cpi_obj.find(">?deallocationTypeRank").value = an_daT.subnodes[gt1[gt1Row][3]].rank;
}
0 Likes
Message 4 of 11

bo_wang
Not applicable

I'm trying to understand In Table.query command what is Gt1.ROW_Number. What this does actually.

Q1:Get the original row of global table 1

And if(res.numRows<=0) continue; What is this code for ?

Q2:Prevent you from filling in an incorrect CP name

res.cloneTo(Table("GlobalTable2")); why are you cloning to Global Table2?

Q3:It‘s for test,You can comment on the code

Message 5 of 11

sudheer_r
Not applicable

@Bob.Wang

You defined gt1 as variable but in Table Query you are using it as Gt1 so got confused. Is both are different or same

Table gt1 = Table("GlobalTable1");
 Table res = Table.query("select *,Gt1.ROW_NUMBER as RN from $1 as Gt1 WHERE [Col 1] = $2 ", gt1, cpi_obj.name);
0 Likes
Message 6 of 11

bo_wang
Not applicable

gt1-defined for FlexScript and Gt1 for SQL,you can also use $1,like $1.ROW_NUMBER.

They both quote GlobalTable1.

Message 7 of 11

sudheer_r
Not applicable

@Bob.Wang thanks I understood.

In below code why are we using these symbols >? in agvnetwork.find(">?controlPoints);

can't we directly write the code as agvnetwork.find("controlPoints");

does it makes any difference or adding these >? will add any advantage

treenode an_cPs= agvnetwork.find(">?controlPoints");


0 Likes
Message 8 of 11

bo_wang
Not applicable
agvnetwork.find("controlPoints) 

is find agvnetwork's child-node that named controlPoints

agvnetwork.find(">?controlPoints")

is find agvnetwork's attribute-node that named controlPoints;

"?" means not limited to the first level.

Message 9 of 11

sudheer_r
Not applicable

@Bob.Wang

In AGVNetwork tree I am looking attribute node controlPoints. But it is not available in AGVNetwork.

29458-agpic.png

0 Likes
Message 10 of 11

joerg_vogel_HsH
Mentor
Mentor

Please open the variables branch as stated in comment

"?" means not limited to the first level.

and please expand the attribute tree of AGVNetwork and not of object Path1.

Message 11 of 11

sudheer_r
Not applicable

@Bob.Wang Thanks it helped me. Please convert this into answer

@Jörg Vogel thanks for your feedback. I found

0 Likes