Assign attribute to Entity on EntityContainer

323 views
Skip to first unread message

jh.vand...@bluerocklogistics.com

unread,
May 18, 2016, 8:18:47 AM5/18/16
to Jaamsim Users Discussion Group
Hi,

I would like to assign a value to an attribute (id) of an Entity that is on an EntityContainer. When I try to assign a numeric value to the Entity in the following way: this.obj.id==2, an error occurs that the attribute cannot be assigned to the entity. It looks like I can only assign something to the EntityContainer. Is it also possible to assign something to the Entity itself (on the EntityContainer)?

Thanks in advance.

Kind regards,
Jan-Hein van de Vliert

Harry King

unread,
May 18, 2016, 4:32:24 PM5/18/16
to Jaamsim Users Discussion Group, jh.vand...@bluerocklogistics.com
Jan-Hein,

At present, there is no way to access an entity once it has been placed in an EntityContainer. We are working on a major extension of he expression system that will make this possible, but it is still several months away.

Can you re-arrange your model so that the entity's attributes are set before it is placed in a container or after it is removed?

Harry

rif...@gmail.com

unread,
May 16, 2017, 11:34:06 PM5/16/17
to Jaamsim Users Discussion Group, jh.vand...@bluerocklogistics.com

Harry

Continuing on the theme of EntityContainers, how do you update an EntityContainer's user defined attribute when loading loading the container with an Entity?

Use Case
The entities being carried have an integer attribute, Type, which can the values of 1, 2, 3 or 4. As each Entity is added from a different queue, I want the EntityContainer entity attribute, MinOfType to be the minimum of the EntityContainer's MinOfType value and the Entity that is being added Type value.
On loading the first entity, the MinOfType = Entity_1.Type.
On loading the second entity, the MinOfType is the minimum of EntityContainer.MinOfType and Entity_2.Type.
etc. Eventually the EntityContainer will have exactly eight entities being carried.

The EntityContainer_n.MinOfType attribute is used for branching later on the material flow, and as to set priorities in various queues.

Thanks in advance.
RiF

Harry King

unread,
Jun 14, 2017, 8:19:58 PM6/14/17
to Jaamsim Users Discussion Group, jh.vand...@bluerocklogistics.com
Jan-Hein,

Release 2017-06 adds a new output "EntityList" for EntityContainer that returns an array of the entities inside the container. This output will allow you to assign attributes values to individual entities in the container. For example, the AttributeAssignmentList input:

   'this.obj.EntityList(1).attrib = 1'

would assign the value 1 to attribute "attrib" for the first entity in the container.

Harry

Paul McIver

unread,
Apr 26, 2024, 3:43:51 AMApr 26
to JaamSim Users Discussion Group

Harry

 

Is there a way to do this programmatically? The number of entities within a container can vary but I want same value applied to the same attribute on all entities within the container. Doing this without having to unpack and repack them all?

 

Basically I'm simulating blood samples (entity) that are now on a plate (container) for analysis. During processing each sample will receive some additives that are added to all samples on a plate (using attributes to assign these values). 

 

Regards

Paul

Harry King

unread,
Apr 26, 2024, 12:25:41 PMApr 26
to JaamSim Users Discussion Group
Hi Paul,

It can be done using the EntityList output for the EntityContainer, but it is a bit tricky because the Assign object does not have the ability to loop through a series of assignments. The solution is to loop the EntityContainer itself through the Assign object, assigning the attribute for each entity in turn. The attached example shows how to accomplish this.

Harry
EntityContainer Assignment Example.cfg

Paul McIver

unread,
Apr 29, 2024, 3:36:03 AMApr 29
to JaamSim Users Discussion Group
Thanks for the solution Harry, much appreciated.

Neater than unpack, assign, repack

Reply all
Reply to author
Forward
0 new messages