*-----------------------------------------------------------------------------
*  Axes manual and with handwheel positioning
*-----------------------------------------------------------------------------
*  Module Description
*
*    Axes manual (tip) positioning
*    Jogging (incremental) positioning
*    Memory key (conventional) positioning
*    Rapid traverse
*    Handwheel
*    Machine control panel (MB_) MBxxx
*
*-----------------------------------------------------------------------------
*-----------------------------------------------------------------------------
*  Handwheel HR 330
*-----------------------------------------------------------------------------
*  Module Description
*    MP 7640: 3
*
*    input and output assignment
*    -----     -----
*      +  I160   -  I161
*    -----     -----
*    -----     -----
*      ~  I162   ~  I162
*    -----     -----
*    The input I162 are only set if plus or minus and the rapid traverse key
*    are pressed.
*-----------------------------------------------------------------------------
*-----------------------------------------------------------------------------
*  Handwheel HR 410 (Id-No. 296 469-45)
*-----------------------------------------------------------------------------
*  Module Description
*    MP 7640: 6
*    MP 7645: 0
*
*    input and output assignment
*
*    -----               -----
*      X                  IV
*    -----               -----
*    -----               -----
*      Y                   V
*    -----               -----
*    -----               -----
*      Z                  Ist
*    -----               -----
*    -----     -----     -----
*     F1        F2        F3         Ist: actual nominal transfer
*    -----     -----     -----       F1:  low speed
*    -----               -----       F2:  medium speed
*      -                   +         F3:  high speed
*    -----               -----       F/A: function A - spindle start
*    -----     -----     -----       F/B: function B - NC start
*     F/A O109  F/B O110  F/C O111   F/C: function C - NC stop
*    -----I173 -----I174 -----I175
*-----------------------------------------------------------------------------

#define /s    KL_active_axis                           K +8
#define /s    KL_HR_axis                               K +9
#define /s    KL_inactive                              K +0
#define /s    KL_MP7640_maximum_value                  K +13
#define /s    KL_handwheel_axis_bitcoded               K +10
#define /s    KL_VT_axis_bitcoded                      K $8000000
#define /s    KL_handwheel_axis                        K +6
#define /s    KL_VT_axis                               K -1
#define /s    KL_HR420                                 K +11

#define /s    ML_XYZ45_plus                            M[32]
#define /c    ML_X_plus                                M &ML_XYZ45_plus + 0
#define /c    ML_Y_plus                                M &ML_XYZ45_plus + 1
#define /c    ML_Z_plus                                M &ML_XYZ45_plus + 2
#define /c    ML_4_plus                                M &ML_XYZ45_plus + 3
#define /c    ML_5_plus                                M &ML_XYZ45_plus + 4
#define /c    ML_6_plus                                M &ML_XYZ45_plus + 5
#define /c    ML_7_plus                                M &ML_XYZ45_plus + 6
#define /c    ML_8_plus                                M &ML_XYZ45_plus + 7
#define /c    ML_9_plus                                M &ML_XYZ45_plus + 8
#define /c    ML_10_plus                               M &ML_XYZ45_plus + 9
#define /c    ML_11_plus                               M &ML_XYZ45_plus + 10
#define /c    ML_12_plus                               M &ML_XYZ45_plus + 11
#define /c    ML_13_plus                               M &ML_XYZ45_plus + 12
#define /c    ML_14_plus                               M &ML_XYZ45_plus + 13
#define /c    ML_15_plus                               M &ML_XYZ45_plus + 14
#define /c    ML_16_plus                               M &ML_XYZ45_plus + 15
#define /c    ML_17_plus                               M &ML_XYZ45_plus + 17
#define /c    ML_18_plus                               M &ML_XYZ45_plus + 18

#define /s    ML_XYZ45_minus                           M[32]
#define /c    ML_X_minus                               M &ML_XYZ45_minus + 0
#define /c    ML_Y_minus                               M &ML_XYZ45_minus + 1
#define /c    ML_Z_minus                               M &ML_XYZ45_minus + 2
#define /c    ML_4_minus                               M &ML_XYZ45_minus + 3
#define /c    ML_5_minus                               M &ML_XYZ45_minus + 4
#define /c    ML_6_minus                               M &ML_XYZ45_minus + 5
#define /c    ML_7_minus                               M &ML_XYZ45_minus + 6
#define /c    ML_8_minus                               M &ML_XYZ45_minus + 7
#define /c    ML_9_minus                               M &ML_XYZ45_minus + 8
#define /c    ML_10_minus                              M &ML_XYZ45_minus + 9
#define /c    ML_11_minus                              M &ML_XYZ45_minus + 10
#define /c    ML_12_minus                              M &ML_XYZ45_minus + 11
#define /c    ML_13_minus                              M &ML_XYZ45_minus + 12
#define /c    ML_14_minus                              M &ML_XYZ45_minus + 13
#define /c    ML_15_minus                              M &ML_XYZ45_minus + 14
#define /c    ML_16_minus                              M &ML_XYZ45_minus + 15
#define /c    ML_17_minus                              M &ML_XYZ45_minus + 16
#define /c    ML_18_minus                              M &ML_XYZ45_minus + 17

#define /s    ML_lamp_XYZ45_plus                       M[32] ;20120926
#define /c    ML_lamp_X_plus                           M &ML_lamp_XYZ45_plus + 0
#define /c    ML_lamp_Y_plus                           M &ML_lamp_XYZ45_plus + 1
#define /c    ML_lamp_Z_plus                           M &ML_lamp_XYZ45_plus + 2
#define /c    ML_lamp_4_plus                           M &ML_lamp_XYZ45_plus + 3
#define /c    ML_lamp_5_plus                           M &ML_lamp_XYZ45_plus + 4
#define /c    ML_lamp_6_plus                           M &ML_lamp_XYZ45_plus + 5

#define /s    ML_lamp_XYZ45_minus                      M[32] ;20120926
#define /c    ML_lamp_X_minus                          M &ML_lamp_XYZ45_minus + 0
#define /c    ML_lamp_Y_minus                          M &ML_lamp_XYZ45_minus + 1
#define /c    ML_lamp_Z_minus                          M &ML_lamp_XYZ45_minus + 2
#define /c    ML_lamp_4_minus                          M &ML_lamp_XYZ45_minus + 3
#define /c    ML_lamp_5_minus                          M &ML_lamp_XYZ45_minus + 4
#define /c    ML_lamp_6_minus                          M &ML_lamp_XYZ45_minus + 5

#define /s    ML_HR_key_NC_stop                        M
#define /s    ML_HR_key_spindle_M5                     M

#define /s    BL_error_code                            B

#define /s    WL_stack_synchronize                     W

#define /s    DL_TC_magazine_axes_active               D

#include Mac_Lib.inc

GLOBAL Manual_handwheel

;----------------------------
LBL Manual_handwheel
;----------------------------

  LN     MG_machine_parameter_are_read
  EMT

  L      BG_MP7640_handwheel_type
  >      KL_MP7640_maximum_value
  IFT
    CM     reserved
  ELSE
    CASE   BG_MP7640_handwheel_type
      CM     MB_total                  ;0  No HR
      CM     MB_total                  ;1  HR330 evaluation by NC
      CM     MB_total                  ;2  HR130 or HR330
      CM     HR330_Handwheel           ;3  HR330 +,- rapid traverse by PLC
      CM     MB_total                  ;4  HR332 faced out
      CM     MB_total                  ;5  HRA110 HR150 + HRA110
      CM     HR410_handwheel           ;6  HR410 keys FCT A..C by PLC
      CM     reserved                  ;7  reserved
      CM     reserved                  ;8  reserved
      CM     reserved                  ;9  reserved
      CM     reserved                  ;10 reserved
      CM     HR420_handwheel           ;11 HR420
      CM     HR5x0_hand_wheel          ;12 HR550
      CM     HR5x0_hand_wheel          ;13 HR520
    ENDC
  ENDI

  L      BG_MP7640_handwheel_type
  >=     KL_HR420
  IFT
    L      NP_W274_code_pushed_key
    ==     KG_key_handwheel_mode
    S      PN_error_key_non_functional

    PS     KG_key_handwheel_mode
    CM     9181
    PL     BL_error_code
    M_display_module_error
  ENDI

  L      MG_manual_mode
  ON     I_ESA_control_operational
  CMT    axes_end_position
  CMT    axes_manu_posit

  L      DG_keys_inhibit
  >      KL_inactive
  O[
    LN     I_HRxx0_key_permissive_mode
    A      MG_automatic_mode
  ]
  =      PN_M4576_suppress_handwheel_pulses

  LN     MG_manu_auto_mode_change
  EMT

  L      K+0
  =      PN_D1144_manual_motion_plus
  =      PN_D1148_manual_motion_minus

EM

;----------------------------
LBL reserved

  L      MG_marker_one
  S      PN_error_check_machine_parameter
  =      MG_win_MP7640_HR_type_not_supported

  CM     MB_total

EM

;----------------------------
LBL MB_total

  L      MG_key_NC_start
  O      MG_manual_mode
  A      I_key_rapid_traverse
  =      PN_M4561_rapid_traverse
  =      O_lamp_rapid_traverse         ;20120926

  L      NP_W304_number_PLC_soft_key_vertical
  ==     SK_NC_start
  O      I_key_NC_start
  O      NP_M4230_NC_START_from_LSV2
  =      MG_key_NC_start

  L      I_key_spindle_M3
  O      MG_SK_spindle_M3
  =      MG_key_spindle_M3

  L      I_key_spindle_M4
  O      MG_SK_spindle_M4
  =      MG_key_spindle_M4

  L      I_key_NC_stop_2_axes_spindle
  =      MG_key_NC_stop_2_axes_spindle

  L      I_key_rapid_traverse
  =      MG_key_rapid_traverse

  L      I_key_axes_motion_from_end_position
  =      MG_key_axes_motion_from_end_position

  CM     axes_keys

;----------------------------
LBL MB_stop_function

  L      I_key_tool_unclamping
  O      I_PB_tool_unclamping
  =      MG_key_tool_unclamping

  L      I_key_release_toolchange
  =      MG_key_release_toolchange

  L      I_key_TC_magazine_guard_unlock
  =      MG_key_TC_magazine_guard_unlock

  L      I_key_guard_unlock
  =      MG_key_guard_unlock

  L      I_key_power_on
  =      MG_key_power_on

  L      I_key_coolant_M07
  =      MG_key_coolant_M07

  L      I_key_coolant_M08
  =      MG_key_coolant_M08

  L      I_key_coolant_M17
  =      MG_key_coolant_M17

  L      I_key_dry_run
  =      MG_key_dry_run

  L      I_key_lubrication_axes
  =      MG_key_lubrication_axes

  L      I_key_chip_conveyor
  =      MG_key_chip_conveyor

  L      I_key_chip_conveyor_back
  =      MG_key_chip_conveyor_back

  L      I_key_enable_table_1
  =      MG_key_enable_table_1

  L      I_key_enable_table_2
  =      MG_key_enable_table_2

  L      I_key_enable_new_workpiece
  =      MG_key_enable_new_workpiece

  L      NP_W304_number_PLC_soft_key_vertical
  ==     SK_working_light
  O      I_key_working_light
  =      MG_key_working_light

  L      I_key_TC_magazine_cw
  =      MG_key_TC_mag_turn_cw

  L      I_key_TC_magazine_ccw
  =      MG_key_TC_mag_turn_ccw

  L      I_key_TC_magazine_n_select
  =      MG_key_TC_magazine_n_select

  L      I_SLS_operating_mode_2_set_up
  =      MG_SLS_operating_mode_2_set_up

  L      I_SLS_operating_mode_3
  =      MG_SLS_operating_mode_3

  L      I_SLS_operating_mode_4
  =      MG_SLS_operating_mode_4

  L      I_key_override_F_100
  =      MG_key_override_F_100

  L      I_key_override_S_100
  =      MG_key_override_S_100

  L      I_key_override_S_plus
  =      MG_key_override_S_plus

  L      I_key_override_S_minus
  =      MG_key_override_S_minus

  L      I_key_permissive_mode
  O      I_HRxx0_key_permissive_mode   ;20120926
  =      MG_key_permissive_mode
  =      O_lamp_permissive_mode        ;20120926
  =      MG_SLS_operating_mode_2_set_up          ;20120926

  L      I_key_S_jog_right_cw
  =      MG_SK_S_jog_right_cw

  L      I_key_S_jog_left_ccw
  =      MG_SK_S_jog_left_ccw

  L      NP_W304_number_PLC_soft_key_vertical
  ==     SK_Spindle_tip_cw
  O      I_key_S_jog_right_cw
  =      MG_key_S_jog_right_cw

  L      NP_W304_number_PLC_soft_key_vertical
  ==     SK_Spindle_tip_ccw
  O      I_key_S_jog_left_ccw
  =      MG_key_S_jog_left_ccw

  L      I_key_workpiece_clamping_on_off
  =      MG_key_workpiece_clamping_on_off

  L      I_key_PC_cabin_open
  =      MG_key_PC_cabin_open

  L      I_key_function_1              ;20120926
  =      MG_key_function_1
  =      O_lamp_function_1

  L      I_key_function_2
  =      MG_key_function_2
  =      O_lamp_function_2             ;20120926

  L      I_key_function_3
  =      MG_key_function_3
  =      O_lamp_function_3             ;20120926

  L      PN_D1144_manual_motion_plus
  O      PN_D1148_manual_motion_minus
  >      K+0
  A      MG_key_NC_start
  =      PN_M4562_axes_keys_memory_function
  S      MG_axes_key_memory_function

  L      NP_W304_number_PLC_soft_key_vertical
  ==     SK_NC_stop
  ON     I_key_NC_stop
  O      I_key_NC_stop_2_axes_spindle
  O      ML_HR_key_NC_stop
  ON     NP_M4231_NC_STOP_from_LSV2
  =      MG_key_NC_stop

  L      I_key_NC_stop_2_axes_spindle
  =      MG_key_NC_stop_2_axes_spindle

  LN     MG_axes_in_motion
  O      MG_pulse_END_PGM_M02_M30
  A      MG_axes_key_memory_function
  R      MG_axes_key_memory_function
  S      MG_key_NC_stop

  L      I_key_spindle_M5
  O      ML_HR_key_spindle_M5
  O      MG_SK_spindle_M5
  =      MG_key_spindle_M5

  L      O_lamp_NC_start
  =      MG_SK_status_NC_start

  L      O_lamp_NC_stop
  =      MG_SK_status_NC_stop

EM

;----------------------------
LBL HR330_Handwheel

  L      NP_M4151_mode_electronic_handwheel
  CMT    MB_stop_function
  JPF    MB_total

  L      I_HR330_key_rapid_traverse
  =      PN_M4561_rapid_traverse

  PS     KL_active_axis
  CM     9035
  M_display_module_error

  PLW
  =X

  L      K +0
  D=     ML_XYZ45_plus
  D=     ML_XYZ45_minus

  L      I_HR330_key_plus
  S      ML_XYZ45_plus[X]

  L      I_HR330_key_minus
  S      ML_XYZ45_minus[X]

EM

;----------------------------
LBL HR410_handwheel

;NC stop, spindle stop active in general

  L      I_HR410_key_NC_stop
  =      ML_HR_key_NC_stop

  L      I_HR410_key_spindle_M5
  =      ML_HR_key_spindle_M5

  L      O_lamp_NC_stop
  =      O_HR410_lamp_NC_stop

  L      O_lamp_NC_start
  =      O_HR410_lamp_NC_start

  L      O_lamp_spindle_M3
  =      O_HR410_lamp_spindle_M3

  L      O_lamp_spindle_M4
  =      O_HR410_lamp_spindle_M4

  L      O_lamp_spindle_M5
  =      O_HR410_lamp_spindle_M5

  L      NP_M4151_mode_electronic_handwheel
  CMT    MB_stop_function
  JPF    MB_total

  L      I_HR410_key_NC_start
  O      NP_M4230_NC_START_from_LSV2
  =      MG_key_NC_start

  L      I_HR410_key_spindle_M3
  =      MG_key_spindle_M3

  L      I_HR410_key_spindle_M4
  =      MG_key_spindle_M4

  L      I_HR410_key_spindle_jog
  =      MG_key_S_jog_right_cw

  L      I_HR410_key_enable_VT
  IFT
    PS     KL_handwheel_axis_bitcoded  ;Number status information
    CM     9035
    M_display_module_error

    PLW
    <>     KL_VT_axis_bitcoded
    IFT

      PS     KL_handwheel_axis         ;Number status information
      PS     KL_VT_axis                ;Value
      CM     9036
      PL     WL_stack_synchronize
      M_display_module_error
    ENDI
  ENDI

EM

;----------------------------
LBL HR420_handwheel

;NC stop, spindle stop active in general

  L      NP_M4662_HR420_key_NC_stop
  =      ML_HR_key_NC_stop

  L      NP_M4665_HR420_key_spindle_stop
  =      ML_HR_key_spindle_M5

  L      NP_M4660_HR420_active
  CMT    MB_stop_function
  JPF    MB_total

  L      NP_M4661_HR420_key_NC_start
  O      NP_M4230_NC_START_from_LSV2
  =      MG_key_NC_start

  L      NP_M4664_HR420_key_spindle_start
  =      MG_key_spindle_M3

  PS     KL_active_axis
  CM     9035
  M_display_module_error

  PLW
  =X

  L      K +0
  D=     ML_XYZ45_plus
  D=     ML_XYZ45_minus

  L      NP_M4666_HR420_key_axis_direction_plus
  S      ML_XYZ45_plus[X]

  L      NP_M4667_HR420_key_axis_direction_minus
  S      ML_XYZ45_minus[X]

EM

;----------------------------
LBL HR5x0_hand_wheel

;NC stop, spindle stop active in general

  L      NP_M4662_HR5x0_key_NC_stop
  =      ML_HR_key_NC_stop

  L      NP_M4665_HR5x0_key_spindle_stop
  =      ML_HR_key_spindle_M5

  L      O_lamp_NC_stop
  =      PN_M4682_HR5x0_LED_key_NC_stop

  L      O_lamp_NC_start
  =      PN_M4681_HR5x0_LED_key_NC_start

  L      O_lamp_spindle_M3
  =      PN_M4684_HR5x0_LED_key_spindle_start

  L      O_lamp_spindle_M5
  =      PN_M4685_HR5x0_LED_key_spindle_stop

  L      NP_M4660_HR5x0_active
  CMT    MB_stop_function
  JPF    MB_total

  L      NP_M4661_HR5x0_key_NC_start
  O      NP_M4230_NC_START_from_LSV2
  =      MG_key_NC_start

  L      NP_M4664_HR5x0_key_spindle_start
  =      MG_key_spindle_M3

  L      NP_M4663_HR5x0_key_rapid_traverse
  =      MG_key_rapid_traverse

  PS     KL_active_axis
  CM     9035
  M_display_module_error

  PLW
  =X

  L      K +0
  D=     ML_XYZ45_plus
  D=     ML_XYZ45_minus

  L      NP_M4666_HR5x0_key_axis_direction_plus
  S      ML_XYZ45_plus[X]

  L      NP_M4667_HR5x0_key_axis_direction_minus
  S      ML_XYZ45_minus[X]

  L      NP_M4668_HR5x0_key_Ctrl
  =      PN_M4688_HR5x0_LED_key_Ctrl

  L      NP_M4669_HR5x0_key_actual_value
  =      PN_M4689_HR5x0_LED_key_actual_value

EM

;----------------------------
LBL axes_keys

  L      ML_lamp_X_plus                ;20120926
  =      O_lamp_axis_X_plus
  L      ML_lamp_Y_plus
  =      O_lamp_axis_Y_plus
  L      ML_lamp_Z_plus
  =      O_lamp_axis_Z_plus
  L      ML_lamp_4_plus
  =      O_lamp_axis_4_plus
  L      ML_lamp_5_plus
  =      O_lamp_axis_5_plus
  L      ML_lamp_6_plus
  =      O_lamp_axis_6_plus

  L      ML_lamp_X_minus               ;20120926
  =      O_lamp_axis_X_minus
  L      ML_lamp_Y_minus
  =      O_lamp_axis_Y_minus
  L      ML_lamp_Z_minus
  =      O_lamp_axis_Z_minus
  L      ML_lamp_4_minus
  =      O_lamp_axis_4_minus
  L      ML_lamp_5_minus
  =      O_lamp_axis_5_minus
  L      ML_lamp_6_minus
  =      O_lamp_axis_6_minus

  L      I_key_axis_X_plus
  =      ML_X_plus
  L      I_key_axis_Y_plus
  =      ML_Y_plus
  L      I_key_axis_Z_plus
  =      ML_Z_plus
  L      I_key_axis_4_plus
  =      ML_4_plus
  L      I_key_axis_5_plus
  =      ML_5_plus
  L      I_key_axis_6_plus
  =      ML_6_plus
  L      I_key_axis_7_plus
  =      ML_7_plus
  L      I_key_axis_8_plus
  =      ML_8_plus
  L      I_key_axis_9_plus
  =      ML_9_plus
  L      I_key_axis_10_plus
  =      ML_10_plus
  L      I_key_axis_11_plus
  =      ML_11_plus
  L      I_key_axis_12_plus
  =      ML_12_plus
  L      I_key_axis_13_plus
  =      ML_13_plus
  L      I_key_axis_14_plus
  =      ML_14_plus
  L      I_key_axis_15_plus
  =      ML_15_plus
  L      I_key_axis_16_plus
  =      ML_16_plus
  L      I_key_axis_17_plus
  =      ML_17_plus
  L      I_key_axis_18_plus
  =      ML_18_plus

  L      I_key_axis_X_minus
  =      ML_X_minus
  L      I_key_axis_Y_minus
  =      ML_Y_minus
  L      I_key_axis_Z_minus
  =      ML_Z_minus
  L      I_key_axis_4_minus
  =      ML_4_minus
  L      I_key_axis_5_minus
  =      ML_5_minus
  L      I_key_axis_6_minus
  =      ML_6_minus
  L      I_key_axis_7_minus
  =      ML_7_minus
  L      I_key_axis_8_minus
  =      ML_8_minus
  L      I_key_axis_9_minus
  =      ML_9_minus
  L      I_key_axis_10_minus
  =      ML_10_minus
  L      I_key_axis_11_minus
  =      ML_11_minus
  L      I_key_axis_12_minus
  =      ML_12_minus
  L      I_key_axis_13_minus
  =      ML_13_minus
  L      I_key_axis_14_minus
  =      ML_14_minus
  L      I_key_axis_15_minus
  =      ML_15_minus
  L      I_key_axis_16_minus
  =      ML_16_minus
  L      I_key_axis_17_minus
  =      ML_17_minus
  L      I_key_axis_18_minus
  =      ML_18_minus

  PS     KL_active_axis
  CM     9035
  M_display_module_error

  PLW
  =X

  L      I_key_axes_plus
  O      MG_SK_axes_plus
  S      ML_XYZ45_plus[X]

  L      I_key_axes_minus
  O      MG_SK_axes_minus
  S      ML_XYZ45_minus[X]

EM

;----------------------------
LBL axes_end_position

#if CFG_emergency_end_position_axes_coded = "active"
*  L      I_emergency_button_unlocked *DC
  LN     I_X_not_overtravelled
  =      I_end_posit_axis_X

  L      I_X_not_overtravelled
  AN     I_X_Y_not_overtravelled
  =      I_end_posit_axis_Y

  L      I_X_Y_not_overtravelled
  AN     I_X_Y_Z_not_overtravelled
  =      I_end_posit_axis_Z

  L      I_X_Y_Z_not_overtravelled
  AN     I_X_Y_Z_4_not_overtravelled
  =      I_end_posit_axis_4

  L      I_X_Y_Z_4_not_overtravelled
  AN     I_X_Y_Z_4_5_not_overtravelled
  =      I_end_posit_axis_5
#endif

  L      I_end_posit_axis_X
  IFT
    L      DG_MP1320_direction_traverse_ref_negative
    BT     KG_axis_X
    IFT
      LN     MG_ref_end_position_X
      =      MG_win_end_position_Xp
      R      ML_X_plus

      L      MG_ref_end_position_X
      =      MG_win_end_position_Xn
      R      ML_X_minus
    ELSE
      L      MG_ref_end_position_X
      =      MG_win_end_position_Xp
      R      ML_X_plus

      LN     MG_ref_end_position_X
      =      MG_win_end_position_Xn
      R      ML_X_minus
    ENDI
  ENDI

  L      I_end_posit_axis_Y
  IFT
    L      DG_MP1320_direction_traverse_ref_negative
    BT     KG_axis_Y
    IFT
      LN     MG_ref_end_position_Y
      =      MG_win_end_position_Yp
      R      ML_Y_plus

      L      MG_ref_end_position_Y
      =      MG_win_end_position_Yn
      R      ML_Y_minus
    ELSE
      L      MG_ref_end_position_Y
      =      MG_win_end_position_Yp
      R      ML_Y_plus

      LN     MG_ref_end_position_Y
      =      MG_win_end_position_Yn
      R      ML_Y_minus
    ENDI
  ENDI

  L      I_end_posit_axis_Z
  IFT
    L      DG_MP1320_direction_traverse_ref_negative
    BT     KG_axis_Z
    IFT
      LN     MG_ref_end_position_Z
      =      MG_win_end_position_Zp
      R      ML_Z_plus

      L      MG_ref_end_position_Z
      =      MG_win_end_position_Zn
      R      ML_Z_minus
    ELSE
      L      MG_ref_end_position_Z
      =      MG_win_end_position_Zp
      R      ML_Z_plus

      LN     MG_ref_end_position_Z
      =      MG_win_end_position_Zn
      R      ML_Z_minus
    ENDI
  ENDI

  L      I_end_posit_axis_4
  IFT
    L      DG_MP1320_direction_traverse_ref_negative
    BT     KG_axis_4
    IFT
      LN     MG_ref_end_position_4
      =      MG_win_end_position_4p
      R      ML_4_plus

      L      MG_ref_end_position_4
      =      MG_win_end_position_4n
      R      ML_4_minus
    ELSE
      L      MG_ref_end_position_4
      =      MG_win_end_position_4p
      R      ML_4_plus

      LN     MG_ref_end_position_4
      =      MG_win_end_position_4n
      R      ML_4_minus
    ENDI
  ENDI

  L      I_end_posit_axis_5
  IFT
    L      DG_MP1320_direction_traverse_ref_negative
    BT     KG_axis_5
    IFT
      LN     MG_ref_end_position_5
      =      MG_win_end_position_5p
      R      ML_5_plus

      L      MG_ref_end_position_5
      =      MG_win_end_position_5n
      R      ML_5_minus
    ELSE
      L      MG_ref_end_position_5
      =      MG_win_end_position_5p
      R      ML_5_plus

      LN     MG_ref_end_position_5
      =      MG_win_end_position_5n
      R      ML_5_minus
    ENDI
  ENDI

EM

;----------------------------
LBL axes_manu_posit

  L      MG_commissioning
  IFT
    L      K+0
    =      DL_TC_magazine_axes_active
  ELSE
    L      DG_TC_magazine_axes
    =      DL_TC_magazine_axes_active
  ENDI

  LD     ML_XYZ45_plus
  AN     DG_keys_inhibit
  AN     DL_TC_magazine_axes_active
  =      PN_D1144_manual_motion_plus
  A      NP_D1100_axes_release         ;20120926
  AN     NP_D1120_limit_switch_plus
  D=     ML_lamp_XYZ45_plus

  LD     ML_XYZ45_minus
  AN     DG_keys_inhibit
  AN     DL_TC_magazine_axes_active
  =      PN_D1148_manual_motion_minus
  A      NP_D1100_axes_release         ;20120926
  AN     NP_D1124_limit_switch_minus
  D=     ML_lamp_XYZ45_minus

EM

