Main Content

simTerminating

Class: simevents.SimulationObserver
Namespace: simevents

Define observer behavior when simulation is terminating

Syntax

simTerminating(obj)

Description

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

Input Arguments

expand all

Object of class SimulationObserver

Examples

expand all

Call this method when simulation is terminating.

function simTerminating(this)
            % Called when simulation is terminating
            %
            % After the simulation terminates, in order to support clicking
            % on entity to see attributes, we gather up all of the entities
            % that exist in the model and save their attribute information
            
            ents = this.mEntityGlyphs.keys;
            for idx = 1 : length(ents)
                ent = ents{idx};
                try
                    enStruct = this.mEntities(ent);
                    str = evalc('disp(enStruct.Attributes)');
                    this.mCachePostRun(ent) = str;
                catch me
                end
            end
            
            % If animation timer is still running, schedule a stop
            if strcmp(this.mTimer.Running, 'on')
                this.mTimerRequestStop = true;
            else
                % If timer is not running, delete it
                delete(this.mTimer);
            end
        end

Version History

Introduced in R2016a