
FUNCTION_BLOCK FB24
VAR_TEMP
    // variables temporaires

END_VAR
VAR
    TR: ARRAY[0..4] OF BOOL;
    flag_Z10_mouv: BOOL;
    tOnByPass: BOOL;
    tOn: S5TIME;
    tOntempo_bin: WORD;

END_VAR

//transition
TR[0]:= "G7_GestionSection".section_2[0] AND B_ASI40B1_presenceP0 AND 
            (B_ASI40B3_presenceRack AND TypeRackSection(section:= 2, typeChariot:= 1)
            OR ChariotZero404(section:=2)); // 0 vers 2
TR[1]:= "G7_GestionSection".section_2[0] AND B_ASI40B1_presenceP0 AND 
            (B_ASI40B3_presenceRack AND TypeRackSection(section:= 2, typeChariot:= 2)
            OR NOT B_ASI40B3_presenceRack)
            AND NOT TR[0]; // 0 vers 1
TR[2]:= "G7_GestionSection".section_2[1] AND (NOT Z10_mouvementEnCours AND flag_Z10_mouv OR tOnByPass); // 1 vers 2
TR[3]:= "G7_GestionSection".section_2[2] AND "GestionChariotDB".nbChariotSection[3] <3 AND NOT B_ASI40B2_presenceP1; //2 vers 3
TR[4]:= "G7_GestionSection".section_2[3] AND NOT B_ASI40B1_presenceP0; // 3 vers 0

//etape
IF TR[0] THEN // TR 0 vers 2
    "G7_GestionSection".section_2[0]:= false;
    "G7_GestionSection".section_2[2]:= true;
END_IF;
IF TR[1] THEN //TR 0 vers 1
    "G7_GestionSection".section_2[0]:= false;
    "G7_GestionSection".section_2[1]:= true;
END_IF;
IF TR[2] THEN //TR 1 vers 2
    "G7_GestionSection".section_2[1]:= false;
    "G7_GestionSection".section_2[2]:= true;
END_IF;
IF TR[3] THEN //TR 2 vers 3
    "G7_GestionSection".section_2[2]:= false;
    "G7_GestionSection".section_2[3]:= true;
END_IF;
IF TR[4] THEN //TR 3 vers 0
    "G7_GestionSection".section_2[3]:= false;
    "G7_GestionSection".section_2[0]:= true;
END_IF;

//gestion tempo
tOn:= S_ODT (T_NO:= T5, S:="G7_GestionSection".section_2[1] AND NOT Z10_mouvementEnCours, TV:=T#10s, R:=FALSE, BI:=tOntempo_bin,Q:=tOnByPass) ;

//gestion front
flag_Z10_mouv:= Z10_mouvementEnCours;

END_FUNCTION_BLOCK
