*-----------------------------------------------------------------------------
*  Function soft-keys
*-----------------------------------------------------------------------------
*  Module Description
*
*-----------------------------------------------------------------------------

#define /s    KL_edit_mode_in_background               K +2
#define /s    KL_MP_edit_active                        K +3
#define /s    KL_status_current_SK_menu                K -1
#define /s    KL_SK_vertical                           K +1
#define /s    KL_mode_machine_edit                     K +2
#define /s    KL_number_current_SK_menu                K +0
#define /s    KL_reserved                              K +0
#define /s    KL_SK_REF_Z                              K +4

#define /s    ML_MP_editor_active                      M
#define /s    ML_key_pressed                           M
#define /s    ML_SK_quit_user_pressed                  M
#define /s    ML_SK_quit_special_pressed               M
#define /s    ML_SK_quit_user_n_pulse                  M
#define /s    ML_SK_quit_special_n_pulse               M
#define /s    ML_user_function_on                      M
#define /s    ML_special_function_on                   M
#define /s    ML_SK_user_on                            M
#define /s    ML_SK_user_off                           M
#define /s    ML_SK_special_on                         M
#define /s    ML_SK_special_off                        M
#define /s    ML_SK_user                               M
#define /s    ML_SK_user_pulse                         M
#define /s    ML_SK_special                            M
#define /s    ML_SK_special_pulse                      M
#define /s    ML_user_M_function_on                    M

#define /s    BL_identifier_1                          B
#define /s    BL_identifier_2                          B
#define /s    BL_identifier_3                          B

#define /s    DL_recources_handle                      D
#define /s    DL_status_information                    D

#include Mac_Lib.inc

GLOBAL Function_softkeys

;----------------------------
LBL Function_softkeys
;----------------------------

  PS     KL_edit_mode_in_background
  CM     9035
  PLW
  ==     KL_MP_edit_active
  EMT

  LN     MG_SK_quit_user
  A      ML_SK_quit_user_pressed
  =      ML_SK_quit_user_n_pulse

  LN     MG_SK_quit_special
  A      ML_SK_quit_special_pressed
  =      ML_SK_quit_special_n_pulse

  L      MG_SK_quit_user
  =      ML_SK_quit_user_pressed

  L      MG_SK_quit_special
  =      ML_SK_quit_special_pressed

  L      MG_key_function_2
  AN     ML_key_pressed
  O      ML_SK_quit_user_n_pulse
  XO     ML_SK_user
  =      ML_SK_user

  L      MG_key_function_3
  AN     ML_key_pressed
  O      ML_SK_quit_special_n_pulse
  XO     ML_SK_special
  =      ML_SK_special

  L      MG_key_function_2
  O      MG_key_function_3
  =      ML_key_pressed

  LN     ML_SK_user
  A      ML_SK_user_pulse
  S      ML_SK_user_off

  LN     ML_SK_special
  A      ML_SK_special_pulse
  S      ML_SK_special_off

  L      ML_SK_user
  AN     ML_SK_user_pulse
  S      ML_SK_user_on
  R      ML_SK_special_on
  R      ML_SK_special

  L      ML_SK_special
  AN     ML_SK_special_pulse
  S      ML_SK_special_on
  R      ML_SK_user_on
  R      ML_SK_user

  L      ML_SK_user
  =      ML_SK_user_pulse

  L      ML_SK_special
  =      ML_SK_special_pulse

  LN     ML_SK_user_on
  AN     ML_SK_user_off
  AN     ML_SK_special_on
  AN     ML_SK_special_off
  IFF
    RPLY   BL_identifier_1
    ==     K+0
    IFT
      SUBM   Softkey_FCT_on_off
      =      BL_identifier_1
      ==     K+0
      S      PN_error_submit_spawn_queue_full
    ENDI
  ENDI

  L      MG_manual_mode
  AN     MG_edit_mode
  =      MG_SK_Ref_enable

  L      MG_SK_Ref_enable
  A      MG_SK_Ref_Z
  S      MG_win_window_NC_start

  L      MG_key_NC_stop
  O      NP_M4176_control_in_operation_on_or_flashes
  R      MG_win_window_NC_start

  L      MG_win_window_NC_start
  AN     NP_M4176_control_in_operation_on_or_flashes
  IFT
    L      MG_key_NC_start
    IFT
      RPLY   BL_identifier_2
      ==     K+0
      IFT
        SUBM   Reference_FCT
        =      BL_identifier_2
        ==     K+0
        S      PN_error_submit_spawn_queue_full
      ENDI
    ENDI
  ENDI

  L      MG_key_NC_stop
  ON     MG_control_operational
  R      MG_user_M_macro_running
  R      MG_user_M_1_on
  R      MG_user_M_2_on
  R      MG_user_M_3_on
  R      MG_user_M_4_on
  R      MG_user_M_5_on
  R      MG_user_M_6_on
  R      MG_user_M_7_on
  R      MG_user_M_8_on
  R      MG_user_M_9_on
  R      MG_user_M_10_on

  L      MG_SK_user_M_1
  AN     MG_user_M_macro_running
  S      MG_user_M_1_on

  L      MG_SK_user_M_2
  AN     MG_user_M_macro_running
  S      MG_user_M_2_on

  L      MG_SK_user_M_3
  AN     MG_user_M_macro_running
  S      MG_user_M_3_on

  L      MG_SK_user_M_4
  AN     MG_user_M_macro_running
  S      MG_user_M_4_on

  L      MG_SK_user_M_5
  AN     MG_user_M_macro_running
  S      MG_user_M_5_on

  L      MG_SK_user_M_6
  AN     MG_user_M_macro_running
  S      MG_user_M_6_on

  L      MG_SK_user_M_7
  AN     MG_user_M_macro_running
  S      MG_user_M_7_on

  L      MG_SK_user_M_8
  AN     MG_user_M_macro_running
  S      MG_user_M_8_on

  L      MG_SK_user_M_9
  AN     MG_user_M_macro_running
  S      MG_user_M_9_on

  L      MG_SK_user_M_10
  AN     MG_user_M_macro_running
  S      MG_user_M_10_on

  L      MG_user_M_1_on
  O      MG_user_M_2_on
  O      MG_user_M_3_on
  O      MG_user_M_4_on
  O      MG_user_M_5_on
  O      MG_user_M_6_on
  O      MG_user_M_7_on
  O      MG_user_M_8_on
  O      MG_user_M_9_on
  O      MG_user_M_10_on
  AN     MG_user_M_macro_running
  AN     NP_M4176_control_in_operation_on_or_flashes
  IFT
    RPLY   BL_identifier_3
    ==     K+0
    IFT
      SUBM   User_M_FCT
      =      BL_identifier_3
      ==     K+0
      S      PN_error_submit_spawn_queue_full
    ENDI
  ENDI

EM

;----------------------------
LBL User_M_FCT

  PS     S"USER_M"
  CM     9291
  M_display_module_error

EM

;----------------------------
LBL Reference_FCT

  PS     S"REF_REF_Z"
  CM     9291
  M_display_module_error

EM

;----------------------------
LBL Softkey_FCT_on_off

  L      ML_SK_user_on
  O      ML_SK_special_on
  AN     ML_user_function_on
  AN     ML_special_function_on
  CMT    FCT_soft_key_on

  L      ML_SK_user_on
  R      ML_SK_user_on
  S      ML_user_function_on
  CMT    Display_user_soft_key

  L      ML_SK_special_on
  R      ML_SK_special_on
  S      ML_special_function_on
  CMT    Display_special_soft_key

  L      ML_SK_user_off
  O      ML_SK_special_off
  R      ML_SK_user_off
  R      ML_SK_special_off
  R      ML_user_function_on
  R      ML_special_function_on
  CMT    FCT_soft_key_off

EM

;----------------------------
LBL FCT_soft_key_on

;Detect current soft key menu

  PS     DL_recources_handle
  PS     S""
  PS     KL_status_current_SK_menu
  PS     KL_SK_vertical
  PS     KL_mode_machine_edit
  CM     9203                          ;Activate soft key menu
  PL     DL_recources_handle
    M_display_module_error

  PS     DL_recources_handle
  PS     KL_number_current_SK_menu
  PS     KL_reserved
  CM     9208                          ;Status information PLC soft keys
  PL     DL_status_information
    M_display_module_error

EM

;----------------------------
LBL Display_user_soft_key

;Display soft key menu user

  PS     DL_recources_handle
  PS     S""
  PS     USER_M
  PS     KL_SK_vertical
  PS     KL_mode_machine_edit
  CM     9203                          ;Activate soft key menu
  PL     DL_recources_handle
    M_display_module_error

  PS     DL_recources_handle           ;Refresh soft key row
  CM     9204
    M_display_module_error

EM

;----------------------------
LBL Display_special_soft_key

;Display soft key menu user

  PS     DL_recources_handle
  PS     S""
  PS     SPEC_FCT
  PS     KL_SK_vertical
  PS     KL_mode_machine_edit
  CM     9203                          ;Activate soft key menu
  PL     DL_recources_handle
    M_display_module_error

  PS     DL_recources_handle           ;Refresh soft key row
  CM     9204
    M_display_module_error

EM

;----------------------------
LBL FCT_soft_key_off

;Display previous current soft key menu

  PS     DL_recources_handle
  PS     S""
  PS     DL_status_information
  PS     KL_SK_vertical
  PS     KL_mode_machine_edit
  CM     9203                          ;Activate soft key menu
  PL     DL_recources_handle
    M_display_module_error

  PS     DL_recources_handle           ;Refresh soft key row
  CM     9204
    M_display_module_error

EM
