classdef (StrictDefaults)slexLawOfLargeNumbersIntegerCounterSysObj < matlab.System
%slexLawOfLargeNumbersIntegerCounterSysObj   Count number of trials.

% Copyright 2013-2016 The MathWorks Inc.

    %#codegen
    
    properties (DiscreteState, SetAccess=private)
        counter       % Total number of executions
        consecCounter % Number of executions since enabled subsystem reset
    end
        
    methods(Access=protected)
        function setupImpl(obj)
            obj.counter = 0;
            obj.consecCounter = 0;
        end
        
        function resetImpl(obj)
            % The consecCounter state is reset whenever the enabled
            % subsystem is reset
            obj.consecCounter = 0;
        end
        
        function [consecCount, totalCount] = stepImpl(obj)
            % Update counters
            obj.consecCounter = obj.consecCounter + 1;
            obj.counter = obj.counter + 1;
            
            % Return count values
            consecCount = obj.consecCounter;
            totalCount = obj.counter;
        end
        
        function icon = getIconImpl(~)
            % Define icon for System block
            icon = {'Integer','Counter'};
        end
    end

    methods(Access = protected, Static)
        function header = getHeaderImpl
            % Define header panel for System block dialog
            headerText = ['Count total number of executions as well ' ...
                'as consecutive executions since last time enabled.'];
            header = matlab.system.display.Header(...
                'Title', 'Integer Counter', ...
                'Text', headerText);
        end
    end
end
