question

SudheerReddy avatar image
0 Likes"
SudheerReddy asked Bob.Wang answered

AGV Max Allocations through code

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

FlexSim 20.1.2
flexsim 20.1.2controlpoints
controlpoint.png (35.3 KiB)
agvcp.fsm (27.2 KiB)
5 |100000

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

1 Answer

·
Bob.Wang avatar image
2 Likes"
Bob.Wang answered

· 9
5 |100000

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

SudheerReddy avatar image SudheerReddy commented ·


@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[i].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 0 ·
Bob.Wang avatar image Bob.Wang SudheerReddy commented ·

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

1 Like 1 ·
SudheerReddy avatar image SudheerReddy Bob.Wang commented ·

@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 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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