function rotor_proudy(block)

setup(block);
  
%endfunction

function setup(block)
  
  % Register number of ports
  block.NumInputPorts  = 2;
  block.NumOutputPorts = 19;

  % Setup port properties to be inherited or dynamic
  block.SetPreCompInpPortInfoToDynamic;
  block.SetPreCompOutPortInfoToDynamic;


  % Register parameters
  block.NumDialogPrms = 1;
  
   % Setup the continous state
  block.NumContStates = 0;

  % Register sample times
  %  [0 offset]            : Continuous sample time
  %  [positive_num offset] : Discrete sample time
  %
  %  [-1, 0]               : Inherited sample time
  %  [-2, 0]               : Variable sample time
  
  block.SampleTimes = [0 0];


  % Register block methods
  block.RegBlockMethod('InitializeConditions',    @InitConditions);
  block.RegBlockMethod('Outputs',                 @Output);  
  block.RegBlockMethod('Derivatives',             @Derivatives);
  block.RegBlockMethod('SetInputPortSamplingMode',@SetInpPortFrameData);
  
%endfunction

function InitConditions(block)

  % poè. hodnota
  
  
%endfunction

function Output(block)
% 
  uhel = block.DialogPrm(1).Data; %uhel natoceni rotoru
  
  theta = uhel*0.01745;
  Iralfa_vstup = block.InputPort(1).Data;
  Irbeta_vstup = block.InputPort(2).Data;
  
  Iralfa = Iralfa_vstup ;
  Irbeta = Irbeta_vstup ;
  
  
  block.OutputPort(1).Data  = cos(theta)         *Iralfa+sin(theta)        *Irbeta;
  block.OutputPort(2).Data  = cos(2*pi/19+theta) *Iralfa+sin(2*pi/19+theta)*Irbeta;
  block.OutputPort(3).Data  = cos(4*pi/19+theta) *Iralfa+sin(4*pi/19+theta)*Irbeta;
  block.OutputPort(4).Data  = cos(6*pi/19+theta) *Iralfa+sin(6*pi/19+theta)*Irbeta;
  block.OutputPort(5).Data  = cos(8*pi/19+theta) *Iralfa+sin(8*pi/19+theta)*Irbeta;
  block.OutputPort(6).Data  = cos(10*pi/19+theta)*Iralfa+sin(10*pi/19+theta)*Irbeta;
  block.OutputPort(7).Data  = cos(12*pi/19+theta)*Iralfa+sin(12*pi/19+theta)*Irbeta;
  block.OutputPort(8).Data  = cos(14*pi/19+theta)*Iralfa+sin(14*pi/19+theta)*Irbeta;
  block.OutputPort(9).Data  = cos(16*pi/19+theta)*Iralfa+sin(16*pi/19+theta)*Irbeta;
  block.OutputPort(10).Data = cos(18*pi/19+theta)*Iralfa+sin(18*pi/19+theta)*Irbeta;
  block.OutputPort(11).Data = cos(20*pi/19+theta)*Iralfa+sin(20*pi/19+theta)*Irbeta;
  block.OutputPort(12).Data = cos(22*pi/19+theta)*Iralfa+sin(22*pi/19+theta)*Irbeta;
  block.OutputPort(13).Data = cos(24*pi/19+theta)*Iralfa+sin(24*pi/19+theta)*Irbeta;
  block.OutputPort(14).Data = cos(26*pi/19+theta)*Iralfa+sin(26*pi/19+theta)*Irbeta;
  block.OutputPort(15).Data = cos(28*pi/19+theta)*Iralfa+sin(28*pi/19+theta)*Irbeta;
  block.OutputPort(16).Data = cos(30*pi/19+theta)*Iralfa+sin(30*pi/19+theta)*Irbeta;
  block.OutputPort(17).Data = cos(32*pi/19+theta)*Iralfa+sin(32*pi/19+theta)*Irbeta;
  block.OutputPort(18).Data = cos(34*pi/19+theta)*Iralfa+sin(34*pi/19+theta)*Irbeta;
  block.OutputPort(19).Data = cos(36*pi/19+theta)*Iralfa+sin(36*pi/19+theta)*Irbeta;
 
  
%endfunction

function Derivatives(block)
% 
   
%endfunction

function SetInpPortFrameData(block,idx,fd)

block.InputPort(idx).SamplingMode = fd;
for i = 1:block.NumOutputPorts
    block.OutputPort(i).SamplingMode = fd;
end
%endfunction