*-----------------------------------------------------------------------------
*  Linear axes compensation
*-----------------------------------------------------------------------------
*  Module Description
*    - it is possible to modify a lineare axes compenpensation via an
*      entry mask within a range of -50 ... +50 µm/m
*
*-----------------------------------------------------------------------------

#define /s    KL_inactive                              K +0
#define /s    KL_axes_compensation_range               K +500 ;;Unit 1/10 µm
#define /s    KL_factor_mm                             K +10000 ;;Factor 0,1µm -> 1mm
#define /s    KL_factor_m                              K +1000 ;;Factor 1mm -> 1m
#define /s    KL_word_range                            K $7FFF

#define /s    ML_error_axes_compensation_changes       M
#define /s    ML_axes_comp_display_has_been_active     M
#define /s    ML_axes_comp_entry_has_been_active       M

#define /s    BL_axis_index                            B

#define /s /r Axis_comp_factor_old                     W [3]
#define /c    WL_axis_comp_X_factor_old                W &Axis_comp_factor_old + 0
#define /c    WL_axis_comp_Y_factor_old                W &Axis_comp_factor_old + 2
#define /c    WL_axis_comp_Z_factor_old                W &Axis_comp_factor_old + 4

#define /c    WL_stack_synchronize                     W

#include Mac_Lib.inc

EXTERN Absolute
GLOBAL Axes_compensation

;----------------------------
LBL Axes_compensation
;----------------------------

  L      MG_marker_one
  R      MG_axis_compensation

  L      K+0
  =      BL_axis_index

  REPEAT
    L      WG_axis_comp_X_factor[BL_axis_index]
    <>     WL_axis_comp_X_factor_old[BL_axis_index]
    IFT
      S      PN_error_axes_compensation_changed

      PS     WG_axis_comp_X_factor[BL_axis_index]
      CM     Absolute
      PLW
      >      KL_axes_compensation_range
      IFT
        S      PN_error_value_not_permissible

        L      KL_inactive
        =      WG_axis_comp_X_factor[BL_axis_index]
      ENDI

      L      WG_axis_comp_X_factor[BL_axis_index]
      =      WL_axis_comp_X_factor_old[BL_axis_index]
    ENDI

    L      WG_axis_comp_X_factor[BL_axis_index]
    >      KL_inactive
    S      MG_axis_compensation

    L      DG_position_axis_X_actl[BL_axis_index]
    /      KL_factor_mm
    X      WG_axis_comp_X_factor[BL_axis_index]
    /      KL_factor_m
    PSW
    >      KL_word_range
    S      PN_error_value_not_permissible
    IFT
      PL     WL_stack_synchronize

      L      KL_word_range
      =      WG_axis_compensation_X[BL_axis_index]
    ELSE
      PLW
      =      WG_axis_compensation_X[BL_axis_index]
    ENDI

    INC    BL_axis_index

    L      BL_axis_index
    >      KG_axis_Z
  UNTILT

  L      PN_error_axes_compensation_changed
  AN     ML_error_axes_compensation_changes
  S      MG_SK_axes_comp_display
  R      MG_SK_axes_comp_enter

  L      PN_error_axes_compensation_changed
  =      ML_error_axes_compensation_changes

  L      MG_SK_axes_comp_display
  AN     ML_axes_comp_display_has_been_active
  R      MG_SK_axes_comp_enter

  L      MG_SK_axes_comp_display
  =      ML_axes_comp_display_has_been_active

  L      MG_SK_axes_comp_enter
  AN     ML_axes_comp_entry_has_been_active
  R      MG_SK_axes_comp_display

  L      MG_SK_axes_comp_enter
  =      ML_axes_comp_entry_has_been_active

EM
