Main Content

preExit

Class: simevents.SimulationObserver
Namespace: simevents

Specify behavior before an entity exits a block with entity storage

Syntax

preExit(obj,evSrc,evData)

Description

preExit(obj,evSrc,evData) is used to specify behavior before an entity exits a block that stores entities. The simulation observer uses this method as a callback for pre-exit event notification and provides handles to the entity, the block and its storage, and the event.

Input Arguments

expand all

Object of class SimulationObserver

Handle to event calendar. The handle will be populated by the simulation observer.

List of handles of block, storage, and entities. The list will be populated by the simulation observer.

Examples

expand all

Specify listener to execute when entity exits a storage element such as a queue or server.

function preExit(this, ~, evData)
            % Override to specify listener for exit from a storage (queue/server)
            % evData contains block, storage, and entity handles

            entity = evData.CurrentEntity;
            
            if strcmp(evData.Block.BlockPath, [this.mModel '/Patron Enter'])
                % Create a new "dot" on the figure at the entry position
                h = plot(this.cEntryPos(1), this.cEntryPos(2), '.');
                set(h, 'MarkerSize', 32);
                
                % Add a mouse-click function to the dot so we can retrieve
                % attribute data when user clicks on this customer
                set(h, 'ButtonDownFcn', @(h,e)entityClickFcn(this,h,e));
                
                % Cache away the entity identifier on this dot
                set(h, 'Tag', num2str(entity.ID));
                
                % Cache away this dot handle so that we can move it in
                % future events
                this.mEntityGlyphs(num2str(entity.ID)) = h;
                
                % Cache away the entity handle
                this.mEntities(num2str(entity.ID)) = entity;

                % Increment the entry statistics
                this.updateStats(this.mTxtEntry, this.INCREMENT);
            
                % Schedule motion for this entity from its current position
                % to a random position in the waiting area
                this.scheduleMotion(entity, this.getRandWaitingPos());
                
                % Increment waiting statistic
                this.updateStats(this.mTxtWaiting, this.INCREMENT);
            elseif strcmp(evData.Block.BlockPath, [this.mModel '/Have Dinner'])
                this.releaseTable(entity);
            end
        end
        
    end

Version History

Introduced in R2016a