eventForward
Class: matlab.DiscreteEventSystem
Package: matlab
Create entity forward event
Syntax
event=eventForward(locationType,locationIndex,delay)
Description
creates an event to forward an entity from the current location to a new location. You
can then schedule this event by returning it as the output argument when implementing an
event action method, such as event
=eventForward(locationType
,locationIndex
,delay
)entry
.
Input Arguments
Output Arguments
Examples
Forward Current Entity to Storage
Define an event that forwards the current entity to storage.
function [entity,events] = entry(obj,storage,entity,src) % Define an event that forwards the current entity to storage % element 2. Event shall be scheduled to execute 0.8 second later. event1 = obj.eventForward('storage', 2, 0.8); % Define an event that forwards the current entity to output port 1. % Event shall be scheduled to execute at current simulation clock time. event2 = obj.eventForward('output', 1, 0); % Define events as event1 and event2 events = [event1, event2]; end
Create a Custom Entity Storage Block to Delay Entities
This example shows how to use discrete-event System object™ methods to create a custom entity storage block that has one input
port, one output port, and one storage element. The discrete-event System object is the instantiation of the matlab.DiscreteEventSystem
class,
which allows you to use the implementation and service methods provided by this
class. Then, you use the MATLAB Discrete-Event System block
to integrate the System object into a SimEvents® model.
The custom MATLAB Discrete-Event System block accepts an entity from its input port and forwards it to its output port with a specified delay. For more information, see Delay Entities with a Custom Entity Storage Block.
classdef CustomEntityStorageBlock < matlab.DiscreteEventSystem % A custom entity storage block with one input, one output, and one storage. % Nontunable properties properties (Nontunable) % Capacity Capacity = 1; % Delay Delay=4; end methods (Access=protected) function num = getNumInputsImpl(~) num = 1; end function num = getNumOutputsImpl(~) num = 1; end function entityTypes = getEntityTypesImpl(obj) entityTypes = obj.entityType('Car'); end function [inputTypes,outputTypes] = getEntityPortsImpl(obj) inputTypes = {'Car'}; outputTypes = {'Car'}; end function [storageSpecs, I, O] = getEntityStorageImpl(obj) storageSpecs = obj.queueFIFO('Car', obj.Capacity); I = 1; O = 1; end end methods function [entity,event] = CarEntry(obj,storage,entity,source) % Specify event actions when entity enters storage. event = obj.eventForward('output', 1, obj.Delay); end end end
Version History
Introduced in R2016a