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
Output Arguments
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