[Scilab-users] Create a super block through a script
Yves Rambi
Yves.Rambinintsoa at gmail.com
Thu Sep 17 14:15:40 CEST 2015
Hello to all,
I am new in this forum and I use sometimes scicos.
Now I'd like to create a script which creates a custom block in Scicos. The
structural information are read from an excel file. In the m-language there
are two commands new_system(...) and add_block(...) in order to perform this
task and there are also commands to create ports, links between the blocks
etc.... Which are the corresponding commands for Scilab?
Here is my m-code:
***************************************
clc
clear;
[num, txt] = xlsread('TCS.xls');
dim = size(txt);
laenge = dim(1,1);
breite = dim (1,2);
System_Name = 'SYS2';
Subsys_Name ='';
PathFlag = '<<Path>>';
InPortFlag = '<<In>>';
OutPortFlag = '<<Out>>';
%POSITION
sys_blk_left = 10;
sys_blk_top = 10;
sys_blk_width = 100;
sys_blk_height = 100;
sys_blk_right = sys_blk_left + sys_blk_width;
sys_blk_bottom = sys_blk_top + sys_blk_height;
inp_blk_left = 100;
inp_blk_top = 10;
inp_blk_width = 20;
inp_blk_height = 10;
inp_blk_right = inp_blk_left + inp_blk_width;
inp_blk_bottom = inp_blk_top + inp_blk_height;
Dist_InPort_OutPort = 1000;
out_blk_left = inp_blk_left + Dist_InPort_OutPort;
out_blk_top = 10;
out_blk_width = 20;
out_blk_height = 10;
out_blk_right = out_blk_left + out_blk_width;
out_blk_bottom = out_blk_top + out_blk_height;
%CREATE AND OPEN SYSTEM
*new_system*(System_Name);
open_system(System_Name);
inter_row=0;
inter_block = 0;
i=1;
block_nr =0;
dim_port_name(1) = 5;
while i<laenge
ColumnText = txt{i,1};
if strcmp( ColumnText ,PathFlag) == 1
block_nr = block_nr +1;
Subsys_Name = txt{i,2};
dim = size(Subsys_Name);
dim = dim(1,2);
Subsys_Name(dim)='';
<b>add_block*('built-in/SubSystem',Subsys_Name);
sys_blk_top = sys_blk_bottom + 10;
sys_blk_bottom = sys_blk_top + sys_blk_height;
sys_blk_right= sys_blk_left + 2*5* max(dim_port_name);
%PLACE AND SIZE BLOCK
if ~isempty(Subsys_Name)
set_param(Subsys_Name,'Position',[sys_blk_left sys_blk_top
sys_blk_right sys_blk_bottom]);
end
inp_blk_left = 10;
inp_blk_top = 10;
out_blk_left = 10;
out_blk_top = 10;
elseif strcmp( ColumnText ,InPortFlag) == 1
inp_blk_left = 10;
inp_blk_top = inp_blk_top + 50;
inp_blk_right = inp_blk_left + inp_blk_width;
inp_blk_bottom = inp_blk_top + inp_blk_height;
Subsys_InPort = strcat(Subsys_Name,'/',txt{i,2});
siz_port_name = size(txt{i,2});
dim_port_name(i) = siz_port_name (1,2);
add_block('built-in/Inport',Subsys_InPort);
set_param(Subsys_InPort,'Position',[inp_blk_left inp_blk_top
inp_blk_right inp_blk_bottom]);
sys_blk_bottom = sys_blk_bottom + 5;
old_dim_port_name = dim_port_name;
elseif strcmp( ColumnText ,OutPortFlag) == 1
out_blk_left = inp_blk_left + Dist_InPort_OutPort;
out_blk_top = out_blk_top + 50;
out_blk_right = out_blk_left + out_blk_width;
out_blk_bottom = out_blk_top + out_blk_height;
Subsys_OutPort = strcat(Subsys_Name,'/',txt{i,2});
siz_port_name = size(txt{i,2});
dim_port_name(i) = siz_port_name (1,2);
add_block('built-in/Outport',Subsys_OutPort);
set_param(Subsys_OutPort,'Position',[out_blk_left out_blk_top
out_blk_right out_blk_bottom]);
sys_blk_bottom = sys_blk_bottom + 5;
end
i=i+1;
end
****************************************
Thank you in advance.
Yves
--
View this message in context: http://mailinglists.scilab.org/Create-a-super-block-through-a-script-tp4032849.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.
More information about the users
mailing list