Create a Discrete-Event System Object

The MATLAB Discrete-Event System block allows you to author a custom discrete-event System object™ and use it in SimEvents® models. To author event-driven entity-flow systems, the block uses discrete-event System object with the matlab.DiscreteEventSystem class, which inherits and extends the matlab.System class.

You can optionally inherit a subset of methods from the matlab.system.mixin package by inheriting matlab.System.mixin.Propagates, matlab.System.mixin.CustomIcon, or matlab.System.mixin.SampleTime classes. This diagram shows the relationships between the classes in the creation of a discrete-event System object.

Methods

The matlab.DiscreteEventSystem class provides methods that let you work with these elements of a discrete-event system:

  • Define properties of the object entity types, ports, and storage

  • Event initialization

  • Runtime behavior of the object

    • blocked — Event action when entity forward fails

    • destroy — Event action upon entity destruction

    • entry — Event action when entity enters storage element

    • exit — Event action before entity exit from storage

    • generate — Event action upon entity creation

    • iterate — Event action when entity iterates

    • modified — Event action upon entity modification by the Entity Find block

    • resourceAcquired — Specify event actions upon successful resource acquisition.

    • resourceReleased — Specify event actions upon successful resource release.

    • testEntry — Event action to accept or refuse entity

    • timer — Event action when timer completes

While implementing these methods, define entity type, entity storage, create, schedule, and cancel events. Use these functions:

Inherited Methods from matlab.System Class

Inheriting matlab.DiscreteEventSystem class also inherits a subset of the matlab.System class methods.

getHeaderImpl

Header for System object display

getPropertyGroupsImpl

Property groups for System object display

isInactivePropertyImpl

Inactive property status

validatePropertiesImpl

Validate property values

processTunedPropertiesImpl

Action when tunable properties change

getNumInputsImpl

Number of inputs to step method

getInputNamesImpl

Names of System block input ports

getNumOutputsImpl

Number of outputs from step method

getOutputNamesImpl

Names of System block output ports

getDiscreteStateImpl

Discrete state property values

setupImpl

Initialize System object

resetImpl

Reset System object states

releaseImpl

Release resources

loadObjectImpl

Load System object from MAT file

saveObjectImpl

 Save System object in MAT file

infoImpl

Information about System object

For more information about these methods, see Customize System Objects for Simulink (Simulink).

Inherited Methods from matlab.system.mixin Package

You can inherit other methods that require the inheritance of additional classes from the matlab.system.mixin package. For example, to specify a discrete state by using getDiscreteStateSpecificationImpl, inherit the matlab.system.mixin.Propagates class. For an example of inheriting this class, see Selection Server - Select Specific Entities from Server.

Inherited Methods from matlab.System.mixin.Propagates Class

To use the methods inherited from matlab.System.mixin.Propagates class, you must subclass from this class in addition to the matlab.DiscreteEventSystem base class. Type the following syntax as the first line of your class definition file, where ObjectName is the name of your object.

classdef ObjectName < matlab.DiscreteEventSystem & matlab.system.mixin.Propagates

This list contains the methods inherited from matlab.system.mixin.Propagates class.

getOutputSizeImpl

Sizes of output ports

getOutputDataTypeImpl

Data types of output ports

isOutputComplexImpl

Complexity of output ports

getDiscreteStateSpecificationImpl

Discrete state size, data type, and complexity

Inherited Methods from matlab.System.mixin.CustomIcon Class

To inherit methods from the matlab.System.mixin.CustomIcon class, type the following syntax as the first line of your class definition file.

classdef ObjectName < matlab.DiscreteEventSystem & matlab.system.mixin.CustomIcon

getIconImpl

Name to display as block icon

Inherited Methods from matlab.System.mixin.SampleTime Class

To inherit methods from the matlab.System.mixin.SampleTime class, type the following syntax as the first line of your class definition file.

classdef ObjectName < matlab.DiscreteEventSystem & matlab.system.mixin.SampleTime

getSampleTime

Query sample time

Reference and Extract Entities

  1. When referencing entity attributes or system properties in a discrete-event System object, use these formats:

    Attribute or PropertyFormatAccess

    attribute

    entity.data.attribute_name

    Read/write

    priority property

    entity.sys.priority

    Read/write

    ID property

    entity.sys.id

    Read-only

  2. If an entity that is a part of a MATLAB Discrete-Event System block is requested for extraction, the exit method of the block is triggered. When the exit method is called, its destination argument is set to extract. See modified for entity modification.

See Also

|

Related Topics