Mathworks SIMEVENTS 3 Reference

SimEvents
Reference
®
3
How to Contact The MathWorks
www.mathworks. comp.soft-sys.matlab Newsgroup www.mathworks.com/contact_TS.html Technical Support
suggest@mathworks.com Product enhancement suggestions
bugs@mathwo doc@mathworks.com Documentation error reports service@mathworks.com Order status, license renewals, passcodes
info@mathwo
com
rks.com
rks.com
Web
Bug reports
Sales, prici
ng, and general information
508-647-7000 (Phone)
508-647-7001 (Fax)
The MathWorks, Inc. 3 Apple Hill Drive Natick, MA 01760-2098
For contact information about worldwide offices, see the MathWorks Web site.
®
SimEvents
© COPYRIGHT 2005–20 10 by The MathWorks, Inc.
The software described in this document is furnished under a license agreement. The software may be used or copied only under the terms of the license agreement. No part of this manual may be photocopied or reproduced in any form without prior written consent from The MathW orks, Inc.
FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation by, for, or through the federal government of the United States. By accepting delivery of the Program or Documentation, the government hereby agrees that this software or documentation qualifies as commercial computer software or commercial computer software documentation as such terms are used or defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014. Accordingly, the terms and conditions of this Agreement and only those rights specified in this Agreement, shall pertain to and govern theuse,modification,reproduction,release,performance,display,anddisclosureoftheProgramand Documentation by the federal government (or other entity acquiring for or through the federal government) and shall supersede any conflicting contractual terms or conditions. If this License fails to meet the government’s needs or is inconsistent in any respect with federal procurement law, the government agrees to return the Program and Docu mentation, unused, to The MathWorks, Inc.
Trademarks
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See
www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand
names may be trademarks or registered trademarks of their respective holders.
Patents
The MathWorks products are protected by one or more U.S. patents. Please see
www.mathworks.com/patents for more information.
Reference
Revision History
March 2007 Online only Revised for Version 2.0 ( Release 2007a). Previously part
of SimEvents
®
User’s Guide.
September 2007 Online only Revised for Version 2.1 (Release 2007b) March 2008 Online only Revised for Version 2.2 (Release 2008a) October 2008 Online only Revised for Version 2.3 (Release 2008b) March 2009 Online only Revised for Version 2.4 (Release 2009a) September 2009 Online only Revised for Version 3.0 (Release 2009b) March 2010 Online only Revised for Version 3.1 (Release 2010a)
Function Reference
1
Library and Models ................................ 1-2
Contents
Simulation Settings
Debugger
Debugger Session Simulation Control State Inspection Breakpoints Debugger Information
Seed Management
2
3
................................ 1-3
......................................... 1-4
................................. 1-4
................................ 1-4
................................... 1-5
...................................... 1-5
.............................. 1-6
................................. 1-7
Alphabetical List
Block Reference
Generators ........................................ 3-2
Entity Generators Event Generators Signal Generators
SimEvents Sinks
Attributes
......................................... 3-4
................................. 3-2
................................. 3-2
................................. 3-2
................................... 3-3
v
Queues ........................................... 3-5
Servers
Routing
Gates
Entity M a nagem en t
Signal Management
SimEvents Ports and Subsystems
Timing
Event Translation
Probes
SimEvents U ser-Defined Functions
........................................... 3-6
........................................... 3-7
............................................. 3-8
................................ 3-9
................................ 3-10
............................................ 3-12
................................. 3-13
............................................ 3-14
................... 3-11
.................. 3-15
vi Contents
Blocks — Alphabetical List
4
Configuration Parameters
5
SimEvents Pane ................................... 5-2
SimEvents Pane Overview Execution order Seed for event randomization
................................... 5-5
.......................... 5-4
........................ 5-6
Maximum events per block .......................... 5-7
Maximum events per model
......................... 5-8
SimEvents Diagnostics Pane
Diagnostics Pane Overview Attribute output de layed relative to entities Response to function call delayed relative to entities Statistical output delayed relative to entities Modification of attribute values used for decision
making
Identical seeds for random number generators
........................................ 5-17
........................ 5-9
......................... 5-10
............ 5-11
..... 5-13
........... 5-15
.......... 5-19
Glossary
Index
vii
viii Contents

Function Reference

Library and Models (p. 1-2) Open the library and example
models
Simulation Settings (p. 1-3) Configure models for discrete-event
simulation
1
Debugger (p. 1-4)
Seed Management (p. 1-7) Manage seeds of random n umber
Run and examine simulations in debug mode
generators
1 Function Reference

Library and Models

simeventsdocex
simeventslib
Open SimEvents example model
Open SimEvents library
®
documentation
1-2

Simulation Settings

simeventsconfig Assign model settings for
Simulation Settings
discrete-event simulation
simeventsstartup
Set default model settings for discrete-event simulation
1-3
1 Function Reference

Debugger

Debugger Session (p. 1-4) Start and stop the debugger
Simulation Control (p. 1-4) Stop, suspend or resume the
simulation
State Inspection (p. 1-5) Query the model for information
about the simulation
Breakpoints (p. 1-5) Create and manage breakpoints in
the debugger
Debugger Information (p. 1-6) Start a n d configure the debugger

Debugger Session

sedb.quit
sedebug Debug discrete-event simulation
dbopts
se_get
Simul
sedb.
sedb
sed
ation Control
cont
.runtoend
b.step
Quit discrete-event simulation debugging session
SimEvents debugger options structure
Continue simulation until next breakpoint
Run until end of discrete-event simulation
Single step in discrete-e ven t simulation
1-4

State Inspection

sedb.blkinfo Block information in discrete-event
simulation
Debugger
sedb.blklist
sedb.currentop
sedb.eninfo Entity information in discrete-event
sedb.evcal
sedb.evinfo Event information in discrete-event
sedb.gceb
sedb.gcebid
sedb.gcen
sedb.gcev
sedb.simtime
Blocks and their identifiers in discrete-event simulation
Current operation in discrete-event simulation
simulation
Event calendar of discrete-event simulation
simulation
Name of currently executing block in discrete-event simulation
Identifier of currently executing block in discrete-event simulation
Identifier of entity currently undergoing operation
Identifier of current event
Current time in discrete-event simulation

Breakpoints

sedb.bdelete Delete breakpoints in discrete-event
simulation
edb.blkbreak
s
sedb.breakpoints List breakpoints in discrete-event
Set breakpoint for discrete-event simulation block
simulation
1-5
1 Function Reference
sedb.disable Disable breakpoints in discrete-event
simulation
sedb.enable Enable breakpoints in discrete-event
simulation
sedb.evbreak
sedb.tbreak

Debugger Information

help
sedb.detail
Setbreakpointforexecutionor cancelation of event
Set timed breakpoint in discrete-event simulation
Help for debugger functions
Customize debugger simulation log in discrete-event simulation
1-6

Seed Management

Seed Management
se_getseeds
se_randomizeseeds Randomize seeds to make them
se_setseeds
Seed values of random number generators in blocks
unique
Set seed values for blocks with random number generators
1-7
1 Function Reference
1-8

Alphabetical List

2
help
Purpose Help for debugger functions
Syntax help
help sedb help functionname
Description help, at the SimEvents debugger command prompt, displays a
summary of debugger commands in the Command Window.
help sedb also displays a summary of debugger commands. This
syntax is valid at either the SimEvents debugger command prompt or the MATLAB
help functionname displays a brief description and the syntax for functionname in the Command Window.
How To • “Starting the SimEvents Debugger”
• “Overview of the SimEve n ts Debugger”
®
command prompt.
2-2
se_getdbopts
Purpose SimEvents debugger options structure
Syntax opts_struct = se_getdbopts
Description opts_struct = se_getdbopts returns an empty options structure that
you can configure and then use as an input to the You can set the
StartFcn field of opts_str uct to a cell array of strings
representing commands that the debugger executes after the debugger session begins.
Examples Set breakpoints upon starting the debugger:
1 At the MATLAB command prompt, create an options structure to
use in future debugger sessions:
opts_struct = se_getdbopts; opts_struct.StartFcn = {'tbreak 1', ' tbreak 2'};
2 For a particular model, begin a debugger session using a syntax
that includes argument causes the debugger to execute the commands in the
opts_struct.StartFcn field automatically:
opts_struct as an input argument. Using this
sedebug function.
sedebug('sedemo_outputswitch', opts_struct)
The output in the MATLAB Command Window reflects model initialization followed by the setting of two b reakpoints:
*** SimEvents Debugger ***
Functions | Help | Watch Video Tutorial
%==============================================================================%
Initializing Model sedemo_outputswitch
Set b1 : Breakpoint for first operation at or after time 1.000000
Set b2 : Breakpoint for first operation at or after time 2.000000
2-3
se_getdbopts
3 Proceed in the simulation until the first breakpoint. At the
sedebug>> prompt, enter:
cont
The output is:
%==============================================================================%
Initializing Time-Based Entity Generators
%..........................................................................%
Scheduling EntityGeneration Event (ev1)
: EventTime = 1.000000000000000
: Priority = 500
: Block = Time-Based Entity Generator
Hit b1 : Breakpoint for first operation at or after time 1.000000
%==============================================================================%
Executing EntityGeneration Event (ev1) Time = 1.000000000000000
: Entity = <none> Priority = 500
: Block = Time-Based Entity Generator
4 End the debugger session. At the sedebug>> prompt, enter:
sedb.quit
See Also sedebug
How To • “Debugger Efficiency Tips”
2-4
se_getseeds
Purpose Seed values of random number generators in blocks
Syntax seedstruct = se_getseeds(sysid)
Description seedstruct = se_getseeds(sysid) returns the names and seed
values of all SimEvents blocks that you previously config ured to use random num ber generators. specifying a system name, subsystem path name, or block path name. Before invoking this function, load or open the system.
sysid indicates the scope of the search by
Output Arguments
seedstruct
Structure with these fields:
system —Valueofthesysid input to se_getseeds
seeds — Structure array, of which each element has these
fields:
- block — Path name of a block that uses a random number
generator, relative to
system
- value — Numeric seed value of the block
See Also se_setseeds | se_randomizeseeds
Tutorials • Se ed Management Workflow for Random Number Generators
How To • “Making Results Repeatable by Storing Sets of Seeds”
• “Sharing Seeds Among Models”
2-5
se_randomizeseeds
Purpose Randomize seeds to make them unique
Syntax se_randomizeseeds(obj)
se_randomizeseeds(obj,'Mode','All') se_randomizeseeds(obj,'Mode','Identical',) se_randomizeseeds(obj,'Mode','SpecifySeeds',sv) se_randomizeseeds(...,'GlobalSeed',seed) se_randomizeseeds(...,'Verbose',verbosity)
Description se_randomizeseeds(obj) or se_randomizeseeds(obj, 'Mode','All')
assignstheseedsofallSimEventsblocksthatuserandomnumber generators within blocks indicated by are unique. The input block path name, or ce ll array of such names . If or subsystem, the function assigns seeds in subsystems of depth. Before invoking this function, load or open the system where you want to assign seeds.
se_randomizeseeds(obj,'Mode','Identical',) changes only those
seeds in the system or subsystem
obj is a system name, subsystem path name,
obj, making sure that the seeds
obj represents a system
obj at any
obj that appear multiple times in obj.
se_randomizeseeds(obj,'Mode','SpecifySeeds',sv) changes only
those s eeds whose current value appears in the vector
se_randomizeseeds(...,'GlobalSeed',seed) specifies a global seed
that the function uses to generate seed values in a repeatable way. is a nonnegative integer. When you use this syntax, it is repeatable for agiven in guarantee uniqueness of generated se ed values.
se_randomizeseeds(...,'Verbose',verbosity),ifverbosity is 'on', explicitly reports the status of each seed change.
seed value, assuming the underlying systems or blocks specified
obj do not change. To ensure repeatability, this syntax does not
See Also se_getseeds | se_setseeds
Tutorials • Avoiding Identical Seeds for Random Number Generators
• Seed Management Workflow for Random Number Generators
2-6
sv.
seed
se_randomizeseeds
• “Example: Varying the Number of Servers Using MATLAB Code”
How To • “Varying Parameters Between Simulation Runs Using MATLAB
Code”
2-7
se_setseeds
Purpose Set see d values for blocks with random number generators
Syntax se_setseeds(seedstruct)
se_setseeds(seedstruct, sysid) oldseedstruct = se_setseeds(seedstruct...) [oldseedstruct, status] = se_setseeds(seedstruct...)
Description se_setseeds(seedstruct) sets the seed parameter values for all
SimEventsblocksspecifiedin function, load or open the system that the represents.
se_setseeds(seedstruct, sysid) applies the seed values to the
system
seedstruct. Before invoking this function, load or open the system, sysid.
oldseedstruct = se_setseeds(seedstruct...) stores the original
seed values in specified in
sysid, overriding the system specified in the system field of
oldseedstruct before setting them to the values
seedstruct.
seedstruct. Before invoking this
system field of seedstruct
Input Arguments
2-8
[oldseedstruct, status] = se_setseeds(seedstruct...) returns
status information indicating when the function does not set a seed.
seedstruct
Structure having the same fields as the output of the se_ getseeds function:
system —Valueofthesysid input to se_getseeds
seeds — Structure array, of which each element has these
fields:
- block — Path name of a block that uses a random number
generator, relative to
system
- value — Numeric seed value of the block
sysid
System name or subsystem path name.
se_setseeds
Output Arguments
oldseedstruct
Structure representing original seed values. The form of
oldseedstruct isthesameasthatofseedstruct.
status
Logical array whose nth entry is false if the nth block in
seedstruct meets one of these conditions:
Does not exist
Is not a SimEvents block
Does not have a seed parameter in its current configuration
See Also se_getseeds | se_randomizeseeds
Tutorials • Se ed Management Workflow for Random Number Generators
How To • “Setting Seed Values Programmatically”
• “Sharing Seeds Among Models”
2-9
sedb.bdelete
Purpose Delete breakpoints in discrete-event simulation
Syntax bdelete id1 id2 ...
bdelete(id_array) bdelete all
Description bdelete id1 id2 ... deletes the breakpoints having identifiers
id1, id2, and so on. To see breakpoints and their identifiers, use
sedb.breakpoints.
bdelete(id_array) deletes the breakpoints in the cell array id_array.
bdelete all deletes all break points.
Examples Manipulate timed breakpoints and run the simulation until a
breakpoint:
1 Begin a debug ger session for a particular model. At the MATLAB
command prompt, enter:
2-10
sedebug('sedemo_timeout')
2 Establish and view breakpoints. At the sedebug>> prompt, enter:
tbreak 0.5 tbreak 1 tbreak 1.5 breakpoints
The output lists the breakpoints:
Set b1 : Breakpoint for first operation at or after time 0.500000
Set b2 : Breakpoint for first operation at or after time 1.000000
Set b3 : Breakpoint for first operation at or after time 1.500000
List of Breakpoints:
ID Type Value Enabled
sedb.bdelete
b1 Timed 0.5 yes
b2 Timed 1 yes
b3 Timed 1.5 yes
3 Delete, disable, and enable some of the breakpoints. View the
resulting list:
bdelete b2 disable b3 disable b1 enable b3 breakpoints
The output is:
Deleted b2 : Breakpoint for f irst operation at or after time 1.000000
Disabled b3 : Breakpoint for firs t operation at or after time 1.500000
Disabled b1 : Breakpoint for firs t operation at or after time 0.500000
Enabled b3 : Breakpoint for first operation at or after time 1.500000
List of Breakpoints:
ID Type Value Enabled
b1 Timed 0.5 no
b3 Timed 1.5 yes
4 Run the simulation until the first enabled breakpoint:
cont
The partial output shows that b3 is the breakpoint at which the debugger stops. The debugger ignores the disabled breakpoint, and doe s not consider the previously deleted breakpoint,
Hit b3 : Breakpoint for first operation at or after time 1.500000
%==============================================================================%
Executing EntityGeneration Event (ev7) Time = 1.500000000000000
b2.
b1,
2-11
sedb.bdelete
: Entity = <none> Priority = 1
: Block = Time-Based Entity Generator
5 End the debugger session. At the sedebug>> prompt, enter:
sedb.quit
See Also sedb.breakpoints | sedb.disable
How To • “Using Breakpoints During Debugging”
2-12
sedb.blkbreak
Purpose Set breakpoint for discrete-event simulation block
Syntax blkbreak(blkid)
blkbreak(blkname) bid = blkbreak(...)
Description blkbreak(blkid) sets a breakpoint for the SimEvents block with
identifier
sedb.blklist.
blkbreak(blkname) sets a breakpoint for the SimEvents block with
path name
bid = blkbreak(...) returns the identifier of the breakpoint.
The following blocks are exceptions that d o n o t support block breakpoints:
Conn
Discrete Event Inport
blkid. To obtain a list of blocks and their identifiers, use
blkname.
Discrete Event Outport
Event-Based Random Number
Event-Based Sequence
Initial Value
Subsystem Configuration
Examples Examine a routing decision using a breakpoint on an Output Switch
block:
1 Begin a debug ger session for a particular model. At the MATLAB
command prompt, enter:
sedebug('sedemo_arq_selective_repeat')
2-13
sedb.blkbreak
2 Double-click the Receiver subsystem to open it. On the Output
Switch block inside the Receiver subsystem, establish a breakpoint. At the
sedebug>> prompt, enter:
blkbreak('sedemo_arq_selective_repeat/Receiver/Output Switch')
The output confirms the creation of the block breakpoint:
Set b1 : Breakpoint for block (blk29) sedemo_arq_selective_repeat/Receiver/Output Switch
3 Proceed until the simulation reaches the breakpoint:
cont
The end of the partial output indicates that the p input signal at the switch block changes from 2 to 1:
%..........................................................................%
Entity Advancing (en2)
: From = Receiver/Get Attribute
: To = Receiver/Zero Delay
%..........................................................................%
Scheduling ServiceCompletion Event (ev6)
: EventTime = 1.100000000000000 (Now)
: Priority = 10
: Entity = en2
: Block = Receiver/Zero Delay
%..........................................................................%
Detected Sample-Time Hit
: Block = Receiver/Discrete Event Subsystem/Din
%..........................................................................%
Scheduling Subsystem Event (ev7)
: EventTime = 1.100000000000000 (Now)
: Priority = 1
: Block = Receiver/Discrete Event Subsystem/Din
%..........................................................................%
Executing Scope
: Block = Receiver/CRC_check
2-14
sedb.blkbreak
%==============================================================================%
Executing Subsystem Event (ev7) Time = 1.100000000000000
: Entity = <none> Priority = 1
: Block = Receiver/Discrete Event Subsystem/Din
Hit b1 : Breakpoint for block (blk29) sedemo_arq_selective_repeat/Receiver/Output Switch
%..........................................................................%
Detected Either Value Change
: NewValue = 1
: PrevValue = 2
: Block = Receiver/Output Switch
4 Examine the source of the new value, 1. In the R eceive r subsystem,
the blocks and signal connections indicate that the p signal arises from a computation in the Discrete Event Subsystem block. The computationinvolvesanattributeofanentity. TheGetAttribute block dialog box indicates that the name of the attribute is
crc_check. To determine which entity has the attribute in this
particular computation, use the output from the preceding step. An entity with identifier Inspect the attributes of this entity, as follows:
en2 departed from the Get Attribute blo ck.
eninfo en2
The output shows a crc_c heck value of 0. According to the main description of the model, a CRC value of
Entity (en2) Current State T = 1.100000000000000
Location: Receiver/Zero Delay
Attributes:
Name Value
crc_check 0
seqNum 1
Timeouts, Timers: None
0 indicates an e rror.
2-15
sedb.blkbreak
5 Proceed in the simulation to the next operation of the switch b lock:
cont
The switch block is about to respond to the new value of the p input signal by scheduling a p ort selection event:
Hit b1 : Breakpoint for block (blk29) sedemo_arq_selective_repeat/Receiver/Output Switch
%..........................................................................%
Scheduling PortSelection Event (ev8)
: EventTime = 1.100000000000000 (Now)
: Priority = SYS1
: Block = Receiver/Output Switch
6 Proceed further in the simulation to the next operation:
cont
2-16
The output shows that the switch block is about to execute the port selection event. Exe cu ti n g that event causes the switch to se le ct the entity output port corresponding to the new value of the p input signal.
Hit b1 : Breakpoint for block (blk29) sedemo_arq_selective_repeat/Receiver/Output Switch
%==============================================================================%
Executing PortSelection Event (ev8) Time = 1.100000000000000
: Entity = <none> Priority = SYS1
: Block = Receiver/Output Switch
7 Continue to proceed further in the simulation to the next operation:
cont
sedb.blkbreak
The output shows that the entity with identifier en2 is about to advancetotheswitchblock:
%==============================================================================%
Executing ServiceCompletion Event (ev6) Time = 1.100000000000000
: Entity = en2 Priority = 10
: Block = Receiver/Zero Delay
%..........................................................................%
Entity Advancing (en2)
: From = Receiver/Zero Delay
: To = Receiver/Entity Departure Event to Function-Call Event
Hit b1 : Breakpoint for block (blk29) sedemo_arq_selective_repeat/Receiver/Output Switch
%..........................................................................%
Entity Advancing (en2)
: From = Receiver/Entity Departure Event to Function-Call Event
: To = Receiver/Output Switch
8 Continue to proceed further in the simulation to the next operation:
cont
The output shows that the entity advances to the Discarded Frames block, consistent with a CRC value of
Hit b1 : Breakpoint for block (blk29) sedemo_arq_selective_repeat/Receiver/Output Switch
%..........................................................................%
Entity Advancing (en2)
: From = Receiver/Output Switch
: To = Receiver/Discarded Frames
9 Disable the breakpoint for the Output Switch block by referencing
0, indicating an error:
its breakpoint identifier:
disable b1
2-17
sedb.blkbreak
Disabling a block breakpoint, when you are done investigating the block, helps you focus on operations that are relevant to you. The output confirms the disabling of the block breakpoint:
Disabled b1 : Breakpoint for block (blk29) sedemo_arq_selective_repeat/Receiver/Output Switch
10 End the debugger session. At the sedebug>> prompt, enter:
sedb.quit
See Also sedb.bdelete | sedb.blklist | sedb.breakpoints | sedb.cont
How To •“DefiningaBreakpoint”
2-18
sedb.blkinfo
Purpose Block information in discrete-event simulation
Syntax blkinfo(blkid)
blkinfo(blkname) blk_struct = blkinfo(...)
Description blkinfo(blkid) displays informati on about the SimEvents block with
identifier
sedb.blklist.
blkinfo(blkname) displays information about the SimEvents block
with path name
blk_struct = blkinfo(...) returns a structure that stores
information about the block.
The following blocks are exceptions that do not provide information:
Conn
Discrete Event Inport
blkid. To obtain a list of blocks and their identifiers, use
blkname.
Output Arguments
Discrete Event Outport
Event-Based Random Number
Event-Based Sequence
Initial Value
Subsystem Configuration
blk_struct
Structure that stores information about the block. The following table describes the each field appears.
blk_struct fields and the blocks for which
2-19
sedb.blkinfo
Field Block
Time
Block
BlockID
BlockType
Capacity
All blocks Current simulation time
All blocks Path name of the block
All blocks Block identifier
All blocks Type of block
All queue and s erver blocks
SelectedInputPort
SelectedOutputPort
GateStatus
InputEntity
CurrentReplica
Status
Input Switch Index of selected entity input port
Output Switch Index of selected entity output port
Enabled Gate
Replicate
Replicate
Replicate, Entity Combiner, and Entity Splitter
Description
Number of entities that the block can store at any one time
'open' or 'closed'
Identifier of the entity that the block is replicating
Identifier of the copy of the input entity that the block created and that is about to advance
Status of block.

Values for Replicate Block:

'Inactive'
2-20
'Replicating X/Y'. X is the index
of the entity output port through which the replica will depart.
Y
is the Number of entity output ports parameter of the block

Values for Entity Combine r B loc k:

'Inactive'
'Combining'

Values for Entity Splitter Block:

'Inactive'
sedb.blkinfo
Field Block
MemoryValue
Count
Entities
Signal Latch Value of the internal memory of the
Entity Departure Counter
All blocks that possess an entity input port
Description
'Splitting'
block
Number of entities th at have departed from this block and arrived at subsequent storage b locks, since the simulation start or the last reset, whichever occurred later.
Structure array, of which each element has these fields:
ID — Entity identifier
Status (queue and server blocks
only) — Status of the en tit y with respect to the block.
Entity Status Values in Queue
Blocks:
- 'Advancing'
- 'Queuing'
- 'Queued'
- 'Timed Out'
Entity Status Values in Server
Blocks:
- 'Advancing'
- 'In Service'
- 'Service Completed'
- 'Preempted'
- 'Timed Out'
2-21
sedb.blkinfo
Field Block
Examples View information about a block:
1 Begin a debug ger session for a particular model. At the MATLAB
command prompt, enter:
sedebug('sedemo_start_timer_read_timer')
2 Proceed in the simulation. At the sedebug>> prompt, enter:
tbreak 2.51 cont
Description
Event (server blocks only) —
Identifier of the service completion event for the entity
EventTime (server blocks only) —
Time of the service completion event for the entity
TimeInQueue (queue blocks only) —
Length of time the entity has been in the queue
2-22
The partial output indicates that the server is about to execute a service completion event:
Hit b1 : Breakpoint for first operation at or after time 2.510000
%==============================================================================%
Executing ServiceCompletion Event (ev8) Time = 2.581301297500028
: Entity = en4 Priority = 1
: Block = Infinite Server
3 View information about the block that is a bout to execute the event:
sedb.blkinfo
blkname = gceb blkid = gcebid
The output is:
blkname =
sedemo_start_timer_read_timer/Infinite Server
blkid =
blk7
4 Proceed further in the simulation:
step
The output shows that the entity is about to depart from the server:
%..........................................................................%
Entity Advancing (en4)
: From = Infinite Server
: To = Read Timer
5 Use the identifier, blkid, to get information about the block and
the status of entities in it:
% Display information in Command Win dow. blkinfo(blkid) % Store information in str uct ure. blkdetails = blkinfo(blkid) % Store status of entities in cell array. blkentities = {blkdetails.Entities.Status}'
The output is:
2-23
sedb.blkinfo
Infinite Server Current State T = 2.581301297500028
Block (blk7): Infinite Server
Entities (Capacity = Inf):
Pos ID Status Event EventTime
1 en2 In Service ev4 2.7303849396254689
2 en4 Advancing ev8 2.581301297500028
3 en5 In Service ev10 2.974736350905304
blkdetails =
Time: 2.5813
Block: 'sedemo_start_timer_read_timer/Infinite Server'
BlockID: 'blk7'
BlockType: 'Infinite Server'
Capacity: Inf
Entities: [1x3 struct]
2-24
blkentities =
'In Service'
'Advancing'
'In Service'
6 Get more information about one of the entities by using data from the
blkdetails structure as an input argument to the eninfo function:
adv_eninfo = eninfo(blkdetails.Entities(1).ID); time_in_system = adv_eninfo.Timers.ElapsedTime
The output is:
time_in_system =
1.5813
7 End the debugger session. At the sedebug>> prompt, enter:
sedb.quit
See Also sedb.blkbreak | sedb.blklist | sedb.gceb
How To • “Inspecting Entities, Blocks, and Events”
sedb.blkinfo
2-25
sedb.blklist
Purpose Blocks and their identifiers in discrete-event simulation
Syntax blklist
blk_cell = blklist
Description blklist displays a list of event-based blocks and block identifiers in
the model that you are debugging. The list includes all blocks for which
blkinfo or blkbreak is valid. The list excludes virtual subsystems but
includes relevant blocks inside virtual s ubsystems. In the Command Window, you can click hyperlinks to highlight the blocks in the model window.
blk_cell = blklist returns the same information as blklist in a cell
array of strings. The first column of The corresponding cells in the second column contain block path names.
Examples In the Command Window, view the block list and store it in a variable:
1 Begin a debug ger session for a particular model. At the MATLAB
command prompt, enter:
blk_cell contains block identifiers.
2-26
sedebug('sedemo_count_attributes')
2 View the list of blocks. At the sedebug>> prompt, enter:
blklist
The output is:
List of blocks in model: sedemo_count_attributes
blk1 Entity Data blk5 Entity Sink blk4 Get Attribute blk3 Set Attribute blk2 Time-Based Entity Generator
sedb.blklist
3 Store the list of blocks in a variable and exam ine one row of the
cell array:
x = blklist; x{1,:}
The output indicates the identifier and path name of one block in the model:
ans =
blk1
ans =
sedemo_count_attributes/Entity Data
4 End the debugger session. At the sedebug>> prompt, enter:
sedb.quit
See Also sedb.blkbreak | sedb.blkinfo
How To •“InspectingBlocks”
2-27
sedb.breakpoints
Purpose List breakpoints in discrete-event simulation
Syntax breakpoints
b_struct = breakpoints
Description breakpoints displays a list of all breakpoints in the simulation. The
list includes disabled breakpoints, as well as breakpoints that the debugger already hit.
b_struct = breakpoints returns a structure array that stores
information about breakpoints in the simulation.
Output Arguments
b_struct
Structure a rray that stores information about breakpoints. The following table describes the fields of each structure in the array.
Field
ID
Type
Value
Enabled
Examples Set and view breakpoints:
1 Begin a debug ger session for a particular model. At the MATLAB
command prompt, enter:
sedebug('sedemo_timeout')
2 Establish breakpoints and then view them in the Command Window.
At the
sedebug>> prompt, enter:
Description
Breakpoint identifier
Type of breakpoint
Value associated with the breakpoint, as a string
1, if the breakpoint is enabled; 0 otherwise
2-28
tbreak 0.5
sedb.breakpoints
tbreak 1 tbreak 1.5 breakpoints
The output confirms the setting of breakpoints and displays th e list of breakpoints:
Set b1 : Breakpoint for first operation at or after time 0.500000
Set b2 : Breakpoint for first operation at or after time 1.000000
Set b3 : Breakpoint for first operation at or after time 1.500000
List of Breakpoints:
ID Type Value Enabled
b1 Timed 0.5 yes
b2 Timed 1 yes
b3 Timed 1.5 yes
3 End the debugger session. At the sedebug>> prompt, enter:
sedb.quit
Manipulate the structure array that is the output from breakpoints:
1 Begin a debug ger session for a particular model. At the MATLAB
command prompt, enter:
sedebug('sedemo_timeout')
2 Establish b reakpoints and then record them in a structure variable.
At the
sedebug>> prompt, enter:
tbreak 0.5 tbreak 1 tbreak 1.5 b = breakpoints
2-29
sedb.breakpoints
The output confirms the setting of breakpoints and displays an initial view of the structure
3 View information about the first breakpoint:
The output is a structure:
b:
Set b1 : Breakpoint for first operation at or after time 0.500000
Set b2 : Breakpoint for first operation at or after time 1.000000
Set b3 : Breakpoint for first operation at or after time 1.500000
b=
1x3 struct array with fields:
ID
Type
Value
Enabled
b1 = b(1)
2-30
b1 =
ID: 'b1'
Type: 'Timed'
Value: '0.5'
Enabled: 1
4 Store the IDs of the enabled breakpoints in a cell array, bid:
idx = find([b.Enabled]); bid = {b(idx).ID}
The output is:
bid =
sedb.breakpoints
'b1' 'b2' 'b3'
5 End the debugger session. At the sedebug>> prompt, enter:
sedb.quit
See Also sedb.blkbreak | sedb.tbreak | sedb.evbreak | sedb.bdelete |
sedb.disable
How To •“DefiningaBreakpoint”
2-31
sedb.cont
Purpose Continue simulation until next breakpoint
Syntax cont
Description cont continues the simulation until it reaches the next breakpoint or
the end, whichever comes first.
Examples Establish a breakpoint at T=2 and then run the simulation until that
point:
1 Begin a debug ger session for a particular model. At the MATLAB
command prompt, enter:
sedebug('sedemo_timeout')
2 Proceed in the simulation. At the sedebug>> prompt, enter:
tbreak 2 detail none cont
2-32
Theoutputendswithamessagedescribingthecontextofthe simulation at T=2:
Set b1 : Breakpoint for first operation at or after time 2.000000
Event Operations (ev) : off
Entity Operations (en) : off
Event Calendar (cal) : off
Hit b1 : Breakpoint for first operation at or after time 2.000000
%==============================================================================%
Executing EntityGeneration Event (ev10) Time = 2.000000000000000
: Entity = <none> Priority = 1
: Block = Time-Based Entity Generator
3 End the debugger session. At the sedebug>> prompt, enter:
sedb.quit
See Also sedb.blkbreak | sedb.tbreak | sedb.evbreak
How To •“DefiningaBreakpoint”
• “Using Breakpoints During Debugging”
sedb.cont
2-33
sedb.currentop
Purpose Current operation in discrete-event simulation
Syntax currentop
Description currentop displays the most recent message in the simulation log.
If this message represents a depe nde nt operation, the output also includes a message about the most recent independent operation in the simulation log.
Definitions Independent Opera tion
An independent operation is one of these operations:
Initialization of the mode l or any Time-Bas ed Entity Generator blocks
in the model. For more information, see “Initialization Messages”.
Execution of an event on the event calendar. How ev er, if the
application executes an event without scheduling it on the event calendar, the event cannot be the basis of an independent operation. To learn which events are on the event calendar, see “Role of the Event Calendar”.
Detection by a reactive port or a monitoring port o f a relevant update
in a time-based i n put sign al. You can think of these relevant updates as zero crossings or level crossings. However, if the input signal is an event-based signal or if the input port is not a reactive or monitoring port, the update is not an independent operation.
For more information, see “Independent Operations and Consequences in the Debugger”.
Dependent Operation
A dependent operation is a consequence of an independent operation.
Examples Compare the current operation display with the simulation log:
opts_struct = se_getdbopts; opts_struct.StartFcn={'step over','step',...
2-34
sedb.currentop
'step','step','currentop','quit'};
sedebug('sedemo_event_priorities',opts_struct)
The output shows that the display of the current operation includes the last entry in the simulation log, which is the current operation. The display a lso includes the last unindented entry in the simulation log, representing the latest independent operation.
2-35
sedb.currentop
y
*** SimEvents Debugger ***
Functions | Quick Start | Debugger Help
%==============================================================================% Initializing Model sedemo_event_priorities %==============================================================================% Initializing Time-Based Entity Generators
%..........................................................................%
Scheduling EntityGeneration Event (ev1) : EventTime = 0.000000000000000 (Now) : Priority = 2 : Block = Time-Based Entity Generator %==============================================================================%
%==============================================================================%
Executing EntityGeneration Event (ev1) Time = 0.000000000000000
Executing EntityGeneration Event (ev1) Time = 0.000000000000000
: Entity = <none> Priority = 2
: Entity = <none> Priority = 2
: Block = Time-Based Entity Generator
: Block = Time-Based Entity Generator
%..........................................................................%
Generating Entity (en1) : Block = Time-Based Entity Generator
%..........................................................................%
Entity Advancing (en1) : From = Time-Based Entity Generator : To = FIFO Queue
%..........................................................................%
%..........................................................................%
Entity Advancing (en1)
Entity Advancing (en1)
: From = FIFO Queue
: From = FIFO Queue
: To = Single Server
: To = Single Server
Current Operation:
%==============================================================================% Executing EntityGeneration Event (ev1) Time = 0.000000000000000 : Entity = <none> Priority = 2 : Block = Time-Based Entity Generator
%..........................................................................%
Entity Advancing (en1) : From = FIFO Queue : To = Single Server
SimEvents Debugger: Abort
Independent operation
Dependent operation
How To •“SimulationLogintheDebugger”
• “Independent Operations and Consequences in the Debugger”
• “Inspecting the Current Point in the Debugger”
2-36
sedb.detail
Purpose Customize debugger simulation log in discrete-event simulation
Syntax detail('none')
detail('default') detail('all') prev = detail(...) detail(struc) detail(paramname1, paramvalue1, paramname2, paramvalue2,...) detail curr = detail
Description detail('none') configures the debugger to omit all simulation log
messages, except upon reaching breakpoints. This syntax is the same as
detail('en',0,'ev',0,'cal',0). Y ou cannot use the step function to
step to anything other than breakpoints when the debugger omits all simulation log messages.
detail('default') resets the detail settings to their default values.
This syntax is the same as
detail('en',1,'ev',1,'cal',0).
detail('all') configures the debugger to show all
simulation log messages. This syntax is the same as
detail('en',1,'ev',1,'cal',1).
prev = detail(...) configures the debugger based on the inputs, and
also returns a structure that describes the previous detail settings.
detail(struc) uses the structure struc to establish detail settings.
detail(paramname1, paramvalue1, paramname2, paramvalue2,...)
configures the debugger to show or omit certainkindsofmessagesinthesimulationlog. Youcanspecifyone, two, or three pairs of parameter names, values,
detail displays the current detail settings.
curr = detail returns a structure that describes the current detail
paramvalueN.
paramnameN,andparameter
settings.
2-37
sedb.detail
Input Arguments
paramnameN
Name of detail setting.
'ev'
'en'
'cal'
paramvalueN
Value of detail setting.
0
1
Event operations, except if at least one detail setting is 1, independent operations representing event executions appear. The exception holds true even if the
Entity operations
Event calendar information
Omit messages, except upon reaching a breakpoint. Omitting entity messages or event messages also means that you cannot rely on the to an operation that corresponds to an omitted message.
Show messages.
'ev' setting is 0.
step function to step
Output Arguments
2-38
struc
Structure having three fields describing the detail settings that you want. Field names are the same as the names in the table that describes the as the values in the table that describes the
curr
Structure that describes the current detail settings. Field names a re the same as the names in the table that describes the
paramnameN input. Field values are the same as the values in the
table that describes the
paramnameN input. Field values are the same
paramvalueN input.
paramvalueN input.
prev
Structure that describes the pr evious detail settings before changing them. Field names are the same as the names in the table that describes the
paramnameN input. Field values are the
same as the values in the table that describes the input.
Examples Configure displays for breakpoints and stepping:
1 Begin a debug ger session for a particular model. At the MATLAB
command prompt, enter:
sedebug('sedemo_timeout')
2 Proceed in the simulation, suppressing the simulation log until the
debugger reaches a breakpoint. At the
tbreak 2 prev = detail('none') cont
sedebug>> prompt, enter:
sedb.detail
paramvalueN
The output ends with the context of the simulation at T =2:
Set b1 : Breakpoint for first operation at or after time 2.000000
prev =
ev: 1
en: 1
cal: 0
Hit b1 : Breakpoint for first operation at or after time 2.000000
%==============================================================================%
Executing EntityGeneration Event (ev10) Time = 2.000000000000000
: Entity = <none> Priority = 1
2-39
sedb.detail
: Block = Time-Based Entity Generator
3 Now that the simulation is at a point of interest, configure the
debugger to show the simulation log. This configuration makes subsequent
step operations more informative. Then move forward
in the simulation:
detail(prev) step over
The output confirms the change in detail settings and then shows the result of enabling the simulation log:
Event Operations (ev) : on
Entity Operations (en) : on
Event Calendar (cal) : off
%..........................................................................%
Generating Entity (en4)
: Block = Time-Based Entity Generator
%..........................................................................%
Entity Advancing (en4)
: From = Time-Based Entity Generator
: To = Schedule Timeout
%..........................................................................%
Scheduling Timeout Event (ev11)
: EventTime = 3.000000000000000
: Priority = 1700
: Entity = en4
: Block = Schedule Timeout
%..........................................................................%
Entity Advancing (en4)
: From = Schedule Timeout
: To = Infinite Server
%..........................................................................%
Scheduling ServiceCompletion Event (ev12)
: EventTime = 2.581301297500028
2-40
sedb.detail
: Priority = 1
: Entity = en4
: Block = Infinite Server
%..........................................................................%
Executing Scope
: Block = Number of En tities Time-Stamped
%..........................................................................%
Scheduling EntityGeneration Event (ev13)
: EventTime = 2.500000000000000
: Priority = 1
: Block = Time-Based Entity Generator
%==============================================================================%
Executing Timeout Event (ev5) Time = 2.000000000000000
: Entity = en2 Priority = 1700
: Block = Infinite Server
4 End the debugger session. At the sedebug>> prompt, enter:
sedb.quit
See Also sedb.blkbreak | sedb.cont | sedb.evbreak | sedb.tbreak
How To • “Customiz ing the Debugger Simulation Log”
2-41
sedb.disable
Purpose Disable breakpoints in discrete-event simulation
Syntax disable id1 id2 ...
disable(id_array) disable all
Description disable id1 id2 ... disables the breakpoints having identifiers
id1, id2, and so on. To see breakpoints and their identifiers, use
sedb.breakpoints. A disabled breakpoint remains in the list but the sedb.cont function ignores it.
disable(id_array) disables the breakpoints in the cell array id_array.
disable all disables all breakpoints.
Examples Manipulate timed breakpoints and run the simulation until a
breakpoint:
1 Begin a debug ger session for a particular model. At the MATLAB
command prompt, enter:
2-42
sedebug('sedemo_timeout')
2 Establish and view breakpoints. At the sedebug>> prompt, enter:
tbreak 0.5 tbreak 1 tbreak 1.5 breakpoints
The output lists the breakpoints:
Set b1 : Breakpoint for first operation at or after time 0.500000
Set b2 : Breakpoint for first operation at or after time 1.000000
Set b3 : Breakpoint for first operation at or after time 1.500000
List of Breakpoints:
sedb.disable
ID Type Value Enabled
b1 Timed 0.5 yes
b2 Timed 1 yes
b3 Timed 1.5 yes
3 Delete, disable, and enable some of the breakpoints. View the
resulting list:
bdelete b2 disable b3 disable b1 enable b3 breakpoints
The output is:
Deleted b2 : Breakpoint for f irst operation at or after time 1.000000
Disabled b3 : Breakpoint for firs t operation at or after time 1.500000
Disabled b1 : Breakpoint for firs t operation at or after time 0.500000
Enabled b3 : Breakpoint for first operation at or after time 1.500000
List of Breakpoints:
ID Type Value Enabled
b1 Timed 0.5 no
b3 Timed 1.5 yes
4 Run the simulation until the first enabled breakpoint:
cont
The partial output shows that b3 is the breakpoint at which the debugger stops. The debugger ignores the disabled breakpoint, and doe s not consider the previously deleted breakpoint,
Hit b3 : Breakpoint for first operation at or after time 1.500000
%==============================================================================%
b2.
b1,
2-43
sedb.disable
Executing EntityGeneration Event (ev7) Time = 1.500000000000000
: Entity = <none> Priority = 1
: Block = Time-Based Entity Generator
5 End the debugger session. At the sedebug>> prompt, enter:
sedb.quit
See Also sedb.breakpoints | sedb.enable | sedb.bdelete
How To • “Using Breakpoints During Debugging”
2-44
sedb.enable
Purpose Enable breakpoints in discrete-event simulation
Syntax enable id1 id2 ...
enable all
Description enable id1 id2 ... enables the breakpoints having identifiers
id1, id2, and so on. To see breakpoints and their identifiers, use
sedb.breakpoints.
enable(id_array) enables the breakpoints in the cell array, id_array.
enable all enables all breakpoints.
Examples Manipulate timed breakpoints and run the simulation until a
breakpoint:
1 Begin a debug ger session for a particular model. At the MATLAB
command prompt, enter:
sedebug('sedemo_timeout')
2 Establish and view breakpoints. At the sedebug>> prompt, enter:
tbreak 0.5 tbreak 1 tbreak 1.5 breakpoints
The output lists the breakpoints:
Set b1 : Breakpoint for first operation at or after time 0.500000
Set b2 : Breakpoint for first operation at or after time 1.000000
Set b3 : Breakpoint for first operation at or after time 1.500000
List of Breakpoints:
ID Type Value Enabled
b1 Timed 0.5 yes
2-45
sedb.enable
b2 Timed 1 yes
b3 Timed 1.5 yes
3 Delete, disable, and enable some of the breakpoints. View the
resulting list:
bdelete b2 disable b3 disable b1 enable b3 breakpoints
The output is:
Deleted b2 : Breakpoint for f irst operation at or after time 1.000000
Disabled b3 : Breakpoint for firs t operation at or after time 1.500000
Disabled b1 : Breakpoint for firs t operation at or after time 0.500000
Enabled b3 : Breakpoint for first operation at or after time 1.500000
List of Breakpoints:
2-46
ID Type Value Enabled
b1 Timed 0.5 no
b3 Timed 1.5 yes
4 Run the simulation until the first enabled breakpoint:
cont
The partial output shows that b3 is the breakpoint at which the debugger stops. The debugger ignores the disabled breakpoint, and doe s not consider the previously deleted breakpoint,
Hit b3 : Breakpoint for first operation at or after time 1.500000
%==============================================================================%
Executing EntityGeneration Event (ev7) Time = 1.500000000000000
: Entity = <none> Priority = 1
b2.
b1,
: Block = Time-Based Entity Generator
5 End the debugger session. At the sedebug>> prompt, enter:
sedb.quit
See Also sedb.breakpoints | sedb.disable | sedb.bdelete
How To • “Using Breakpoints During Debugging”
sedb.enable
2-47
sedb.eninfo
Purpose Entity information in discrete-event simulation
Syntax eninfo(enid)
en_struct = eninfo(enid)
Description eninfo(enid) displays information about the location, attributes,
timers, and timeouts on an entity.
en_struct = eninfo(enid) returns a structure that stores information
about the entity.
enid is the identifier of the entity.
Output Arguments
en_struct
Structure that stores information about the entity. The following table describes the
Field
Time
Location
Attributes
Timers
Timeouts
en_struct fields.
Description
Current simulation time
Path name of the block containing the entity
Structure whose field names and values match the names and values of the attributes of the entity
Structure array, of which each element has these fields:
Tag —Timertag
ElapsedTime — Time elapsed since the
timer started
Structure array, of which each element has these fields:
Tag —Timeouttag
2-48
sedb.eninfo
Field
Description
TimeOfTimeout — Scheduled time of
timeout event
Event— Identifier of timeout event
Examples View the values of the attributes of an entity:
1 Begin a debug ger session for a particular model. At the MATLAB
command prompt, enter:
sedebug('sedemo_star_routing')
2 Proceed in the simulation. At the sedebug>> prompt, enter:
tbreak 0.1 cont
The partial output shows the entity identifier, en1,inthedisplay:
Hit b1 : Breakpoint for first operation at or after time 0.100000
%==============================================================================%
Executing ServiceCompletion Event (ev2) Time = 0.300000000000000
: Entity = en1 Priority = 5
: Block = Distribution Center/Infinite Server
3 Get the ID of an entity:
% Get ID of current entity. enid = gcen
The workspace variable, enid, holds the same entity identifier, en1, from the display:
enid =
2-49
sedb.eninfo
en1
4 Use the identifier, enid, to get information about the entity:
% Display information in Command Win dow. eninfo(enid) % Store information in str uct ure. endetails = eninfo(enid) % View attributes. enattrs = endetails.Attributes % View one attribute. enServiceProcess = enattrs.ServiceProcess % Equivalently, view one attribute starting from endetails. enServiceProcess = endetails.Attributes.ServiceProcess;
The output is:
Entity (en1) Current State T = 0.300000000000000
Location: Distribution Center/Infinite Server
2-50
Attributes:
Name Value
CurrentRoute 1
CurrentServiceTime 2
CurrentStep 2
JobClass 1
JobID 1
JobServiceStatus [1x15]
LastServiceLocation 0
ServiceProcess [6x1]
ServiceTime [6x1]
Timeouts, Timers: None
endetails =
sedb.eninfo
Time: 0.3
Location: 'sedemo_star_routing/Distribution Center/Infinite Server'
Attributes: [1x1 struct]
Timers: [0x0 struct]
Timeouts: [0x0 struct]
enattrs =
CurrentRoute: 1
CurrentServiceTime: 2
CurrentStep: 2
JobClass: 1
JobID: 1
JobServiceStatus: [0 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN]
LastServiceLocation: 0
ServiceProcess: [6x1 double]
ServiceTime: [6x1 double]
enServiceProcess =
1
2
4
2
3
5
5 End the debugger session. At the sedebug>> prompt, enter:
sedb.quit
See Also sedb.gcen | sedb.blkinfo | sedb.evinfo | sedb.currentop
How To • “Obtaining Entity Identifiers”
2-51
sedb.eninfo
• “Inspecting Entities, Blocks, and Events”
2-52
sedb.evbreak
Purpose Set breakpoint for execution or cancelation of event
Syntax evbreak(evid)
bid = evbreak(evid)
Description evbreak(evid) sets a breakpoint for execution or cancelation of the
event with identifier, on the event calendar and their identifiers, use
bid = evbreak(evid) returns the identifier of the breakpoint.
Examples Set a breakpoint on a service completion event:
1 Begin a debug ger session for a particular model. At the MATLAB
command prompt, enter:
sedebug('sedemo_server_service_time')
2 Proceed in the simulation. At the sedebug>> prompt, enter:
evid,inthesimulation. Toobtainalistofevents
sedb.evcal.
step over
The output is:
%==============================================================================%
Initializing Time-Based Entity Generators
%..........................................................................%
Scheduling EntityGeneration Event (ev1)
: EventTime = 0.000000000000000 (Now)
: Priority = 500
: Block = Time-Based Entity Generator
%..........................................................................%
Scheduling EntityGeneration Event (ev2)
: EventTime = 0.000000000000000 (Now)
: Priority = 500
: Block = Time-Based Entity Generator 1
%..........................................................................%
Scheduling EntityGeneration Event (ev3)
2-53
sedb.evbreak
: EventTime = 0.000000000000000 (Now)
: Priority = 500
: Block = Time-Based Entity Generator 3
%==============================================================================%
Executing EntityGeneration Event (ev1) Time = 0.000000000000000
: Entity = <none> Priority = 500
: Block = Time-Based Entity Generator
3 Proceed further:
step over
The output shows that a service completion event with identifier,
ev4, appears on the event calendar. The scheduled time of the event
is T=1.
%..........................................................................%
Generating Entity (en1)
: Block = Time-Based Entity Generator
%..........................................................................%
Entity Advancing (en1)
: From = Time-Based Entity Generator
: To = Single Server
%..........................................................................%
Scheduling ServiceCompletion Event (ev4)
: EventTime = 1.000000000000000
: Priority = 500
: Entity = en1
: Block = Single Server
%..........................................................................%
Executing Scope
: Block = Num. Entities
%..........................................................................%
Scheduling EntityGeneration Event (ev5)
: EventTime = 1.000000000000000
: Priority = 500
: Block = Time-Based Entity Generator
%==============================================================================%
2-54
sedb.evbreak
Executing EntityGeneration Event (ev2) Time = 0.000000000000000
: Entity = <none> Priority = 500
: Block = Time-Based Entity Generator 1
4 Set a bre
to exec
akpoint that causes the debugger to stop when it is about
utetheservicecompletionevent,
ev4:
evbreak ev4
The output confirms the operation:
Set b1 : Breakpoint for execu tion or cancelation of event ev4
5 Run the simulation until the breakpoint:
cont
The partial output shows that the debugger proceeds through a different event at T=1, and stops upon hitting the breakpoint at event
ev4. Because that event is not the first event the simulation executes
at that time, the example shows how an event breakpoint differs from a timed breakpoint. A timed breakpoint at T=1 would have caused the debugger to stop upon the first event at this time,
%==============================================================================%
Executing ServiceCompletion Event (ev6) Time = 1.000000000000000
: Entity = en2 Priority = 300
: Block = Infinite Server
%..........................................................................%
Entity Advancing (en2)
: From = Infinite Server
: To = Entity Sink2
%..........................................................................%
Destroying Entity (en2)
: Block = Entity Sink2
ev6.
Hit b1 : Breakpoint for execution or cancelation of event ev4
%==============================================================================%
2-55
sedb.evbreak
Executing ServiceCompletion Event (ev4) Time = 1.000000000000000
: Entity = en1 Priority = 500
: Block = Single Server
6 End the debugger session. At the sedebug>> prompt, enter:
sedb.quit
See Also sedb.evcal | sedb.cont | sedb.breakpoints | sedb.bdelete
How To •“DefiningaBreakpoint”
2-56
sedb.evcal
Purpose Event calendar of discrete-event simulation
Syntax evcal
cal_struct = evcal
Description evcal displays the list of events on the event calendar. The listing
for the event in progress or the event selected for execution includes the characters identifier. The display includes this event unless all its immediate consequences are complete.
cal_struct = evcal returns a structure that stores information about
the event calendar.
=>. These characters appear to the left of the event
Output Arguments
cal_struct
Structure that stores information about the event calendar. The
cal_struct fields are in the following table.
Field
Time
ExecutingEvent
Description
Current simulation time
Structure that describes the event in progress or selected for execution. The structure has these fields:
ID —Eventidentifier
EventType — Type of event
EventTime — Scheduled time of event
Priority —Priorityofevent
Entity — Identifier of entity associated
with the event
Block — Path name of block that executes
the event
2-57
sedb.evcal
Field
PendingEvents
Description
Structure array that describes events that are not in progress or selected for execution. Each structure in the array has these fields:
ID —Eventidentifier
EventType — Type of event
EventTime — Scheduled time of event
Priority —Priorityofevent
Entity — Identifier of entity associated
with the event
Block — Path name of block that executes
the event
Examples View the event calendar and then manipulate a structure variable that
storesthesameinformation:
1 Begin a debug ger session for a particular model. At the MATLAB
command prompt, enter:
sedebug('sedemo_timeout')
2-58
2 Proceed in the simulation. At the sedebug>> prompt, enter:
tbreak 2 detail none cont
Theoutputendswithamessagedescribingthecontextof simulation at T=2:
Set b1 : Breakpoint for first operation at or after time 2.000000
Event Operations (ev) : off
the
sedb.evcal
Entity Operations (en) : off
Event Calendar (cal) : off
Hit b1 : Breakpoint for first operation at or after time 2.000000
%==============================================================================%
Executing EntityGeneration Event (ev10) Time = 2.000000000000000
: Entity = <none> Priority = 1
: Block = Time-Based Entity Generator
3 View t
he event calendar:
% View event calendar. evcal
The following output lists all events on the event calendar:
Current Time = 2.000000000000000
%------------------------------------------------------------------------------%
Events in the Event Calendar
ID EventTime EventType Priority Entity Block
=> ev10 2.000000000000000 EntityGeneration 1 <none> Time-Based Entity Generator
ev5 2.000000000000000 Timeout 1700 en2 Infinite Server
ev6 2.730384939625469 ServiceCompletion 1 en2 Infinite Server
4 Store the event calendar as a structure and get more information
about the first pending event:
% Store event calendar as a structure. cal_struct = evcal ev5struct = cal_struct.PendingEvents(1)
The output is:
cal_struct =
Time: 2
2-59
sedb.evcal
ExecutingEvent: [1x1 struct]
PendingEvents: [2x1 struct]
ev5struct =
ID: 'ev5'
EventType: 'Timeout'
EventTime: 2
Priority: '1700'
Entity: 'en2'
Block: 'sedemo_timeout/Infinite Server'
5 Find the types of pending events whose scheduled time is the current
simulation time:
idx = find([cal_struct.PendingEvents.EventTime] == simtime); simult_event_types = {cal_struct.PendingEvents(idx).EventType}'
The output is:
2-60
simult_event_types =
'Timeout'
6 Store all event times in a vector:
ev_times = cal_struct.ExecutingEvent.EventTime; ev_times = [ev_times, cal_struct.PendingEvents.EventTime]'
The output is:
ev_times =
2.0000
2.0000
2.7304
7 End the debugger session. At the sedebug>> prompt, enter:
sedb.quit
After the debugger session ends, cal_str uct and the other variables remain in the workspace.
See Also sedb.evinfo
How To • “Viewing the Event Calendar”
sedb.evcal
2-61
sedb.evinfo
Purpose Event information in discrete-event simulation
Syntax ev_struct = evinfo(evid)
Description ev_struct = evinfo(evid) returns a structure that stores information
about the event with identifier event calendar and their identifiers, use
evid. To obtain a list of events on the
sedb.evcal.
Output Arguments
ev_struct
Structure that stores informatio n about the event. The follow ing table describes the
Field
ID
EventType
EventTime
Priority
Entity
Block
Description
Event identifier
Type of event
Scheduled time of event
Priority of event
Identifier of entity associated with the event
Path name of block that executes the event
Examples View event information:
1 Begin a debug ger session for a particular model. At the MATLAB
command prompt, enter:
sedebug('sedemo_count_attributes')
2 Proceed in the simulation. At the sedebug>> prompt, enter:
ev_struct fields.
2-62
step
The output shows the identifier, ev1,inthedisplay:
sedb.evinfo
%==============================================================================%
Initializing Time-Based Entity Generators
%..........................................................................%
Scheduling EntityGeneration Event (ev1)
: EventTime = 0.000000000000000 (Now)
: Priority = 1
: Block = Time-Based Entity Generator
3 View information about the event that the application is about to
schedule:
evid = gcev evdetails = evinfo(evid)
The output shows the same identifier, ev1, in the workspace variable,
evid,andtheID field of the structure, evdetails:
evid =
ev1
evdetails =
ID: 'ev1'
EventType: 'EntityGeneration'
EventTime: 0
Priority: '1'
Entity: ''
Block: [1x51 char]
4 End the debugger session. At the sedebug>> prompt, enter:
sedb.quit
See Also sedb.gcev | sedb.evcal
2-63
sedb.evinfo
How To • “Inspecting Entities, Blocks, and Events”
2-64
sedb.gceb
Purpose Name of currently executing block in discrete-event simulation
Syntax blkname =gceb
Description blkname =gcebreturns the path name of the block associated with the
current operation. If the current operation is not associated with a block,
blkname is an empty string. If an entity is advancing, blkname
indicates the block from which the entity departs.
Examples View information about a block:
1 Begin a debug ger session for a particular model. At the MATLAB
command prompt, enter:
sedebug('sedemo_start_timer_read_timer')
2 Proceed in the simulation. At the sedebug>> prompt, enter:
tbreak 2.51 cont
The partial output indicates that the server is about to execute a service completion event:
Hit b1 : Breakpoint for first operation at or after time 2.510000
%==============================================================================%
Executing ServiceCompletion Event (ev8) Time = 2.581301297500028
: Entity = en4 Priority = 1
: Block = Infinite Server
3 View information about the block that is a bout to execute the event:
blkname = gceb blkid = gcebid
The output is:
2-65
sedb.gceb
blkname =
sedemo_start_timer_read_timer/Infinite Server
blkid =
blk7
4 Proceed further in the simulation:
step
The output shows that the entity is about to depart from the server:
%..........................................................................%
Entity Advancing (en4)
: From = Infinite Server
: To = Read Timer
2-66
5 Use the identifier, blkid, to get information abo
ut the block and
the status of entities in it:
% Display information in Command Win dow. blkinfo(blkid) % Store information in str uct ure. blkdetails = blkinfo(blkid) % Store status of entities in cell array. blkentities = {blkdetails.Entities.Status}'
The output is:
Infinite Server Current State T = 2.581301297500028
Block (blk7): Infinite Server
Entities (Capacity = Inf):
sedb.gceb
Pos ID Status Event EventTime
1 en2 In Service ev4 2.7303849396254689
2 en4 Advancing ev8 2.581301297500028
3 en5 In Service ev10 2.974736350905304
blkdetails =
Time: 2.5813
Block: 'sedemo_start_timer_read_timer/Infinite Server'
BlockID: 'blk7'
BlockType: 'Infinite Server'
Capacity: Inf
Entities: [1x3 struct]
blkentities =
'In Service'
'Advancing'
'In Service'
6 Get more information about one of the entities by using data from the
blkdetails structure as an input argument to the eninfo function:
adv_eninfo = eninfo(blkdetails.Entities(1).ID); time_in_system = adv_eninfo.Timers.ElapsedTime
The output is:
time_in_system =
1.5813
7 End the debugger session. At the sedebug>> prompt, enter:
sedb.quit
2-67
sedb.gceb
See Also sedb.blkinfo
How To • “Inspecting the Current Point in the Debugger”
2-68
sedb.gcebid
Purpose Identifier of currently executing block in discrete-event simulation
Syntax blkid = gcebid
Description blkid = gcebid returns the identifier of the block associated with
the current operation. If the current operation is not associated with ablock, indicates the block from which the entity departs.
Examples View information about a block:
1 Begin a debug ger session for a particular model. At the MATLAB
2 Proceed in the simulation. At the sedebug>> prompt, enter:
blkid is an empty string. If an entity is advancing, blkid
command prompt, enter:
sedebug('sedemo_start_timer_read_timer')
tbreak 2.51 cont
The partial output indicates that the server is about to execute a service completion event:
Hit b1 : Breakpoint for first operation at or after time 2.510000
%==============================================================================%
Executing ServiceCompletion Event (ev8) Time = 2.581301297500028
: Entity = en4 Priority = 1
: Block = Infinite Server
3 View information about the block that is a bout to execute the event:
blkname = gceb blkid = gcebid
The output is:
2-69
sedb.gcebid
blkname =
sedemo_start_timer_read_timer/Infinite Server
blkid =
blk7
4 Proceed further in the simulation:
step
The output shows that the entity is about to depart from the server:
%..........................................................................%
Entity Advancing (en4)
: From = Infinite Server
: To = Read Timer
2-70
5 Use the identifier, blkid, to get information abo
ut the block and
the status of entities in it:
% Display information in Command Win dow. blkinfo(blkid) % Store information in str uct ure. blkdetails = blkinfo(blkid) % Store status of entities in cell array. blkentities = {blkdetails.Entities.Status}'
The output is:
Infinite Server Current State T = 2.581301297500028
Block (blk7): Infinite Server
Entities (Capacity = Inf):
sedb.gcebid
Pos ID Status Event EventTime
1 en2 In Service ev4 2.7303849396254689
2 en4 Advancing ev8 2.581301297500028
3 en5 In Service ev10 2.974736350905304
blkdetails =
Time: 2.5813
Block: 'sedemo_start_timer_read_timer/Infinite Server'
BlockID: 'blk7'
BlockType: 'Infinite Server'
Capacity: Inf
Entities: [1x3 struct]
blkentities =
'In Service'
'Advancing'
'In Service'
6 Get more information about one of the entities by using data from the
blkdetails structure as an input argument to the eninfo function:
adv_eninfo = eninfo(blkdetails.Entities(1).ID); time_in_system = adv_eninfo.Timers.ElapsedTime
The output is:
time_in_system =
1.5813
7 End the debugger session. At the sedebug>> prompt, enter:
sedb.quit
2-71
sedb.gcebid
See Also sedb.blkinfo
How To • “Inspecting the Current Point in the Debugger”
2-72
sedb.gcen
Purpose Identifier of entity currently undergoing operation
Syntax enid = g cen
Description enid = gcen returns the identifier of the entity that undergoes the
current operation. If the current operation does not apply to a unique entity,
Examples View the values of the attributes of an entity:
1 Begin a debug ger session for a particular model. At the MATLAB
2 Proceed in the simulation. At the sedebug>> prompt, enter:
enid is empty.
command prompt, enter:
sedebug('sedemo_star_routing')
tbreak 0.1 cont
The partial output shows the entity identifier, en1,inthedisplay:
Hit b1 : Breakpoint for first operation at or after time 0.100000
%==============================================================================%
Executing ServiceCompletion Event (ev2) Time = 0.300000000000000
: Entity = en1 Priority = 5
: Block = Distribution Center/Infinite Server
3 Get the ID of an entity:
% Get ID of current entity. enid = gcen
The workspace variable, enid, holds the same entity identifier, en1, from the display:
2-73
sedb.gcen
enid =
en1
4 Use the identifier, enid, to get information about the entity:
% Display information in Command Win dow. eninfo(enid) % Store information in str uct ure. endetails = eninfo(enid) % View attributes. enattrs = endetails.Attributes % View one attribute. enServiceProcess = enattrs.ServiceProcess % Equivalently, view one attribute starting from endetails. enServiceProcess = endetails.Attributes.ServiceProcess;
The output is:
2-74
Entity (en1) Current State T = 0.300000000000000
Location: Distribution Center/Infinite Server
Attributes:
Name Value
CurrentRoute 1
CurrentServiceTime 2
CurrentStep 2
JobClass 1
JobID 1
JobServiceStatus [1x15]
LastServiceLocation 0
ServiceProcess [6x1]
ServiceTime [6x1]
Timeouts, Timers: None
sedb.gcen
endetails =
Time: 0.3
Location: 'sedemo_star_routing/Distribution Center/Infinite Server'
Attributes: [1x1 struct]
Timers: [0x0 struct]
Timeouts: [0x0 struct]
enattrs =
CurrentRoute: 1
CurrentServiceTime: 2
CurrentStep: 2
JobClass: 1
JobID: 1
JobServiceStatus: [0 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN]
LastServiceLocation: 0
ServiceProcess: [6x1 double]
ServiceTime: [6x1 double]
enServiceProcess =
1
2
4
2
3
5
5 End the debugger session. At the sedebug>> prompt, enter:
sedb.quit
See Also sedb.eninfo
2-75
sedb.gcen
How To • “Inspecting the Current Point in the Debugger”
2-76
sedb.gcev
Purpose Identifier of current event
Syntax evid = g cev
Description evid = gcev returns the identifier of the event associated with the
current operation. If the current operation does not change the event calendar, be the scheduling, execution, or cancelation of an event.
Examples View the event associated with the current operation:
1 Begin a debug ger session for a particular model. At the MATLAB
command prompt, enter:
2 Proceed in the simulation. At the sedebug>> prompt, enter:
evid is an empty strin g. A change to the event calendar can
sedebug('sedemo_async_stateflow_ent')
tbreak 1 cont
The output ends with the current operation, which is the execution of the event with identifier
%==============================================================================%
Executing ServiceCompletion Event (ev6) Time = 1.000000000000000
: Entity = en2 Priority = 500
: Block = Asynchronous Execution/Single Server
3 View information about the event associated with the current
ev6:
operation:
evid = gcev evdetails = evinfo(evid)
The output shows the same identifier, ev6, in the workspace variable,
evid,andtheID field of the structure, evdetails:
2-77
sedb.gcev
evid =
ev6
evdetails =
ID: 'ev6'
EventType: 'ServiceCompletion'
EventTime: 1
Priority: '500'
Entity: 'en2'
Block: 'sedemo_async_stateflow_ent/Asynchronous Execution/Single Server'
4 Proceed further in the simulation:
step
The output is:
2-78
%..........................................................................%
Scheduling EntityRequest Event (ev7)
: EventTime = 1.000000000000000 (Now)
: Priority = SYS2
: Block = Asynchronous Execution/Single Server
5 View information about the event associated w
operation. This event is the entity request e scheduling, not the service completion even
vent the simulation is
t whose execution causes
the scheduling of the entity request event.
evid_next = gcev evdetails_next = evinfo(evid_next)
The output refers to the event identifier, ev7:
ith the current
evid_next =
ev7
evdetails_next =
ID: 'ev7'
EventType: 'EntityRequest'
EventTime: 1
Priority: 'SYS2'
Entity: ''
Block: 'sedemo_async_stateflow_ent/Asynchronous Execution/Single Server'
6 End the debugger session. At the sedebug>> prompt, enter:
sedb.quit
See Also sedb.evinfo | sedb.evcal
sedb.gcev
How To • “Inspecting Entities, Blocks, and Events”
2-79
sedb.quit
Purpose Quit discrete-event simulation debugging session
Syntax quit
sedb.quit
Description quit, at the SimEvents debugger command prompt, stops the
simulation and exits the debugging session.
sedb.quit isthesameastheprecedingquit syntax. Specifying the sedb package prevents you from inadvertentlyendingtheMATLAB
session by entering the command at the incorrect command prompt.
See Also sedb.runtoend
2-80
sedb.runtoend
Purpose Run until end of discrete-event simulation
Syntax runtoend
Description runtoend continues the simulation until the end, ignoring timed and
event breakpoints. At the end of the simulation, the debugging session ends.
How To • “Stopping the Debugger”
2-81
sedb.simtime
Purpose Current time in discrete-event simulation
Syntax t = simtime
Description t = simt ime, at the SimEvents debugger command prompt, returns
the current simulation time.
Examples Set a breakpoint to advance the simulation by 2 s from the current time:
1 Begin a debug ger session for a particular model. At the MATLAB
command prompt, enter:
sedebug('sedemo_count_attributes')
2 Use the current time to set a breakpoint. At the sedebug>> prompt,
enter:
t = simtime; tbreak(t+2)
2-82
The following output confirms the setting of the breakpoint:
Set b1 : Breakpoint for first operation at or after time 2.000000
3 Run the simulation until the breakpoint:
cont
The output describes simulation behavior and then confirms that the debugger has reached the breakpoint. Here is an excerpt:
Hit b1 : Breakpoint for first operation at or after time 2.000000
%==============================================================================%
Executing EntityGeneration Event (ev3) Time = 2.000000000000000
: Entity = <none> Priority = 1
: Block = Time-Based Entity Generator
4 End the debugger session. At the sedebug>> prompt, enter:
sedb.quit
How To • “Inspecting the Current Point in the Debugger”
sedb.simtime
2-83
sedb.step
Purpose Single step in discrete-event simulation
Syntax step
step in step over step out
Description step or step in, at the SimEvents debugger command prompt,
advances the simulation by the smallest p o ssible step in the d ebugger.
step over advances the simulation to the next message at the same
level in the simulation log.
step out advances the simulation to the next independent operation
that appears in the simulation log.
Definitions Level in the Simulation Log
The figure illustrates the t w o-level hierarchy of the simulation log to help you distinguish among syntaxes.
2-84
Loading...