classdef (Hidden = true) HostDemoApplicationFramework < rtw.pil.RtIOStreamApplicationFramework
%HOSTDEMOAPPLICATIONFRAMEWORK provides a BUILDINFO for use with host-based PIL
%   HOSTDEMOAPPLICATIONFRAMEWORK provides the application framework for
%   host-based PIL.
%
%   This is an undocumented class. Its methods and properties are likely to
%   change without warning from one release to the next.

%   Copyright 2007-2018 The MathWorks, Inc.
%   


  methods
    % constructor
    function this = HostDemoApplicationFramework(componentArgs)
      narginchk(1, 1);
      % call super class constructor
      this@rtw.pil.RtIOStreamApplicationFramework(componentArgs);
      % add to the BuildInfo property
      %
      
      % get the BuildInfo object to update
      buildInfo = this.getBuildInfo;

      % use host main    
      this.addPILMain('host');  
      
      % support target_io functions
      this.addTargetIo;
                 
      if rtw.connectivity.Utils.isCommServiceAPIEnabled
          buildInfo.addDefines('USING_CS_API=1', 'OPTS');
      else
          rtiostreamPath = fullfile(matlabroot, ...
              'toolbox', ...
              'coder', ...              
              'rtiostream', ...
              'src', ...
              'rtiostreamtcpip');
          buildInfo.addSourcePaths(rtiostreamPath);
          % add rtiostream source file
          buildInfo.addSourceFiles('rtiostream_tcpip.c');
          
          % for SIL, increase the target/server side transmit buffer size so we
          % minimize the number of packets sent over the network
          this.setTargetRecvBufferSizeBytes(50000);
          this.setTargetSendBufferSizeBytes(50000);
          
          % If using the LCC compiler on PC we must explicitly add the
          % sockets library
          if ispc && componentArgs.usingLcc
              addLCCSocketsLib(buildInfo);
          end
      end
    end 
    
    % configuration for word addressable hardware
    function configWordAddressable(this, config)
        if ~config.getExtendedHardwareConfig.isByteAddressable
            buildInfo = this.getBuildInfo;
            % add the required define for word addressable testing support
            buildInfo.addDefines('-DHOST_WORD_ADDRESSABLE_TESTING=1', ...
                                 'OPTS');            
        end                
    end
  end
end
