{
    S7_Author := "ABH";
    S7_BlockNumber := "15180";
    S7_BlockTitle := "MLC_4Tc";
    S7_Family := "ZeusControl";
    S7_Optimized := "TRUE";
    S7_PreferredLanguage := "LAD";
    S7_Version := "1.0"
}
FUNCTION_BLOCK "FB15180_ZC_FERM_AD_PROD"
    VAR_INPUT
        { S7_MLC := "MLC_4MW" }
        NombreSecuencia : String := 'ADICION PRODUCTO';
        { S7_MLC := "MLC_sE" }
        Pulso1Seg : Bool;
        { S7_MLC := "MLC_56c" }
        Ack : Bool;
        { S7_MLC := "MLC_3GF" }
        OrdenMarcha : Bool;
        { S7_MLC := "MLC_4W5" }
        EstadoEnMarcha : Bool;
        { S7_MLC := "MLC_43f" }
        EnEtapa : Bool;
        { S7_MLC := "MLC_4AC" }
        OrdenPausa : Bool;
        { S7_MLC := "MLC_56k" }
        OrdenSaltarEtapa : Bool;
        { S7_MLC := "MLC_YC" }
        ConfirmacionPulsador : Bool;
        { S7_MLC := "MLC_44R" }
        LT_Tanque : Real;
        Parametros : _.UDT_ZC_RECETA_BATCH_ETAPA := (
            { S7_MLC := "MLC_4p9" }
            TipoEtapa := (),
            { S7_MLC := "MLC_iA" }
            P_Real_1 := (),
            { S7_MLC := "MLC_3bE" }
            P_Real_2 := (),
            { S7_MLC := "MLC_53v" }
            P_Real_3 := (),
            { S7_MLC := "MLC_YF" }
            P_Real_4 := (),
            { S7_MLC := "MLC_3m5" }
            P_Real_5 := (),
            { S7_MLC := "MLC_4pg" }
            P_Real_6 := (),
            { S7_MLC := "MLC_3xQ" }
            P_Real_7 := (),
            { S7_MLC := "MLC_4Ui" }
            P_Real_8 := (),
            { S7_MLC := "MLC_4Ct" }
            P_Real_9 := (),
            { S7_MLC := "MLC_yZ" }
            P_Real_10 := (),
            { S7_MLC := "MLC_n5" }
            P_Real_11 := (),
            { S7_MLC := "MLC_4Qv" }
            P_Real_12 := (),
            { S7_MLC := "MLC_qQ" }
            P_Real_13 := (),
            { S7_MLC := "MLC_Uw" }
            P_Real_14 := (),
            { S7_MLC := "MLC_4YD" }
            P_Real_15 := (),
            { S7_MLC := "MLC_4Qn" }
            P_Real_16 := (),
            { S7_MLC := "MLC_3pP" }
            P_Real_17 := (),
            { S7_MLC := "MLC_42j" }
            P_Int_1 := (),
            { S7_MLC := "MLC_3Ca" }
            P_Int_2 := (),
            { S7_MLC := "MLC_3aT" }
            P_Int_3 := (),
            { S7_MLC := "MLC_4Mj" }
            P_Int_4 := (),
            { S7_MLC := "MLC_ud" }
            P_Int_5 := (),
            { S7_MLC := "MLC_Z9" }
            P_Int_6 := (),
            { S7_MLC := "MLC_3yM" }
            P_Int_7 := (),
            { S7_MLC := "MLC_PP" }
            P_Int_8 := (),
            { S7_MLC := "MLC_jn" }
            P_Int_9 := (),
            { S7_MLC := "MLC_y3" }
            P_Int_10 := (),
            { S7_MLC := "MLC_3wc" }
            P_Int_11 := (),
            { S7_MLC := "MLC_4VY" }
            P_Int_12 := (),
            { S7_MLC := "MLC_VM" }
            P_Int_13 := (),
            { S7_MLC := "MLC_44G" }
            P_Int_14 := (),
            { S7_MLC := "MLC_R6" }
            P_Int_15 := (),
            { S7_MLC := "MLC_QM" }
            P_String_1 := (),
            { S7_MLC := "MLC_tv" }
            P_String_2 := (),
            { S7_MLC := "MLC_47k" }
            P_String_3 := (),
            { S7_MLC := "MLC_sq" }
            P_String_4 := (),
            { S7_MLC := "MLC_3yk" }
            P_String_5 := (),
            { S7_MLC := "MLC_g5" }
            P_String_6 := (),
            { S7_MLC := "MLC_4rN" }
            P_String_7 := (),
            { S7_MLC := "MLC_4mg" }
            P_String_8 := (),
            { S7_MLC := "MLC_3MS" }
            P_String_9 := (),
            { S7_MLC := "MLC_3GJ" }
            P_String_10 := ()
        );
        AdicionProductoConfirmacion : Array[0..9] of Bool;
        AdicionProductoDosificado : Array[0..9] of Real;
    END_VAR
    VAR_OUTPUT
        { S7_MLC := "MLC_4vf" }
        PermisoPulsador : Bool;
        { S7_MLC := "MLC_4J2" }
        MarchaAgitador : Bool;
        { S7_MLC := "MLC_4AN" }
        VelocidadAgitador : Real;
        { S7_MLC := "MLC_4GH" }
        ProductoActual : Int;
        { S7_MLC := "MLC_529" }
        AdicionProductoPermiso : Array[0..9] of Bool;
        { S7_MLC := "MLC_gC" }
        AdicionProductoCalculado : Array[0..9] of Real;
        Despresurizar : Bool;
        { S7_MLC := "MLC_h6" }
        PermisoSaltarEtapa : Bool;
        { S7_MLC := "MLC_Pj" }
        SecuenciaIniciada : Bool;
        { S7_MLC := "MLC_fa" }
        FinSecuencia : Bool;
    END_VAR
    VAR RETAIN
        { S7_MLC := "MLC_4DD" }
        s_EtapaActual : Int;
        { S7_MLC := "MLC_4RU" }
        s_TextoEtapa : String[100];
        s_Pausa_M : Bool;
        s_Pausa_V : Bool;
        s_Continuar : Bool;
    END_VAR
    VAR
        {
            S7_Access := "ReadOnly := External";
            S7_Visibility := "Hidden := External"
        }
        s_Pulsos : Array[0..15] of Bool := [
            3(()),
            { S7_MLC := "MLC_3q8" }
        (),
            { S7_MLC := "MLC_4h9" }
        (),
            { S7_MLC := "MLC_Qe" }
        (),
            4(()),
            { S7_MLC := "MLC_3iE" }
        (),
            { S7_MLC := "MLC_3X8" }
        ()
        ];
    END_VAR
    VAR RETAIN
        { S7_MLC := "MLC_uS" }
        s_TiempoEtapa : STRUCT
            { S7_MLC := "MLC_3Rs" }
            Activar : Bool;
            { S7_MLC := "MLC_4Qq" }
            Reset : Bool;
            { S7_MLC := "MLC_4yy" }
            Actual : Int;
            { S7_MLC := "MLC_YT" }
            SP : Int;
            { S7_MLC := "MLC_4m7" }
            Restante : Int;
        END_STRUCT;
    END_VAR
    VAR
        {
            S7_Access := "ReadOnly := External";
            S7_Setpoint := "False";
            S7_Visibility := "Hidden := External"
        }
        s_TON : Array[1..#NUM_MAX_TON] of _.UDT_ZC_DISP_TON := [
            { S7_MLC := "MLC_3df" }
        (),
            { S7_MLC := "MLC_3Nb" }
        ()
        ];
        s_FF : Array[1..#NUM_MAX_FF] of _.UDT_ZC_DISP_FF;
        { S7_MLC := "MLC_u5" }
        s_KilosInicialTanque : Real := 0.0;
    END_VAR
    VAR RETAIN
        {
            S7_MLC := "MLC_43i";
            S7_Setpoint := "True"
        }
        s_ProductoActual : Int := 0;
    END_VAR
    VAR
        { S7_MLC := "MLC_4Vs" }
        s_NumeroCiclosAgitador : Int;
    END_VAR
    VAR_TEMP
        for_i : Int;
        t_ProductoActual_Kg : Real;
        t_CalcularDosificacion : Bool;
        t_x0 : Real;
        t_x1 : Real;
        t_x : Real;
        t_y0 : Real;
        t_y1 : Real;
    END_VAR
    VAR CONSTANT
        SiempreON : Bool := TRUE;
        SiempreOFF : Bool := FALSE;
        NUM_MAX_TON : Int := 2;
        NUM_MAX_FF : Int := 1;
    END_VAR

    {
        S7_Language := "SCL";
        S7_NetworkTitle := "MLC_3st"
    }
    NETWORK
        (*
        ============================================================================
        ZEUS CONTROL, S.A.
        (c)Copyright (2024) All Rights Reserved
        -----------------------------------------------------------------------------
        
        Software:       TIA Portal 18
        Restricciones:  PLC serie 1200/1500
        
        
        Nombre:         FB15180_ZC_FERM_AD_PROD
        Descripcion:    Bloque de gestión de fase adicion de producto
        
        Dependencias:   
            FC:         -
            FB:         -
            DB:         -
            UDT:        -
                     
        
        Change log:
        
            Version     Fecha       Tecnico a cargo     Descripción
            
            01.00.00    08.07.2025  (ABH)               Primera versión
            
         ============================================================================
         *)
    END_NETWORK
    {
        S7_Language := "LAD";
        S7_NetworkTitle := "MLC_3PZ"
    }
    NETWORK
        RUNG wire#powerrail
        END_RUNG
    END_NETWORK
    {
        S7_Language := "LAD";
        S7_NetworkTitle := "MLC_3jX"
    }
    NETWORK
        RUNG wire#powerrail
            Contact( #SiempreON )
            wire#w1
            Contact( #OrdenPausa )
            wire#w2
            S_Coil( #s_Pausa_M )
        END_RUNG
        RUNG wire#w1
            I_Contact( #EstadoEnMarcha )
        END_RUNG wire#w2
        RUNG wire#w1
            Contact( #s_Pausa_M )
            wire#w3
            Move(
                in := 3,
                out1 => #s_TON[1].SP
            )
            Coil( #s_TON[1].IN )
        END_RUNG
        RUNG wire#w3
            Contact( #s_TON[1].Q )
            I_Contact( #s_Continuar )
            S_Coil( #s_Pausa_V )
        END_RUNG
        RUNG wire#w1
            I_Contact( #OrdenPausa )
            Contact( #EstadoEnMarcha )
            wire#w4
            R_Coil( #s_Pausa_V )
        END_RUNG
        RUNG wire#w4
            S_Coil( #s_Continuar )
        END_RUNG
        RUNG wire#w1
            Contact( #s_Continuar )
            wire#w5
            Move(
                in := 3,
                out1 => #s_TON[2].SP
            )
            Coil( #s_TON[2].IN )
        END_RUNG
        RUNG wire#w5
            Contact( #s_TON[2].Q )
            wire#w6
            R_Coil( #s_Pausa_M )
        END_RUNG
        RUNG wire#w6
            R_Coil( #s_Continuar )
        END_RUNG
        RUNG wire#w1
            { S7_Templates := "SrcType := Int" }
            EQ_Contact(
                in1 := #s_EtapaActual,
                in2 := 0
            )
            wire#w7
            R_Coil( #s_Pausa_M )
        END_RUNG
        RUNG wire#w7
            R_Coil( #s_Pausa_V )
        END_RUNG
        RUNG wire#w7
            R_Coil( #s_Continuar )
        END_RUNG
    END_NETWORK
    {
        S7_Language := "LAD";
        S7_NetworkTitle := "MLC_3Wz"
    }
    NETWORK
        RUNG wire#powerrail
            I_Contact( #EnEtapa )
            Move(
                in := 0,
                out1 => #s_EtapaActual
            )
        END_RUNG
    END_NETWORK
    {
        S7_Language := "SCL";
        S7_NetworkTitle := "MLC_525"
    }
    NETWORK
        //  ================================================================
        //  TEXTO ETAPA
        CASE #s_EtapaActual OF
            0:
                #s_TextoEtapa := CONCAT_STRING(IN1:= #NombreSecuencia,IN2:= ' - REPOSO');
                
            120:
                #s_TextoEtapa := CONCAT_STRING(IN1 := #NombreSecuencia, IN2 := ' - ESPERA INICIO');
                
            130:
                #s_TextoEtapa := CONCAT_STRING(IN1 := #NombreSecuencia, IN2 := ' - ADICION DE PRODUCTO ', IN3 := "FC15001_ZC_INT_TO_STRING"(#s_ProductoActual+1));
                
            140:
                #s_TextoEtapa := CONCAT_STRING(IN1 := #NombreSecuencia, IN2 := ' - COMPROBACION INGREDIENTES');
                
            150:
                #s_TextoEtapa := CONCAT_STRING(IN1 := #NombreSecuencia, IN2 := ' - HOMOGENIZACION');
                
            999:
                #s_TextoEtapa := CONCAT_STRING(IN1 := #NombreSecuencia, IN2 := ' - FIN DE SECUENCIA');
                
            ELSE
                #s_TextoEtapa := CONCAT_STRING(IN1 := #NombreSecuencia, IN2 := ' - FUERA DE ETAPA');
        END_CASE;
        
    END_NETWORK
    {
        S7_Language := "SCL";
        S7_NetworkTitle := "MLC_3Mw"
    }
    NETWORK
        
        //  ================================================================
        //  Limite producto actual
        IF #s_ProductoActual < 0 THEN
            #s_ProductoActual := 0;
        END_IF;
        IF #s_ProductoActual > 9 THEN
            #s_ProductoActual := 9;
        END_IF;
        
    END_NETWORK
    {
        S7_Language := "LAD";
        S7_NetworkTitle := "MLC_3PR"
    }
    NETWORK
        RUNG wire#powerrail
        END_RUNG
    END_NETWORK
    {
        S7_Language := "SCL";
        S7_NetworkTitle := "MLC_Ui"
    }
    NETWORK
        CASE #s_ProductoActual OF
                
            0:
                #t_ProductoActual_Kg := #Parametros.P_Real_8;
            1:
                #t_ProductoActual_Kg := #Parametros.P_Real_9;
            2:
                #t_ProductoActual_Kg := #Parametros.P_Real_10;
            3:
                #t_ProductoActual_Kg := #Parametros.P_Real_11;
            4:
                #t_ProductoActual_Kg := #Parametros.P_Real_12;
            5:
                #t_ProductoActual_Kg := #Parametros.P_Real_13;
            6:
                #t_ProductoActual_Kg := #Parametros.P_Real_14;
            7:
                #t_ProductoActual_Kg := #Parametros.P_Real_15;
            8:
                #t_ProductoActual_Kg := #Parametros.P_Real_16;
            9:
                #t_ProductoActual_Kg := #Parametros.P_Real_17;
                
        END_CASE;
        
    END_NETWORK
    {
        S7_Language := "LAD";
        S7_NetworkTitle := "MLC_3M9"
    }
    NETWORK
        RUNG wire#powerrail
        END_RUNG
    END_NETWORK
    {
        S7_Language := "LAD";
        S7_NetworkTitle := "MLC_4BX"
    }
    NETWORK
        RUNG wire#powerrail
            { S7_Templates := "SrcType := Int" }
            EQ_Contact(
                in1 := #s_EtapaActual,
                in2 := 0
            )
            Contact( #EnEtapa )
            Contact( #OrdenMarcha )
            Move(
                in := 120,
                out1 => #s_EtapaActual
            )
            wire#w1
            Move(
                in := 0,
                out1 => #s_TiempoEtapa.Actual
            )
        END_RUNG
        RUNG wire#w1
            Move(
                in := 0,
                out1 => #s_ProductoActual
            )
        END_RUNG
        RUNG wire#w1
            Move(
                in := 0,
                out1 => #s_NumeroCiclosAgitador
            )
        END_RUNG
        RUNG wire#w1
            Coil( #t_CalcularDosificacion )
        END_RUNG
    END_NETWORK
    {
        S7_Language := "LAD";
        S7_NetworkTitle := "MLC_Le"
    }
    NETWORK
        RUNG wire#powerrail
            { S7_Templates := "SrcType := Int" }
            EQ_Contact(
                in1 := #s_EtapaActual,
                in2 := 120
            )
            wire#w1
            P_Trig( #s_Pulsos[2] )
            Move(
                in := 5,
                out1 => #s_TiempoEtapa.SP
            )
        END_RUNG
        RUNG wire#w1
            S_Coil( #s_TiempoEtapa.Activar )
        END_RUNG
        RUNG wire#w1
            Contact( #ConfirmacionPulsador )
            Move(
                in := 130,
                out1 => #s_EtapaActual
            )
            Move(
                in := 0,
                out1 => #s_TiempoEtapa.Actual
            )
        END_RUNG
    END_NETWORK
    {
        S7_Language := "LAD";
        S7_NetworkTitle := "MLC_5Bj"
    }
    NETWORK
        RUNG wire#powerrail
            { S7_Templates := "SrcType := Int" }
            EQ_Contact(
                in1 := #s_EtapaActual,
                in2 := 130
            )
            wire#w1
            P_Trig( #s_Pulsos[3] )
            Move(
                in := 2,
                out1 => #s_TiempoEtapa.SP
            )
        END_RUNG
        RUNG wire#w1
            S_Coil( #s_TiempoEtapa.Activar )
        END_RUNG
        RUNG wire#w1
            { S7_Templates := "SrcType := Real" }
            EQ_Contact(
                in1 := #t_ProductoActual_Kg,
                in2 := 0.0
            )
            { S7_Templates := "DestType := Int" }
            Inc( #s_ProductoActual )
            { S7_Templates := "SrcType := Int" }
            GE_Contact(
                in1 := #s_ProductoActual,
                in2 := 9
            )
            Move(
                in := 140,
                out1 => #s_EtapaActual
            )
            Move(
                in := 0,
                out1 => #s_TiempoEtapa.Actual
            )
        END_RUNG
        RUNG wire#w1
            { S7_Templates := "SrcType := Int" }
            GE_Contact(
                in1 := #s_TiempoEtapa.Actual,
                in2 := #s_TiempoEtapa.SP
            )
            Contact( #AdicionProductoConfirmacion[#s_ProductoActual] )
            Move(
                in := 140,
                out1 => #s_EtapaActual
            )
            Move(
                in := 0,
                out1 => #s_TiempoEtapa.Actual
            )
        END_RUNG
        RUNG wire#w1
            Contact( #OrdenSaltarEtapa )
            Move(
                in := 160,
                out1 => #s_EtapaActual
            )
            Move(
                in := 0,
                out1 => #s_TiempoEtapa.Actual
            )
        END_RUNG
    END_NETWORK
    {
        S7_Language := "LAD";
        S7_NetworkTitle := "MLC_43Q"
    }
    NETWORK
        RUNG wire#powerrail
            { S7_Templates := "SrcType := Int" }
            EQ_Contact(
                in1 := #s_EtapaActual,
                in2 := 140
            )
            wire#w1
            P_Trig( #s_Pulsos[4] )
            Move(
                in := 1,
                out1 => #s_TiempoEtapa.SP
            )
        END_RUNG
        RUNG wire#w1
            { S7_Templates := "SrcType := Int" }
            LE_Contact(
                in1 := #s_ProductoActual,
                in2 := 9
            )
            { S7_Templates := "DestType := Int" }
            Inc( #s_ProductoActual )
            Move(
                in := 130,
                out1 => #s_EtapaActual
            )
            Move(
                in := 0,
                out1 => #s_TiempoEtapa.Actual
            )
        END_RUNG
        RUNG wire#w1
            { S7_Templates := "SrcType := Int" }
            GT_Contact(
                in1 := #s_ProductoActual,
                in2 := 9
            )
            Move(
                in := 150,
                out1 => #s_EtapaActual
            )
            Move(
                in := 0,
                out1 => #s_TiempoEtapa.Actual
            )
        END_RUNG
        RUNG wire#w1
            Contact( #OrdenSaltarEtapa )
            Move(
                in := 999,
                out1 => #s_EtapaActual
            )
            Move(
                in := 0,
                out1 => #s_TiempoEtapa.Actual
            )
        END_RUNG
    END_NETWORK
    {
        S7_Language := "LAD";
        S7_NetworkTitle := "MLC_48r"
    }
    NETWORK
        RUNG wire#powerrail
            { S7_Templates := "SrcType := Int" }
            EQ_Contact(
                in1 := #s_EtapaActual,
                in2 := 150
            )
            wire#w1
            P_Trig( #s_Pulsos[5] )
            Move(
                in := 1,
                out1 => #s_TiempoEtapa.SP
            )
        END_RUNG
        RUNG wire#w1
            S_Coil( #s_TiempoEtapa.Activar )
        END_RUNG
        RUNG wire#w1
            { S7_Templates := "SrcType := Int" }
            GE_Contact(
                in1 := #s_NumeroCiclosAgitador,
                in2 := #Parametros.P_Int_1
            )
            wire#w2
            Move(
                in := 999,
                out1 => #s_EtapaActual
            )
            Move(
                in := 0,
                out1 => #s_TiempoEtapa.Actual
            )
        END_RUNG
        RUNG wire#w1
            Contact( #OrdenSaltarEtapa )
        END_RUNG wire#w2
    END_NETWORK
    {
        S7_Language := "LAD";
        S7_NetworkTitle := "MLC_gr"
    }
    NETWORK
        RUNG wire#powerrail
            { S7_Templates := "SrcType := Int" }
            EQ_Contact(
                in1 := #s_EtapaActual,
                in2 := 999
            )
            wire#w1
            P_Trig( #s_Pulsos[10] )
            Move(
                in := 3,
                out1 => #s_TiempoEtapa.SP
            )
        END_RUNG
        RUNG wire#w1
            I_Contact( #EnEtapa )
            S_Coil( #s_TiempoEtapa.Activar )
        END_RUNG
        RUNG wire#w1
            { S7_Templates := "SrcType := Int" }
            GE_Contact(
                in1 := #s_TiempoEtapa.Actual,
                in2 := #s_TiempoEtapa.SP
            )
            Move(
                in := 0,
                out1 => #s_EtapaActual
            )
            Move(
                in := 0,
                out1 => #s_TiempoEtapa.Actual
            )
        END_RUNG
    END_NETWORK
    {
        S7_Language := "LAD";
        S7_NetworkTitle := "MLC_4LS"
    }
    NETWORK
        RUNG wire#powerrail
        END_RUNG
    END_NETWORK
    {
        S7_Language := "LAD";
        S7_NetworkTitle := "MLC_594"
    }
    NETWORK
        RUNG wire#powerrail
            Contact( #s_TiempoEtapa.Activar )
            wire#w1
            Contact( #EstadoEnMarcha )
            I_Contact( #s_Pausa_M )
            Contact( #Pulso1Seg )
            { S7_Templates := "SrcType := Int" }
            LT_Contact(
                in1 := #s_TiempoEtapa.Actual,
                in2 := #s_TiempoEtapa.SP
            )
            { S7_Templates := "DestType := Int" }
            Inc( #s_TiempoEtapa.Actual )
        END_RUNG
        RUNG wire#w1
            Contact( #s_TiempoEtapa.Reset )
            Move(
                in := 0,
                out1 => #s_TiempoEtapa.Actual
            )
        END_RUNG
        RUNG wire#w1
            R_Coil( #s_TiempoEtapa.Activar )
        END_RUNG
        RUNG wire#powerrail
            Sub(
                in1 := #s_TiempoEtapa.SP,
                in2 := #s_TiempoEtapa.Actual,
                out => #s_TiempoEtapa.Restante
            )
            { S7_Templates := "SrcType := Int" }
            LE_Contact(
                in1 := #s_TiempoEtapa.Restante,
                in2 := 0
            )
            Move(
                in := 0,
                out1 => #s_TiempoEtapa.Restante
            )
        END_RUNG
    END_NETWORK
    {
        S7_Language := "SCL";
        S7_NetworkTitle := "MLC_3Zi"
    }
    NETWORK
        
        //  ============================================================================
        //  TON
        FOR #for_i := 1 TO #NUM_MAX_TON DO
            "FC2928_ZC_TON_INDV"(Pulso1seg:=#Pulso1Seg,
                                 TON:=#s_TON[#for_i]);
        END_FOR;
        
        //  ============================================================================
        //  FF
        FOR #for_i := 1 TO #NUM_MAX_FF DO
            "FC2926_ZC_FF_INDV"(Pulso1Seg := #Pulso1Seg,
                                FF:=#s_FF[#for_i]);
        END_FOR;
        
    END_NETWORK
    {
        S7_Language := "LAD";
        S7_NetworkTitle := "MLC_3zF"
    }
    NETWORK
        RUNG wire#powerrail
        END_RUNG
    END_NETWORK
    {
        S7_Language := "SCL";
        S7_NetworkTitle := "MLC_jt"
    }
    NETWORK
        
        IF #t_CalcularDosificacion THEN
            #s_KilosInicialTanque := #LT_Tanque;
            #AdicionProductoCalculado[0] := (#s_KilosInicialTanque * #Parametros.P_Real_8) / 1000.0;
            #AdicionProductoCalculado[1] := (#s_KilosInicialTanque * #Parametros.P_Real_9) / 1000.0;
            #AdicionProductoCalculado[2] := (#s_KilosInicialTanque * #Parametros.P_Real_10) / 1000.0;
            #AdicionProductoCalculado[3] := (#s_KilosInicialTanque * #Parametros.P_Real_11) / 1000.0;
            #AdicionProductoCalculado[4] := (#s_KilosInicialTanque * #Parametros.P_Real_12) / 1000.0;
            #AdicionProductoCalculado[5] := (#s_KilosInicialTanque * #Parametros.P_Real_13) / 1000.0;
            #AdicionProductoCalculado[6] := (#s_KilosInicialTanque * #Parametros.P_Real_14) / 1000.0;
            #AdicionProductoCalculado[7] := (#s_KilosInicialTanque * #Parametros.P_Real_15) / 1000.0;
            #AdicionProductoCalculado[8] := (#s_KilosInicialTanque * #Parametros.P_Real_16) / 1000.0;
            #AdicionProductoCalculado[9] := (#s_KilosInicialTanque * #Parametros.P_Real_17) / 1000.0;
            
        END_IF;
        
    END_NETWORK
    {
        S7_Language := "LAD";
        S7_NetworkTitle := "MLC_3TC"
    }
    NETWORK
        RUNG wire#powerrail
            Contact( #SiempreON )
            wire#w1
            Move(
                in := #Parametros.P_Int_4,
                out1 => #s_FF[1].Config_SetPointTiempoFlip
            )
            Move(
                in := #Parametros.P_Int_3,
                out1 => #s_FF[1].Config_SetPointTiempoFlop
            )
        END_RUNG
        RUNG wire#w1
            { S7_Templates := "SrcType := Int" }
            EQ_Contact(
                in1 := #s_EtapaActual,
                in2 := 150
            )
            I_Contact( #s_Pausa_V )
            { S7_Templates := "SrcType := Real" }
            GT_Contact(
                in1 := #LT_Tanque,
                in2 := #Parametros.P_Real_2
            )
            { S7_Templates := "SrcType := Real" }
            LT_Contact(
                in1 := #LT_Tanque,
                in2 := #Parametros.P_Real_3
            )
            Coil( #s_FF[1].Orden_Activar )
        END_RUNG
    END_NETWORK
    {
        S7_Language := "LAD";
        S7_NetworkTitle := "MLC_4Mw"
    }
    NETWORK
        RUNG wire#powerrail
            Contact( #SiempreON )
            I_Contact( #s_FF[1].Estado_Flip )
            P_Trig( #s_Pulsos[11] )
            Contact( #s_FF[1].Orden_Activar )
            { S7_Templates := "DestType := Int" }
            Inc( #s_NumeroCiclosAgitador )
        END_RUNG
    END_NETWORK
    {
        S7_Language := "LAD";
        S7_NetworkTitle := "MLC_3bS"
    }
    NETWORK
        RUNG wire#powerrail
        END_RUNG
    END_NETWORK
    {
        S7_Language := "LAD";
        S7_NetworkTitle := "MLC_Yt"
    }
    NETWORK
        RUNG wire#powerrail
            { S7_Templates := "SrcType := Int" }
            EQ_Contact(
                in1 := #s_EtapaActual,
                in2 := 120
            )
            { S7_Templates := "SrcType := Int" }
            GE_Contact(
                in1 := #s_TiempoEtapa.Actual,
                in2 := #s_TiempoEtapa.SP
            )
            Coil( #PermisoPulsador )
        END_RUNG
    END_NETWORK
    {
        S7_Language := "LAD";
        S7_NetworkTitle := "MLC_3RK"
    }
    NETWORK
        RUNG wire#powerrail
            { S7_Templates := "SrcType := Int" }
            EQ_Contact(
                in1 := #s_EtapaActual,
                in2 := 130
            )
            Coil( #Despresurizar )
        END_RUNG
    END_NETWORK
    {
        S7_Language := "LAD";
        S7_NetworkTitle := "MLC_LS"
    }
    NETWORK
        RUNG wire#powerrail
            { S7_Templates := "SrcType := Int" }
            EQ_Contact(
                in1 := #s_EtapaActual,
                in2 := 150
            )
            I_Contact( #s_Pausa_M )
            Contact( #s_FF[1].Estado_Flip )
            Coil( #MarchaAgitador )
        END_RUNG
    END_NETWORK
    {
        S7_Language := "SCL";
        S7_NetworkTitle := "MLC_3hH"
    }
    NETWORK
        
        IF #Parametros.P_Int_5 = 1 THEN
            // =============================================================================
            //VELOCIDAD FIJA
            #VelocidadAgitador := #Parametros.P_Real_1;
        ELSE
            // =============================================================================
            //VELOCIDAD POR NIVEL
            #t_x0 := #Parametros.P_Real_2;
            #t_x1 := #Parametros.P_Real_3;
            #t_x := #LT_Tanque;
            #t_y0 := #Parametros.P_Real_4;
            #t_y1 := #Parametros.P_Real_5;
            #VelocidadAgitador := #t_y0 + (#t_y1 - #t_y0) * ((#t_x - #t_x0) / (#t_x1 - #t_x0));
            IF #VelocidadAgitador > #t_y1 THEN
                #VelocidadAgitador := #t_y1;
            END_IF;
            IF #VelocidadAgitador < #t_y0 THEN
                #VelocidadAgitador := #t_y0;
            END_IF;
        END_IF;
                                        
    END_NETWORK
    {
        S7_Language := "LAD";
        S7_NetworkTitle := "MLC_4Mk"
    }
    NETWORK
        RUNG wire#powerrail
            Move(
                in := #s_ProductoActual,
                out1 => #ProductoActual
            )
        END_RUNG
    END_NETWORK
    {
        S7_Language := "SCL";
        S7_NetworkTitle := "MLC_365"
    }
    NETWORK
        
        //  =========================================================================================
        //  Permiso confirmar productos
        #AdicionProductoPermiso[0] := (#s_ProductoActual = 0) AND (#AdicionProductoDosificado[0] > 0.0) AND (#s_EtapaActual >= 130) AND (#s_EtapaActual <= 130);
        #AdicionProductoPermiso[1] := (#s_ProductoActual = 1) AND (#AdicionProductoDosificado[1] > 0.0) AND (#s_EtapaActual >= 130) AND (#s_EtapaActual <= 130);
        #AdicionProductoPermiso[2] := (#s_ProductoActual = 2) AND (#AdicionProductoDosificado[2] > 0.0) AND (#s_EtapaActual >= 130) AND (#s_EtapaActual <= 130);
        #AdicionProductoPermiso[3] := (#s_ProductoActual = 3) AND (#AdicionProductoDosificado[3] > 0.0) AND (#s_EtapaActual >= 130) AND (#s_EtapaActual <= 130);
        #AdicionProductoPermiso[4] := (#s_ProductoActual = 4) AND (#AdicionProductoDosificado[4] > 0.0) AND (#s_EtapaActual >= 130) AND (#s_EtapaActual <= 130);
        #AdicionProductoPermiso[5] := (#s_ProductoActual = 5) AND (#AdicionProductoDosificado[5] > 0.0) AND (#s_EtapaActual >= 130) AND (#s_EtapaActual <= 130);
        #AdicionProductoPermiso[6] := (#s_ProductoActual = 6) AND (#AdicionProductoDosificado[6] > 0.0) AND (#s_EtapaActual >= 130) AND (#s_EtapaActual <= 130);
        #AdicionProductoPermiso[7] := (#s_ProductoActual = 7) AND (#AdicionProductoDosificado[7] > 0.0) AND (#s_EtapaActual >= 130) AND (#s_EtapaActual <= 130);
        #AdicionProductoPermiso[8] := (#s_ProductoActual = 8) AND (#AdicionProductoDosificado[8] > 0.0) AND (#s_EtapaActual >= 130) AND (#s_EtapaActual <= 130);
        #AdicionProductoPermiso[9] := (#s_ProductoActual = 9) AND (#AdicionProductoDosificado[9] > 0.0) AND (#s_EtapaActual >= 130) AND (#s_EtapaActual <= 130);
        
        
    END_NETWORK
    {
        S7_Language := "LAD";
        S7_NetworkTitle := "MLC_4RE"
    }
    NETWORK
        RUNG wire#powerrail
            { S7_Templates := "SrcType := Int" }
            GE_Contact(
                in1 := #s_EtapaActual,
                in2 := 130
            )
            { S7_Templates := "SrcType := Int" }
            LE_Contact(
                in1 := #s_EtapaActual,
                in2 := 150
            )
            Coil( #PermisoSaltarEtapa )
        END_RUNG
    END_NETWORK
    {
        S7_Language := "LAD";
        S7_NetworkTitle := "MLC_3Eu"
    }
    NETWORK
        RUNG wire#powerrail
            { S7_Templates := "SrcType := Int" }
            GT_Contact(
                in1 := #s_EtapaActual,
                in2 := 0
            )
            Coil( #SecuenciaIniciada )
        END_RUNG
    END_NETWORK
    {
        S7_Language := "LAD";
        S7_NetworkTitle := "MLC_4rA"
    }
    NETWORK
        RUNG wire#powerrail
            { S7_Templates := "SrcType := Int" }
            EQ_Contact(
                in1 := #s_EtapaActual,
                in2 := 999
            )
            Coil( #FinSecuencia )
        END_RUNG
    END_NETWORK
END_FUNCTION_BLOCK
