*-----------------------------------------------------------------------------
*  Working area monitoring
*-----------------------------------------------------------------------------
*  Module Description
*
*-----------------------------------------------------------------------------

#define /s    KL_distance_to_go                        K +4

#define /s    ML_working_area_monitoring_off           M
#define /s    ML_axes_motion_from_end_pos_active       M

#include Mac_Lib.inc

GLOBAL Work_area_monitor

;----------------------------
LBL Work_area_monitor
;----------------------------

  L      MG_M32_working_area_monitoring_off
  S      PN_M4092_quit_M_function
  S      MG_SK_working_area_monitoring_off

  LN     MG_control_operational
  O      MG_manu_auto_mode_change
  O      MG_auto_manu_mode_change
  O      MG_pulse_END_PGM_M02_M30
  R      MG_SK_working_area_monitoring_off

*$WS - evtl. negativer Pulse Axes in Position
  LN     I_key_axis_Y_plus
  AN     I_key_axis_Y_minus
  AN     I_key_axis_Z_plus
  AN     I_key_axis_Z_minus
  A      ML_axes_motion_from_end_pos_active
  R      MG_SK_working_area_monitoring_off

  L      I_key_axis_Y_plus
  O      I_key_axis_Y_minus
  O      I_key_axis_Z_plus
  O      I_key_axis_Z_minus
  =      ML_axes_motion_from_end_pos_active

  L      MG_SK_working_area_monitoring_off
  AN     ML_working_area_monitoring_off
  S      PN_error_monitoring_working_area_off

  LN     MG_SK_working_area_monitoring_off
  A      ML_working_area_monitoring_off
  R      PN_error_monitoring_working_area_off

  L      MG_SK_working_area_monitoring_off
  =      ML_working_area_monitoring_off

  L      MG_SK_working_area_monitoring_off
  ON     MG_reference_axes_traversed
  R      PN_error_protection_working_area
  EMT

  L      DG_position_axis_Y_ref
  <      DG_working_area_manu_Y
  IFT
    L      DG_position_axis_Z_ref
    <      DG_working_area_manu_Z
    A      MG_axes_in_motion
    S      PN_error_protection_working_area
  ENDI

  L      MG_automatic_mode
  IFT
    PS     K&DG_distance_to_go_X_axis
    PS     KL_distance_to_go
    CM     9041
    M_display_module_error

    L      DG_distance_to_go_Y_axis
    +      DG_position_axis_Y_ref
    <      DG_working_area_auto_Y
    IFT
      L      DG_distance_to_go_Z_axis
      +      DG_position_axis_Z_ref
      <      DG_working_area_auto_Z
      S      PN_error_protection_working_area
    ENDI
  ENDI

EM
