
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 marche AND "HMI_DB".HMI_Z8_AU AND reset; // 0 vers 1
  TR[1]:= step[1] AND NOT marche OR NOT "HMI_DB".HMI_Z8_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;

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

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

IF step[0] THEN
    //reset G7 du mode auto
    DB120.DBB0:= 1; // reset G7 général
    DB121.DBB0:= 1; // reset G7 section 0
    DB121.DBB2:= 1; // reset G7 section 1
    DB121.DBB4:= 1; // reset G7 section 2
    DB121.DBB6:= 1; // reset G7 section 3
    DB121.DBB8:= 1; // reset G7 section 4
    DB121.DBB10:= 1; // reset G7 section 5
    DB121.DBB12:= 1; // reset G7 tapis 0     
    
    DB122.DBW0:= 0; // reset table sortie mode manu
    DB123.DBW0:= 0; // reset table sortie mode Maintenance
    
    ResetHmiDb();
END_IF;
END_FUNCTION_BLOCK
