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
Partwith two attributes,
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
Partin 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
Partin each processed batch.
Use an Entity Output Switch block to route a
Partto the corresponding customer based on its
Simulate Model and Review Results
Simulate the model.
Open the Simulation Data Inspector and observe that the parts are generated with
Observe that the Diagnostic Viewer displays
Colorvalues 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.
Entity Batch Creator | Entity Server | Entity Batch Splitter | Entity Generator | Entity Output Switch