Entity ID for Entity Multicast
2 views (last 30 days)
Show older comments
I am working on a model that needs to print out the entity ID every time an entity enters a server. I am using entitySys.id to get the entity id, but it seems like when it goes through the 'Entity Multicast', the Entity Muticast is generating two new entities, so the input entity and the two output entitys' id is different (if input entity's ID = 1, output entity IDs are 2 and 3). Is there a way to fix this?
3 Comments
Answers (1)
Altaïr
on 16 May 2025
The Entity Multicast block is used to broadcast entities by cloning them and sending each copy with a specified Multicast tag. Any Entity Queue block set to receive entities via Multicast with the same tag will receive these cloned copies. Since the entities are cloned, each will have a unique ID different from the original entity's ID. More details about the Entity Multicast block can be found in the documentation using:
web(fullfile(docroot, 'simevents/ref/entitymulticast.html'))
To keep track of the original entity's ID, an attribute can be added to the entity. For example, attributes such as original_ID and new_ID can be included. The original_ID can be set as entitySys.id in the Entity Generator, and new_ID can be set as entitySys.id in the Entity Queue. This approach ensures that both the original and cloned entity IDs are tracked as the entities move through the model. Here's how the Entity Generator and Entity Queue event actions would look like:
Entity Generator:


Entity Queue:

For an overview of how queues and servers function, the following documentation page can be accessed:
web(fullfile(docroot, 'simevents/gs/role-of-queues-in-simevents-models.html'))
0 Comments
See Also
Categories
Find more on Discrete-Event Simulation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!