eventGenerate
Class: matlab.DiscreteEventSystem
Namespace: matlab
Create entity generate event
Syntax
event=eventGenerate(storageID,tag,delay,priority)
Description
creates an event to generate an entity. You can then schedule this event by returning it
as the output argument when implementing an event action method, such as event
=eventGenerate(storageID
,tag
,delay
,priority
)entry
.
Input Arguments
storageID
— Storage index
double
Index of the storage element, where a new entity will be generated.
tag
— Tag
character vector
Custom tag of this entity generate event.
delay
— Delay
double
Time delay between current simulation time and the time the entity will be generated.
priority
— Priority
double
Positive integer value indicating system priority of the new entity. A smaller numeric value indicates a higher priority.
Output Arguments
event
— Event
MATLAB® structure
Event that generates an new entity in the specified storage element.
Examples
Define Entity Generation Event
Define entity generation event in storage element 3
.
function event = setupEvents(obj) % Define an entity generation event % - A new entity shall be created in storage element 3 % - The event has a custom tag 'seed' % - The event shall be executed 0.5 second later % - The new entity shall be initialized with a priority of 200 event = obj.eventGenerate(3, 'seed', 0.5, 200); end
Create a Custom Block to Generate Entities
This example shows how to create a custom source block that generates entities and to manage discrete states when implementing the discrete-event System object™ methods.
For more information, see Custom Entity Generator Block with Signal Input and Signal Output.
classdef CustomEntityStorageBlockGeneration < matlab.DiscreteEventSystem... & matlab.System % A custom entity generator block. % Nontunable properties properties (Nontunable) % Generation period period = 1; end properties(DiscreteState) % Entity priority priority; % Entity value value; end % Discrete-event algorithms methods function [events, out1] = setupEvents(obj) % Set up entity generation events at simulation start. events = obj.eventGenerate(1,'mygen',obj.period,obj.priority); % Set up the initial value of the output signal. out1 = 10; end function [entity,events,out1] = generate(obj,storage,entity,tag,in1) % Specify event actions when entity is generated in storage. entity.data = obj.value; % The priority value is assigned from the input signal. obj.priority = in1; % Output signal is the assigned priority value. out1 = obj.priority; events = [obj.eventForward('output',1,0) ... obj.eventGenerate(1,'mygen',obj.period,obj.priority)]; end end methods(Access = protected) function entityTypes = getEntityTypesImpl(obj) entityTypes = obj.entityType('Material'); end function [inputTypes,outputTypes] = getEntityPortsImpl(obj) % Specify entity input and output ports. Return entity types at % a port as strings in a cell array. Use empty string to % indicate a data port. inputTypes = {''}; outputTypes = {'Material',''}; end function resetImpl(obj) % Initialize / reset discrete-state properties. obj.priority = 10; obj.value = 1:12; end function [storageSpecs, I, O] = getEntityStorageImpl(obj) storageSpecs = obj.queueFIFO('Material', 1); I = 0; O = [1 0]; end function num = getNumInputsImpl(obj) % Define total number of inputs for system with optional % inputs. num = 1; end function num = getNumOutputsImpl(~) % Define total number of outputs. num = 2; end function [out1 out2] = getOutputSizeImpl(obj) % Return size for each output port. out1 = [1 12]; out2 = 1; end function [out1 out2] = getOutputDataTypeImpl(obj) % Return data type for each output port. out1 = "double"; out2 = "double"; end function [out1 out2] = isOutputComplexImpl(obj) % Return true for each output port with complex data. out1 = false; out2 = false; end function [sz,dt,cp] = getDiscreteStateSpecificationImpl(obj,name) % Return size, data type, and complexity of discrete-state % specified in name. switch name case 'priority' sz = [1 1]; case 'value' sz = [1 12]; end dt = "double"; cp = false; 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)