view m-toolbox/m/gui/gltpda/g_saveresult.m @ 33:5e7477b94d94 database-connection-manager

Add known repositories list to LTPDAPreferences
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
line wrap: on
line source

function g_saveresult(block)

%             This is the automatic function wrapper
% =================================================================
% ================ level-2 M file S-function ======================
% =================================================================
% To save as standalone variable(s) into global shared workspace the AO(s)
% received as input from the corresponding block, executed in Simulink.
%
%  $Id: g_saveresult.m,v 1.4 2008/03/21 16:13:54 nicola Exp $

setup(block);
  
%%
function setup(block)

  %% Register dialog parameter: none, because they're retrieved directly
  %% from the memory. This will prevent the user to modify the parameters
  %% outside the proper parameters panel:
  block.NumDialogPrms = 0;

  %% Register number of input and output ports
  block.NumInputPorts  = 1;
  block.NumOutputPorts = 1;

  %% Setup functional port properties to dynamically inherited.
  block.SetPreCompInpPortInfoToDynamic;
  block.SetPreCompOutPortInfoToDynamic;
  
  block.InputPort(1).DirectFeedthrough = true;
  block.InputPort(1).DatatypeID = 0;
  block.InputPort(1).Complexity = 0;
% block.InputPort(1).Dimensions = 2;
  block.OutputPort(1).DatatypeID = 0;
  block.OutputPort(1).Complexity = 0;
% block.OutputPort(1).Dimensions = 1;
  block.SampleTimes = [0 0];
  block.SetAccelRunOnTLC(false);
 
  %% Register methods
  block.RegBlockMethod('SetInputPortSamplingMode',@SetInpPortFrameData);
  block.RegBlockMethod('SetInputPortDimensions',  @SetInpPortDims);
  block.RegBlockMethod('SetOutputPortDimensions', @SetOutPortDims);
  block.RegBlockMethod('Outputs',                 @Outputs);
  
  function SetInpPortFrameData(block, idx, fd)
  block.InputPort(1).SamplingMode = fd;
  block.OutputPort(1).SamplingMode = fd;

  function SetInpPortDims(block, idx, di)
  block.InputPort(idx).Dimensions = di;

  function SetOutPortDims(block, idx, di)
  block.OutputPort(idx).Dimensions = di;


%%
function Outputs(block)
global LTPDAinvar LTPDAoutvar

% Check if the user wants to stop the execution:
lastChar = get(findobj('Name','LTPDA Progress Bar'),'CurrentCharacter');
if ~isempty(lastChar) && strcmp(lastChar,'x')
    set_param(bdroot, 'SimulationCommand', 'stop')
    return
end

y = numel(block.InputPort(1).Data);
for j=1:y
    yy = numel(LTPDAinvar{block.InputPort(1).Data(j)});
    if yy >1
        for jj=1:yy
            LTPDAoutvar = [LTPDAoutvar;{LTPDAinvar{block.InputPort(1).Data(j)}(jj)}];
        end
    else
        LTPDAoutvar = [LTPDAoutvar;{LTPDAinvar{block.InputPort(1).Data(j)}}];
    end
end

% %========================================================================

block.OutputPort(1).Data = block.InputPort(1).Data;

%endfunction