📄 fm_block.m
字号:
function fm_block% FM_BLOCK change the mask properties of the current% selected Simulink block%%see also FM_LIB, FM_SIM, FM_SIMDATA, FM_SIMSETT%%Author: Federico Milano%Date: 11-Nov-2002%Update: 01-Aug-2003%Version: 1.0.1%%E-mail: fmilano@thunderbox.uwaterloo.ca%Web-site: http://thunderbox.uwaterloo.ca/~fmilano%% Copyright (C) 2002-2005 Federico Milano%% This toolbox is free software; you can redistribute it and/or modify% it under the terms of the GNU General Public License as published by% the Free Software Foundation; either version 2.0 of the License, or% (at your option) any later version.%% This toolbox is distributed in the hope that it will be useful, but% WITHOUT ANY WARRANTY; without even the implied warranty of% MERCHANDABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU% General Public License for more details.%% You should have received a copy of the GNU General Public License% along with this toolbox; if not, write to the Free Software% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,% USA.sys = get_param(0,'CurrentSystem');block = get_param(sys,'CurrentBlock');gg = get_param([sys,'/',block],'Selected');mask = get_param([sys,'/',block],'MaskType');object = [sys,'/',block];Values = get_param(object,'MaskValues');set_param(object,'LinkStatus','none')a = get_param(object,'MaskEnables');b = get_param(object,'MaskPrompts');switch mask case 'Bus' colors = {'black','blue','green','red','yellow', ... 'cyan','orange','darkgreen','lightblue','gray'}; set_param(object,'BackgroundColor', ... colors{rem(round(str2num(Values{5}))-1,10)+1}); case 'Syn' tipo = str2num(Values{2}); idx = [10,11]; % Ko,Kp Taa switch tipo case 2, a(idx) = {'off'; 'off'}; case 3, a(idx) = {'on'; 'off'}; case 4, a(idx) = {'on'; 'off'}; case 5.1, a(idx) = {'on'; 'off'}; case 5.2, a(idx) = {'on'; 'on'}; case 5.3, a(idx) = {'off'; 'off'}; case 6, a(idx) = {'on'; 'on'}; case 8, a(idx) = {'off'; 'on'}; end case 'Mot' tipo = str2num(Values{2}); idx = [4, 7]; switch tipo case 1, a(idx) = {'off'; 'off'}; case 3, a(idx) = {'on'; 'off'}; case 5, a(idx) = {'on'; 'on'}; end case 'Mn' tipo = Values{4}; switch tipo case 'on', b{2} = 'Percentage of active && reactive powers [%, %]'; case 'off', b{2} = 'Active && reactive powers [p.u., p.u.]'; end case 'Pl' tipo = Values{4}; switch tipo case 'on' b{2} = 'Percentage of resistance, active current and active power [%, %, %]'; b{3} = 'Percentage of reactance, reactive current and reactive power [%, %, %]'; case 'off' b{2} = 'Resistance, active current and active power [p.u., p.u., p.u.]'; b{3} = 'Reactance, reactive current and reactive power [p.u., p.u., p.u.]'; end case 'Breaker' inputs = [get_param(object,'Ports'), 0, 0, 0, 0, 0]; if inputs(6) display1 = ['plot([1 2 2 1 1],[-1 -1 1 1 -1]),color(''red''),', ... 'plot([1 2],[-1 1],[2 1],[-1 1])']; else display1 = ['plot([1 2 2 1 1],[-1 -1 1 1 -1],', ... '[1 2],[-1 1],[2 1],[-1 1])']; end display2 = ['plot([1 2 2 1 1],[-1 -1 1 1 -1])']; tipo = Values{2}; switch tipo case 'on', set_param(object,'MaskDisplay',display1); case 'off', set_param(object,'MaskDisplay',display2); end case 'Oxl' tipo = Values{2}; switch tipo case 'on', a([3, 4]) = {'off','off'}; case 'off', a([3, 4]) = {'on' ,'on'}; end case 'Pss' tipo = str2num(Values{1}); switch tipo case 1, a([2 5 6 7 8 9 10]) = {'off','on', 'off','off','off','off','off'}; case 2, a([2 5 6 7 8 9 10]) = {'on' ,'off','on', 'off','off','off','off'}; case 3, a([2 5 6 7 8 9 10]) = {'on' ,'off','on', 'off','off','off','off'}; case 4, a([2 5 6 7 8 9 10]) = {'on' ,'off','on', 'on', 'on', 'on' ,'on'}; case 5, a([2 5 6 7 8 9 10]) = {'on' ,'off','on', 'on', 'on', 'on' ,'on'}; end case 'Svc' inputs = [get_param(object,'Ports'), 0, 0, 0, 0, 0]; if inputs(6) display1 = ['plot([0.5 0.5],[1 0.8],[0.5 0.5],[0 0.2],[0 1 1 0 0],[0.8 0.8 0.2 0.2 0.8]),', ... ' plot([-0.1 1.1],[0 0],[0.1 0.9],[-0.05 -0.05],[0.3 0.7],[-0.1 -0.1]), color(''green'')', ... ' plot([-0.4 -0.4 1.4 1.4],[0.1 0.3 0.7 0.9])']; display2 = ['plot([0.5 0.5],[0 0.2],[-0.5 1.5],[0 0],[3 5],[-0.9 -0.9],', ... '[0.5 0.5],[-1.6 -1.8],[4 4],[0.2 -0.8],[1.9 1.9],[0.2 0.4],[1.9 1.9],[-1.8 -2],', ... '[0.5 4],[0.2 0.2],[0.5 0.5],[-0.65 -0.85],[4 4],[-1.8 -0.9],[0.5 4],[-1.8 -1.8],', ... '[1.3 2.5],[-2 -2],[1.5 2.3],[-2.05 -2.05],[1.7 2.1],[-2.1 -2.1]), ', ... 'plot(4+yc,-0.7+0.1*xc,', ... '0.5-0.5*xi,-1.15+0.175+0.125*yi,', ... '0.5-0.5*xi,-1.15-0.325+0.125*yi,', ... '0.5-0.5*xi,-1.15-0.075+0.125*yi), ', ... 'color(''magenta''), plot([-0.5 1.5 1.5 -0.5 -0.5],[-0.65 -0.65 0 0 -0.65],', ... '[0 -0.5 -1 0],[-0.2 -0.45 -0.2 -0.2],[-0.7 -1.2],[-0.35 -0.35],[-1 0],[-0.45 -0.45],', ... '[1 1.5 2 1],[-0.45 -0.2 -0.45 -0.45],[2 1],[-0.2 -0.2],[1.7 2.2],[-0.3 -0.3])']; else display1 = ['plot([0.5 0.5],[1 0.8],[0.5 0.5],[0 0.2],[0 1 1 0 0],[0.8 0.8 0.2 0.2 0.8],', ... '[-0.1 1.1],[0 0],[0.1 0.9],[-0.05 -0.05],[0.3 0.7],[-0.1 -0.1], ', ... '[-0.4 -0.4 1.4 1.4],[0.1 0.3 0.7 0.9])']; display2 = ['plot([0.5 0.5],[0 0.2],[-0.5 1.5],[0 0],[3 5],[-0.9 -0.9],', ... '[0.5 0.5],[-1.6 -1.8],[4 4],[0.2 -0.8],[1.9 1.9],[0.2 0.4],[1.9 1.9],[-1.8 -2],', ... '[0.5 4],[0.2 0.2],[0.5 0.5],[-0.65 -0.85],[4 4],[-1.8 -0.9],[0.5 4],[-1.8 -1.8],', ... '[1.3 2.5],[-2 -2],[1.5 2.3],[-2.05 -2.05],[1.7 2.1],[-2.1 -2.1]), ', ... 'plot(4+yc,-0.7+0.1*xc,', ... '0.5-0.5*xi,-1.15+0.175+0.125*yi,', ... '0.5-0.5*xi,-1.15-0.325+0.125*yi,', ... '0.5-0.5*xi,-1.15-0.075+0.125*yi), ', ... 'plot([-0.5 1.5 1.5 -0.5 -0.5],[-0.65 -0.65 0 0 -0.65],', ... '[0 -0.5 -1 0],[-0.2 -0.45 -0.2 -0.2],[-0.7 -1.2],[-0.35 -0.35],[-1 0],[-0.45 -0.45],', ... '[1 1.5 2 1],[-0.45 -0.2 -0.45 -0.45],[2 1],[-0.2 -0.2],[1.7 2.2],[-0.3 -0.3])']; end tipo = str2num(Values{2}); idx1 = [3 4 6]; idx2 = [7 8 9]; switch tipo case 1 b(idx1) = {'Regulator Time Constant Tr [s]'; ... 'Regulator Gain Kr [p.u./p.u.]'; ... 'B_max and B_min [p.u. p.u.]'}; a(idx2) = {'off'; 'off'; 'off'}; set_param(object,'MaskDisplay',display1); case 2 b(idx1) = {'Regulator Time Constant T2 [s]'; ... 'Regulator Gain K [p.u./p.u.]'; ... 'Alpha_max and Alpha_min [rad rad]'}; a(idx2) = {'on'; 'on'; 'on'}; set_param(object,'MaskDisplay',display2); end case 'Tcsc' inputs = [get_param(object,'Ports'), 0, 0, 0, 0, 0]; if inputs(6) display1 = ['plot([1 0.8],[0.5 0.5],[0 0.2],[0.5 0.5],[0.8 0.8 0.2 0.2 0.8],[0 1 1 0 0]), ' ... 'color(''green''), plot([0.1 0.3 0.7 0.9],[-0.4 -0.4 1.4 1.4])']; display2 = ['plot([-1.6 -1.8 -1.8],[0.5 0.5 4],[0.2 0.2],[0.5 4],[-0.9 -0.9],[3 5],', ... '[0 0.2],[0.5 0.5],[-0.65 -0.85],[0.5 0.5],[-1.8 -0.9],[4 4],', ... '[0.2 -0.8],[4 4],[0.2 0.4],[1.9 1.9],[-1.8 -2],[1.9 1.9]), ', ... 'plot(-0.7+0.1*xc,4+yc,', ... '-1.15+0.175+0.125*yi,0.5+0.5*xi,', ... '-1.15-0.325+0.125*yi,0.5+0.5*xi,', ... '-1.15-0.075+0.125*yi,0.5+0.5*xi), ', ... 'color(''magenta''), plot([-0.65 -0.65 0 0 -0.65],[-0.5 1.5 1.5 -0.5 -0.5],', ... '[-0.2 -0.45 -0.2 -0.2],[0 -0.5 -1 0],[-0.35 -0.35],[-0.7 -1.2],[-0.45 -0.45],[-1 0],', ... '[-0.45 -0.2 -0.45 -0.45],[1 1.5 2 1],[-0.2 -0.2],[2 1],[-0.3 -0.3],[1.7 2.2])']; else display1 = ['plot([1 0.8],[0.5 0.5],[0 0.2],[0.5 0.5],[0.8 0.8 0.2 0.2 0.8],[0 1 1 0 0],' ... '[0.1 0.3 0.7 0.9],[-0.4 -0.4 1.4 1.4])']; display2 = ['plot([-1.6 -1.8 -1.8],[0.5 0.5 4],[0.2 0.2],[0.5 4],[-0.9 -0.9],[3 5],', ... '[0 0.2],[0.5 0.5],[-0.65 -0.85],[0.5 0.5],[-1.8 -0.9],[4 4],', ... '[0.2 -0.8],[4 4],[0.2 0.4],[1.9 1.9],[-1.8 -2],[1.9 1.9]), ', ... 'plot([-0.65 -0.65 0 0 -0.65],[-0.5 1.5 1.5 -0.5 -0.5],', ... '[-0.2 -0.45 -0.2 -0.2],[0 -0.5 -1 0],[-0.35 -0.35],[-0.7 -1.2],[-0.45 -0.45],[-1 0],', ...
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -