function [ZVe,NVe,Q,IN,OU,MT,NV,BRF]=struc030(SOR,OU,P1,P2)
%        [ZVe,NVe,Q,IN,OU,MT,NV,BRF]=struc030(SOR,OU,P1,P2)
%STRUC030 S(dt+book:ex2/par3-u/PID): Par=[VS T1 T2];
%                                    Reg=[VR d1 d2];
%                                    P1=k
%         Whole-number dead time, single control loop - undelayed input
%         signal;
%         example 2 paragraph 3 in book "Entwurf digitaler Regler für
%         elektrische Antriebe", Geitner, VDE-Verlag 1996;
%	      structure and simulation see SIST030.mdl; loop design:
%         loop: PID-type controller, two first-order time-delay elements,
%               dead time = k * sampling time,

%AUXILIARY FILE for symbolical definition - no stand-alone calling !!!
%	  SOR:   switch - to shift between plant or control structure
%	  OU:    vector using continuous output numbers for discretized plant state
%            description
%     P1,P2: posibility of any parameter transfer via bod_es.m

% KEY WORDS: Digital Magnitude Optimum, symbolical plant and control structure
%            definition, application basis for: bod_es. / bod_esg.m / bod_esp.m

% Copyright (c) 2011-2023 Dr. Gert-Helge Geitner, TU Dresden,
%                     https://wwwpub.zih.tu-dresden.de/~geitner/ae_1_0e.htm
% Digital Magnitude Optimum reference: Geitner, G.-H.:
%                    Entwurf digitaler Regler für elektrische Antriebe.
%                    VDE-Verlag GmbH Berlin und Offenbach 1996
%                    ISBN 3-8007-1847-2

if SOR==0  %plant structure definition

% ****** beginning ******
%

sz1='VS;';  sn1='conv([T1 1],[T2 1]);';
 Q=[1 0]; IN=[1]; OU=[1];
 MT=[0 1];
 NV=['VS; T1; T2; '];
% ****** ending ******

s=0; zae=0; ZVe=[]; NVe=[]; BRF=0;
while s==0 zae=zae+1;  eval(['ZVe=[ZVe sz' num2str(zae) '];'],'s=1;');
                       eval(['NVe=[NVe sn' num2str(zae) '];'],'s=1;'); end

else  %control structure definition

%******* beginning ******
rz2='VR*[1 d1 d2];';         rn2='[1 -1];';
rz3='[';		               rn3='1;';
for i=1:P1 rz3=[rz3 '0 ']; end
rz3=[rz3 '1];'];
QQ=[1  3
    2 -1
    3  2];
BME=[2];
BMA=[1];
 BM=[3
     0];  BRF=1;
NV=['VR; d1; d2; '];
%****** ending ******

s=0; zae=length(OU); ZVe=[]; NVe=[];
while s==0 zae=zae+1;  eval(['ZVe=[ZVe rz' num2str(zae) '];'],'s=1;');
                       eval(['NVe=[NVe rn' num2str(zae) '];'],'s=1;'); end
Q=QQ;IN=BME;OU=BMA;MT=BM;
end
