plc4good.org.ua

PCS7: KalFilt - Kalman filter (FB1925)



flow



The Kalman filter is a non-linear stochastic state observer.
It forms a framework for parallel simulation of a dynamic process model, whose states are compared with real data in each cycle.

FB1925 huge code without interface...



Name: FB1925
Symbolic Name: KalFilt
Symbol Comment: Kalman-Filter
Family: Control
Version: 9.2
Author: AdvLib90
Last modified: 23/08/2018
Use:
Size in work memory: 44748 bytes
Signature: compiled by SCL compiler version: SCLCOMP K05.06.00.00_11.01.00.01 release





{
Scl_ResetOptions ;
Scl_OverwriteBlocks:=           'y' ;
Scl_GenerateReferenceData :=    'y' ;
Scl_S7ServerActive:=            'n' ;
Scl_CreateObjectCode:=          'y' ;
Scl_OptimizeObjectCode:=        'y' ;
Scl_MonitorArrayLimits:=        'n' ;
Scl_CreateDebugInfo :=          'n' ;
Scl_SetOKFlag:=                 'n' ;
Scl_SetMaximumStringLength:=    '254'
}
 
 
FUNCTION_BLOCK FB11925 //"KalFilt"
TITLE ='Kalman-Filter'
{ S7_m_c := 'true'; S7_tasklist := 'OB100'; PO_Count := '100' }
AUTHOR : AdvLib90
FAMILY : Control
NAME : KalFilt
VERSION : '9.2'
 
 
BEGIN
 
xError:=FALSE;
xErrorFc:=FALSE;
xErrorPara:=FALSE;
xErrorUk:=FALSE;
xErrorYk:=FALSE;
xErrorYn:=FALSE;
xErrorNAN:=FALSE;
xErrorInv:=FALSE;
rSampleTime:=SrKonSampleTime;
byWorstQC:=B#16#80;
ErrorNum:=0;
xFeat_StartupWithOutInit:=Feature.Bit0;
xFeat_OosLiEn:=Feature.Bit1;
xFeat_ResetInLi:=Feature.Bit2;
xFeat_OnlyActPos:=Feature.Bit4;
xFeat_SSinOOS:=Feature.Bit5;
xFeatLocalAuth:=Feature.Bit24;
dwStatus1:=Status1;
dwStatus2:=Status2;
IF ((((NumberU>7) OR (NumberY>7)) OR (NumberX>15)) OR ((NumberYn>5) AND SampleEn)) THEN //A7d0//
    xErrorPara:=TRUE;
END_IF; //A7d0//
 
 
nRetval:=RD_SINFO(TOP_SI := stcTOP_SI
         ,START_UP_SI :=  stcSTART_UP_SI
         );
xOB_Cycle:=(BYTE_TO_INT(stcTOP_SI.NUM AND B#16#FF)>=30) AND (BYTE_TO_INT(stcTOP_SI.NUM AND B#16#FF)<=38);
xOB_Start:=BYTE_TO_INT(stcTOP_SI.NUM AND B#16#FF)=100;
 
IF (xFeatLocalAuth) THEN //A7d1//
    OpSt_Out:=OpSt_In OR DW#16#80000000;
ELSE //A7d1//
    OpSt_Out:=OpSt_In AND DW#16#7FFFFFFF;
END_IF; //A7d2//
IF (OnOp) THEN //A7d3//
    OosAct.Value:=FALSE;
    Y1Filt.ST:=B#16#80;
    Y2Filt.ST:=B#16#80;
    Y3Filt.ST:=B#16#80;
    Y4Filt.ST:=B#16#80;
    Y5Filt.ST:=B#16#80;
    Y6Filt.ST:=B#16#80;
    Y7Filt.ST:=B#16#80;
    X1.ST:=B#16#80;
    X2.ST:=B#16#80;
    X3.ST:=B#16#80;
    X4.ST:=B#16#80;
    X5.ST:=B#16#80;
    X6.ST:=B#16#80;
    X7.ST:=B#16#80;
    X8.ST:=B#16#80;
    X9.ST:=B#16#80;
    X10.ST:=B#16#80;
    X11.ST:=B#16#80;
    X12.ST:=B#16#80;
    X13.ST:=B#16#80;
    X14.ST:=B#16#80;
    X15.ST:=B#16#80;
ELSIF ((((OosLi.Value) AND xFeat_OosLiEn) AND (NOT(SxOosLi))) OR OosOp) THEN //A7d5//
    OosAct.Value:=TRUE;
    IF (xFeat_SSinOOS) THEN //A7d6//
        X1.ST:=B#16#60;
        X2.ST:=B#16#60;
        X3.ST:=B#16#60;
        X4.ST:=B#16#60;
        X5.ST:=B#16#60;
        X6.ST:=B#16#60;
        X7.ST:=B#16#60;
        X8.ST:=B#16#60;
        X9.ST:=B#16#60;
        X10.ST:=B#16#60;
        X11.ST:=B#16#60;
        X12.ST:=B#16#60;
        X13.ST:=B#16#60;
        X14.ST:=B#16#60;
        X15.ST:=B#16#60;
        U1Out.ST:=B#16#60;
        U2Out.ST:=B#16#60;
        U3Out.ST:=B#16#60;
        U4Out.ST:=B#16#60;
        U5Out.ST:=B#16#60;
        U6Out.ST:=B#16#60;
        U7Out.ST:=B#16#60;
        Y1Out.ST:=B#16#60;
        Y2Out.ST:=B#16#60;
        Y3Out.ST:=B#16#60;
        Y4Out.ST:=B#16#60;
        Y5Out.ST:=B#16#60;
        Y6Out.ST:=B#16#60;
        Y7Out.ST:=B#16#60;
        Yn1Out.ST:=B#16#60;
        Yn2Out.ST:=B#16#60;
        Yn3Out.ST:=B#16#60;
        Yn4Out.ST:=B#16#60;
        Yn5Out.ST:=B#16#60;
        Y1Filt.ST:=B#16#60;
        Y2Filt.ST:=B#16#60;
        Y3Filt.ST:=B#16#60;
        Y4Filt.ST:=B#16#60;
        Y5Filt.ST:=B#16#60;
        Y6Filt.ST:=B#16#60;
        Y7Filt.ST:=B#16#60;
        Z1Out.ST:=B#16#60;
        Z2Out.ST:=B#16#60;
        Z3Out.ST:=B#16#60;
        Z4Out.ST:=B#16#60;
        Z5Out.ST:=B#16#60;
        SaPo_ExtAct.ST:=B#16#60;
        SaRe_ExtAct.ST:=B#16#60;
    ELSE //A7d6//
        U1Out.ST:=U1.ST;
        U2Out.ST:=U2.ST;
        U3Out.ST:=U3.ST;
        U4Out.ST:=U4.ST;
        U5Out.ST:=U5.ST;
        U6Out.ST:=U6.ST;
        U7Out.ST:=U7.ST;
        Y1Out.ST:=Y1.ST;
        Y2Out.ST:=Y2.ST;
        Y3Out.ST:=Y3.ST;
        Y4Out.ST:=Y4.ST;
        Y5Out.ST:=Y5.ST;
        Y6Out.ST:=Y6.ST;
        Y7Out.ST:=Y7.ST;
        Z1Out.ST:=B#16#80;
        Z2Out.ST:=B#16#80;
        Z3Out.ST:=B#16#80;
        Z4Out.ST:=B#16#80;
        Z5Out.ST:=B#16#80;
        Yn1Out.ST:=B#16#80;
        Yn2Out.ST:=B#16#80;
        Yn3Out.ST:=B#16#80;
        Yn4Out.ST:=B#16#80;
        Yn5Out.ST:=B#16#80;
        SaPo_ExtAct.ST:=B#16#80;
        SaRe_ExtAct.ST:=B#16#80;
        Y1Filt.ST:=B#16#80;
        Y2Filt.ST:=B#16#80;
        Y3Filt.ST:=B#16#80;
        Y4Filt.ST:=B#16#80;
        Y5Filt.ST:=B#16#80;
        Y6Filt.ST:=B#16#80;
        Y7Filt.ST:=B#16#80;
        X1.ST:=B#16#80;
        X2.ST:=B#16#80;
        X3.ST:=B#16#80;
        X4.ST:=B#16#80;
        X5.ST:=B#16#80;
        X6.ST:=B#16#80;
        X7.ST:=B#16#80;
        X8.ST:=B#16#80;
        X9.ST:=B#16#80;
        X10.ST:=B#16#80;
        X11.ST:=B#16#80;
        X12.ST:=B#16#80;
        X13.ST:=B#16#80;
        X14.ST:=B#16#80;
        X15.ST:=B#16#80;
    END_IF;
END_IF; //A7d5//
SxOosLi:=OosLi.Value;
OnAct.Value:=NOT(OosAct.Value);
 
IF (OosAct.Value) THEN //A7d8//
    ErrorNum:=0;
    ST_Worst:=B#16#80;
END_IF; //A7d8//
 
 
 
 
IF (((Reset) OR LoadParam) OR ((NOT(xFeat_StartupWithOutInit)) AND xOB_Start)) THEN //A7d9//
 
   
 
    IF ((Reset) OR LoadParam) THEN //A7da//
        Reset:=FALSE;
        nAnlauf:=-2;
    ELSE //A7da//
        nAnlauf:=-1;
    END_IF; //A7db//
   
    SxErrorStart:=FALSE;
    SxErrorDB:=FALSE;
    SxErrorLimit:=FALSE;
    SxErrorFC:=FALSE;
    SxErrorSampleTime:=FALSE;
    SampExtracted:=FALSE;
    LabResIncluded:=FALSE;
    SbSampleAbort:=FALSE;
    SbSampleTimeOut:=FALSE;
    SbSampleLimit:=FALSE;
    SaPo_Ext:=FALSE;
    SaPo_Int:=FALSE;
    SaRe_Ext:=FALSE;
    SaRe_Int:=FALSE;
    SnUfactorCounter:=0;
   
    MxZero(dim :=  15
       ,StcMxN :=  StcNullmx
       ); // VOID
      
    MxUnity(dim :=  NumberX
        ,StcMxI :=  StcImx
        ); // VOID  
 
    IF (LoadParam) THEN //A7dc//
        SxErrorDB:=TRUE;
        xErrorPara:=FALSE;
        ErrorNum:=0;
        KalFunct.SampleTime:=SrKonSampleTime;
        KalFunct.ProModId:=ModelNo;
        KalFunct.CalcFunc:=-2;
        KalFunct.NumberX:=NumberX;
        KalFunct.NumberY:=NumberY;
        KalFunct.NumberYn:=NumberYn;
        KalFunct.NumberZ:=NumberZ;
       
        KalFunct(StcX_MinusK := StcNullmx
                      ,StcX_PlusK := StcNullmx
                      ,StcU := StcNullmx
                      );
       
        StcTemp1:=KalFunct.StcX_MinK1;
        StcTemp2:=KalFunct.StcY_MinusK;
        StcTemp3:=KalFunct.StcH;
        StcTemp4:=KalFunct.StcPHI;
       
        StcStcKonf:=KalFunct.StcKalDB;
 
        SxErrorFC:=KalFunct.Error;
        SrKonSampleTime:=StcStcKonf.SampleTime;
        IF (SrKonSampleTime<SampleTime) THEN //A7dd//
            SnKonUfactor:=1;
            ErrorNum:=2;
            SxErrorSampleTime:=TRUE;
        ELSE //A7dd//
            SnKonUfactor:=REAL_TO_INT(SrKonSampleTime/SampleTime);
        END_IF; //A7de//
        
        IF (StcStcKonf.MatrixSize<=15) THEN //A7dc//
            NumberX:=StcStcKonf.NumberX;
            NumberU:=StcStcKonf.NumberU;
            NumberY:=StcStcKonf.NumberY;
            NumberZ:=StcStcKonf.NumberZ;
            IF (StcStcKonf.SampleEn=1) THEN //A7e0//
                SampleEn:=TRUE;
            ELSE //A7e0//
                SampleEn:=FALSE;
            END_IF; //A7e1//
           
            IF (SampleEn) THEN //A7e2//
                NumberYn:=StcStcKonf.NumberYn;
            END_IF; //A7e2//
           
            StcQ_k:=StcNullmx;
            FOR laufu:=1 TO StcStcKonf.NumberX BY 1 DO
                StcQ_k_aux.arr1[laufu,laufu]:=StcStcKonf_aux.Q_Diag[laufu];
            END_FOR;
           
            Q11:=StcQ_k.elem11;
            Q22:=StcQ_k.elem22;
            Q33:=StcQ_k.elem33;
            Q44:=StcQ_k.elem44;
            Q55:=StcQ_k.elem55;
            Q66:=StcQ_k.elem66;
            Q77:=StcQ_k.elem77;
            Q88:=StcQ_k.elem88;
            Q99:=StcQ_k.elem99;
            Q1010:=StcQ_k.elemAA;
            Q1111:=StcQ_k.elemBB;
            Q1212:=StcQ_k.elemCC;
            Q1313:=StcQ_k.elemDD;
            Q1414:=StcQ_k.elemEE;
            Q1515:=StcQ_k.elemFF;
           
            StcR_k:=StcNullmx;
            FOR laufu:=1 TO StcStcKonf.NumberY BY 1 DO
                StcR_k_aux.arr1[laufu,laufu]:=StcStcKonf_aux.R_Diag[laufu];
            END_FOR;
           
            R11:=StcR_k.elem11;
            R22:=StcR_k.elem22;
            R33:=StcR_k.elem33;
            R44:=StcR_k.elem44;
            R55:=StcR_k.elem55;
            R66:=StcR_k.elem66;
            R77:=StcR_k.elem77;
           
            StcX_dach_minus_k:=StcNullmx;
            FOR laufu:=1 TO StcStcKonf.NumberX BY 1 DO
                StcX_dach_minus_k_aux.arr1[laufu,1]:=StcStcKonf_aux.X_Start[laufu];
            END_FOR;
           
            X1Start:=StcX_dach_minus_k.elem11;
            X2Start:=StcX_dach_minus_k.elem21;
            X3Start:=StcX_dach_minus_k.elem31;
            X4Start:=StcX_dach_minus_k.elem41;
            X5Start:=StcX_dach_minus_k.elem51;
            X6Start:=StcX_dach_minus_k.elem61;
            X7Start:=StcX_dach_minus_k.elem71;
            X8Start:=StcX_dach_minus_k.elem81;
            X9Start:=StcX_dach_minus_k.elem91;
            X10Start:=StcX_dach_minus_k.elemA1;
            X11Start:=StcX_dach_minus_k.elemB1;
            X12Start:=StcX_dach_minus_k.elemC1;
            X13Start:=StcX_dach_minus_k.elemD1;
            X14Start:=StcX_dach_minus_k.elemE1;
            X15Start:=StcX_dach_minus_k.elemF1;
           
            x_dach_limit:=StcNullmx_aux;
            FOR laufu:=1 TO StcStcKonf.NumberX BY 1 DO
                x_dach_limit_aux.elemente[laufu,1]:=StcStcKonf_aux.X_LoLim[laufu];
                x_dach_limit_aux.elemente[laufu,2]:=StcStcKonf_aux.X_HiLim[laufu];
            END_FOR;
            X1LimScale.Low:=x_dach_limit.elemente[1, 1];
            X1LimScale.High:=x_dach_limit.elemente[1, 2];
            X2LimScale.Low:=x_dach_limit.elemente[2, 1];
            X2LimScale.High:=x_dach_limit.elemente[2, 2];
            X3LimScale.Low:=x_dach_limit.elemente[3, 1];
            X3LimScale.High:=x_dach_limit.elemente[3, 2];
            X4LimScale.Low:=x_dach_limit.elemente[4, 1];
            X4LimScale.High:=x_dach_limit.elemente[4, 2];
            X5LimScale.Low:=x_dach_limit.elemente[5, 1];
            X5LimScale.High:=x_dach_limit.elemente[5, 2];
            X6LimScale.Low:=x_dach_limit.elemente[6, 1];
            X6LimScale.High:=x_dach_limit.elemente[6, 2];
            X7LimScale.Low:=x_dach_limit.elemente[7, 1];
            X7LimScale.High:=x_dach_limit.elemente[7, 2];
            X8LimScale.Low:=x_dach_limit.elemente[8, 1];
            X8LimScale.High:=x_dach_limit.elemente[8, 2];
            X9LimScale.Low:=x_dach_limit.elemente[9, 1];
            X9LimScale.High:=x_dach_limit.elemente[9, 2];
            X10LimScale.Low:=x_dach_limit.elemente[10, 1];
            X10LimScale.High:=x_dach_limit.elemente[10, 2];
            X11LimScale.Low:=x_dach_limit.elemente[11, 1];
            X11LimScale.High:=x_dach_limit.elemente[11, 2];
            X12LimScale.Low:=x_dach_limit.elemente[12, 1];
            X12LimScale.High:=x_dach_limit.elemente[12, 2];
            X13LimScale.Low:=x_dach_limit.elemente[13, 1];
            X13LimScale.High:=x_dach_limit.elemente[13, 2];
            X14LimScale.Low:=x_dach_limit.elemente[14, 1];
            X14LimScale.High:=x_dach_limit.elemente[14, 2];
            X15LimScale.Low:=x_dach_limit.elemente[15, 1];
            X15LimScale.High:=x_dach_limit.elemente[15, 2];
 
            IF (SampleEn) THEN //A7eb//
                FOR laufu:=1 TO StcStcKonf.NumberYn BY 1 DO
                    StcR_n_aux.arr1[laufu,laufu]:=StcStcKonf_aux.Rn_Diag[laufu];
                    yn_LoLim_aux.elemente[laufu]:=StcStcKonf_aux.Yn_LoLim[laufu];
                    yn_HiLim_aux.elemente[laufu]:=StcStcKonf_aux.Yn_HiLim[laufu];
                END_FOR;
                Rn11:=StcR_n.elem11;
                Rn22:=StcR_n.elem22;
                Rn33:=StcR_n.elem33;
                Rn44:=StcR_n.elem44;
                Rn55:=StcR_n.elem55;
                Yn1LimScale.Low:=yn_LoLim.elemente[1];
                Yn1LimScale.High:=yn_HiLim.elemente[1];
                Yn2LimScale.Low:=yn_LoLim.elemente[2];
                Yn2LimScale.High:=yn_HiLim.elemente[2];
                Yn3LimScale.Low:=yn_LoLim.elemente[3];
                Yn3LimScale.High:=yn_HiLim.elemente[3];
                Yn4LimScale.Low:=yn_LoLim.elemente[4];
                Yn4LimScale.High:=yn_HiLim.elemente[4];
                Yn5LimScale.Low:=yn_LoLim.elemente[5];
                Yn5LimScale.High:=yn_HiLim.elemente[5];
            END_IF; //A7eb//
            SxErrorDB:=FALSE;
            LoadParam:=FALSE;
        END_IF;
    END_IF;
   
   
   
    IF ((NOT(SxErrorDB)) AND (NOT(xErrorPara))) THEN //A7ee//
        StcX_dach_minus_k:=StcNullmx;
       
        StcX_dach_minus_k.zeilenzahl:=NumberX;
        StcX_dach_minus_k.spaltenzahl:=1;
        StcX_dach_minus_k.elem11:=X1Start;
        StcX_dach_minus_k.elem21:=X2Start;
        StcX_dach_minus_k.elem31:=X3Start;
        StcX_dach_minus_k.elem41:=X4Start;
        StcX_dach_minus_k.elem51:=X5Start;
        StcX_dach_minus_k.elem61:=X6Start;
        StcX_dach_minus_k.elem71:=X7Start;
        StcX_dach_minus_k.elem81:=X8Start;
        StcX_dach_minus_k.elem91:=X9Start;
        StcX_dach_minus_k.elemA1:=X10Start;
        StcX_dach_minus_k.elemB1:=X11Start;
        StcX_dach_minus_k.elemC1:=X12Start;
        StcX_dach_minus_k.elemD1:=X13Start;
        StcX_dach_minus_k.elemE1:=X14Start;
        StcX_dach_minus_k.elemF1:=X15Start;
       
        x_dach_limit:=StcNullmx_aux;
       
        x_dach_limit.zeilenzahl:=NumberX;
        x_dach_limit.spaltenzahl:=2;
        x_dach_limit.elemente[1, 1]:=X1LimScale.Low;
        x_dach_limit.elemente[1, 2]:=X1LimScale.High;
        x_dach_limit.elemente[2, 1]:=X2LimScale.Low;
        x_dach_limit.elemente[2, 2]:=X2LimScale.High;
        x_dach_limit.elemente[3, 1]:=X3LimScale.Low;
        x_dach_limit.elemente[3, 2]:=X3LimScale.High;
        x_dach_limit.elemente[4, 1]:=X4LimScale.Low;
        x_dach_limit.elemente[4, 2]:=X4LimScale.High;
        x_dach_limit.elemente[5, 1]:=X5LimScale.Low;
        x_dach_limit.elemente[5, 2]:=X5LimScale.High;
        x_dach_limit.elemente[6, 1]:=X6LimScale.Low;
        x_dach_limit.elemente[6, 2]:=X6LimScale.High;
        x_dach_limit.elemente[7, 1]:=X7LimScale.Low;
        x_dach_limit.elemente[7, 2]:=X7LimScale.High;
        x_dach_limit.elemente[8, 1]:=X8LimScale.Low;
        x_dach_limit.elemente[8, 2]:=X8LimScale.High;
        x_dach_limit.elemente[9, 1]:=X9LimScale.Low;
        x_dach_limit.elemente[9, 2]:=X9LimScale.High;
        x_dach_limit.elemente[10, 1]:=X10LimScale.Low;
        x_dach_limit.elemente[10, 2]:=X10LimScale.High;
        x_dach_limit.elemente[11, 1]:=X11LimScale.Low;
        x_dach_limit.elemente[11, 2]:=X11LimScale.High;
        x_dach_limit.elemente[12, 1]:=X12LimScale.Low;
        x_dach_limit.elemente[12, 2]:=X12LimScale.High;
        x_dach_limit.elemente[13, 1]:=X13LimScale.Low;
        x_dach_limit.elemente[13, 2]:=X13LimScale.High;
        x_dach_limit.elemente[14, 1]:=X14LimScale.Low;
        x_dach_limit.elemente[14, 2]:=X14LimScale.High;
        x_dach_limit.elemente[15, 1]:=X15LimScale.Low;
        x_dach_limit.elemente[15, 2]:=X15LimScale.High;
       
        StcX_dach_plus_k:=StcNullmx;
       
        StcX_dach_plus_k.zeilenzahl:=NumberX;
        StcX_dach_plus_k.spaltenzahl:=1;
 
        StcU_k:=StcNullmx;
        StcU_k.zeilenzahl:=NumberU;
        StcU_k.spaltenzahl:=1;
   
       
        StcY_k:=StcNullmx;
        StcY_k.zeilenzahl:=NumberY;
        StcY_k.spaltenzahl:=1;
 
        StcY_dach_minus_k:=StcNullmx;
        StcY_dach_minus_k.zeilenzahl:=NumberY;
        StcY_dach_minus_k.spaltenzahl:=1;
 
        StcR_k:=StcNullmx;
        StcR_k.zeilenzahl:=NumberY;
        StcR_k.spaltenzahl:=NumberY;
       
        StcR_n:=StcNullmx;
        StcR_n.zeilenzahl:=NumberYn;
        StcR_n.spaltenzahl:=NumberYn;
       
        StcK_n:=StcNullmx;
        StcK_n.zeilenzahl:=NumberX;
        StcK_n.spaltenzahl:=NumberYn;
       
        StcH_n:=StcNullmx;
        StcH_n.zeilenzahl:=NumberYn;
        StcH_n.spaltenzahl:=NumberX;
       
        StcY_n:=StcNullmx;
        StcY_n.zeilenzahl:=NumberYn;
        StcY_n.spaltenzahl:=1;
       
        StcSum_phi_n:=StcNullmx;
        StcSum_phi_n.zeilenzahl:=NumberX;
        StcSum_phi_n.spaltenzahl:=NumberX;
       
        EY_limit_n:=StcNullmx_aux;
        EY_limit_n.zeilenzahl:=NumberYn;
        EY_limit_n.spaltenzahl:=1;
       
        EYP:=StcNullmx_aux;
        EYP.zeilenzahl:=NumberY;
        EYP.spaltenzahl:=5;
       
        ey_n:=StcNullmx_aux;
        ey_n.zeilenzahl:=NumberYn;
        ey_n.spaltenzahl:=1;
       
        StcQ_k:=StcNullmx;
        StcQ_k.zeilenzahl:=NumberX;
        StcQ_k.spaltenzahl:=NumberX;
       
        StcP_minus_k:=StcNullmx;
        StcP_minus_k.zeilenzahl:=NumberX;
        StcP_minus_k.spaltenzahl:=NumberX;
       
        StcP_plus_k:=StcNullmx;
        StcP_plus_k.zeilenzahl:=NumberX;
        StcP_plus_k.spaltenzahl:=NumberX;
       
        StcK_k:=StcNullmx;
        StcK_k.zeilenzahl:=NumberX;
        StcK_k.spaltenzahl:=NumberY;
       
        StcPhi_k:=StcNullmx;
        StcPhi_k.zeilenzahl:=NumberX;
        StcPhi_k.spaltenzahl:=NumberX;
       
        StcH_k:=StcNullmx;
        StcH_k.zeilenzahl:=NumberY;
        StcH_k.spaltenzahl:=NumberX;
       
        KalFunct(SampleTime := SrKonSampleTime
              ,ProModId :=  ModelNo
              ,CalcFunc :=  nAnlauf
              ,NumberX :=  NumberX
              ,NumberY :=  NumberY
              ,NumberYn :=  NumberYn
              ,NumberZ :=  NumberZ
              ,StcX_MinusK :=  StcNullmx
              ,StcX_PlusK :=  StcNullmx
              ,StcU :=  StcNullmx
              );
       
        StcTemp1:=KalFunct.StcX_MinK1;
        StcTemp2:=KalFunct.StcY_MinusK;
        StcTemp3:=KalFunct.StcH;
        StcTemp4:=KalFunct.StcPHI;
 
        StcStcKonf:=KalFunct.StcKalDB;
 
        SxErrorFC:=KalFunct.Error;
        FOR i:=1 TO StcX_dach_plus_k.zeilenzahl BY 1 DO
            IF (StcX_dach_minus_k_aux1.arr1[i,1] < x_dach_limit.elemente[i,1]) OR (StcX_dach_minus_k_aux1.arr1[i,1] > x_dach_limit.elemente[i,2]) THEN
                SxErrorLimit:=TRUE;
            END_IF;
        END_FOR;
    END_IF;   
 
    SxErrorStart:=(((SxErrorLimit) OR SxErrorFC) OR SxErrorDB) OR SxErrorSampleTime;
       
ELSIF (((((NOT(OosAct.Value)) AND xOB_Cycle) AND (NOT(xErrorPara))) AND (NOT(SxErrorStart))) AND (SnUfactorCounter=1)) THEN //A7f3//
    rSampleTime:=SrKonSampleTime;
    IF (rSampleTime<1.000000e-003) THEN //A7f4//
        rSampleTime:=1.000000e-003;
        ErrorNum:=2;
    END_IF; //A7f4//
    xSamplePoint:=((SaPo_Ext) AND SaPo_LiOp) OR ((NOT(SaPo_LiOp)) AND SaPo_Int);
    xSampleResult:=((SaRe_Ext) AND SaRe_LiOp) OR ((NOT(SaRe_LiOp)) AND SaRe_Int);
    x_dach_limit.elemente[1, 1]:=X1LimScale.Low;
    x_dach_limit.elemente[1, 2]:=X1LimScale.High;
    x_dach_limit.elemente[2, 1]:=X2LimScale.Low;
    x_dach_limit.elemente[2, 2]:=X2LimScale.High;
    x_dach_limit.elemente[3, 1]:=X3LimScale.Low;
    x_dach_limit.elemente[3, 2]:=X3LimScale.High;
    x_dach_limit.elemente[4, 1]:=X4LimScale.Low;
    x_dach_limit.elemente[4, 2]:=X4LimScale.High;
    x_dach_limit.elemente[5, 1]:=X5LimScale.Low;
    x_dach_limit.elemente[5, 2]:=X5LimScale.High;
    x_dach_limit.elemente[6, 1]:=X6LimScale.Low;
    x_dach_limit.elemente[6, 2]:=X6LimScale.High;
    x_dach_limit.elemente[7, 1]:=X7LimScale.Low;
    x_dach_limit.elemente[7, 2]:=X7LimScale.High;
    x_dach_limit.elemente[8, 1]:=X8LimScale.Low;
    x_dach_limit.elemente[8, 2]:=X8LimScale.High;
    x_dach_limit.elemente[9, 1]:=X9LimScale.Low;
    x_dach_limit.elemente[9, 2]:=X9LimScale.High;
    x_dach_limit.elemente[10, 1]:=X10LimScale.Low;
    x_dach_limit.elemente[10, 2]:=X10LimScale.High;
    x_dach_limit.elemente[11, 1]:=X11LimScale.Low;
    x_dach_limit.elemente[11, 2]:=X11LimScale.High;
    x_dach_limit.elemente[12, 1]:=X12LimScale.Low;
    x_dach_limit.elemente[12, 2]:=X12LimScale.High;
    x_dach_limit.elemente[13, 1]:=X13LimScale.Low;
    x_dach_limit.elemente[13, 2]:=X13LimScale.High;
    x_dach_limit.elemente[14, 1]:=X14LimScale.Low;
    x_dach_limit.elemente[14, 2]:=X14LimScale.High;
    x_dach_limit.elemente[15, 1]:=X15LimScale.Low;
    x_dach_limit.elemente[15, 2]:=X15LimScale.High;
    StcR_k.elem11:=R11;
    StcR_k.elem22:=R22;
    StcR_k.elem33:=R33;
    StcR_k.elem44:=R44;
    StcR_k.elem55:=R55;
    StcR_k.elem66:=R66;
    StcR_k.elem77:=R77;
    StcQ_k.elem11:=Q11;
    StcQ_k.elem22:=Q22;
    StcQ_k.elem33:=Q33;
    StcQ_k.elem44:=Q44;
    StcQ_k.elem55:=Q55;
    StcQ_k.elem66:=Q66;
    StcQ_k.elem77:=Q77;
    StcQ_k.elem88:=Q88;
    StcQ_k.elem99:=Q99;
    StcQ_k.elemAA:=Q1010;
    StcQ_k.elemBB:=Q1111;
    StcQ_k.elemCC:=Q1212;
    StcQ_k.elemDD:=Q1313;
    StcQ_k.elemEE:=Q1414;
    StcQ_k.elemFF:=Q1515;
    StcR_n.elem11:=Rn11;
    StcR_n.elem22:=Rn22;
    StcR_n.elem33:=Rn33;
    StcR_n.elem44:=Rn44;
    StcR_n.elem55:=Rn55;
    IF (SimOn) THEN //A7f5//
        arrAnalogValue[1]:=SimU1;
        arrAnalogValue[2]:=SimU2;
        arrAnalogValue[3]:=SimU3;
        arrAnalogValue[4]:=SimU4;
        arrAnalogValue[5]:=SimU5;
        arrAnalogValue[6]:=SimU6;
        arrAnalogValue[7]:=SimU7;
        FOR i:=1 TO StcU_k.zeilenzahl BY 1 DO
            arrQualityCode[i]:=B#16#60;
        END_FOR;   
    ELSE //A7f5//
 
        IF (U1.Value<U1LimScale.Low) THEN //A7f9//
            arrAnalogValue[1]:=U1LimScale.Low;
        ELSIF (U1.Value>U1LimScale.High) THEN //A7fb//
            arrAnalogValue[1]:=U1LimScale.High;
        ELSE //A7fb//
            arrAnalogValue[1]:=U1.Value;
        END_IF; //A7fa//
       
        IF (U2.Value<U2LimScale.Low) THEN //A7fc//
            arrAnalogValue[2]:=U2LimScale.Low;
        ELSIF (U2.Value>U2LimScale.High) THEN //A7fe//
            arrAnalogValue[2]:=U2LimScale.High;
        ELSE //A7fe//
            arrAnalogValue[2]:=U2.Value;
        END_IF; //A7fd//
       
        IF (U3.Value<U3LimScale.Low) THEN //A7ff//
            arrAnalogValue[3]:=U3LimScale.Low;
        ELSIF (U3.Value>U3LimScale.High) THEN //A801//
            arrAnalogValue[3]:=U3LimScale.High;
        ELSE //A801//
            arrAnalogValue[3]:=U3.Value;
        END_IF; //A800//
       
        IF (U4.Value<U4LimScale.Low) THEN //A802//
            arrAnalogValue[4]:=U4LimScale.Low;
        ELSIF (U4.Value>U4LimScale.High) THEN //A804//
            arrAnalogValue[4]:=U4LimScale.High;
        ELSE //A804//
            arrAnalogValue[4]:=U4.Value;
        END_IF; //A803//
       
        IF (U5.Value<U5LimScale.Low) THEN //A805//
            arrAnalogValue[5]:=U5LimScale.Low;
        ELSIF (U5.Value>U5LimScale.High) THEN //A807//
            arrAnalogValue[5]:=U5LimScale.High;
        ELSE //A807//
            arrAnalogValue[5]:=U5.Value;
        END_IF; //A806//
       
        IF (U6.Value<U6LimScale.Low) THEN //A808//
            arrAnalogValue[6]:=U6LimScale.Low;
        ELSIF (U6.Value>U6LimScale.High) THEN //A80a//
            arrAnalogValue[6]:=U6LimScale.High;
        ELSE //A80a//
            arrAnalogValue[6]:=U6.Value;
        END_IF; //A809//
       
        IF (U7.Value<U7LimScale.Low) THEN //A80b//
            arrAnalogValue[7]:=U7LimScale.Low;
        ELSIF (U7.Value>U7LimScale.High) THEN //A80d//
            arrAnalogValue[7]:=U7LimScale.High;
        ELSE //A80d//
            arrAnalogValue[7]:=U7.Value;
        END_IF; //A80c//
       
        arrQualityCode[1]:=U1.ST;
        arrQualityCode[2]:=U2.ST;
        arrQualityCode[3]:=U3.ST;
        arrQualityCode[4]:=U4.ST;
        arrQualityCode[5]:=U5.ST;
        arrQualityCode[6]:=U6.ST;
        arrQualityCode[7]:=U7.ST;
        SimU1:=U1.Value;
        SimU2:=U2.Value;
        SimU3:=U3.Value;
        SimU4:=U4.Value;
        SimU5:=U5.Value;
        SimU6:=U6.Value;
        SimU7:=U7.Value;
    END_IF;
    FOR i:=1 TO StcU_k.zeilenzahl BY 1 DO
        stcInST.b0:=byWorstQC;
        stcInST.b1:=arrQualityCode[i];
       
        byWorstQC:=SelST16(InST := stcInST
            ,Num := 2
            ,SelPrio := 0
            ); // BYTE       
       
        IF ((arrQualityCode[i] AND B#16#C0)=B#16#0) THEN //A810//
            xErrorUk:=TRUE;
            ErrorNum:=20+i;
        END_IF; //A810//
       
        StcU_k_aux.arr1[i,1]:=ChkREAL(In := arrAnalogValue[i]
                ,ErrNum := nChkRealError
                ); // REAL               
       
        IF ((nChkRealError=1) OR (nChkRealError=3)) THEN //A811//
            xErrorNAN:=TRUE;
        END_IF; //A811//       
       
    END_FOR;
   
    IF (SimOn) THEN //A812//
        arrAnalogValue[1]:=SimY1;
        arrAnalogValue[2]:=SimY2;
        arrAnalogValue[3]:=SimY3;
        arrAnalogValue[4]:=SimY4;
        arrAnalogValue[5]:=SimY5;
        arrAnalogValue[6]:=SimY6;
        arrAnalogValue[7]:=SimY7;
       
        FOR i:=1 TO StcY_k.zeilenzahl BY 1 DO
            arrQualityCode[i]:=B#16#60;
        END_FOR;
    ELSE //A812//
        IF (Y1.Value<Y1LimScale.Low) THEN //A816//
            arrAnalogValue[1]:=Y1LimScale.Low;
        ELSIF (Y1.Value>Y1LimScale.High) THEN //A818//
            arrAnalogValue[1]:=Y1LimScale.High;
        ELSE //A818//
            arrAnalogValue[1]:=Y1.Value;
        END_IF; //A817//
       
        IF (Y2.Value<Y2LimScale.Low) THEN //A819//
            arrAnalogValue[2]:=Y2LimScale.Low;
        ELSIF (Y2.Value>Y2LimScale.High) THEN //A81b//
            arrAnalogValue[2]:=Y2LimScale.High;
        ELSE //A81b//
            arrAnalogValue[2]:=Y2.Value;
        END_IF; //A81a//
       
        IF (Y3.Value<Y3LimScale.Low) THEN //A81c//
            arrAnalogValue[3]:=Y3LimScale.Low;
        ELSIF (Y3.Value>Y3LimScale.High) THEN //A81e//
            arrAnalogValue[3]:=Y3LimScale.High;
        ELSE //A81e//
            arrAnalogValue[3]:=Y3.Value;
        END_IF; //A81d//
       
        IF (Y4.Value<Y4LimScale.Low) THEN //A81f//
            arrAnalogValue[4]:=Y4LimScale.Low;
        ELSIF (Y4.Value>Y4LimScale.High) THEN //A821//
            arrAnalogValue[4]:=Y4LimScale.High;
        ELSE //A821//
            arrAnalogValue[4]:=Y4.Value;
        END_IF; //A820//
       
        IF (Y5.Value<Y5LimScale.Low) THEN //A822//
            arrAnalogValue[5]:=Y5LimScale.Low;
        ELSIF (Y5.Value>Y5LimScale.High) THEN //A824//
            arrAnalogValue[5]:=Y5LimScale.High;
        ELSE //A824//
            arrAnalogValue[5]:=Y5.Value;
        END_IF; //A823//
       
        IF (Y6.Value<Y6LimScale.Low) THEN //A825//
            arrAnalogValue[6]:=Y6LimScale.Low;
        ELSIF (Y6.Value>Y6LimScale.High) THEN //A827//
            arrAnalogValue[6]:=Y6LimScale.High;
        ELSE //A827//
            arrAnalogValue[6]:=Y6.Value;
        END_IF; //A826//
       
        IF (Y7.Value<Y7LimScale.Low) THEN //A828//
            arrAnalogValue[7]:=Y7LimScale.Low;
        ELSIF (Y7.Value>Y7LimScale.High) THEN //A82a//
            arrAnalogValue[7]:=Y7LimScale.High;
        ELSE //A82a//
            arrAnalogValue[7]:=Y7.Value;
        END_IF; //A829//
       
        arrQualityCode[1]:=Y1.ST;
        arrQualityCode[2]:=Y2.ST;
        arrQualityCode[3]:=Y3.ST;
        arrQualityCode[4]:=Y4.ST;
        arrQualityCode[5]:=Y5.ST;
        arrQualityCode[6]:=Y6.ST;
        arrQualityCode[7]:=Y7.ST;
        SimY1:=Y1.Value;
        SimY2:=Y2.Value;
        SimY3:=Y3.Value;
        SimY4:=Y4.Value;
        SimY5:=Y5.Value;
        SimY6:=Y6.Value;
        SimY7:=Y7.Value;
    END_IF; //A815//
   
    FOR i:=1 TO StcY_k.zeilenzahl BY 1 DO
       
       
        IF ((arrQualityCode[i] AND B#16#C0)=B#16#0) THEN //A810//
            StcR_k_aux_r.arr1[i,i]:=1.0e+10;
            xErrorYk:=TRUE;
        END_IF; //A810//
       
        StcY_k_aux.arr1[i,1]:=ChkREAL(In := arrAnalogValue[i]
                ,ErrNum := nChkRealError
                ); // REAL               
       
        IF ((nChkRealError=1) OR (nChkRealError=3)) THEN //A811//
            xErrorNAN:=TRUE;
        END_IF; //A811//       
    END_FOR;
    ST_Worst:=byWorstQC;
   
   
    IF (xErrorNAN) THEN //A82f//
        ErrorNum:=30;
        byWorstQC:=B#16#28;
    END_IF; //A82f//
    IF (SampleEn) THEN //A830//
        IF (SaRe_LiOp) THEN //A831//
            arrAnalogValue[1]:=Yn1_Ext.Value;
            arrAnalogValue[2]:=Yn2_Ext.Value;
            arrAnalogValue[3]:=Yn3_Ext.Value;
            arrAnalogValue[4]:=Yn4_Ext.Value;
            arrAnalogValue[5]:=Yn5_Ext.Value;
            arrQualityCode[1]:=Yn1_Ext.ST;
            arrQualityCode[2]:=Yn2_Ext.ST;
            arrQualityCode[3]:=Yn3_Ext.ST;
            arrQualityCode[4]:=Yn4_Ext.ST;
            arrQualityCode[5]:=Yn5_Ext.ST;
        ELSE //A831//
            arrAnalogValue[1]:=Yn1_Int;
            arrAnalogValue[2]:=Yn2_Int;
            arrAnalogValue[3]:=Yn3_Int;
            arrAnalogValue[4]:=Yn4_Int;
            arrAnalogValue[5]:=Yn5_Int;
            arrQualityCode[1]:=B#16#80;
            arrQualityCode[2]:=B#16#80;
            arrQualityCode[3]:=B#16#80;
            arrQualityCode[4]:=B#16#80;
            arrQualityCode[5]:=B#16#80;
        END_IF; //A832//
       
        FOR i:=1 TO StcY_n.zeilenzahl BY 1 DO
            IF (((SampleEn) AND SampExtracted) AND xSampleResult) THEN //A835//
                IF ((arrQualityCode[i] AND B#16#C0)=B#16#0) THEN //A835//
                    xErrorYn:=TRUE;
                END_IF;
            END_IF; //A835//
            
            StcY_n_aux.arr1[i,1]:=ChkREAL(In := arrAnalogValue[i]
                    ,ErrNum := nChkRealError
                    ); // REAL       
                   
            IF (((SampleEn) AND SampExtracted) AND xSampleResult) THEN //A837//
                IF ((nChkRealError=1) OR (nChkRealError=3)) THEN //A811//
                    xErrorYn:=TRUE;
                END_IF; //A811//       
            END_IF;   
 
        END_FOR;
    END_IF; //A830//
   
    IF (((SampleEn) AND SampExtracted) AND xSampleResult) THEN //A839//
        IF (xErrorYn) THEN //A839//
            SbSampleAbort:=TRUE;
            SampExtracted:=FALSE;
            LabResIncluded:=FALSE;
            SaPo_Ext:=FALSE;
            SaPo_Int:=FALSE;
            SaRe_Ext:=FALSE;
            SaRe_Int:=FALSE;
            xSampleResult:=FALSE;
            xSamplePoint:=FALSE;
        END_IF;
    END_IF; //A839//
   
    IF (NOT((xErrorUk) OR xErrorNAN)) THEN //A83b//
        KalFunct.SampleTime:=rSampleTime;
        KalFunct.ProModId:=ModelNo;
        KalFunct.CalcFunc:=1;
        KalFunct.NumberX:=NumberX;
        KalFunct.NumberY:=NumberY;
        KalFunct.NumberYn:=NumberYn;
        KalFunct.NumberZ:=NumberZ;
 
        KalFunct(StcX_MinusK := StcX_dach_minus_k
                      ,StcX_PlusK := StcNullmx
                      ,StcU := StcU_k
                      );
       
        StcTemp1:=KalFunct.StcX_MinK1;
        StcY_dach_minus_k:=KalFunct.StcY_MinusK;
        StcTemp2:=KalFunct.StcH;
        StcTemp3:=KalFunct.StcPHI;
       
        StcStcKonf:=KalFunct.StcKalDB;
 
        SxErrorFC:=KalFunct.Error;
       
        IF ((NumberY<>StcY_dach_minus_k.zeilenzahl) OR (1<>StcY_dach_minus_k.spaltenzahl)) THEN //A83c//
            xErrorFc:=TRUE;
        END_IF; //A83c//
       
        xErrorFc:=(xErrorFc) OR xError;
        KalFunct.SampleTime:=rSampleTime;
        KalFunct.ProModId:=ModelNo;
        KalFunct.CalcFunc:=3;
        KalFunct.NumberX:=NumberX;
        KalFunct.NumberY:=NumberY;
        KalFunct.NumberYn:=NumberYn;
        KalFunct.NumberZ:=NumberZ;
       
        KalFunct(StcX_MinusK := StcX_dach_minus_k
                      ,StcX_PlusK := StcNullmx
                      ,StcU := StcU_k
                      );
       
        StcTemp1:=KalFunct.StcX_MinK1;
        StcTemp2:=KalFunct.StcY_MinusK;
        StcH_k:=KalFunct.StcH;
        StcTemp3:=KalFunct.StcPHI;
        StcStcKonf:=KalFunct.StcKalDB;
       
       
        SxErrorFC:=KalFunct.Error;
       
        IF ((NumberY<>StcH_k.zeilenzahl) OR (NumberX<>StcH_k.spaltenzahl)) THEN //A83d//
            xErrorFc:=TRUE;
        END_IF; //A83d//       
       
        xErrorFc:=(xErrorFc) OR xError;
       
        IF (((SampleEn) AND xSamplePoint) AND (NOT(SampExtracted))) THEN //A83e//
            StcP_minus_n:=StcP_minus_k;
            KalFunct.SampleTime:=rSampleTime;
            KalFunct.ProModId:=ModelNo;
            KalFunct.CalcFunc:=6;
            KalFunct.NumberX:=NumberX;
            KalFunct.NumberY:=NumberY;
            KalFunct.NumberYn:=NumberYn;
            KalFunct.NumberZ:=NumberZ;
           
            KalFunct(StcX_MinusK := StcX_dach_minus_k
                          ,StcX_PlusK := StcNullmx
                          ,StcU := StcU_k
                          );
           
            StcTemp1:=KalFunct.StcX_MinK1;
            Stcy_dach_minus_n:=KalFunct.StcY_MinusK;
            StcTemp2:=KalFunct.StcH;
            StcTemp3:=KalFunct.StcPHI;
            StcStcKonf:=KalFunct.StcKalDB;
           
            SxErrorFC:=KalFunct.Error;
           
            IF ((NumberYn<>Stcy_dach_minus_n.zeilenzahl) OR (1<>Stcy_dach_minus_n.spaltenzahl)) THEN //A83f//
                xErrorFc:=TRUE;
            END_IF; //A83f//
           
            xErrorFc:=(xErrorFc) OR xError;
            KalFunct.SampleTime:=rSampleTime;
            KalFunct.ProModId:=ModelNo;
            KalFunct.CalcFunc:=5;
            KalFunct.NumberX:=NumberX;
            KalFunct.NumberY:=NumberY;
            KalFunct.NumberYn:=NumberYn;
            KalFunct.NumberZ:=NumberZ;
 
           
            KalFunct(StcX_MinusK := StcX_dach_minus_k
                          ,StcX_PlusK := StcNullmx
                          ,StcU := StcU_k
                          );
           
            StcTemp1:=KalFunct.StcX_MinK1;
            StcTemp2:=KalFunct.StcY_MinusK;
            StcH_n:=KalFunct.StcH;
            StcTemp3:=KalFunct.StcPHI;
            StcStcKonf:=KalFunct.StcKalDB;
           
            SxErrorFC:=KalFunct.Error;
           
            IF ((NumberYn<>StcH_n.zeilenzahl) OR (NumberX<>StcH_n.spaltenzahl)) THEN //A840//
                xErrorFc:=TRUE;
            END_IF; //A840//
           
            xErrorFc:=(xErrorFc) OR xError;           
 
        END_IF; //A83e//
       
       
       
        IF (NOT(xErrorFc)) THEN //A841//
       
            MxTrans(StcMxA :=  StcH_k
                    ,StcMxAT :=  StcTemp1
                    ); // VOID       
       
            MxMul(StcMxA :=  StcH_k
                  ,StcMxB :=  StcP_minus_k
                  ,StcMxC :=  StcTemp2
                  ); // VOID
 
            MxMul(StcMxA :=  StcTemp2
                  ,StcMxB :=  StcTemp1
                  ,StcMxC :=  StcTemp3
                  ); // VOID
                 
            MxAdd(StcMxA := StcTemp3
                  ,StcMxB := StcR_k
                  ,StcMxC := StcTemp2
                  ); // VOID
      
                 
            MxInv(StcMxA := StcTemp2
                  ,StcMxAI := StcTemp3
                  ); // VOID
                  
            MxMul(StcMxA :=  StcP_minus_k
                  ,StcMxB :=  StcTemp1
                  ,StcMxC :=  StcTemp2
                  ); // VOID
 
            IF (StcTemp3.zeilenzahl>0) THEN //A842//
                MxMul(StcMxA :=  StcTemp2
                      ,StcMxB :=  StcTemp3
                      ,StcMxC :=  StcK_k
                      ); // VOID
            ELSE //A842//
                xErrorInv:=TRUE;
                StcK_k:=StcNullmx;
            END_IF; //A843//
           
            IF ((((SampleEn) AND SampExtracted) AND xSampleResult) AND (NOT(LabResIncluded))) THEN //A844//
               
            MxTrans(StcMxA :=  StcH_n
                    ,StcMxAT :=  StcTemp1
                    ); // VOID       
                
            MxMul(StcMxA :=  StcH_n
                  ,StcMxB :=  StcP_minus_n
                  ,StcMxC :=  StcTemp2
                  ); // VOID
 
            MxMul(StcMxA :=  StcTemp2
                  ,StcMxB :=  StcTemp1
                  ,StcMxC :=  StcTemp3
                  ); // VOID
 
            MxAdd(StcMxA := StcTemp3
                  ,StcMxB := StcR_n
                  ,StcMxC := StcTemp2
                  ); // VOID
                 
            MxInv(StcMxA := StcTemp2
                  ,StcMxAI := StcTemp3
                  ); // VOID
 
            MxMul(StcMxA :=  StcP_minus_n
                  ,StcMxB :=  StcTemp1
                  ,StcMxC :=  StcTemp2
                  ); // VOID
 
                IF (StcTemp3.zeilenzahl>0) THEN //A845//
                    MxMul(StcMxA :=  StcTemp2
                          ,StcMxB :=  StcTemp3
                          ,StcMxC :=  StcK_n
                          ); // VOID
                ELSE //A845//
                    xErrorInv:=TRUE;
                    StcK_n:=StcNullmx;
                END_IF;
            END_IF; //A844//
           
            IF ((((SampleEn) AND SampExtracted) AND xSampleResult) AND (NOT(LabResIncluded))) THEN //A847//
               
                MxRBnd(StcMxA := StcY_dach_minus_k
                       ,StcMxB := Stcy_dach_minus_n
                       ,StcMxC := StcTemp1
                       ); // VOID
                
                MxRBnd(StcMxA := StcY_k
                       ,StcMxB := StcY_n
                       ,StcMxC := StcTemp2
                       ); // VOID
                
                MxSub(StcMxA := StcTemp2
                      ,StcMxB := StcTemp1
                      ,StcMxC := StcTemp3
                      ); // VOID
 
                EY_limit_n.elemente[1, 1]:=ABS(EYn1Lim);
                EY_limit_n.elemente[2, 1]:=ABS(EYn2Lim);
                EY_limit_n.elemente[3, 1]:=ABS(EYn3Lim);
                EY_limit_n.elemente[4, 1]:=ABS(EYn4Lim);
                EY_limit_n.elemente[5, 1]:=ABS(EYn5Lim);
               
                FOR i:=1 TO StcY_n.zeilenzahl BY 1 DO
               
                    IF StcTemp3_aus.arr[i+StcY_k.zeilenzahl,1] < -EY_limit_n.elemente[i,1] THEN
                        StcTemp3_aus.arr[i+StcY_k.zeilenzahl,1]:=-EY_limit_n.elemente[i,1];
                        SbSampleLimit:=TRUE;
                    ELSIF StcTemp3_aus.arr[i+StcY_k.zeilenzahl,1] > EY_limit_n.elemente[i,1] THEN //A84c//
                        StcTemp3_aus.arr[i+StcY_k.zeilenzahl,1]:=EY_limit_n.elemente[i,1];
                        SbSampleLimit:=TRUE;
                    END_IF; //A84c//
                    ey_n.elemente[i,1]:=StcTemp3_aus.arr[i+StcY_k.zeilenzahl,1];
                END_FOR;   
               
                MxMul(StcMxA :=  StcSum_phi_n
                      ,StcMxB :=  StcK_n
                      ,StcMxC :=  StcTemp1
                      ); // VOID
               
                MxCBnd(StcMxA := StcK_k
                       ,StcMxB := StcTemp1
                       ,StcMxC := StcTemp2
                       ); // VOID
                      
                MxMul(StcMxA :=  StcTemp2
                      ,StcMxB :=  StcTemp3
                      ,StcMxC :=  StcTemp4
                      ); // VOID
 
                MxAdd(StcMxA := StcX_dach_minus_k
                  ,StcMxB := StcTemp4
                  ,StcMxC := StcX_dach_plus_k
                  ); // VOID
 
                MxSub(StcMxA := StcY_k
                      ,StcMxB := StcY_dach_minus_k
                      ,StcMxC := StcTemp1
                      ); // VOID
 
            ELSE //A847//
           
                MxSub(StcMxA := StcY_k
                      ,StcMxB := StcY_dach_minus_k
                      ,StcMxC := StcTemp1
                      ); // VOID
           
                MxMul(StcMxA :=  StcK_k
                      ,StcMxB :=  StcTemp1
                      ,StcMxC :=  StcTemp2
                      ); // VOID
           
                MxAdd(StcMxA := StcX_dach_minus_k
                  ,StcMxB := StcTemp2
                  ,StcMxC := StcX_dach_plus_k
                  ); // VOID
 
            END_IF; //A84d//
           
            EYn1:=ey_n.elemente[1, 1];
            EYn2:=ey_n.elemente[2, 1];
            EYn3:=ey_n.elemente[3, 1];
            EYn4:=ey_n.elemente[4, 1];
            EYn5:=ey_n.elemente[5, 1];
            EY1:=StcTemp1.elem11;
            EY2:=StcTemp1.elem21;
            EY3:=StcTemp1.elem31;
            EY4:=StcTemp1.elem41;
            EY5:=StcTemp1.elem51;
            EY6:=StcTemp1.elem61;
            EY7:=StcTemp1.elem71;
           
           
            FOR j:=1 TO NumberY BY 1 DO
                FOR i:=1 TO 4 BY 1 DO
                    EYP.elemente[j,6-i]:=EYP.elemente[j,5-i];
                END_FOR;
            END_FOR; //A84f//
           
            IF (NumberY>=1) THEN //A852//
                EYP.elemente[1, 1]:=(EY1*1.000000e+002)/(Y1LimScale.High-Y1LimScale.Low);
                EY1P_k5:=EYP.elemente[1, 5];
                EY1P_k4:=EYP.elemente[1, 4];
                EY1P_k3:=EYP.elemente[1, 3];
                EY1P_k2:=EYP.elemente[1, 2];
                EY1P_k1:=EYP.elemente[1, 1];
            END_IF; //A852//
           
            IF (NumberY>=2) THEN //A853//
                EYP.elemente[2, 1]:=(EY2*1.000000e+002)/(Y2LimScale.High-Y2LimScale.Low);
                EY2P_k5:=EYP.elemente[2, 5];
                EY2P_k4:=EYP.elemente[2, 4];
                EY2P_k3:=EYP.elemente[2, 3];
                EY2P_k2:=EYP.elemente[2, 2];
                EY2P_k1:=EYP.elemente[2, 1];
            END_IF; //A853//
           
            IF (NumberY>=3) THEN //A854//
                EYP.elemente[3, 1]:=(EY3*1.000000e+002)/(Y3LimScale.High-Y3LimScale.Low);
                EY3P_k5:=EYP.elemente[3, 5];
                EY3P_k4:=EYP.elemente[3, 4];
                EY3P_k3:=EYP.elemente[3, 3];
                EY3P_k2:=EYP.elemente[3, 2];
                EY3P_k1:=EYP.elemente[3, 1];
            END_IF; //A854//
           
            IF (NumberY>=4) THEN //A855//
                EYP.elemente[4, 1]:=(EY4*1.000000e+002)/(Y4LimScale.High-Y4LimScale.Low);
                EY4P_k5:=EYP.elemente[4, 5];
                EY4P_k4:=EYP.elemente[4, 4];
                EY4P_k3:=EYP.elemente[4, 3];
                EY4P_k2:=EYP.elemente[4, 2];
                EY4P_k1:=EYP.elemente[4, 1];
            END_IF; //A855//
           
            IF (NumberY>=5) THEN //A856//
                EYP.elemente[5, 1]:=(EY5*1.000000e+002)/(Y5LimScale.High-Y5LimScale.Low);
                EY5P_k5:=EYP.elemente[5, 5];
                EY5P_k4:=EYP.elemente[5, 4];
                EY5P_k3:=EYP.elemente[5, 3];
                EY5P_k2:=EYP.elemente[5, 2];
                EY5P_k1:=EYP.elemente[5, 1];
            END_IF; //A856//
           
            IF (NumberY>=6) THEN //A857//
                EYP.elemente[6, 1]:=(EY6*1.000000e+002)/(Y6LimScale.High-Y6LimScale.Low);
                EY6P_k5:=EYP.elemente[6, 5];
                EY6P_k4:=EYP.elemente[6, 4];
                EY6P_k3:=EYP.elemente[6, 3];
                EY6P_k2:=EYP.elemente[6, 2];
                EY6P_k1:=EYP.elemente[6, 1];
            END_IF; //A857//
           
            IF (NumberY>=7) THEN //A858//
                EYP.elemente[7, 1]:=(EY7*1.000000e+002)/(Y7LimScale.High-Y7LimScale.Low);
                EY7P_k5:=EYP.elemente[7, 5];
                EY7P_k4:=EYP.elemente[7, 4];
                EY7P_k3:=EYP.elemente[7, 3];
                EY7P_k2:=EYP.elemente[7, 2];
                EY7P_k1:=EYP.elemente[7, 1];
            END_IF; //A858//
           
           
           
            FOR i:=1 TO StcX_dach_plus_k.zeilenzahl BY 1 DO
                IF (StcX_dach_plus_k_aux1.arr1[i,1] < x_dach_limit.elemente[i,1]) THEN //A85b//
                    StcX_dach_plus_k_aux1.arr1[i,1] := x_dach_limit.elemente[i,1];
                    arrQualityCode[i]:=B#16#78;
                ELSIF (StcX_dach_plus_k_aux1.arr1[i,1] > x_dach_limit.elemente[i,2]) THEN //A85d//
                    StcX_dach_plus_k_aux1.arr1[i,1] := x_dach_limit.elemente[i,2];
                    arrQualityCode[i]:=B#16#78;
                ELSIF (xErrorYk) THEN //A85e//
                    arrQualityCode[i]:=B#16#68;
                ELSE //A85e//
                    arrQualityCode[i]:=B#16#80;
                END_IF; //A85c//
            END_FOR; //A85a//
           
            IF (xErrorInv) THEN //A85f//
                FOR i:=1 TO StcX_dach_plus_k.zeilenzahl BY 1 DO
                    arrQualityCode[i]:=B#16#68;
                END_FOR;
                ErrorNum:=31;
            END_IF; //A85f//
           
            MxMul(StcMxA :=  StcK_k
                  ,StcMxB :=  StcH_k
                  ,StcMxC :=  StcTemp1
                  ); // VOID
           
            MxSub(StcMxA := StcImx
                  ,StcMxB := StcTemp1
                  ,StcMxC := StcTemp2
                  ); // VOID
 
            MxTrans(StcMxA :=  StcTemp2
                    ,StcMxAT :=  StcTemp1
                    ); // VOID       
               
            MxMul(StcMxA :=  StcTemp2
                  ,StcMxB :=  StcP_minus_k
                  ,StcMxC :=  StcTemp3
                  ); // VOID
            
            MxMul(StcMxA :=  StcTemp3
                  ,StcMxB :=  StcTemp1
                  ,StcMxC :=  StcTemp4
                  ); // VOID
           
            MxTrans(StcMxA :=  StcK_k
                    ,StcMxAT :=  StcTemp1
                    ); // VOID       
               
            MxMul(StcMxA :=  StcK_k
                  ,StcMxB :=  StcR_k
                  ,StcMxC :=  StcTemp2
                  ); // VOID
           
            MxMul(StcMxA :=  StcTemp2
                  ,StcMxB :=  StcTemp1
                  ,StcMxC :=  StcTemp3
                  ); // VOID
           
            MxAdd(StcMxA := StcTemp4
              ,StcMxB := StcTemp3
              ,StcMxC := StcP_plus_k
              ); // VOID
 
            IF (((SampleEn) AND SampExtracted) AND xSampleResult) THEN //A862//
 
                MxMul(StcMxA :=  StcK_n
                      ,StcMxB :=  StcH_n
                      ,StcMxC :=  StcTemp1
                      ); // VOID
           
                MxSub(StcMxA := StcImx
                      ,StcMxB := StcTemp1
                      ,StcMxC := StcTemp2
                      ); // VOID
 
                MxTrans(StcMxA :=  StcTemp2
                        ,StcMxAT :=  StcTemp1
                        ); // VOID       
 
                MxMul(StcMxA :=  StcTemp2
                      ,StcMxB :=  StcP_minus_n
                      ,StcMxC :=  StcTemp3
                      ); // VOID
           
                MxMul(StcMxA :=  StcTemp3
                      ,StcMxB :=  StcTemp1
                      ,StcMxC :=  StcTemp4
                      ); // VOID
           
                MxSub(StcMxA := StcTemp4
                      ,StcMxB := StcP_minus_n
                      ,StcMxC := StcTemp1
                      ); // VOID
 
                MxMul(StcMxA :=  StcSum_phi_n
                      ,StcMxB :=  StcTemp1
                      ,StcMxC :=  StcTemp2
                      ); // VOID
           
                MxTrans(StcMxA :=  StcSum_phi_n
                        ,StcMxAT :=  StcTemp1
                        ); // VOID       
 
                MxMul(StcMxA :=  StcTemp2
                      ,StcMxB :=  StcTemp1
                      ,StcMxC :=  StcTemp3
                      ); // VOID
           
                MxMul(StcMxA :=  StcSum_phi_n
                      ,StcMxB :=  StcK_n
                      ,StcMxC :=  StcTemp2
                      ); // VOID
           
                MxMul(StcMxA :=  StcTemp2
                      ,StcMxB :=  StcR_n
                      ,StcMxC :=  StcTemp4
                      ); // VOID
           
                MxTrans(StcMxA :=  StcK_n
                        ,StcMxAT :=  StcTemp2
                        ); // VOID       
 
                MxMul(StcMxA :=  StcTemp4
                      ,StcMxB :=  StcTemp2
                      ,StcMxC :=  StcTemp1
                      ); // VOID
           
                MxTrans(StcMxA :=  StcSum_phi_n
                        ,StcMxAT :=  StcTemp2
                        ); // VOID       
 
                MxMul(StcMxA :=  StcTemp1
                      ,StcMxB :=  StcTemp2
                      ,StcMxC :=  StcTemp4
                      ); // VOID
           
                MxAdd(StcMxA := StcTemp3
                      ,StcMxB := StcTemp4
                      ,StcMxC := StcTemp1
                      ); // VOID
           
                StcTemp2:=StcP_plus_k;
 
                MxAdd(StcMxA := StcTemp2
                      ,StcMxB := StcTemp1
                      ,StcMxC := StcP_plus_k
                      ); // VOID
 
            END_IF; //A862//
           
            KalFunct.SampleTime:=rSampleTime;
            KalFunct.ProModId:=ModelNo;
            KalFunct.CalcFunc:=2;
            KalFunct.NumberX:=NumberX;
            KalFunct.NumberY:=NumberY;
            KalFunct.NumberYn:=NumberYn;
            KalFunct.NumberZ:=NumberZ;
           
            KalFunct(StcX_MinusK := StcNullmx
                          ,StcX_PlusK := StcX_dach_plus_k
                          ,StcU := StcU_k
                          );
           
           
            StcX_dach_minus_k:=KalFunct.StcX_MinK1;
            StcTemp1:=KalFunct.StcY_MinusK;
            StcTemp2:=KalFunct.StcH;
            StcTemp3:=KalFunct.StcPHI;
            StcStcKonf:=KalFunct.StcKalDB;
           
            SxErrorFC:=KalFunct.Error;
           
            IF ((NumberX<>StcX_dach_minus_k.zeilenzahl) OR (1<>StcX_dach_minus_k.spaltenzahl)) THEN //A863//
                xErrorFc:=TRUE;
            END_IF; //A863//
           
            xErrorFc:=(xErrorFc) OR xError;
           
        END_IF; //A841//
       
       
       
        IF (NOT(xErrorFc)) THEN //A864//
       
            KalFunct.SampleTime:=rSampleTime;
            KalFunct.ProModId:=ModelNo;
            KalFunct.CalcFunc:=4;
            KalFunct.NumberX:=NumberX;
            KalFunct.NumberY:=NumberY;
            KalFunct.NumberYn:=NumberYn;
            KalFunct.NumberZ:=NumberZ;
           
            KalFunct(StcX_MinusK := StcNullmx
                          ,StcX_PlusK := StcX_dach_plus_k
                          ,StcU := StcU_k
                          );
           
           
            StcTemp1:=KalFunct.StcX_MinK1;
            StcTemp2:=KalFunct.StcY_MinusK;
            StcTemp3:=KalFunct.StcH;
            StcPhi_k:=KalFunct.StcPHI;
            StcStcKonf:=KalFunct.StcKalDB;
           
            SxErrorFC:=KalFunct.Error;
       
 
            IF ((NumberX<>StcPhi_k.zeilenzahl) OR (NumberX<>StcPhi_k.spaltenzahl)) THEN //A865//
                xErrorFc:=TRUE;
            END_IF; //A865//
           
            xErrorFc:=(xErrorFc) OR xError;
            
           
            IF (SampleEn) THEN //A864//
                IF ((NOT(SampExtracted)) AND xSamplePoint) THEN //A867//
                    SampExtracted:=TRUE;
                    LabResIncluded:=FALSE;
                    xSampleResult:=FALSE;
                    SbSampleAbort:=FALSE;
                    SbSampleTimeOut:=FALSE;
                    SbSampleLimit:=FALSE;
                    StcSum_phi_n:=StcPhi_k;
                   
                    IF (xFeat_ResetInLi) THEN //A868//
                        SaPo_Ext:=FALSE;
                    END_IF; //A868//
                    SaPo_Int:=FALSE;
                    SrTimeMon:=0.0;
                ELSIF (SampExtracted) THEN //A86a//
               
                    StcTemp1:=StcSum_phi_n;
                   
                    MxMul(StcMxA :=  StcTemp1
                          ,StcMxB :=  StcPhi_k
                          ,StcMxC :=  StcSum_phi_n
                          ); // VOID
 
                    SrTimeMon:=SrTimeMon+rSampleTime;
                   
                    IF ((NOT(LabResIncluded)) AND xSampleResult) THEN //A86b//
                        SbSampleTimeOut:=FALSE;
                        SbSampleAbort:=FALSE;
                        SampExtracted:=FALSE;
                        LabResIncluded:=TRUE;
                        IF (xFeat_ResetInLi) THEN //A86c//
                            SaRe_Ext:=FALSE;
                        END_IF; //A86c//
                        SaRe_Int:=FALSE;
                    ELSE //A86b//
                        IF ((SrTimeMon/60.0)>INT_TO_REAL(TimeMon)) THEN //A86a//
                            SbSampleTimeOut:=TRUE;
                            SbSampleAbort:=TRUE;
                            SampExtracted:=FALSE;
                            LabResIncluded:=FALSE;
                            SaRe_Ext:=FALSE;
                            SaRe_Int:=FALSE;
                        END_IF;
                    END_IF;
                END_IF; //A86a//
                DTimeMon:=SrTimeMon/60.0;
            END_IF;
        END_IF; //A864//
       
        IF (NOT(xErrorFc)) THEN //A7f3//
           
            MxTrans(StcMxA :=  StcPhi_k
                    ,StcMxAT :=  StcTemp1
                    ); // VOID       
 
            MxMul(StcMxA :=  StcPhi_k
                  ,StcMxB :=  StcP_plus_k
                  ,StcMxC :=  StcTemp2
                  ); // VOID
           
            MxMul(StcMxA :=  StcTemp2
                  ,StcMxB :=  StcTemp1
                  ,StcMxC :=  StcTemp3
                  ); // VOID
           
            MxAdd(StcMxA := StcTemp3
                  ,StcMxB := StcQ_k
                  ,StcMxC := StcP_minus_k
                  ); // VOID
 
            P11:=StcP_minus_k.elem11;
            P22:=StcP_minus_k.elem22;
            P33:=StcP_minus_k.elem23;
            P44:=StcP_minus_k.elem44;
            P55:=StcP_minus_k.elem55;
            P66:=StcP_minus_k.elem66;
            P77:=StcP_minus_k.elem77;
            P88:=StcP_minus_k.elem88;
            P99:=StcP_minus_k.elem99;
            P1010:=StcP_minus_k.elemAA;
            P1111:=StcP_minus_k.elemBB;
            P1212:=StcP_minus_k.elemCC;
            P1313:=StcP_minus_k.elemDD;
            P1414:=StcP_minus_k.elemEE;
            P1515:=StcP_minus_k.elemFF;
            
            FOR i:=1 TO 15 BY 1 DO
                IF (i<=StcX_dach_plus_k.zeilenzahl) THEN //A872//
                    arrAnalogValue[i]:=StcX_dach_plus_k_aux1.arr1[i,1];
                ELSE
                    arrAnalogValue[i]:=0.0;
                    arrQualityCode[i]:=B#16#0;
                END_IF; //A873//
            END_FOR;
           
            X1.Value:=arrAnalogValue[1];
            X1.ST:=arrQualityCode[1];
            X2.Value:=arrAnalogValue[2];
            X2.ST:=arrQualityCode[2];
            X3.Value:=arrAnalogValue[3];
            X3.ST:=arrQualityCode[3];
            X4.Value:=arrAnalogValue[4];
            X4.ST:=arrQualityCode[4];
            X5.Value:=arrAnalogValue[5];
            X5.ST:=arrQualityCode[5];
            X6.Value:=arrAnalogValue[6];
            X6.ST:=arrQualityCode[6];
            X7.Value:=arrAnalogValue[7];
            X7.ST:=arrQualityCode[7];
            X8.Value:=arrAnalogValue[8];
            X8.ST:=arrQualityCode[8];
            X9.Value:=arrAnalogValue[9];
            X9.ST:=arrQualityCode[9];
            X10.Value:=arrAnalogValue[10];
            X10.ST:=arrQualityCode[10];
            X11.Value:=arrAnalogValue[11];
            X11.ST:=arrQualityCode[11];
            X12.Value:=arrAnalogValue[12];
            X12.ST:=arrQualityCode[12];
            X13.Value:=arrAnalogValue[13];
            X13.ST:=arrQualityCode[13];
            X14.Value:=arrAnalogValue[14];
            X14.ST:=arrQualityCode[14];
            X15.Value:=arrAnalogValue[15];
            X15.ST:=arrQualityCode[15];
           
            KalFunct.SampleTime:=rSampleTime;
            KalFunct.ProModId:=ModelNo;
            KalFunct.CalcFunc:=1;
            KalFunct.NumberX:=NumberX;
            KalFunct.NumberY:=NumberY;
            KalFunct.NumberYn:=NumberYn;
            KalFunct.NumberZ:=NumberZ;
           
            KalFunct(StcX_MinusK := StcX_dach_plus_k
                          ,StcX_PlusK := StcNullmx
                          ,StcU := StcU_k
                          );
           
           
            StcY_filt_plus_k:=KalFunct.StcY_MinusK;
            StcZ_k:=KalFunct.StcZ;
           
            SxErrorFC:=KalFunct.Error;
 
            Y1Filt.Value:=StcY_filt_plus_k.elem11;
            Y2Filt.Value:=StcY_filt_plus_k.elem21;
            Y3Filt.Value:=StcY_filt_plus_k.elem31;
            Y4Filt.Value:=StcY_filt_plus_k.elem41;
            Y5Filt.Value:=StcY_filt_plus_k.elem51;
            Y6Filt.Value:=StcY_filt_plus_k.elem61;
            Y7Filt.Value:=StcY_filt_plus_k.elem71;
            Y1Filt.ST:=byWorstQC;
            Y2Filt.ST:=byWorstQC;
            Y3Filt.ST:=byWorstQC;
            Y4Filt.ST:=byWorstQC;
            Y5Filt.ST:=byWorstQC;
            Y6Filt.ST:=byWorstQC;
            Y7Filt.ST:=byWorstQC;
        END_IF;
    ELSE //A83b//
        X1.ST:=byWorstQC;
        X2.ST:=byWorstQC;
        X3.ST:=byWorstQC;
        X4.ST:=byWorstQC;
        X5.ST:=byWorstQC;
        X6.ST:=byWorstQC;
        X7.ST:=byWorstQC;
        X8.ST:=byWorstQC;
        X9.ST:=byWorstQC;
        X10.ST:=byWorstQC;
        X11.ST:=byWorstQC;
        X12.ST:=byWorstQC;
        X13.ST:=byWorstQC;
        X14.ST:=byWorstQC;
        X15.ST:=byWorstQC;
    END_IF;
END_IF; //A7f3//
 
SaPo_ExtAct.Value:=SaPo_LiOp;
SaRe_ExtAct.Value:=SaRe_LiOp;
EYPScaleOut.High:=EYPScale;
EYPScaleOut.Low:=-EYPScale;
U1Out.Value:=StcU_k.elem11;
U2Out.Value:=StcU_k.elem21;
U3Out.Value:=StcU_k.elem31;
U4Out.Value:=StcU_k.elem41;
U5Out.Value:=StcU_k.elem51;
U6Out.Value:=StcU_k.elem61;
U7Out.Value:=StcU_k.elem71;
Y1Out.Value:=StcY_k.elem11;
Y2Out.Value:=StcY_k.elem21;
Y3Out.Value:=StcY_k.elem31;
Y4Out.Value:=StcY_k.elem41;
Y5Out.Value:=StcY_k.elem51;
Y6Out.Value:=StcY_k.elem61;
Y7Out.Value:=StcY_k.elem71;
Yn1Out.Value:=StcY_n.elem11;
Yn2Out.Value:=StcY_n.elem21;
Yn3Out.Value:=StcY_n.elem31;
Yn4Out.Value:=StcY_n.elem41;
Yn5Out.Value:=StcY_n.elem51;
Z1Out.Value:=StcZ_k.elem11;
Z2Out.Value:=StcZ_k.elem21;
Z3Out.Value:=StcZ_k.elem31;
Z4Out.Value:=StcZ_k.elem41;
Z5Out.Value:=StcZ_k.elem51;
IF (SimOn) THEN //A875//
    U1Out.ST:=B#16#60;
    U2Out.ST:=B#16#60;
    U3Out.ST:=B#16#60;
    U4Out.ST:=B#16#60;
    U5Out.ST:=B#16#60;
    U6Out.ST:=B#16#60;
    U7Out.ST:=B#16#60;
    Y1Out.ST:=B#16#60;
    Y2Out.ST:=B#16#60;
    Y3Out.ST:=B#16#60;
    Y4Out.ST:=B#16#60;
    Y5Out.ST:=B#16#60;
    Y6Out.ST:=B#16#60;
    Y7Out.ST:=B#16#60;
ELSIF (NOT(OosAct.Value)) THEN //A877//
    U1Out.ST:=U1.ST;
    U2Out.ST:=U2.ST;
    U3Out.ST:=U3.ST;
    U4Out.ST:=U4.ST;
    U5Out.ST:=U5.ST;
    U6Out.ST:=U6.ST;
    U7Out.ST:=U7.ST;
    Y1Out.ST:=Y1.ST;
    Y2Out.ST:=Y2.ST;
    Y3Out.ST:=Y3.ST;
    Y4Out.ST:=Y4.ST;
    Y5Out.ST:=Y5.ST;
    Y6Out.ST:=Y6.ST;
    Y7Out.ST:=Y7.ST;
    Z1Out.ST:=B#16#80;
    Z2Out.ST:=B#16#80;
    Z3Out.ST:=B#16#80;
    Z4Out.ST:=B#16#80;
    Z5Out.ST:=B#16#80;
    Yn1Out.ST:=B#16#80;
    Yn2Out.ST:=B#16#80;
    Yn3Out.ST:=B#16#80;
    Yn4Out.ST:=B#16#80;
    Yn5Out.ST:=B#16#80;
    SaPo_ExtAct.ST:=B#16#80;
    SaRe_ExtAct.ST:=B#16#80;
END_IF; //A877//
 
dwOS_Perm_aux_byte[3]:=OS_Perm_aux[0];//
dwOS_Perm_aux_byte[2]:=OS_Perm_aux[1];//
dwOS_Perm_aux_byte[1]:=OS_Perm_aux[2];//
dwOS_Perm_aux_byte[0]:=OS_Perm_aux[3];//
OS_PermOut:=dwOS_Perm;
IF (xOB_Start) THEN //A878//
    OS_PermLog:=DW#16#0;
ELSIF (OosAct.Value) THEN
    OS_PermLog:=DW#16#2 AND OS_PermOut;
ELSE
    dwOS_PermLog:=OS_Perm_aux_dword;
    dwOS_PermLog_aux[1]:=FALSE;
 
    IF ((SaPo_LiOp) AND SaRe_LiOp) THEN //A87b//
        dwOS_PermLog_aux[16]:=FALSE;//
        dwOS_PermLog_aux[13]:=FALSE;//
    ELSIF ((NOT(SaRe_LiOp)) AND SaPo_LiOp) THEN //A87d//
        dwOS_PermLog_aux[16]:=FALSE;//
        dwOS_PermLog_aux[13]:=((dwOS_PermLog_aux[13]) AND SampleEn) AND SampExtracted;//
    ELSIF ((NOT(SaPo_LiOp)) AND SaRe_LiOp) THEN //A87e//
        dwOS_PermLog_aux[16]:=dwOS_PermLog_aux[13];//
        dwOS_PermLog_aux[13]:=FALSE;//
    ELSE //A87e//
        dwOS_PermLog_aux[16]:=dwOS_PermLog_aux[13];//
        dwOS_PermLog_aux[13]:=((dwOS_PermLog_aux[13]) AND SampleEn) AND SampExtracted;//
    END_IF;   
 
    IF (NOT(SimOn)) THEN //A87f//
        dwOS_PermLog_aux[6]:=FALSE;//
        dwOS_PermLog_aux[7]:=FALSE;//
    END_IF; //A87f//
 
tempdwOS_PermLog_aux_b[3]:=dwOS_PermLog_aux_byte[0];
tempdwOS_PermLog_aux_b[2]:=dwOS_PermLog_aux_byte[1];
tempdwOS_PermLog_aux_b[1]:=dwOS_PermLog_aux_byte[2];
tempdwOS_PermLog_aux_b[0]:=dwOS_PermLog_aux_byte[3];
 
OS_PermLog:=tempdwOS_PermLog;
 
END_IF;
 
ErrorPara:=((SxErrorStart) OR xErrorPara) OR xErrorFc;
 
IF (SxErrorStart) THEN //A880//
    ST_Worst:=B#16#0;
    IF (SxErrorDB) THEN //A881//
        ErrorNum:=6;
    ELSIF (SxErrorLimit) THEN //A883//
        ErrorNum:=7;
    ELSIF (SxErrorFC) THEN //A884//
        ErrorNum:=3;
    ELSIF (SxErrorSampleTime) THEN //A885//
        ErrorNum:=2;
    ELSE //A885//
        ErrorNum:=4;
    END_IF;   
ELSE
    IF (xErrorPara) THEN //A887//
        ErrorNum:=4;
    ELSIF (xErrorFc) THEN //A886//
        ErrorNum:=3;
    END_IF;   
END_IF; //A886//
 
IF (SnUfactorCounter=SnKonUfactor) THEN //A88a//
    SnUfactorCounter:=1;
ELSE //A88a//
    SnUfactorCounter:=SnUfactorCounter+1;
END_IF; //A88b//
 
IF (NOT(OosAct.Value)) THEN //A88c//
    dwStatus1:=DW#16#0;
    dwStatus1_aux[24]:=Occupied;//
    dwStatus1_aux[25]:=BatchEn;//
    dwStatus1_aux[26]:=SimOn;//
    dwStatus1_aux[31]:=SampleEn;//
    dwStatus1_aux[16]:=SampleEn AND SampExtracted;//
    dwStatus1_aux[17]:=(SampleEn) AND LabResIncluded;//
    dwStatus1_aux[18]:=SbSampleAbort;//
    dwStatus1_aux[19]:=SbSampleTimeOut;//
    dwStatus1_aux[20]:=SbSampleLimit;//
    dwStatus1_aux[21]:=SaPo_ExtAct.Value;//
    dwStatus1_aux[22]:=SaRe_ExtAct.Value;//
    dwStatus1_aux[8]:=NOT(UserAna1.ST=B#16#FF);//
    dwStatus1_aux[9]:=NOT(UserAna2.ST=B#16#FF);//
    dwStatus1_aux[10]:=NOT(UserAna3.ST=B#16#FF);//
    dwStatus1_aux[11]:=NOT(UserAna4.ST=B#16#FF);//
    dwStatus1_aux[12]:=NOT(UserAna5.ST=B#16#FF);//
    dwStatus1_aux[13]:=NOT(UserAna6.ST=B#16#FF);//
    dwStatus1_aux[14]:=NOT(UserAna7.ST=B#16#FF);//
    dwStatus1_aux[15]:=NOT(UserAna8.ST=B#16#FF);//
    dwStatus1_aux[0]:=NOT(UserAna9.ST=B#16#FF);//
    dwStatus1_aux[1]:=NOT(UserAna10.ST=B#16#FF);//
ELSE //A88c//
    dwStatus1:=DW#16#0;
    dwStatus2:=DW#16#0;
END_IF; //A88d//
dwStatus1_aux[27]:=OosAct.Value;//
dwStatus1_aux[28]:=OosLi.Value;//
dwStatus1_aux[30]:=OnAct.Value;//
Status1:=dwStatus1;
Status2:=dwStatus2;
OnOp:=FALSE;
OosOp:=FALSE;
 
END_FUNCTION_BLOCK
 





flow

Block checksum equals.







Original library PCS7 APL (V9.0sp2) (zip, 4.6Mb)

Documentation (pdf, 22Mb)



Íàçàä