Main Content

matlab.DiscreteEventSystem Class

Namespace: matlab
Superclasses: matlab.System

Base class for discrete-event system objects

Description

matlab.DiscreteEventSystem is the base class for discrete-event System objects. In your class definition file, you must subclass your object from this base class (or from another class that derives from this base class). Subclassing allows you to use the implementation and service methods provided by this base class to build your object. For more information about implementing matlab.DiscreteEventSystem class with MATLAB Discrete-Event System block, see Create Custom Blocks Using MATLAB Discrete-Event System Block.

Type this syntax as the first line of your class definition file to directly inherit from the matlab.DiscreteEventSystem base class, where ObjectName is the name of your object:

classdef ObjectName < matlab.DiscreteEventSystem

For more information about implementing a discrete-event System object™, see Create a Discrete-Event System Object. For information about linking the discrete-event System object to a SimEvents® model and creating a custom behavior, see Delay Entities with a Custom Entity Storage Block.

The matlab.DiscreteEventSystem class is a handle class.

Class Attributes

Abstract
false
HandleCompatible
true
StrictDefaults
false

For information on class attributes, see Class Attributes.

Methods

expand all

Examples

collapse all

This example shows how to use discrete-event System object methods to create a custom entity storage block that has one input port, one output port, and one storage element. The discrete-event System object is the instantiation of the matlab.DiscreteEventSystem class, which allows you to use the implementation and service methods provided by this class. Then, you use the MATLAB Discrete-Event System block to integrate the System object into a SimEvents model. The custom MATLAB Discrete-Event System block accepts an entity from its input port and forwards it to its output port with a specified delay. For more information, see Delay Entities with a Custom Entity Storage Block.

classdef CustomEntityStorageBlock < matlab.DiscreteEventSystem
                        
    % A custom entity storage block with one input, one output, and one storage. 
 
    % Nontunable properties 
    properties (Nontunable)
    % Capacity
        Capacity = 1;
    % Delay
        Delay=4;
    end
    
    methods (Access=protected)        
        function num = getNumInputsImpl(~)
            num = 1;
        end
        
        function num = getNumOutputsImpl(~)
            num = 1;
        end      
        
        function entityTypes = getEntityTypesImpl(obj)
            entityTypes = obj.entityType('Car');
        end
        
        function [inputTypes,outputTypes] = getEntityPortsImpl(obj)
            inputTypes = {'Car'};
            outputTypes = {'Car'};
        end

        function [storageSpecs, I, O] = getEntityStorageImpl(obj)
            storageSpecs = obj.queueFIFO('Car', obj.Capacity);
            I = 1;
            O = 1;
        end
       
    end
    
   methods
       
        function [entity,event] = CarEntry(obj,storage,entity,source)
            % Specify event actions when entity enters storage.
        
             event = obj.eventForward('output', 1, obj.Delay);
           
        end
     
    end
    
end

Version History

Introduced in R2016a