eventAcquireResource

Class: matlab.DiscreteEventSystem
Package: matlab

Create a resource acquisition event

Syntax

event = eventAcquireResource(resourceSpec,tag)

Description

event = eventAcquireResource(resourceSpec,tag) creates an event to acquire resources from existing Resource Pool blocks. You can specify names and amount of resources to acquire. For more details, see resourceSpecification.

If all the requested resources are not available during the event execution, the acquisition event remains active. When the requested resources become available, the event is rescheduled for immediate execution.

Input Arguments

expand all

Specify the name and the amount of resources to be acquired by the entities.

Custom tag of this entity resource acquisition event. You can use the tag to identify an event when multiple events act on the same entity. For more information about managing multiple events, see Custom Entity Storage Block with Multiple Timer Events.

Output Arguments

expand all

Event that acquires resources for the entity.

Examples

expand all

On entity entry to a storage element, an entity acquires one resource of type Test1. The tag of this resource acquisition event is TestTag.

function [entity,events] = entry(obj, storage, entity, source)
% On entity entry, acquire a resource from the specified pool.    
resourceSpec = obj.resourceSpecification('Test1', 1);
event = obj.eventAcquireResource(resourceSpec, 'TestTag');
end

Introduced in R2019a