www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgcaloutput/cgcaloutput.m

    function obj = cgcaloutput(node, file)
%CGCALOUTPUT  Object for exporting calibration information
%
%  C = CGCALOUTPUT(nodePtr) constructs an export object for outputting all
%  of the calibration information in nodePtr and it's children.
%
%  C = CGCALOUTPUT(nodePtr,filename) specifies the filename to export to.

%  Copyright 2000-2009 The MathWorks, Inc. and Ford Global Technologies, Inc.


obj = struct('ptrlist', null(xregpointer,0),...
    'filename', '',...
    'Source',xregpointer);

if nargin > 0
    % extract all calibration items from the node and sub-nodes.
   
    cgp = project(node.info);
    A = getConnections(cgp);
    if node==address(cgp)
        % use all items for project
        ind = 1:length(A.pData);
    else
        nodeind= find(A,'pointer',node);
        if isempty(nodeind) && node.isa('cgcontainer')
            % not at a major item (e.g. cgfeattblnode)
            pdata = node.getdata;
            nodeind= find(A,'pointer',pdata);
            if isempty(nodeind) && pdata.isa('cgoptimoutput')
                % get main optimization data
                node = node.Parent;
                nodeind= find(A,'pointer',node);
            end
        end
        if isempty(nodeind)
            % can't find anything
            ind = [];
        else
            % get all dependencies from node
            switch A.Type{nodeind}
                case 'Normalizer'
                    % just consider normalizer
                    ind = nodeind;
                case 'Table'
                    % just consider table and its normalizer(s)
                    ind = [nodeind getDependents(A,nodeind,[],false)];
                otherwise
                    % all dependents
                    ind = [nodeind getAllDpts(A,nodeind,[],false)];
            end
        end
            
    end
    % calibratable data is in pData
    p = A.pData(ind);
    q = p(~isnull(p));
    
    
    useitem = false(size(q));
    for n = 1:length(q)
        this = q(n).info;
        if isa(this, 'cgexpr') && iscalibratable(this) && ~isempty(this)
            if isa(this,'cgnormaliser') 
                parent = get(this,'Flist');
                if isempty(parent) || ~parent(1).isa('cglookupone')
                    useitem(n) = true;
                end
            else
                useitem(n) = true;
            end
        end
    end 
    obj.ptrlist = q(useitem);
    obj.Source = node;
    if nargin > 1
        obj.filename = file;
    end
end

obj = class(obj,'cgcaloutput');