classdef UserCustomizeBase < handle
    %   This class is to customize the asap2 file

    %   Copyright 2020 The MathWorks, Inc.
    properties(Hidden,SetAccess = public,GetAccess = private)
        % The Header section of asap2 file.
        % Not a part of the subclasses
        Header
        Alignment
    end
    properties(Access = public)
        % Part of subclass and could be modified by user.
        HeaderComment
        ModParComment
        ModCommonComment
        ASAP2FileName
        ByteOrder

    end

    methods(Access = public)
       
        function this = UserCustomizeBase()
            this.HeaderComment = 'Header Comments go here';
            this.ModParComment = 'MOD PAR Comment Goes Here';
            this.ModCommonComment = 'Mod Common Comment Here';
        end
        function header = writeHeader(this)
            % Function: writeHeader
            % Abstract: Define format for HEADER section of ASAP2 file.
            % User could either just specify the Header Comment or could
            % use the function in the derived class to have additional
            % text.
            header = sprintf(['  /begin HEADER "', this.HeaderComment,'"',...
                     newline,...
                     newline,...
                '  /end HEADER']);
        end
        
        function hardwareInterface = writeHardwareInterface(this)
            % Function: writeHardwareInterface
            % Abstract: Used to define hardware interface for ASAP2 file.
            % The MOD_PAR and MOD_COMMON SECTION could be modified.
            % User could either just specify the MOD_PAR,MOD_COMMON 
            % Comment and the byte order or could
            % use the function in the derived class to have additional
            % text.
            hardwareInterface = sprintf(['    /begin MOD_PAR "',this.ModParComment,'"',...
                newline,...
                newline,...
                '    /end MOD_PAR',...
                newline,...
                newline,...
                '    /begin MOD_COMMON  "',this.ModCommonComment,'"',...
                newline,...
                '      ' this.ByteOrder, ...
                newline,...
                this.Alignment,...
                newline,...
                '    /end MOD_COMMON']);
        end
        
        function fileTail = writeFileTail(this)
            % Function: writeFileTail
            % Abstract: Text to include at end of ASAP2 file.
            % User could either just specify the ASAP2 file name to be
            % in the comment section of file  or could use the function in
            % the derived class to have additional text.
            fileTail = sprintf(['/* (add any file trailer comments here) */'...
                '\n/* EOF ',this.ASAP2FileName,'*/']);
        end
        
        function fileHeader = writeFileHead(this)
            % Function: writeFileHead
            % Abstract: Text to include at beginning of ASAP2 file.
            % User could either just specify the ASAP2 file name to be
            % in the comment section of file  or could use the function in
            % the derived class to have additional text.
            fileHeader = sprintf(['/******************************************************************************\n',...
                ' *' newline,...
                ' *  ASAP2 file:     ', this.ASAP2FileName,...
                newline,...
                this.Header,...
                ' ******************************************************************************/'
                ]);
        end
    end  
end


% LocalWords:   ddd mmm HH yyyy
