entry
Class: matlab.DiscreteEventSystem
Namespace: matlab
Event action when entity enters storage element
Syntax
[entity,events]=entry(obj,storage,entity,source)
[entity,events,out1,...]=entry(obj,storage,entity,source,in1,...)
Description
[
specifies event actions of the object when an entity enters storage. entity
,events
]=entry(obj
,storage
,entity
,source
)
[
such event actions of the object when the block has one or more input signal ports
and/or signal output ports.entity
,events
,out1
,...]=entry(obj
,storage
,entity
,source
,in1
,...)
Input Arguments
obj
— Discrete-event System object™
MATLAB® object
Discrete-event System object.
storage
— Storage
double
Index of the storage element.
entity
— Entity
MATLAB structure
Entity entering storage component. Entity has these fields:
sys
(MATLABstructure
) — It has these fields:id
(double
) — Entity IDpriority
(double
) — Entity priority
data
— Entity data
source
— Source location
MATLAB structure
Source location of entity, such as an input port or a storage element. It has these fields:
type
(character vector
) — Specifyinput
orstorage
index
(double
) — Input or storage index
in1
— Signal input
any value
Any data inputs of the object. These input arguments exist only when the object has data inputs.
Output Arguments
entity
— Entity
MATLAB structure
Entity entering storage, possibly with changed data. See entity.
events
— Events
vector of MATLAB structures
Events to be scheduled. Use matlab.DiscreteEventSystem
class methods to create events.
Each event has these fields:
type
(character vector
) — Type of the eventdelay
(double
) — Delay before the eventpriority
(double
) — Priority of the eventStorage
(double
) — Index of the storage elementtag
(character vector
) — Event taglocation
(MATLABstructure
) — Source or destination location of entity, see source
out1
— Signal output
any value
Data outputs of the object. You must specify these output arguments when the object has data outputs.
Examples
Event Action Upon Entity Entry
Event action for entity entry to storage.
function [entity,events] = entry(obj,storage,entity,src) % Specify event actions when entity entered storage. disp(['Entity of ID ' num2str(entity.sys.id) ... ' has entered storage element ' num2str(storage)]); switch src.type case 'input' disp(['Entity came from input port ' num2str(src.index)]); case 'storage' disp(['Entity came from storage element ' num2str(src.index)]); end events = [ ... obj.eventDestroy(), ... % Destroy the newly entered entity obj.eventIterate(2, '')]; % Iterate entities in storage element 2 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 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
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)