gusucode.com > private工具箱matlab源码程序 > private/code_chart_header_file_sfun.m

    function code_chart_header_file_sfun(fileNameInfo, chart, specsIdx)


%   Copyright 1995-2013 The MathWorks, Inc.

    global gChartInfo 

    %%% Collect all testpoint data and states. This calculation is instance
    %%% dependent, hence has to be done in chart code gen loop.
    gChartInfo.testPoints = sf('TestPointsIn', chart, 0.0, gChartInfo.codingDebug && ~gChartInfo.codingExtMode);
    gChartInfo.hasTestPoint = ~isempty(gChartInfo.testPoints.data) || ...
                              ~isempty(gChartInfo.testPoints.state) || ...
                              ~isempty(gChartInfo.testPoints.aslStates); 
                          
    gChartInfo.loggedSignals = sf('LoggedSignalsIn', chart);
    gChartInfo.hasLoggedSignals = ~isempty(gChartInfo.loggedSignals.data) || ...
                                  ~isempty(gChartInfo.loggedSignals.state) || ...
                                  ~isempty(gChartInfo.loggedSignals.aslStates); 
    
	chartNumber = sf('get',chart,'chart.number');
	chartUniqueName = sf('CodegenNameOf',chart);

	fileName = fullfile(fileNameInfo.targetDirName,fileNameInfo.chartHeaderFiles{chartNumber+1}{specsIdx});
    sf_echo_generating('Coder',fileName);

	file = fopen(fileName,'Wt');
	if file<3
		construct_coder_error([],sprintf('Failed to create file: %s.',fileName),1);
		return;
	end

fprintf(file,'#ifndef __%s_h__\n',chartUniqueName);
fprintf(file,'#define __%s_h__\n',chartUniqueName);
fprintf(file,'\n');
fprintf(file,'/* Include files */\n');
fprintf(file,'#include "sf_runtime/sfc_sf.h"\n');
fprintf(file,'#include "sf_runtime/sfc_mex.h"\n');
fprintf(file,'#include "rtwtypes.h"\n');
   if fileNameInfo.multiword_types
fprintf(file,'#include "multiword_types.h"\n');
   end

   if gChartInfo.hasTestPoint
fprintf(file,'#include "rtw_capi.h"\n');
fprintf(file,'#include "rtw_modelmap.h"\n');
   end

fprintf(file,'\n');

   file = dump_module(fileName,file,chart,'header');
   if file < 3
     return;
   end

fprintf(file,'extern void sf_%s_get_check_sum(mxArray *plhs[]);\n',chartUniqueName);
fprintf(file,'extern void %s_method_dispatcher(SimStruct *S, int_T method, void *data);\n',chartUniqueName);
fprintf(file,'\n');
fprintf(file,'#endif\n');
fprintf(file,'\n');
	fclose(file);
	try_indenting_file(fileName);