Class: matlab.DiscreteEventSystem
Package: matlab

Event action upon successful resource acquisition


[entity,event,out1,...] = resourceAcquired(obj,storage,entity,resources,tag,in1,...)


[entity,event,out1,...] = resourceAcquired(obj,storage,entity,resources,tag,in1,...) specifies event action for a discrete-event System object™ upon successful acquisition of a resource. Resource acquisition is successful only if all of the specified resources are acquired.

Input Arguments

expand all

Discrete-event System object.

Index of the storage element.

Entity that acquires the resource. Entity has these fields:

  • sys (MATLAB structure) consisting of:

    • id (double) — Entity ID

    • priority (double) — Entity priority

  • data — Entity data

An array of structures that specifies the resources that have been acquired.

Tag of the currently executing resource acquisition event.

First data input.

Output Arguments

expand all

Entity acquiring the resource.

Events to be scheduled. 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 (see source)

First data output.


expand all

Suppose that an entity acquires resources successfully with a scheduled eventAcquireResource and the tag of this event is MyResourceAcquireEvent. Then this acquisition invokes the resourceAcquired method to forward entities to the output.

function [entity,events] = entry(obj, storage, entity, source)
  % On entry, acquire one resource of type Resource1.
  resRequest = obj.resourceSpecification('Resource1', 1);
  events = obj.eventAcquireResource(resRequest, 'MyResourceAcquireEvent');       
function [entity,events] = resourceAcquired(obj, storage,...  
                            entity, resources, MyResourceAcquireEvent )
  % After resource acquisition with MyResourceAcquireEvent, forward 
  % the entity to the output.                    
  events = obj.eventForward('output', storage, 0.0);

Introduced in R2019a