Main Content

blocked

Class: matlab.DiscreteEventSystem
Namespace: matlab

Event action when entity forward fails

Syntax

[entity,events]=blocked(obj,storage,entity,destination)
[entity,events,out1,...]=blocked(obj,storage,entity,destination,in1,...)

Description

[entity,events]=blocked(obj,storage,entity,destination) specifies event actions of the object when an entity forward fails because the destination storage element has reached its maximum capacity.

[entity,events,out1,...]=blocked(obj,storage,entity,destination,in1,...) specifies such event actions of the object when the block has one or more input signal ports and/or signal output ports.

Input Arguments

expand all

Discrete-event System object.

Index of the storage element.

Entity leaving storage element. Entity has these fields:

  • sys (MATLAB structure) — It has these fields:

    • id (double) — Entity ID

    • priority (double) — Entity priority

  • data — Entity data

Destination of entity, such as an output port or a storage element. It has these fields:

  • type (character vector) — Specify output or storage

  • index (double) — Output or storage index

Any data inputs of the object. These input arguments exist only when the object has data inputs.

Output Arguments

expand all

Entity leaving storage, possibly with changed data.

Events to be scheduled after the method returns. Use matlab.DiscreteEventSystem class methods to create events. Each event has these fields:

  • type (character vector) — Type of the event

  • delay (double) — Delay before the event

  • priority (double) — Priority of the event

  • Storage (double) — Index of the storage element

  • tag (character vector) — Event tag

  • location (MATLAB structure) — Source or destination location of entity

Data outputs of the object. You must specify these output arguments when the object has data outputs.

Examples

expand all

Cancel the current forward event upon blocking. Schedule an event to forward the entity to the next location. Destroy the entity if no storage can accept the entity.

function [entity,events] = blocked(obj,storage,entity,dst)
    % Cancel the current forward event. Schedule an event to
    % forward the entity to the next location. Destroy the entity
    % if no storage can accept the entity.
    if dst.index < obj.numStorage
        events = [...
            obj.cancelForward(dst.type, dst.index), ...
            obj.eventForward('storage', dst.index+1, 0)];
    else
        events = [...
            obj.cancelForward(dst.type, dst.index), ...
            obj.eventDestroy()];
    end
end

Version History

Introduced in R2016a