Documentation
Structure of a macro file
Each block need a macro file in the macros-directory.
function [x,y,typ] = hart_ser2par(job,arg1,arg2)
The macro is a scilab funtion. Filename and funktion name must be identical. The input and ouput structure must not be changed.
x=[];y=[];typ=[];
select job
case 'plot' then
exprs=arg1.graphics.exprs;
ch=exprs(1);samples=exprs(2)
standard_draw(arg1)
In the plot part it is possible to plot the content of a variable in front of the block. Here the first variable "ch" and the second variable "samples" is loaded and can be used for plotting.
case 'getinputs' then
[x,y,typ]=standard_inputs(arg1)
case 'getoutputs' then
[x,y,typ]=standard_outputs(arg1)
case 'getorigin' then
[x,y]=standard_origin(arg1)
The getinputs,getoutputs and getorigin parts should not be changed.
case 'set' thenThe set case is selected every time, when the block is opened in Scicos.
x=arg1
model=arg1.model;
graphics=arg1.graphics;
exprs=graphics.exprs;
while %t doThe getvalue-funktion opens a graphical dialog. The first input-parameter is the title, the second parameter is the text of each box and the last parameter is the definition of the type that can be inserted. Following definition are possible:
[ok,ch,samples,exprs]=..
getvalue('Set ser2par block parameters',..
['Channels:';
'No of Samples:'],..
list('vec',-1,'vec',-1),exprs)
- "mat" : for constant matrix
- "col" : for constant column vector
- "row" : for constant row vector
- "vec" : for constant vector
- "str" : for string
- "lis" : for list
if ~ok then break,endNothing will be saved, if an error occurs.
outport=ch;The check_io funktion sets the dimension of the inputs and outputs.
inport=ch;
if exists('inport') then in=ones(inport,1), else in=1, end
if exists('outport') then out=ones(outport,1)*samples, else out=1, end
[model,graphics,ok]=check_io(model,graphics,in,out,1,[])
if ok thenIn the next step, spezific parts of the the model-structure are changed. Take a look at the scilab help for more Information.
graphics.exprs=exprs;
model.ipar=[ch;
samples;];
model.dstate=[];
model.rpar=[];
x.graphics=graphics;x.model=model
break
end
end
case 'define' thenThe define case is only selected once, when the block is inserted in the scicos diagram.
ch=1;
samples=50;
model=scicos_model()
model.sim=list('rt_ser2par',4)
outport=ch;
inport=ch;
if exists('inport') then model.in=ones(inport,1), else model.in=1, end
if exists('outport') then model.out=ones(outport,1)*samples, else model.out=1, end
model.evtin=[1]
model.rpar=[]
model.ipar=[ch;
samples;]
model.dstate=[];
model.blocktype='d'
model.dep_ut=[%f %f]
exprs=[sci2exp(ch),sci2exp(samples)]Each variable, which can be changed through the getvalue-dialog must inserted here.
gr_i=['xstringb(orig(1),orig(2),[''1 -> ''+string(samples);''ser2par''],sz(1),sz(2),''fill'');']This part defines the look of the block.
x=standard_define([3 2],model,exprs,gr_i)
end
endfunction