classdef (Hidden = true) LinkApplicationFramework < rtw.pil.RtIOStreamApplicationFramework
%LINKAPPLICATIONFRAMEWORK provides an RTW.BuildInfo object for use with a PIL rtw.connectivity.Builder.
%
%   This is an undocumented class. Its methods and properties are likely to
%   change without warning from one release to the next.

%   Copyright 2007-2013 The MathWorks, Inc.


    methods
        function this = LinkApplicationFramework(componentArgs, ...
                                                 rxBufferSizeBytes, ...
                                                 txBufferSizeBytes)
            narginchk(3, 3);
            
            % call super class constructor                             
            this@rtw.pil.RtIOStreamApplicationFramework(componentArgs);
            %
            % add to the BuildInfo property
            % 
            pil_src_path = fullfile(matlabroot, ...
                                    'toolbox', ...
                                    'rtw', ...
                                    'targets', ...
                                    'pil', ...
                                    'c');     

            % get the BuildInfo object to add to
            buildInfo = this.getBuildInfo;                                                                   
            buildInfo.addSourceFiles('ide_rtiostream.c', pil_src_path);             
            % set the data buffer sizes on the target
            % With the new comm service infrastructure, the link based
            % implementations have 2 receive buffers, one for the
            % breakpoint synchronization and the other for the actually
            % comm service receive buffer, so in oder not to incur any
            % additional memory requirements, we will divide 
            % rxBufferSizeBytes by 2. 
            assert(isequal(mod(rxBufferSizeBytes, 2),0),...
                'rxBufferSizeBytes must be multiple of 2');
            this.setTargetRecvBufferSizeBytes(rxBufferSizeBytes/2);
            this.setTargetSendBufferSizeBytes(txBufferSizeBytes);
        end
    end
end
