Main Content

Group Entities Using Batching

This example shows how to create, process, and split batched entities using Entity Batch Creator and Entity Batch Splitter blocks. In the model, An Entity Generator block is used to represent produced parts in a facility. The parts are batched by an Entity Batch Creator block. A batch is processed by an Entity Server block. When the processing is complete, the batch is split into individual parts by the Entity Batch Splitter block for their delivery.

In the model:

  • Use an Entity Generator block to generate a Part with two attributes, Color and Customer, representing color and delivery destination. To generate three different colors and two different delivery destinations for each Part, in the Event actions tab, in the Generate action field enter this code. field:

entity.Color = randi([1 3]);
entity.Customer = randi([1 2]);

  • Use an Entity Batch Creator block to generate a batch that contains four parts.

  • Use an Entity Server block to process and change the color of the third Part in each batch. In the Event actions tab, in the Entry field enter this code.

entity.batch(3).Color = 5;

  • Use an Entity Batch Splitter block to split parts. In the Entry action, use disp(entity.batch(3).Color) to display the color of the third Part in each processed batch.

  • Use an Entity Output Switch block to route a Part to the corresponding customer based on its Customer attribute.

Simulate Model and Review Results

Simulate the model.

Open the Simulation Data Inspector and observe that the parts are generated with Color values 1, 2, or 3.

  • Observe that the Diagnostic Viewer displays Color values of the third entity in each batch after batch processing.

  • Scope blocks labeled as For Customer 1 and For Customer 2 display the number of parts delivered to each customer.

See Also

| | | |

Related Topics