*-----------------------------------------------------------------------------
*  Chip Conveyor
*-----------------------------------------------------------------------------
*  Module Description
*
*-----------------------------------------------------------------------------

#define /s    KL_default_interval_pause                K +10
#define /s    KL_default_interval_on                   K +20

#define /s    ML_key_pressed                           M
#define /s    ML_interval_init                         M

GLOBAL Chip_conveyor

;----------------------------
LBL Chip_conveyor
;----------------------------

  L      MG_M51_chip_conveyor_on
  O      MG_M50_chip_conveyor_off
  S      PN_M4092_quit_M_function

  L      NP_M4158_mode_block_scan
  EMT

  L      MG_key_chip_conveyor
  AN     ML_key_pressed
  XO     MG_SK_chip_conveyor
  =      MG_SK_chip_conveyor

  L      MG_key_chip_conveyor
  =      ML_key_pressed

  L      MG_M51_chip_conveyor_on
  S      MG_SK_chip_conveyor

  L      MG_M50_chip_conveyor_off
  O      MG_pulse_END_PGM_M02_M30
  O      MG_auto_manu_mode_change
  O      MG_SK_chip_con_back
  O      MG_key_chip_conveyor_back
  ON     MG_control_operational
  R      MG_SK_chip_conveyor

  L      MG_key_chip_conveyor_back
  O      MG_SK_chip_con_back
  AN     O_chip_conveyor
  A      I_guard_1_closed_locked
  A      I_guard_2_closed_locked
  =      O_chip_conveyor_back

  L      MG_SK_chip_conveyor
  A      I_guard_1_closed_locked
  A      I_guard_2_closed_locked
  AN     MG_chip_conveyor_pause_interval
  =      O_chip_conveyor

  L      MG_SK_chip_conveyor
  A      MG_clock_1_s
  O      O_chip_conveyor
  O      MG_test_lamps
  =      O_lamp_chip_conveyor

  L      MG_SK_chip_con_back           ;20120926
  O      O_chip_conveyor_back
  O      MG_test_lamps
  =      O_lamp_chip_conveyor_back

  L      MG_SK_back
  R      MG_SK_setup_chip_conveyor

  L      MG_chip_conveyor_reset_interval
  R      MG_chip_conveyor_reset_interval
  R      ML_interval_init

  L      MG_SK_chip_conveyor
  A      MG_SK_interval_chip_conveyor
  =      MG_chip_conveyor_pause_interval
  EMF

  LN     ML_interval_init
  IFT
    S      ML_interval_init

    L      WG_interval_pause_time_setup
    =      WG_interval_pause_time

    L      WG_interval_on_time_setup
    =      WG_interval_on

    L      WG_interval_pause_time_setup
    <      K +0
    IFT
      R      ML_interval_init

      L      KL_default_interval_pause
      =      WG_interval_pause_time_setup
    ENDI

    L      WG_interval_on_time_setup
    <=     K +0
    IFT
      R      ML_interval_init

      L      KL_default_interval_on
      =      WG_interval_on_time_setup
    ENDI
  ENDI

  L      WG_interval_on
  >      K +0
  IFT
    R      MG_chip_conveyor_pause_interval

    L      MG_pulse_1_s
    IFT
      DEC    WG_interval_on
    ENDI
  ELSE
    L      WG_interval_pause_time
    <=     K +0
    R      ML_interval_init

    L      MG_pulse_1_min
    IFT
      DEC    WG_interval_pause_time
    ENDI
  ENDI

EM
