question

Ryosuke S avatar image
0 Likes"
Ryosuke S asked Ryosuke S commented

Is there a way of knowing which control area the agv is in?

As title, is there a way of knowing what TaskExecutor (TE) is on which control area (CA)?

What I would like to do is set multiple control area to act as one. I'm controlling whether the TE can enter the CA with Matrix and status table defined in Globaltable. I've set the 3 control areas to one group and wait for event in group. This way, when TE allocates at either CA in the group, the event is triggered. While TE is on the CA, I'd like to know TE is on which CA to keep the status table updated even though it enters next CA.

Multiple_ControlArea_alt_en.fsm

FlexSim 20.1.3
processflowflexsim 20.1.3control area
5 |100000

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

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Ryosuke S commented

Here's a user command that returns an array of control areas for which the AGV is allocated. You should put it in a user command such as getTEsCAallocations(<agv>) , since the structure of the control area tree may change in the future or have an API added to get this value and then you can just change it in the user command:

/**Custom Code*/
Object te=param(1);  
treenode networkCAlinks=Model.find("AGVNetwork>variables/controlAreas");
Array cas;
forobjectlayerunder(networkCAlinks) {
    Object ca=node("+/~",a);
    treenode allocs=getvarnode(ca,"allocations");
    for (int n=allocs.subnodes.length;n>0;n--) {
        if (te==node("../..+/~",allocs.subnodes[n].value)) {
            cas.push(ca);
            break;
        }
    }
}
return cas;


Here's another user command that returns the array of agvs in a control Area. You should put it in a user command such as getCAallocatedAGVs(<controlArea>) , since the structure of the control area tree may change in the future or have an API added to get this value and then you can just change it in the user command:

//treenode controlArea=param(1);   //for user command
treenode controlArea=Model.find("AGVNetwork/ControlArea1");  //in a script

treenode allocs=getvarnode(controlArea,"allocations");
Array agvs=Array(allocs.subnodes.length);
for (int n=allocs.subnodes.length;n>0;n--)
    agvs[n]=node("../..+/~",allocs.subnodes[n].value);
return agvs;


I've added both as user commands to your model.multiple-controlarea-alt-en_jl.fsm



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

Ryosuke S avatar image Ryosuke S commented ·

@jason.lightfoot Thank you very much for the user command. It was so useful!! I've been able to create what I wanted! Thank you. I'm attaching the completed model.

multiple-controlarea_behave_as_one.fsm

0 Likes 0 ·
Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered Ryosuke S commented

There is a field "Assign Event Object To" in the Event Trigger Source activity which has declared variable in the source code called "object". The Reference is to the Control area which triggered the event. I assign this reference to a label at the token:

token.labels.assert("area",object)

Later you can check, if this reference is a member of the group.

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

Ryosuke S avatar image Ryosuke S commented ·

@Jörg Vogel Thank you! I'll give myself a try with your solution.

0 Likes 0 ·