*-----------------------------------------------------------------------------
*  Axis Limit - Shifting traverse range M71 M72 M73
*-----------------------------------------------------------------------------
*  Module Description
*    Limit          | Operand         | M-function
*    1              | MG_axis_limit_1 | M71
*    2              | MG_axis_limit_2 | M72
*    3              | MG_axis_limit_3 | M73
*
*    The shifting of the traverse range is effected by M functions macros:
*      PLC:\MFUNCT\MFUNCT.TAB
*      PLC:\MFUNCT\M71.H
*      PLC:\MFUNCT\M72.H
*      PLC:\MFUNCT\M73.H
*
*-----------------------------------------------------------------------------

#define /s    KL_inactive                              K -1
#define /s    KL_string_lengh_1_character              K +1
#define /s    KL_max_axis_number                       K +18

#define /s    ML_axis_limit_init                       M

#define /s    BL_string_position                       B
#define /s    BL_axis_index                            B

#define /s    WL_string_length                         W
#define /s    WL_number_string_character_append        W

#include Mac_Lib.inc

GLOBAL Identifier_axis_x
GLOBAL Axis_limit

;----------------------------
LBL Axis_limit

  L      MG_machine_parameter_are_read
  AN     ML_Axis_Limit_Init
  IFT
    S      ML_Axis_Limit_Init
    S      PN_M4135_strobe_axes_limit

    L      BG_MP1350_reference_mode_X
    ==     K+2
    A      MG_alternating_table_on
    R      MG_axis_limit_1
    S      MG_axis_limit_2
    R      MG_axis_limit_3

    L      MG_axis_limit_2
    =      PN_M4574_axis_limit_Bit_0

    L      MG_axis_limit_3
    =      PN_M4575_axis_limit_Bit_1
  ENDI

  L      MG_M71_axis_limit_1
  S      MG_axis_limit_1
  R      MG_axis_limit_2
  R      MG_axis_limit_3
  S      PN_M4092_quit_M_function
  CMT    Identifier_axis_x

  L      MG_M72_axis_limit_2
  R      MG_axis_limit_1
  S      MG_axis_limit_2
  R      MG_axis_limit_3
  S      PN_M4092_quit_M_function
  CMT    Identifier_axis_x

  L      MG_M73_axis_limit_3
  R      MG_axis_limit_1
  R      MG_axis_limit_2
  S      MG_axis_limit_3
  S      PN_M4092_quit_M_function
  CMT    Identifier_axis_x

EM

;----------------------------
LBL Identifier_axis_x

  LN     MG_axis_limit_1
  AN     MG_axis_limit_2
  AN     MG_axis_limit_3
  S      MG_axis_limit_1

  L      MG_axis_limit_1
  IFT
    L      SG_ident_axes_limit_1
    =      SG_ident_axes_limit_x
  ENDI

  L      MG_axis_limit_2
  IFT
    L      SG_ident_axes_limit_2
    =      SG_ident_axes_limit_x
  ENDI

  L      MG_axis_limit_3
  IFT
    L      SG_ident_axes_limit_3
    =      SG_ident_axes_limit_x
  ENDI

; Test string length MP100.x

  PS     K&SG_ident_axes_limit_x
  CM     9071
  PL     WL_string_length
  M_display_module_error

  L      KL_max_axis_number
  -      WL_string_length
  =      WL_number_string_character_append

  L      WL_number_string_character_append
  >      K+0
  WHILET
    L      S"-"
    +      SG_ident_axes_limit_x
    =      SG_ident_axes_limit_x
    DEC    WL_number_string_character_append

    L      WL_number_string_character_append
    >      K +0
  ENDW

  L      KL_max_axis_number
  =      BL_string_position

  L      K +0
  =      BL_axis_index
  REPEAT

    DEC    BL_string_position

    L      BL_string_position
    =X

    L      SG_ident_axes_limit_x^X
    =      SG_identifier_axis_n
    =      SG_identifier_axis_1[BL_axis_index]

    L      KL_string_lengh_1_character
    =X

    L      S""
    =      SG_identifier_axis_n^X

    L      SG_identifier_axis_n
    =      SG_identifier_axis_1[BL_axis_index]

    INC    BL_axis_index

    L      BL_axis_index
    >=     KL_max_axis_number
  UNTILT

  L      S"-"
  =      SG_identifier_axis_15

  L      S"S"
  =      SG_identifier_axis_19

#if CFG_3D_head = "active"
  L      KG_3D_head_axis_1
  >      KL_inactive
  IFT
    L      SG_identifier_axis_1[KG_3D_head_axis_1]
    =      SG_identifier_3D_axis_1
  ELSE
    L      S"-"
    =      SG_identifier_3D_axis_1
  ENDI

  L      KG_3D_head_axis_2
  >      KL_inactive
  IFT
    L      SG_identifier_axis_1[KG_3D_head_axis_2]
    =      SG_identifier_3D_axis_2
  ELSE
    L      S"-"
    =      SG_identifier_3D_axis_2
  ENDI
#endif

EM
