Products & Services Solutions Academia Support User Community Company

Learn more about SimEvents   

sedb.evcal - Package: sedb

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 =>. 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 event calendar.

Outputs

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

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. 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.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
  1. View the 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
  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
        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

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS