eventForward
Class: matlab.DiscreteEventSystem
Namespace: 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
locationType
— Location type
character vector
Type of the new location. Specify 'storage'
if
the new location is a storage element of the discrete-event system.
Specify 'output'
if you want the entity to exit
from an output port of the discrete-event system.
locationIndex
— Location index
double
Index of the new location. If location type is 'storage'
,
it indicates the index of a storage element. If location type is 'output'
,
it indicates the index of an output port.
delay
— Delay
double
Time delay between current simulation time and the time the entity will be forwarded.
Output Arguments
event
— Event
MATLAB® structure
Event that forwards the entity in current event action context to a new location.
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
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)