This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Using Custom Visualization for Entities

Overview

These examples show how you can create MATLAB based custom visualization for entities. The example illustrates the visualization of a restaurant layout with customer entities entering, dining, and leaving.

Structure of Model

The model contains the following major components:

  • The Resource Pool block models the tables in the restaurant. Since there are 10 tables in the restaurant, the resource amount is 10.

  • The Entity Generator block (Patron Enter) generates entities representing customers. They enter a waiting area, represented by a Resource Acquire. Here they wait for a free table.

  • When a table is available for a customer, he can move to the Entity Server block which models the duration of eating.

  • When the customer is done eating, he releases the table back to the pool and exits the restaurant.

modelname = 'seExampleCustomVisualization';
open_system(modelname);

Visualizing the Restaurant

seExampleRestaurantAnimator visualizes the restaurant as follows:

  • seExampleRestaurantAnimator provides the visualization of the restaurant layout for the model.

  • It generates the figure containing the layout of a restaurant with an entrance, a waiting area, 10 dining tables, and an exit.

  • As entities move during the simulation, it creates a marker (glyph) for each entity in the figure and programs motion for the marker so that it appears to move from one point to another.

  • The animator assigns a table ID for each waiting customer and shows the customer moving to the table.

  • To inspect the attributes of the customer entity, pause the model and click on a customer entity glyph. The figure displays the TimeToDine attribute.

  • To make the motion appear continuous, it uses a MATLAB timer to periodically execute a function that incrementally moves each entity towards its destination.

  • It uses MATLAB graphics to display statistics on the figure about the number of entities entering, waiting, and leaving.

  • Clicking an entity in the visualization displays the attributes that it contains. It uses a MATLAB graphics callback to program a ButtonDownFcn on each entity marker.

animator = seExampleRestaurantAnimator;
sim(modelname);
waitfor(animator.getFigureHandle, 'Tag', 'End');

close(animator.getFigureHandle);
bdclose all;
clear modelname animator