*-----------------------------------------------------------------------------
*  WZW Automatik Einzelarmgreifer
*-----------------------------------------------------------------------------
*  Modul-Beschreibung
*
*-----------------------------------------------------------------------------

#define /s    KL_WZ_ohne_Platz                         K -1
#define /s    KL_WZ_mit_Platz                          K +1
#define /s    KL_Werkzeug_in_Spindel                   K +0
#define /s    KL_String_Anzahl                         K +3

#define /s    ML_2nd_TOOL_CALL_folgt                   M
#define /s    ML_TOOL_CALL_alt                         M
#define /s    ML_Schritt_Start                         M
#define /s    ML_WZW_Diagnose                          M

#define /s    BL_WZM_Achs_Index                        B
#define /s    BL_WZM_Index                             B
#define /s    BL_String_Index                          B
#define /s    BL_Schritt_WZW                           B

#define /s    WL_Zeile_Dialog_Datei                    W

#include Mac_Lib.inc

EXTERN Start_Posit
EXTERN In_Posit

GLOBAL WZW_auto

;----------------------------
LBL WZW_auto
;----------------------------

  LN     MG_WZW_Auto_aktiv
  EMT

  L      PN_M4540_T_neu_zuerst_Festplatzwechsel
  R      PN_M4540_T_neu_zuerst_Festplatzwechsel

  L      NP_M4521_TOOL_CALL_T_0_programmiert
  A      NP_M4520_TOOL_CALL_2_Strobe
  A      NP_M4073_Strobe_TOOL_CALL
  A      MG_WZW_T0_auto_manu_notwendig
  S      PN_Fehler_TOOL_CALL_T0
  EMT

  L      NP_M4073_Strobe_TOOL_CALL
  IFT
    L      NP_W262_Werkzeug_Platz_Nummer
    >=     KL_WZ_mit_Platz
    AN     NP_M4175_Stern_blinkt
    AN     MG_WZW_automatisch
    S      MG_WZW_automatisch
    IFT
      L      NP_W262_Werkzeug_Platz_Nummer
      =      WG_WZW_Platz_Nummer

      L      NP_W264_Werkzeug_Nummer
      =      WG_WZW_auto_Werkzeug_Nummer
    ENDI
  ENDI

  L      STG_WZM[BG_WZM_Index_Tool_Call].WG_MP7261_WZM_max_Platz
  >=     KL_WZ_mit_Platz
  A      MG_WZW_manuell
  A      NP_M4073_Strobe_TOOL_CALL
  O      MG_WZW_automatisch
  A[
    L      MG_Impuls_Internal_STOP
    ON     MG_Steuerung_betriebsbereit
  ]
  S      MG_Platz_Tabelle_pruefen

  L      MG_Platz_Tabelle_angewaehlt
  A      MG_WZW_Grund_Stellung
  AN     MG_WZW_manuell
  AN     MG_WZW_automatisch
  R      MG_Platz_Tabelle_pruefen

  L      MG_Platz_Tabelle_pruefen
  AN     MG_WZW_manuell
  AN     MG_WZW_automatisch
  AN     MG_WZW_Help
  A      MG_WZW_Grund_Stellung
  =      PN_Fehler_Platz_Tabelle_pruefen

  L      MG_WZW_automatisch
  R      TS_WZW_Timeout
  S      TS_WZW_Timer_allgemein

  CASE   BG_Schritt_WZW
    CM     WZW_auto_Start              ;00
    CM     WZ_in_Spindel_OK            ;01
    CM     WZW_Magazin_Start           ;02
    CM     Magazin_in_Pos              ;03
    CM     Mag_voll_leer               ;04
    CM     Spi_voll_leer               ;05
    CM     T_Schleuse_auf              ;06
    CM     Z1_ein_aus_Start            ;07
    CM     S_Start                     ;08
    CM     T_Schleuse_ist_auf          ;09
    CM     Z1_in_Pos_e_a               ;10
    CM     X_Start                     ;11
    CM     S_in_WZW_Pos                ;12
    CM     X_in_WZW_Pos                ;13
#if WZ_Magazin_bewegt_sich_zu_Spindel = &aktiv
    CM     Mag_zu_Spindel              ;14
    CM     Mag_in_Spindel              ;15
#else
    CM     Y_Start                     ;14
    CM     Y_in_WZW_Pos                ;15
#endif
    CM     WZ_entspannen               ;16
    CM     WZ_entspannt                ;17
    CM     Time_ausheben               ;18
    CM     T0_Tneu_Status              ;19
    CM     T_Status_ok                 ;20
    CM     Z2_ein_aus_Start            ;21
    CM     Z2_in_Pos_e_a               ;22
    CM     Tool_Call_2nd               ;23
    CM     Tool_Call_Wait              ;24
    CM     WZ_Status_lesen             ;25
    CM     Sprung_spannen              ;26 ---> (1)
    CM     WZW_Magazin_Start           ;27
    CM     Magazin_in_Pos              ;28
    CM     Mag_voll                    ;29
    CM     Z3_ein_Start                ;30
    CM     Z3_in_Pos_ein               ;31
    CM     WZ_spannen                  ;32 <--- (1)
    CM     WZ_gespannt                 ;33
    CM     Tneu_in_Status              ;34
    CM     T_Status_ok                 ;35
#if WZ_Magazin_bewegt_sich_zu_Spindel = &aktiv
    CM     Mag_zu_Grund_Stellung       ;36
    CM     Mag_in_Grund_Stellung       ;37
#else
    CM     Y_vor_Start                 ;36
    CM     Y_in_vor_Pos                ;37
#endif
    CM     T_Schleuse_zu               ;38
    CM     T_Schleuse_ist_zu           ;39
    CM     Spi_leer_voll               ;40
    CM     Tool_Call_quitt             ;41
    CM     WZW_auto_Ende               ;42
    CM     Time                        ;reserviert
  ENDC

  PLL
  S      TS_WZW_Timeout
  =      ML_Schritt_Start
  IFT
    INC    BG_Schritt_WZW
  ENDI

  L      MG_WZW_Diagnose
  CMT    Diagnose_String

  LN     MG_WZW_automatisch
  EMT

  L      MG_Impuls_NC_Start
  R      MG_WZW_Unterbrechung

  L      MG_Taste_NC_Start_P_Impuls
  S      TS_WZW_Timeout

  L      MG_Taste_NC_Stop
  O      MG_Impuls_External_STOP
  R      TS_WZW_Timeout
  R      TR_WZW_Timeout

  LN     TS_WZW_Timeout
  AN     TR_WZW_Timeout
  =      PN_Fehler_WZW_Timeout
  S      MG_WZW_Unterbrechung

  L      MG_Impuls_Internal_STOP
  O      MG_BA_Wechsel_Auto_Manu
  O      MG_Arbeitsraum_offen
  ON     MG_Steuerung_betriebsbereit
  CMT    WZW_auto_Reset

  L      PN_Fehler_WZW_Timeout
  IFT
    CM     Diagnose_String

    PS     K &PN_Fehler_WZW_Timeout - 4800
    PS     K &SG_WZW_Diagnose_Zeile_2
    PS     BG_Schritt_WZW
    PS     BG_Schritt_WZW
    CM     9084                        ;PLC-Fehlermeldung anzeigen
    M_Modul_Fehler_anzeigen
  ENDI

EM

;----------------------------
LBL Diagnose_String

  L      K +0
  =      BL_String_Index

    L      BG_Schritt_WZW
    =      BL_Schritt_WZW
    REPEAT
;$WS Call 60286
      L      BL_Schritt_WZW
      =X

      L      KF Diagnose[X]
      =      WL_Zeile_Dialog_Datei
      =X

      L      S#D0[X]
      =      SG_WZW_Diagnose_Zeile_1[BL_String_Index]

      INC    BL_Schritt_WZW
      INC    BL_String_Index
      INCX

      L      BL_String_Index
      >=     KL_String_Anzahl
    UNTILT

  L      BG_Schritt_WZW
  =      BL_Schritt_WZW

EM

;----------------------------
LBL Sprung_spannen                     ;26

  PS     MG_Eins_Merker

  LN     ML_2nd_TOOL_CALL_folgt
  O      NP_M4523_TOOL_CALL_ohne_Platznummer
  IFT
    L      BG_Schritt_WZW
    +      K+5
    =      BG_Schritt_WZW
  ENDI

EM

;----------------------------
LBL WZW_auto_Start                     ;00

  LN     MG_WZW_Grund_Stellung
  A      MG_WZW_automatisch
  S      PN_Fehler_WZW_Grund_Stellung
  S      MG_WZW_Unterbrechung

  L      STG_WZM[BG_WZM_Index_Tool_Call].MG_WZM_Start
  S      TS_WZW_Timeout

  L      MG_WZW_automatisch
  AN     MG_WZW_manuell
  AN     STG_WZM[BG_WZM_Index_Tool_Call].MG_WZM_Start
  A      MG_WZW_Grund_Stellung
  AN     MG_WZW_Unterbrechung
  PSL

EM

;----------------------------
LBL WZ_in_Spindel_OK                   ;01

  L      MG_Taste_NC_Start_P_Impuls
  A      MG_BA_Automatik
  R      MG_WZW_ohne_Tool_Call

  L      MG_WZW_ohne_Tool_Call
  =      PN_Fehler_WZ_Spindel_ok
  =      MG_Win_Window_JA_Nein
  S      TS_WZW_Timeout

  LN     MG_Referenz_Achsen_aufgenommen
  S      PN_Fehler_Referenz_notwendig

  LN     MG_WZW_ohne_Tool_Call
  AN     PN_Fehler_Referenz_notwendig
  AN     MG_WZW_Unterbrechung
  PSL

  L      NP_M4175_Stern_blinkt
  JPT    WZW_auto_Reset

EM

;----------------------------
LBL Spi_voll_leer                      ;05

  L      NP_M4521_TOOL_CALL_T_0_programmiert
  CMT    Spi_voll
  CMF    Spi_leer

EM

;----------------------------
LBL Spi_leer_voll                      ;40

  L      NP_W262_Werkzeug_Platz_Nummer
  ==     KL_WZ_ohne_Platz
  O      NP_M4521_TOOL_CALL_T_0_programmiert
  CMF    Spi_voll
  CMT    Spi_leer

EM

;----------------------------
LBL Spi_voll

  LN     MG_Sn_I_WZ_ist_in_Spindel
  AN     MG_Inbetriebnahme
  AN     STG_Spindel[BG_Index_Sn].MG_WZ_Ueberwachung_inaktiv
  S      PN_Fehler_Spindel_leer

  LN     PN_Fehler_Spindel_leer
  PSL

  L      NP_M4175_Stern_blinkt
  JPT    WZW_auto_Reset

EM

;----------------------------
LBL Spi_leer

  L      MG_Sn_I_WZ_ist_in_Spindel
  AN     MG_Inbetriebnahme
  AN     STG_Spindel[BG_Index_Sn].MG_WZ_Ueberwachung_inaktiv
  S      PN_Fehler_Spindel_nicht_leer

  LN     PN_Fehler_Spindel_nicht_leer
  PSL

  L      NP_M4175_Stern_blinkt
  JPT    WZW_auto_Reset

EM

;----------------------------
LBL Mag_voll_leer                      ;04

  L      NP_M4521_TOOL_CALL_T_0_programmiert
  CMT    Mag_leer
  CMF    Mag_voll

EM

;----------------------------
LBL Mag_leer

  L      STG_WZM[BG_WZM_Index_Tool_Call].MG_I_WZM_Platz_belegt
  AN     MG_Inbetriebnahme
  AN     STG_WZM[BG_WZM_Index_Tool_Call].MG_WZM_Ueberwachung_inaktiv
  S      PN_Fehler_WZM_Platz_belegt

  LN     PN_Fehler_WZM_Platz_belegt
  PSL

  L      NP_M4175_Stern_blinkt
  JPT    WZW_auto_Reset

EM

;----------------------------
LBL Mag_voll                           ;29

  LN     STG_WZM[BG_WZM_Index_Tool_Call].MG_I_WZM_Platz_belegt
  AN     MG_Inbetriebnahme
  AN     STG_WZM[BG_WZM_Index_Tool_Call].MG_WZM_Ueberwachung_inaktiv
  S      PN_Fehler_WZM_Werkzeug_fehlt

  LN     PN_Fehler_WZM_Werkzeug_fehlt
  PSL

  L      NP_M4175_Stern_blinkt
  JPT    WZW_auto_Reset

EM

;----------------------------
LBL WZW_Magazin_Start                  ;02 ;27

  CM     Magazin_Position
  PLL
  =N     STG_WZM[BG_WZM_Index_Tool_Call].MG_WZM_Tool_Call

  LN     MG_WZW_Unterbrechung
  PSL

EM

;----------------------------
LBL Magazin_in_Pos                     ;03 ;28

  CM     Magazin_Position

  L      STG_WZM[BG_WZM_Index_Tool_Call].MG_WZM_Start
  AN     MG_WZW_Unterbrechung
  S      TS_WZW_Timeout

  PLL
  AN     MG_WZW_Unterbrechung
  PSL

EM

#if WZ_Magazin = &Asynchron
;----------------------------
LBL Magazin_Position

  L      STG_WZM[BG_WZM_Index_Tool_Call].BG_WZM_Achs_Index
  =      BL_WZM_Achs_Index

  PS     BL_WZM_Achs_Index
  L      WG_WZW_Platz_Nummer
  X      STG_WZM[BG_WZM_Index_Tool_Call].DG_WZM_Platz_Pos_Differenz
  PSW
  CM     In_Posit
  PLL
  AN     STG_WZM[BG_WZM_Index_Tool_Call].MG_Status[KG_Posit_aktiv]
  AN     STG_WZM[BG_WZM_Index_Tool_Call].MG_WZM_Start
  AN     STG_WZM[BG_WZM_Index_Tool_Call].MG_WZM_Tool_Call
  PSL

EM
#endif

#if WZ_Magazin = &Impuls
;----------------------------
LBL Magazin_Position

  L      STG_WZM[BG_WZM_Index_Tool_Call].WG_WZM_Ist_Platz
  ==     WG_WZW_Platz_Nummer
  AN     STG_WZM[BG_WZM_Index_Tool_Call].MG_WZM_Start
  AN     STG_WZM[BG_WZM_Index_Tool_Call].MG_WZM_Tool_Call
  AN     STG_WZM[BG_WZM_Index_Tool_Call].MG_WZM_Referenz_notwendig
  PSL

EM
#endif

;----------------------------
LBL S_Start                            ;08

  LN     MG_WZW_Unterbrechung
  PSL
  EMF

  L      MG_Spindel_mit_Messgeraet
  S      MG_WZW_Spindel_Richten_ein

EM

;----------------------------
LBL S_in_WZW_Pos                       ;12

  LN     MG_Spindel_mit_Messgeraet
  A      MG_Spindel_aus
  O      MG_Spindel_in_WZW_Position
  AN     MG_WZW_Spindel_Richten_ein
  AN     MG_WZW_Unterbrechung
  PSL


EM

;----------------------------
LBL Z1_ein_aus_Start                   ;07

  L      NP_M4521_TOOL_CALL_T_0_programmiert
  CMT    Z_ein_Start
  CMF    Z_aus_Start

EM

;----------------------------
LBL Z1_in_Pos_e_a                      ;10

  L      NP_M4521_TOOL_CALL_T_0_programmiert
  CMT    Z_in_Pos_ein
  CMF    Z_in_Pos_aus

EM

;----------------------------
LBL Z2_ein_aus_Start                   ;21

  L      NP_M4522_TOOL_CALL_mit_Platznummer
  CMT    Z_ein_Start
  CMF    Z_aus_Start

EM

;----------------------------
LBL Z2_in_Pos_e_a                      ;22

  L      NP_M4522_TOOL_CALL_mit_Platznummer
  CMT    Z_in_Pos_ein
  CMF    Z_in_Pos_aus

EM

;----------------------------
LBL Z3_ein_Start                       ;30

  CM     Z_ein_Start

EM

;----------------------------
LBL Z3_in_Pos_ein                      ;31

  CM     Z_in_Pos_ein

EM

;----------------------------
LBL Z_ein_Start

  L      MG_WZW_Unterbrechung
  IFT
    PS     MG_Null_Merker
  ELSE
    PS     KG_Achse_Z
    PS     DG_WZW_Pos_Z_einsetzen
    CM     Start_Posit
  ENDI

EM

;----------------------------
LBL Z_aus_Start

  L      MG_WZW_Unterbrechung
  IFT
    PS     MG_Null_Merker
  ELSE
    PS     KG_Achse_Z
    PS     DG_WZW_Pos_Z_ausheben
    CM     Start_Posit
  ENDI

EM

;----------------------------
LBL Z_in_Pos_ein

#if WZ_Magazin_bewegt_sich_zu_Spindel = &aktiv
  L      I_WZM_in_Spindel
  S      MG_Sn_O_Spindel_ausblasen
#else
  PS     KG_Achse_Y
  PS     DG_WZW_Pos_Y
  CM     In_Posit
  PLL
  S      MG_Sn_O_Spindel_ausblasen
#endif

  L      MG_WZW_Unterbrechung
  R      MG_Sn_O_Spindel_ausblasen

  PS     KG_Achse_Z
  PS     DG_WZW_Pos_Z_einsetzen
  CM     In_Posit
  PLL
  AN     MG_WZW_Unterbrechung
  R      MG_Sn_O_Spindel_ausblasen
  PSL

EM

;----------------------------
LBL Z_in_Pos_aus

#if WZ_Magazin_bewegt_sich_zu_Spindel = &aktiv
  L      I_WZM_in_Spindel
  S      MG_Sn_O_Spindel_ausblasen
#else
  PS     KG_Achse_Y
  PS     DG_WZW_Pos_Y
  CM     In_Posit
  PLL
  S      MG_Sn_O_Spindel_ausblasen
#endif

  L      MG_WZW_Unterbrechung
  R      MG_Sn_O_Spindel_ausblasen

  PS     KG_Achse_Z
  PS     DG_WZW_Pos_Z_ausheben
  CM     In_Posit
  PLL
  AN     MG_WZW_Unterbrechung
  R      MG_Sn_O_Spindel_ausblasen
  PSL

EM

;----------------------------
LBL X_Start                            ;11

  L      MG_WZW_Unterbrechung
  IFT
    PS     MG_Null_Merker
  ELSE
    PS     KG_Achse_X
    PS     DG_WZW_Pos_X
    CM     Start_Posit
  ENDI

EM

;----------------------------
LBL X_in_WZW_Pos                       ;13

  PS     KG_Achse_X
  PS     DG_WZW_Pos_X
  CM     In_Posit
  PLL
  AN     MG_WZW_Unterbrechung
  PSL

EM

#if WZ_Magazin_bewegt_sich_zu_Spindel = &aktiv
;----------------------------
LBL Mag_zu_Spindel                     ;14

  L      MG_Eins_Merker
  S      O_WZM_zu_Spindel
  R      O_WZM_zu_Grund_Stellung
  PSL

EM

;----------------------------
LBL Mag_in_Spindel                     ;15

  L      I_WZM_in_Spindel
  AN     I_WZM_in_Grund_Stellung
  AN     MG_WZW_Unterbrechung
  PSL

EM

;----------------------------
LBL Mag_zu_Grund_Stellung              ;36

  L      MG_Eins_Merker
  R      O_WZM_zu_Spindel
  S      O_WZM_zu_Grund_Stellung
  PSL

EM

;----------------------------
LBL Mag_in_Grund_Stellung              ;37

  LN     I_WZM_in_Spindel
  A      I_WZM_in_Grund_Stellung
  AN     MG_WZW_Unterbrechung
  PSL

EM
#else
;----------------------------
LBL Y_Start                            ;14

  L      MG_WZW_Unterbrechung
  IFT
    PS     MG_Null_Merker
  ELSE
    PS     KG_Achse_Y
    PS     DG_WZW_Pos_Y
    CM     Start_Posit
  ENDI

EM

;----------------------------
LBL Y_in_WZW_Pos                       ;15

  PS     KG_Achse_Y
  PS     DG_WZW_Pos_Y
  CM     In_Posit
  PLL
  AN     MG_WZW_Unterbrechung
  PSL

EM

;----------------------------
LBL Y_vor_Start                        ;36

  L      MG_WZW_Unterbrechung
  IFT
    PS     MG_Null_Merker
  ELSE
    PS     KG_Achse_Y
    PS     DG_WZW_Pos_Y_vor
    CM     Start_Posit
  ENDI

EM

;----------------------------
LBL Y_in_vor_Pos                       ;37

  PS     KG_Achse_Y
  PS     DG_WZW_Pos_Y_vor
  CM     In_Posit
  PLL
  AN     MG_WZW_Unterbrechung
  PSL

EM
#endif

;----------------------------
LBL WZ_Status_lesen                    ;25

  L      MG_Eins_Merker
  S      MG_WZ_Status_lesen
  PSL

EM

;----------------------------
LBL WZ_entspannen                      ;16

  L      MG_Eins_Merker
  S      MG_Sn_O_WZ_entspannen
  PSL

EM

;----------------------------
LBL WZ_spannen                         ;32

  L      MG_Eins_Merker
  R      MG_Sn_O_WZ_entspannen
  PSL

EM

;----------------------------
LBL WZ_entspannt                       ;17

  LN     MG_Sn_I_WZ_gespannt
  A      MG_Sn_I_WZ_entspannt
  AN     MG_WZW_Unterbrechung
  PSL

EM

;----------------------------
LBL WZ_gespannt                        ;33

  L      MG_Sn_I_WZ_gespannt
  AN     MG_Sn_I_WZ_entspannt
  AN     MG_WZW_Unterbrechung
  PSL

EM

;----------------------------
LBL T_Schleuse_auf                     ;06

  L      MG_Eins_Merker
  S      O_WZ_Schleuse_auf
  R      O_WZ_Schleuse_zu
  PSL

EM

;----------------------------
LBL T_Schleuse_zu                      ;38

  L      MG_Eins_Merker
  R      O_WZ_Schleuse_auf
  S      O_WZ_Schleuse_zu
  PSL

EM

;----------------------------
LBL T_Schleuse_ist_auf                 ;09

#if CFG_WZ_Magazin_Schleuse = "aktiv"
  L      I_WZ_Schleuse_auf
  AN     I_WZ_Schleuse_zu
  AN     MG_WZW_Unterbrechung
  PSL

#else
  PS     MG_Eins_Merker
#endif

EM

;----------------------------
LBL T_Schleuse_ist_zu                  ;39

#if CFG_WZ_Magazin_Schleuse = "aktiv"
  LN     I_WZ_Schleuse_auf
  A      I_WZ_Schleuse_zu
  AN     MG_WZW_Unterbrechung
  PSL
#else
  PS     MG_Eins_Merker
#endif

EM

;----------------------------
LBL T0_Tneu_Status                     ;19

  LN     MG_WZW_Unterbrechung
  S      PN_M4538_Vorwahl_Werkzeug
  PSL

EM

;----------------------------
LBL Tneu_in_Status                     ;34

  LN     MG_WZ_Status_lesen
  AN     MG_WZW_Unterbrechung
  PSL
  EMF

  L      NP_W262_Werkzeug_Platz_Nummer
  >=     KL_WZ_mit_Platz
  S      PN_M4538_Vorwahl_Werkzeug
  EMF

  L      NP_W264_Werkzeug_Nummer
  =      WG_Werkzeug_in_Spindel

EM

;----------------------------
LBL T_Status_ok                        ;20 ;35

  LN     PN_M4538_Vorwahl_Werkzeug
  PSL

EM

;----------------------------
LBL Tool_Call_2nd                      ;23

  LN     NP_M4520_TOOL_CALL_2_Strobe
  ON     NP_M4073_Strobe_TOOL_CALL
  PSL
  EMT

  L      NP_M4520_TOOL_CALL_2_Strobe
  AN     MG_WZW_Unterbrechung
  S      ML_2nd_TOOL_CALL_folgt
  S      PN_M4093_Quit_TOOL_CALL

EM

;----------------------------
LBL Tool_Call_Wait                     ;24

  L      NP_M4073_Strobe_TOOL_CALL
  PSL
  EMF

  L      NP_W262_Werkzeug_Platz_Nummer
  >=     KL_WZ_mit_Platz
  IFT
    L      NP_W262_Werkzeug_Platz_Nummer
    =      WG_WZW_Platz_Nummer

    L      NP_W264_Werkzeug_Nummer
    =      WG_WZW_auto_Werkzeug_Nummer
  ENDI

EM

;----------------------------
LBL Tool_Call_quitt                     ;41

  L      NP_W262_Werkzeug_Platz_Nummer
  ==     KL_WZ_ohne_Platz
  ON     NP_M4073_Strobe_TOOL_CALL
  S      MG_WZ_Vorwahl_Status_lesen
  PSL
  EMT

  L      NP_M4073_Strobe_TOOL_CALL
  AN     MG_WZW_Unterbrechung
  S      PN_M4093_Quit_TOOL_CALL

EM

;----------------------------
LBL WZW_auto_Ende                      ;42

  PS     MG_Null_Merker

;----------------------------
LBL WZW_auto_Reset

  L      MG_Eins_Merker
  R      MG_Sn_O_Spindel_ausblasen
  R      MG_WZW_automatisch
  R      MG_WZW_Unterbrechung
  R      STG_WZM[BG_WZM_Index_Tool_Call].MG_WZM_Tool_Call
  R      MG_WZW_Spindel_Richten_ein
  R      PN_Fehler_WZ_Spindel_ok
  R      MG_Win_Window_JA_Nein
  R      ML_2nd_TOOL_CALL_folgt

  L      K+0
  =      BG_Schritt_WZW
  =      BL_WZM_Index

  REPEAT
    L      MG_Eins_Merker
    R      STG_WZM[BL_WZM_Index].MG_WZM_Tool_Call

    INC    BL_WZM_Index

    L      BL_WZM_Index
    >=     KG_WZM_max_Anzahl
  UNTILT

  L      K+0
  =      BL_WZM_Index

EM

;----------------------------
LBL Time_ausheben                      ;18

  L      NP_M4522_TOOL_CALL_mit_Platznummer
  PSL
  EMT

  PLL
  CMF    Time

EM

;----------------------------
LBL Time

  LN     TR_WZW_Timer_allgemein
  =      TS_WZW_Timer_allgemein
  PSL

EM

;----------------------------
KFIELD Diagnose                        ;Case
  KG_Dia_WZW_Auto_Einzelarm            ;-1
  KG_Dia_WZW_auto_Start                ;00
  KG_Dia_WZ_in_Spindel_OK              ;01
  KG_Dia_WZW_Magazin_Start             ;02
  KG_Dia_Magazin_in_Pos                ;03
  KG_Dia_Mag_voll_leer                 ;04
  KG_Dia_Spi_voll_leer                 ;05
  KG_Dia_T_Schleuse_auf                ;06
  KG_Dia_Z1_ein_aus_Start              ;07
  KG_Dia_S_Start                       ;08
  KG_Dia_T_Schleuse_ist_auf            ;09
  KG_Dia_Z1_in_Pos_e_a                 ;10
  KG_Dia_X_Start                       ;11
  KG_Dia_S_in_WZW_Pos                  ;12
  KG_Dia_X_in_WZW_Pos                  ;13
#if WZ_Magazin_bewegt_sich_zu_Spindel = &aktiv
  KG_Dia_Mag_zu_Spindel                ;14
  KG_Dia_Mag_in_Spindel                ;15
#else
  KG_Dia_Y_Start                       ;14
  KG_Dia_Y_in_WZW_Pos                  ;15
#endif
  KG_Dia_WZ_entspannen                 ;16
  KG_Dia_WZ_entspannt                  ;17
  KG_Dia_Time_ausheben                 ;18
  KG_Dia_T0_Tneu_Status                ;19
  KG_Dia_T_Status_ok                   ;20
  KG_Dia_Z2_ein_aus_Start              ;21
  KG_Dia_Z2_in_Pos_e_a                 ;22
  KG_Dia_Tool_Call_2nd                 ;23
  KG_Dia_Tool_Call_Wait                ;24
  KG_Dia_WZ_Status_lesen               ;25
  KG_Dia_Sprung_spannen                ;26
  KG_Dia_WZW_Magazin_Start             ;27
  KG_Dia_Magazin_in_Pos                ;28
  KG_Dia_Mag_voll                      ;29
  KG_Dia_Z3_ein_Start                  ;30
  KG_Dia_Z3_in_Pos_ein                 ;31
  KG_Dia_WZ_spannen                    ;32
  KG_Dia_WZ_gespannt                   ;33
  KG_Dia_Tneu_in_Status                ;34
  KG_Dia_T_Status_ok                   ;35
#if WZ_Magazin_bewegt_sich_zu_Spindel = &aktiv
  KG_Dia_Mag_zu_Grund_Stellung         ;36
  KG_Dia_Mag_in_Grund_Stellung         ;37
#else
  KG_Dia_Y_vor_Start                   ;36
  KG_Dia_Y_in_vor_Pos                  ;37
#endif
  KG_Dia_T_Schleuse_zu                 ;38
  KG_Dia_T_Schleuse_ist_zu             ;39
  KG_Dia_Spi_leer_voll                 ;40
  KG_Dia_Tool_Call_quitt                ;41
  KG_Dia_WZW_auto_Ende                 ;42
  KG_Dia_leer                          ;43
ENDK
