comparison m-toolbox/m/gui/gltpda/g_saveresult.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 function g_saveresult(block)
2
3 % This is the automatic function wrapper
4 % =================================================================
5 % ================ level-2 M file S-function ======================
6 % =================================================================
7 % To save as standalone variable(s) into global shared workspace the AO(s)
8 % received as input from the corresponding block, executed in Simulink.
9 %
10 % $Id: g_saveresult.m,v 1.4 2008/03/21 16:13:54 nicola Exp $
11
12 setup(block);
13
14 %%
15 function setup(block)
16
17 %% Register dialog parameter: none, because they're retrieved directly
18 %% from the memory. This will prevent the user to modify the parameters
19 %% outside the proper parameters panel:
20 block.NumDialogPrms = 0;
21
22 %% Register number of input and output ports
23 block.NumInputPorts = 1;
24 block.NumOutputPorts = 1;
25
26 %% Setup functional port properties to dynamically inherited.
27 block.SetPreCompInpPortInfoToDynamic;
28 block.SetPreCompOutPortInfoToDynamic;
29
30 block.InputPort(1).DirectFeedthrough = true;
31 block.InputPort(1).DatatypeID = 0;
32 block.InputPort(1).Complexity = 0;
33 % block.InputPort(1).Dimensions = 2;
34 block.OutputPort(1).DatatypeID = 0;
35 block.OutputPort(1).Complexity = 0;
36 % block.OutputPort(1).Dimensions = 1;
37 block.SampleTimes = [0 0];
38 block.SetAccelRunOnTLC(false);
39
40 %% Register methods
41 block.RegBlockMethod('SetInputPortSamplingMode',@SetInpPortFrameData);
42 block.RegBlockMethod('SetInputPortDimensions', @SetInpPortDims);
43 block.RegBlockMethod('SetOutputPortDimensions', @SetOutPortDims);
44 block.RegBlockMethod('Outputs', @Outputs);
45
46 function SetInpPortFrameData(block, idx, fd)
47 block.InputPort(1).SamplingMode = fd;
48 block.OutputPort(1).SamplingMode = fd;
49
50 function SetInpPortDims(block, idx, di)
51 block.InputPort(idx).Dimensions = di;
52
53 function SetOutPortDims(block, idx, di)
54 block.OutputPort(idx).Dimensions = di;
55
56
57 %%
58 function Outputs(block)
59 global LTPDAinvar LTPDAoutvar
60
61 % Check if the user wants to stop the execution:
62 lastChar = get(findobj('Name','LTPDA Progress Bar'),'CurrentCharacter');
63 if ~isempty(lastChar) && strcmp(lastChar,'x')
64 set_param(bdroot, 'SimulationCommand', 'stop')
65 return
66 end
67
68 y = numel(block.InputPort(1).Data);
69 for j=1:y
70 yy = numel(LTPDAinvar{block.InputPort(1).Data(j)});
71 if yy >1
72 for jj=1:yy
73 LTPDAoutvar = [LTPDAoutvar;{LTPDAinvar{block.InputPort(1).Data(j)}(jj)}];
74 end
75 else
76 LTPDAoutvar = [LTPDAoutvar;{LTPDAinvar{block.InputPort(1).Data(j)}}];
77 end
78 end
79
80 % %========================================================================
81
82 block.OutputPort(1).Data = block.InputPort(1).Data;
83
84 %endfunction
85