实体Generator
Generate Entities
Libraries:
SimEvents
Description
The实体Generatorblock generates entities. Entities are discrete items of interest that you can define in a discrete-event simulation. An entity can carry scalar, bus, or vector data. The meaning of an entity depends on the model. Entity can represent customers in a queuing system, data packets from a remote controller to an actuator, or any discrete item you define.
By default the block entity generation method isTime-based
. In this method, the block generates entities using intergeneration times specified by thePeriod, from an input signal or statistical distribution. SeeEntities in a SimEvents Model, for more information about creating time-based and randomized entities.
The block also creates event-based entities. ChooseEvent-based
as theGeneration Methodfor an external event to specify the entity intergeneration time. For an example, seeGenerate Entities When Events Occur.
To customize actions when the entity is generated or it exits the block, in theEvent actionstab, in theGenerate action
, orExit action
field, enter MATLAB®code. For more information, seeEvents and Event Actions.
Examples
Ports
Input
Port_1—Input to trigger entity generation upon arrival of events
scalar | vector | matrix
Dependencies
To enable this port, click the实体generationtab and selectEvent-based
for theGeneration method.
Data Types:single
|double
|int8
|int16
|int32
|int64
|uint8
|uint16
|uint32
|uint64
|Boolean
|enumerated
|bus
|不动点
Port_2—Input for the signal that determines the intergeneration time value for the next entity generation
scalar | vector | matrix
Dependencies
To enable this port, click the实体generationtab and selectTime-based
for theGeneration methodandSignal port
for theTime source.
Data Types:double
Output
Port_1—Output generated entity
scalar | vector | matrix
Output port for the generated entities departing the generator.
Data Types:single
|double
|int8
|int16
|int32
|int64
|uint8
|uint16
|uint32
|uint64
|Boolean
|enumerated
|bus
|不动点
Port_d—de数量的实体parted the block
scalar
de数量的实体parted the block.
Dependencies
To enable this port, click theStatisticstab and select the box labeledNumber of entities departed, d.
Data Types:double
Port_pe—Pending entity in block
off (default) | on
Outputs1
for a pending entity, and0
otherwise.
Dependencies
To enable this port, select theStatistics>Pending entity in block, pe.
Data Types:double
Port_w—Average intergeneration time
off (default) | on
Outputs the average time between generation of entities.
Dependencies
To enable this port, select theStatistics>Average intergeneration time, w.
Data Types:double
Parameters
Generation method—Select the method of entity generation
Time-based
(default) |Event-based
Choose the entity generation method. ChooseTime-based
to generate entities using intergeneration times from an input signal or statistical distribution. ChooseEvent-based
对于一个外部事件来确定实体强度rgeneration time.
Programmatic Use
Block Parameter:GenerationMethod |
Type: character vector |
Values:'Time-based' |'Event-based' |
Default:'Time-based' |
Time source—Select the source of the intergeneration time
Dialog
(default) |Signal port
|MATLAB action
Specify the source for entity intergeneration time.
Select
Dialog
to specify a fixed period between entity generations.Select
Signal port
to generate entities based on an input signal.Select
MATLAB action
to define a MATLAB Script that defines the intergeneration time represented bydt
.
For more information about specifying intergeneration times for entities, seeSpecify Intergeneration Times for Entities.
Dependencies
This parameter is visible when theGeneration methodis set toTime-based
.
Programmatic Use
Block Parameter:TimeSource |
Type: character vector |
Values:'Dialog' |'Signal port' |'MATLAB action' |
Default:'Dialog' |
Period—Define the period between the generation of entities
1
(default) | scalar
Specify the time between entity intergeneration. For instance, if thePeriodis1
, the block waits1
simulation time in between entity generations. See,Specify Intergeneration Times for Entitiesfor more information.
可调:Yes
Dependencies
This parameter is visible whenGeneration methodis set toTime-based
.
Programmatic Use
Block Parameter:Period |
Type: character vector |
Values:'1' | scalar |
Default:'1' |
Intergeneration time action—Specify the time between entity generations
dt = rand(1,1)
(default) | MATLAB code
Use MATLAB code to specify service time.dt
specifies the time between entity generations. You can manually specifydt
or useInsert patternbutton to generate entities with a repeating sequence or from a distribution. The block uses this parameter every time it is ready for entity generation. For an example, seeSpecify Intergeneration Times for Entities.
Dependencies
This parameter is visible whenService time sourceis set toMATLAB action
.
Programmatic Use
Block Parameter:IntergenerationTimeAction |
Type: character vector |
Values: MATLAB code |
Default:'dt = rand(1,1);' |
Generate entity at simulation start—Generate an entity at the start of the simulation
on
(default) |off
Generates entity at the start of the simulation.
Programmatic Use
Block Parameter:GenerateEntityAtSimulationStart |
Type: character vector |
Values:'on' |'off' |
Default:'on' |
实体type—Choose the type of entity to generate
Structured
(default) |Anonymous
|Bus object
Choose the type of entity to generate.
The
Anonymous
type has one data value associated with it.The
Structured
type (default) includes name and initial value attributes that you can specify.You can attach more than one attribute to an entity by clicking.
You can delete attributes by clicking.
You can change the order of the attributes by clickingand.
You can convert a
Structured
type entity to a bus object by clicking
The
Bus object
type lets you generate bus objects as entities.ClickLaunch Type Editorto open the Type Editor to generate bus objects. A bus object can be an element of another bus object which can be used to create hierarchy in the data that is attached to an entity.
For more information, seeEntities in a SimEvents Model.
Programmatic Use
Block Parameter:实体Type |
Type: character vector |
Values:'Structured' |'Anonymous' |'Bus object' |
Default:'Structured' |
实体priority—Specify the priority of the generated entity
300
(default) | scalar
Determines the priority of the generated entity. The lower the value the higher the priority For more information, seeWorking with Entity Attributes and Entity Priorities.
Programmatic Use
Block Parameter:实体Priority |
Type: character vector |
Values:'300' | scalar |
Default:'300' |
实体type name—Specify the name of the generated entity
实体
(default) | character vector
Determines the name of the generated entity.
Dependencies
This parameter is visible when实体typeis set toBus object
orStructured
.
Programmatic Use
Block Parameter:实体TypeName |
Type: character vector |
Values:'Entity' | character vector |
Default:'Entity' |
Data initial value—Specify the initial value of anonymous entity data
0
(default) | scalar | vector | matrix
Set the anonymous entity data initial value. This value cannot be of type int64 or fixed-point.
Dependencies
This parameter is visible when you set实体typetoAnonymous
.
Programmatic Use
Block Parameter:DataInitialValue |
Type: character vector |
Values:'0' | scalar | vector | matrix |
Default:'0' |
Attribute Name—Define the name of the generated entity attribute
Attribute1
(default) | character vector
Define entity attribute name.
Note
When done, you can export the structured entity type as a bus object, with the name实体type name, to the base workspace. Export the bus object when using theMATLAB Discrete-Event Systemand离散事件图blocks.
Dependencies
This parameter is visible when实体typeis set toStructured
.
Programmatic Use
Block Parameter:AttributeName |
Type: character vector |
Values:'Attribute1' | character vector |
Default:'Attribute1' |
Attribute Initial Value—Define the generated entity attribute initial value
1
(default) | scalar
Specify the entity attribute initial value. This parameter is visible when实体typeis set toStructured
. This value can not be of type fixed-point.
Programmatic Use
Block Parameter:AttributeInitialValue |
Type: character vector |
Values:1 | scalar |
Default:'1' |
Event actions—Specify the behavior of the entity on certain events
Generate
(default) |Exit
Define the behavior in theEvent actionparameter. TheGenerate
action is called when an entity is generated and theExit
action is called just before an entity exits the block.
Programmatic Use
Block Parameter:GenerateAction, ExitAction |
Type: character vector |
Values: MATLAB code |
Default:'' |
Number of entities departed, d—Outputs the number of entities that have departed the block
off
(default) |on
de数量的实体parted the block.
Programmatic Use
Block Parameter:NumberEntitiesDeparted |
Type: character vector |
Values:'on' |'off' |
Default:'off' |
Pending entity present in block, pe—Pending entities
off
(default) |on
Indicates whether an entity that is yet to depart is present in the block. The value is1
for a pending entity, and0
otherwise. This block can have at most one pending entity because its storage capacity is one. If there is an existing pending entity, the block does not generate another entity until the pending entity departs the block.
Programmatic Use
Block Parameter:PendingEntityInBlock |
Type: character vector |
Values:'on' |'off' |
Default:'off' |
Average intergeneration time, w—Average time between generation of entities
off
(default) |on
Outputs the average time between generation of entities.Average intergeneration time, wis the ratio of the total generation time to the total number of generated entities.
Programmatic Use
Block Parameter:AverageIntergenerationTime |
Type: character vector |
Values:'on' |'off' |
Default:'off' |
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)
- 挪威(English)
- Österreich(Deutsch)
- Portugal(English)
- Sweden(English)
- Switzerland
- United Kingdom(English)