Event action upon successful resource acquisition
[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.
out1,...] = resourceAcquired(
obj— Discrete-event System object
Discrete-event System object.
storage— Storage that the entity resides in
Index of the storage element.
entity— Entity that is acquiring the resources
Entity that acquires the resource. Entity has these fields:
structure) consisting of:
double) — Entity ID
double) — Entity
data — Entity data
resources— Acquired resources
An array of structures that specifies the resources that have been acquired.
tag— Tag of the resource acquisition event
Tag of the currently executing resource acquisition event.
in1— First data input
First data input.
entity— Entity with changed value
Entity acquiring the resource.
event— Events to be scheduled
Events to be scheduled. Use
matlab.DiscreteEventSystem class methods to create events. Each event has
character vector) — Type of the
double) — Delay before the
double) — Priority of the
double) — Index of the storage
character vector) — Event
structure) — Source or destination (see source)
out1— First data output
First data output.
Suppose that an entity acquires resources successfully with a
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'); end 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); end