
FUNCTION_BLOCK FB8
VAR
    TR: ARRAY[0..1] OF BOOL;
    Step: ARRAY[0..1] OF BOOL;
    reset: BOOL;
END_VAR

//transition
  TR[0]:= step[0] AND EmgStop AND "HMI_DB".HMI_Z10_AU AND Reset; // 0 vers 1
  TR[1]:= step[1] AND NOT EmgStop OR NOT "HMI_DB".HMI_Z10_AU; // 1 vers 0
  
  // etape
IF TR[0] THEN
    step[0]:= false;
    step[1]:= true;
END_IF;
IF TR[1] THEN
    step[1]:= false;
    step[0]:= true;
END_IF;

//prog
IF step[0] THEN
    reset:=false;
END_IF;
IF resetGeneral THEN
    "HMI_DB".HMI_Z10_AU:= true;
    reset:= true;
END_IF;

//gestion reset


//init G7
IF NOT step[0] AND NOT step[1] THEN
    step[0]:= true;
END_IF;

IF step[0] THEN
    ResetHMI(); // reset certaine valeur de lHMI
    
    DB20.DBW0:= 256; // reset G7 général
    DB21.DBB0:= 1; // reset G7 init
    DB25.DBW0:= 256; // reset G7 auto;
    DB32.DBB0:= 1; // reset G7 PrendreDeposer rack
    DB30.DBB0:= 1; // reset G7 Manu
    DB35.DBB0:= 1; // reset G7 maintenance axe X
    DB35.DBB4:= 1; // reset G7 maintenance axe Z
    DB35.DBB8:= 1; // reset G7 maintenance offset axe Z
    DB36.DBD0:= 16777216; // reset G7 maintenance teachPos

END_IF;
END_FUNCTION_BLOCK

