question

Michael Zabritski avatar image
0 Likes"
Michael Zabritski asked Michael Zabritski commented

Assign parent group location to patient label

In this sample model, I have a series of nested location groups (Depts > Pods > Beds). Patients are being moved to the dept with the most beds available. Once a patient gets a location, I'm trying to assign the top level group name (Dept in this case) to the patient so I can use it with A* navigation barriers later on. Would like to allow one barrier to only allow Dept 1 patients thru while another barrier only allows Dept 2 patients thru.

When I assign the label using last acquired location resource, it assigns the current location but I can't figure out a way to get which Dept the bed belongs to. I then need to make sure I can use that Dept label with A*

Thanks


Logic Flow Test.fsm

FlexSim 20.1.2
flexsim 20.1.2assign labellocation group
logic-flow-test.fsm (244.6 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.

Parker S avatar image
0 Likes"
Parker S answered Michael Zabritski commented

@Michael Zabritski

There may be a way to do this by accessing the parent groups, but I believe a simpler way would be to assign the Dept label directly onto your beds.

Let me know if this would work for what you are trying to achieve.


deptlabel.gif (935.6 KiB)
· 2
5 |100000

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

Matthew Gillespie avatar image Matthew Gillespie ♦♦ commented ·

If you go this route, there are some ways to speed up adding a label to a bunch of objects at once. If you select all the objects in one department in a group, and then add the label to one of them you can copy the label to all the selected objects by clicking on the label you want to copy and then clicking the button in the bottom right:

You could also do this by running a script:

Array beds = Group("Dept 1").toFlatArray();

for (int i = 1; i <= beds.length; i++) {
    beds[i].Dept = 1;
}
1 Like 1 ·
1613670466120.png (7.2 KiB)
Michael Zabritski avatar image Michael Zabritski commented ·

Thanks Parker. That is exactly what I hoping for and a bit easier for my novice experience to understand than Matthew's code.

1 Like 1 ·
Matthew Gillespie avatar image
0 Likes"
Matthew Gillespie answered

You can use the Group.isMember(obj, 1) method to find out if an object is a member of a certain group. For example, this code returns 1 if the bed is in Dept1 and 2 if it's in Dept2:

Object bed = patient.Locations[1];

if (Group("Dept 1").isMember(bed, 1))
    return 1;
    
if (Group("Dept 2").isMember(bed, 1))
    return 2;    

DeptLabel.fsm


deptlabel.fsm (52.6 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.

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.