Skip to Main Content Skip to Search
Product Documentation

sedb.evcal - Package: sedb

Event calendar of discrete-event simulation

Syntax

evcal
cal_struct = evcal
evcal enID
evcal evID
evcal blkID
evcal blkname
evcal all
evcal merged

Description

evcal displays the list of events on the event calendar of the discrete-event system in progress. If no discrete-event system is in progress, this command displays the event calendar for each discrete-event system in the model. The listing for the event in progress or the event selected for execution includes the characters =>. These characters appear to the left of the event identifier. The display includes this event unless all its immediate consequences are complete.

cal_struct = evcal returns a structure that stores information about the events in the event calendar of the requested discrete-event system, cal_struct.

evcal enID displays the list of events on the event calendar for the discrete-event system that contains the entity, enID.

evcal evID displays the list of events on the event calendar for the discrete-event system that contains the event, evID.

evcal blkID displays the list of events on the event calendar for the discrete-event system that contains the block identifier, blkID.

evcal blkname displays the list of events on the event calendar for the discrete-event system that contains the block name, blkname.

evcal all displays all event calendars for each discrete-event system in the model with a list of pending events in each event calendar.

evcal merged displays a merged list of events from all event calendars in the model. This function displays the events in the order in which they will execute.

Output Arguments

cal_struct

Structure that stores information about the event calendar. The cal_struct fields are in the following table.

FieldDescription
TimeCurrent simulation time
ExecutingEvent

Structure that describes the event in progress or selected for execution. The structure has these fields:

  • ID — Event identifier

  • EventType — Type of event

  • EventTime — Scheduled time of event

  • Priority — Priority of event

  • Entity — Identifier of entity associated with the event

  • Block — Path name of block that executes the event

DiscreteEventSystemIDDiscrete-event system ID of the containing discrete-event system.
PendingEvents

Structure array that describes events that are not in progress or selected for execution. Each structure in the array has these fields:

  • ID — Event identifier

  • EventType — Type of event

  • EventTime — Scheduled time of event

  • Priority — Priority of event

  • 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 stores the same information:

  1. Begin a debugger session for a particular model. At the MATLAB command prompt, enter:

    sedebug('sedemo_timeout')
  2. Establish a breakpoint and proceed in the simulation. At the sedebug>> prompt, enter:

    tbreak 2
    detail none
    cont

    The output ends with a message describing the context of the simulation at T=2:

    Set b1 : Breakpoint for first operation at or after time 2
    
      Event Operations  (ev)   :  off
      Entity Operations (en)   :  off
      Signal Operations (sig)  :  off
      Event Calendar    (cal)  :  off
    
    
    Hit b1 : Breakpoint for first operation at or after time 2
    
    %==============================================================================%
    Executing EntityGeneration Event (ev10)               Time = 2.000000000000000
    : Entity = <none>                                     Priority = 1
    : Block  = Time-Based Entity Generator
  1. View the event calendar:

    % View event calendar.
    evcal

    The following output lists all events on the event calendar for the current discrete-event system:

    Event Calendar for Discrete-Event System ID: 0 at T = 2.000000000000000
    %------------------------------------------------------------------------------%
    Discrete-Event System ID: 0  Highlight
        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
  2. 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
        DiscreteEventSystemID: 0
               ExecutingEvent: [1x1 struct]
                PendingEvents: [2x1 struct]
    
    
    ev5struct =
    
               ID: 'ev5'
        EventType: 'Timeout'
        EventTime: 2
         Priority: '1700'
           Entity: 'en2'
            Block: 'sedemo_timeout/Infinite Server'
    
  3. 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:

    simult_event_types =
    
        'Timeout'
    
  4. 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
    
  5. End the debugger session. At the sedebug>> prompt, enter:

    sedb.quit

    After the debugger session ends, cal_struct and the other variables remain in the workspace.

See Also

sedb.evinfo

How To

  


Free Discrete Event Simulation Technical Kit

Model electronic system architectures, process flows, and logistics as queuing systems or agent-based systems.

Get free kit

Trials Available

Try the latest version of discrete-event simulation products.

Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS