⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pwritespecconstructioncmd.m

📁 利用Stateflow 进行嵌入式代码开发很好用
💻 M
字号:
function txtBuffer = pWriteSpecConstructionCmd(iStruct, type)
%PWRITESPECCONSTRUCTIONCMD Writes the ML construction commands needed to
%   fill the specification structure, generate the c-mex, build the c-mex 
%   and generate tlc block file according to the ISTRUCT content.
%

%   Copyright 2005 The MathWorks, Inc.
%   $File: $
%   $Revision: $
%   $Date:  $

error(nargchk(1, 2, nargin));

% for TLC or C ?
if nargin < 2
    type = 'c';
else
    type = lower(type);
end

% get input struture fieldnames
fieldNames = fieldnames(iStruct);

% initialize output buffer
txtBuffer = [];

% first initialize the structure defintion
txtBuffer = [txtBuffer, sprintf('     def = legacy_code_initialize;\n')];

% walk through the structure fields
for ii = 1:length(fieldNames)
    
    switch class(iStruct.(fieldNames{ii}))
        case 'char'
            if ~isempty(iStruct.(fieldNames{ii}))
                txtBuffer = [txtBuffer, ...
                    sprintf('     def.%s = ''%s'';\n', fieldNames{ii}, iStruct.(fieldNames{ii}))];
            end

        case 'cell'

            if ~cellfun('isempty', iStruct.(fieldNames{ii}))
                txtBuffer = [txtBuffer, ...
                    sprintf('     def.%s = {', fieldNames{ii})];
                sep = '';
                c = char(iStruct.(fieldNames{ii}));
                for jj = 1:size(c, 1)
                    txtBuffer = [txtBuffer, ...
                        sprintf('%s''%s''', sep, deblank(c(jj, :)))];
                    sep = ', ';
                end
                txtBuffer = [txtBuffer, sprintf('};\n')];
            end

        otherwise

    end
end

if strcmp(type, 'c')
    txtBuffer = [txtBuffer, sprintf('     legacy_code_sfcn_cmex_generate(def);\n')];
    txtBuffer = [txtBuffer, sprintf('     legacy_code_compile(def);\n')];
else
    txtBuffer = [txtBuffer, sprintf('     legacy_code_sfcn_tlc_generate(def);\n')];
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -