question

shanice.c avatar image
0 Likes"
shanice.c asked shanice.c commented

How to get group that a control point is belong to with Flexscript?

I'd like to group control points on one path to as a group. Let AGV use cp to find the path it belong to. And using globalTable that listed all paths to control these paths. Now I'm having problem how to get group that a control point is belong to with Flexscript? I could only found isMember to check if the object is a member of the group.

traffic control.fsm

traffic control.fsm

FlexSim 21.2.0
get group
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

·
Mischa Spelt avatar image
1 Like"
Mischa Spelt answered shanice.c commented

There is no 'direct' way to do this and I would say that in general, your model logic is 'the wrong way around' if you do need this.

However, if you are really sure this is what you want, you can go through the Groups attribute.

treenode obj = so();
treenode groups = obj.find(">Groups");
treenode globalGroups = model.find("/Tools/Groups");
Array result = [];

for(int i = 1; i <= groups.subnodes.length; i += 1)
{
  treenode group = groups.subnodes[i].value.up;

  // Make sure to filter out e.g. chart template groups
  if(group.up == globalGroups)
  {
    result.push(group.name);
  }
}

return result;
· 6
5 |100000

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

shanice.c avatar image shanice.c commented ·

@Mischa Spelt Thank you for your reply. Maybe it's like you mentioned above that my logic is wrong. Maybe identify which group AGV is located is not an efficient way. Then I tried to put CP in a same group in the an array, but the same problem is that there's still no direct way to get which Array the CP is belonging in code. The reason I want to use above described concept on traffic control problem is because I would like to mimic in real practice how dispatching system developer write their code. I'm still not sure how to realize my concept in process flow and code.

The propose of building this model is to measure if scale up the AGV numbers in this system, in which place will come across blocking easily. I know maybe if I use Flexsim built- in process flow template, I don't have to worry about traffic problem. Could you give me some suggestion upon your hands-on experience?

0 Likes 0 ·
Jordan Johnson avatar image Jordan Johnson ♦♦ commented ·

This is technically correct, but I would say that it is better practice to use Object Properties rather than digging through the tree:

Object obj = so();
Array groupNames = obj.getProperty("AllGroups");
for (int i = 1; i <= groupNames.length; i++) {
    string groupName = groupNames[i];
    // ...
}

Using properties is better because we may change the tree structure in the future, and we would update the getProperty() method to work correctly.

0 Likes 0 ·
shanice.c avatar image shanice.c Jordan Johnson ♦♦ commented ·

Hi @Jordan Johnson, thank you for your reply. May I ask in second line, what object does the property("AllGroups") belongs to? Because I could only find "AllGroups" used in Property Table. I've gone through description of so(), it says to designate a node as so, right-click on the node in the tree and select Edit|Designate This Node (so). But after I do this, I'd like to see if there's something happen, but it seems nothing has been chosen. My question is how "so()" works to represent each controlpoint?

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ shanice.c commented ·
You would right-click on the control point and set it as so().
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.