Main Content


Class: simevents.SimulationObserver
Package: simevents

Specify behavior when simulation starts




simStarted(obj) determines the behavior when the simulation starts. Override this function to specify the behavior of your visualization when the simulation starts, as determined by the SimulationStatus parameter.

Input Arguments

expand all

Object of class SimulationObserver


expand all

Initialize the animation canvas.

function simStarted(this)
            % Initialize the animation canvas
            % Re-initialize runtime work variables for simulation
            this.mEntityGlyphs = containers.Map('keytype', 'char', 'valuetype', 'any');
            this.mEntities = containers.Map('keytype', 'char', 'valuetype', 'any');
            this.mCombineMap = containers.Map('keytype', 'char', 'valuetype', 'char');
            this.mCachePostRun = containers.Map('keytype', 'char', 'valuetype', 'char');
            this.mTableOccupy = zeros(1, size(this.cTablePos,1)) - 1;
            % Setup the figure with the restaurant floor as background
            close all;
            im = imread('restaurant.png');
            this.mFig = gcf;
            set(this.mFig, 'Tag', 'Begin');
            this.mAx = gca;
            set(this.mFig, 'toolbar', 'none');
            set(this.mFig, 'menubar', 'none');
            set(this.mAx, 'XTickLabel', '');
            set(this.mAx, 'YTickLabel', '');
            set(this.mAx, 'Box', 'on');
            set(this.mAx, 'TickLength', [0 0]);
            set(this.mAx, 'position', [0 0 1 1]);
            hold on;
            % Set up the numeric statistics text labels on the figure
            this.mTxtEntry = text(170,850, '0');
            this.mTxtWaiting = text(10,160, '0');
            this.mTxtExit = text(920,330, '0');
            this.mTxtSelectedEnt = text(50,600,'');
            set(this.mTxtEntry, 'Color', [0.8500 0.3250 0.0980], 'FontWeight', 'bold', 'FontSize', 14);
            set(this.mTxtWaiting, 'Color', [0.8500 0.3250 0.0980], 'FontWeight', 'bold', 'FontSize', 14);
            set(this.mTxtExit, 'Color', [0.8500 0.3250 0.0980], 'FontWeight', 'bold', 'FontSize', 14);
            this.mLineSelectedEnt = plot(0,0,'.');
            % Set up the timer
            this.mTimer = timer(...
                'TimerFcn',      @(t,e)animate(this,t,e), ...
                'ExecutionMode', 'fixedSpacing', ...
                'Period',        this.cTimerPeriod);
            this.mTimerData = containers.Map('keytype', 'char', 'valuetype', 'any');
            this.mTimerRequestStop = false;
            this.mTimerRequestPause = false;

Version History

Introduced in R2016a