MACHINE  lathe

INCLUDE {
         $UGII_CAM_USER_DEF_EVENT_DIR/ude.cdl
        }

FORMATTING
{
  WORD_SEPARATOR " "
  END_OF_LINE ""
  SEQUENCE sequence_number 10  10 1 9999

################ FORMAT DECLARATIONS #################
  FORMAT AbsCoord "&__6.3_"
  FORMAT Coordinate "&__5.3_"
  FORMAT Digit_2 "&_02.10"
  FORMAT Digit_4 "&__1_30"
  FORMAT Digit_5 "&__5_00"
  FORMAT Dwell_INVERSE "&__3_00"
  FORMAT Dwell_REVOLUTIONS "&__3_00"
  FORMAT Dwell_SECONDS "&__5.3_"
  FORMAT EventNum "&+03_00"
  FORMAT Feed "&__7.2_"
  FORMAT Feed_FRN "&__5.3_"
  FORMAT Feed_INV "&__5.3_"
  FORMAT Feed_IPM "&__4.1_"
  FORMAT Feed_IPR "&__1.4_"
  FORMAT Feed_MMPM "&__5.0_"
  FORMAT Feed_MMPR "&__2.3_"
  FORMAT Hcode "&_02_00"
  FORMAT Rev "&__4_00"
  FORMAT String "%s"
  FORMAT Tcode "&_02_0_"
  FORMAT Zero_int "&_01_0_"
  FORMAT Zero_real "&_01.10"
  FORMAT g28 "&_02_0_"
  FORMAT g53 "&__2.1_"
  FORMAT user_fmt_sem_ponto "&_02_0_"
  FORMAT user_fmt_tool_change "&_02_0_"

################ ADDRESS DECLARATIONS ################
  ADDRESS G_cutcom
  {
      FORMAT      user_fmt_sem_ponto
      FORCE       off
      MAX         999999999.9999 Truncate
      MIN         -999999999.9999 Truncate
      LEADER      "G"
  }

  ADDRESS G_plane
  {
      FORMAT      Digit_2
      FORCE       off
      LEADER      "G"
  }

  ADDRESS G_adjust
  {
      FORMAT      Digit_2
      FORCE       off
      LEADER      "G"
  }

  ADDRESS G_feed
  {
      FORMAT      user_fmt_sem_ponto
      FORCE       off
      LEADER      "G"
  }

  ADDRESS G_spin
  {
      FORMAT      Digit_2
      FORCE       off
      LEADER      "G"
  }

  ADDRESS G_return
  {
      FORMAT      g28
      FORCE       always
      LEADER      "G"
  }

  ADDRESS G_motion
  {
      FORMAT      Digit_2
      FORCE       off
      MAX         9999 Truncate
      MIN         -9999 Truncate
      LEADER      "G"
  }

  ADDRESS G_mode
  {
      FORMAT      Digit_2
      FORCE       off
      LEADER      "G"
  }

  ADDRESS G_dwell
  {
      FORMAT      Digit_2
      FORCE       off
      LEADER      "G"
  }

  ADDRESS G
  {
      FORMAT      user_fmt_sem_ponto
      FORCE       off
      MAX         99 Truncate
      MIN         0 Truncate
      LEADER      "G"
  }

  ADDRESS X
  {
      FORMAT      Coordinate
      FORCE       off
      MAX         99999.999 Truncate
      MIN         -99999.999 Truncate
      LEADER      [$mom_sys_leader(X)]
      ZERO_FORMAT Zero_real
  }

  ADDRESS Y
  {
      FORMAT      Coordinate
      FORCE       off
      MAX         99999.999 Truncate
      MIN         -99999.999 Truncate
      LEADER      [$mom_sys_leader(Y)]
      ZERO_FORMAT Zero_real
  }

  ADDRESS Z
  {
      FORMAT      Coordinate
      FORCE       off
      MAX         99999.999 Truncate
      MIN         -99999.999 Truncate
      LEADER      [$mom_sys_leader(Z)]
      ZERO_FORMAT Zero_real
  }

  ADDRESS I
  {
      FORMAT      Coordinate
      FORCE       always
      MAX         99999.999 Truncate
      MIN         -99999.999 Truncate
      LEADER      "I"
      ZERO_FORMAT Zero_real
  }

  ADDRESS J
  {
      FORMAT      Coordinate
      FORCE       always
      MAX         99999.999 Truncate
      MIN         -99999.999 Truncate
      LEADER      "J"
      ZERO_FORMAT Zero_real
  }

  ADDRESS K
  {
      FORMAT      Coordinate
      FORCE       always
      MAX         99999.999 Truncate
      MIN         -99999.999 Truncate
      LEADER      "K"
      ZERO_FORMAT Zero_real
  }

  ADDRESS R
  {
      FORMAT      Coordinate
      FORCE       off
      MAX         99999.999 Truncate
      MIN         -99999.999 Truncate
      LEADER      "R"
      ZERO_FORMAT Zero_real
  }

  ADDRESS F
  {
      FORMAT      Coordinate
      FORCE       always
      MAX         9999.9 Warning
      MIN         .0001 Warning
      LEADER      "F"
      ZERO_FORMAT Zero_real
  }

  ADDRESS S
  {
      FORMAT      Digit_5
      FORCE       off
      MAX         99999 Truncate
      MIN         0 Truncate
      LEADER      "S"
      ZERO_FORMAT Zero_int
  }

  ADDRESS T
  {
      FORMAT      Tcode
      FORCE       off
      MAX         99 Truncate
      MIN         0 Truncate
      LEADER      "T"
  }

  ADDRESS D
  {
      FORMAT      Digit_2
      FORCE       off
      MAX         99 Truncate
      MIN         0 Truncate
      LEADER      "D"
  }

  ADDRESS H
  {
      FORMAT      Hcode
      FORCE       off
      MAX         99 Truncate
      MIN         0 Truncate
      LEADER      "H"
  }

  ADDRESS dwell
  {
      FORMAT      Dwell_SECONDS
      FORCE       off
      MAX         99999.999 Truncate
      MIN         0.001 Truncate
      LEADER      "X"
      ZERO_FORMAT Zero_real
  }

  ADDRESS cycle_dwell
  {
      FORMAT      Dwell_SECONDS
      FORCE       off
      MAX         99999.999 Truncate
      MIN         0.001 Truncate
      LEADER      "P"
      ZERO_FORMAT Zero_real
  }

  ADDRESS P_cutcom
  {
      FORMAT      Dwell_SECONDS
      FORCE       off
      MAX         99999.999 Truncate
      MIN         0.001 Truncate
      LEADER      "P"
      ZERO_FORMAT Zero_real
  }

  ADDRESS K_cycle
  {
      FORMAT      Coordinate
      FORCE       off
      MAX         99999.999 Truncate
      MIN         -99999.999 Truncate
      LEADER      "K"
      ZERO_FORMAT Zero_real
  }

  ADDRESS cycle_step1
  {
      FORMAT      Coordinate
      FORCE       off
      MAX         99999.999 Truncate
      MIN         -99999.999 Truncate
      LEADER      "I"
      ZERO_FORMAT Zero_real
  }

  ADDRESS cycle_step
  {
      FORMAT      Coordinate
      FORCE       off
      MAX         99999.999 Truncate
      MIN         -99999.999 Truncate
      LEADER      "Q"
      ZERO_FORMAT Zero_real
  }

  ADDRESS Q_cutcom
  {
      FORMAT      Dwell_SECONDS
      FORCE       off
      MAX         99999.999 Truncate
      MIN         0.001 Truncate
      LEADER      "Q"
      ZERO_FORMAT Zero_real
  }

  ADDRESS E
  {
      FORMAT      Coordinate
      FORCE       off
      MAX         99999.999 Truncate
      MIN         -99999.999 Truncate
      LEADER      "E"
      ZERO_FORMAT Zero_real
  }

  ADDRESS M_spindle
  {
      FORMAT      Digit_2
      FORCE       off
      LEADER      "M"
  }

  ADDRESS M_range
  {
      FORMAT      Digit_2
      FORCE       off
      LEADER      "M"
  }

  ADDRESS M_coolant
  {
      FORMAT      Digit_2
      FORCE       off
      MAX         99 Truncate
      MIN         0 Truncate
      LEADER      "M"
  }

  ADDRESS M
  {
      FORMAT      Digit_2
      FORCE       always
      LEADER      "M"
  }

  ADDRESS user_add
  {
      FORMAT      g53
      FORCE       off
      LEADER      "G"
      ZERO_FORMAT Zero_real
  }

  ADDRESS user_add_1
  {
      FORMAT      user_fmt_tool_change
      FORCE       off
      LEADER      ""
  }

  ADDRESS user_add_2
  {
      FORMAT      user_fmt_tool_change
      FORCE       off
      LEADER      ""
  }

  ADDRESS N
  {
      FORMAT      Digit_4
      FORCE       always
      MAX         9999 Truncate
      LEADER      [$mom_sys_leader(N)]
      ZERO_FORMAT Zero_int
  }

  ADDRESS Text
  {
      FORMAT      String
      FORCE       always
      LEADER      ""
  }


################ ADDRESS DECLARATIONS ################
  ADDRESS LF_AAXIS
  {
      FORMAT      AbsCoord
      FORCE       always
      LEADER      ""
      ZERO_FORMAT Zero_real
  }

  ADDRESS LF_ENUM
  {
      FORMAT      Digit_5
      FORCE       always
      LEADER      ""
      ZERO_FORMAT Zero_int
  }

  ADDRESS LF_BAXIS
  {
      FORMAT      AbsCoord
      FORCE       always
      LEADER      ""
      ZERO_FORMAT Zero_real
  }

  ADDRESS LF_XABS
  {
      FORMAT      AbsCoord
      FORCE       always
      LEADER      ""
      ZERO_FORMAT Zero_real
  }

  ADDRESS LF_FEED
  {
      FORMAT      Feed
      FORCE       always
      LEADER      ""
      ZERO_FORMAT Zero_real
  }

  ADDRESS LF_YABS
  {
      FORMAT      AbsCoord
      FORCE       always
      LEADER      ""
      ZERO_FORMAT Zero_real
  }

  ADDRESS LF_SPEED
  {
      FORMAT      Rev
      FORCE       always
      LEADER      ""
      ZERO_FORMAT Zero_int
  }

  ADDRESS LF_ZABS
  {
      FORMAT      AbsCoord
      FORCE       always
      LEADER      ""
      ZERO_FORMAT Zero_real
  }


############ BLOCK TEMPLATE DECLARATIONS #############
  BLOCK_TEMPLATE absolute_mode
  {
       G_cutcom[$mom_sys_cutcom_code(OFF)]
       G_feed[$mom_sys_feed_rate_mode_code(MMPR)]
       G[$mom_sys_unit_code(MM)]
  }

  BLOCK_TEMPLATE auto_tool_change
  {
       T[$mom_tool_number]
  }

  BLOCK_TEMPLATE auto_tool_change_1
  {
       G_return[28]
       Text[UW]
  }

  BLOCK_TEMPLATE auto_tool_change_2
  {
       T[$mom_tool_number]
       user_add_2[$mom_tool_number]
  }

  BLOCK_TEMPLATE auxfun
  {
       M[$mom_auxfun]
  }

  BLOCK_TEMPLATE circular_move
  {
       G_motion[$mom_sys_circle_code($mom_arc_direction)]\opt
       X[$mom_pos(0)]
       Z[$mom_pos(2)]
       I[$mom_pos_arc_center(0) - $mom_prev_pos(0)]
       K[$mom_pos_arc_center(2) - $mom_prev_pos(2)]
       F[$feed]
  }

  BLOCK_TEMPLATE coolant_off
  {
       M_coolant[$mom_sys_coolant_code(OFF)]
  }

  BLOCK_TEMPLATE coolant_on
  {
       M_coolant[$mom_sys_coolant_code(ON)]\opt
  }

  BLOCK_TEMPLATE coordinate_system
  {
       G[$mom_sys_reset_code]
  }

  BLOCK_TEMPLATE cutcom_off
  {
       G_cutcom[$mom_sys_cutcom_code(OFF)]
  }

  BLOCK_TEMPLATE cutcom_on
  {
       G_cutcom[$mom_sys_cutcom_code($mom_cutcom_status)]\opt
       D[$mom_cutcom_adjust_register]\opt
  }

  BLOCK_TEMPLATE cycle_bore
  {
       G_motion[$mom_sys_cycle_bore_code]
       X[$mom_cycle_feed_to_pos(0)]
       Z[$mom_cycle_feed_to_pos(2)]
       R[$mom_cycle_rapid_to_pos($mom_cycle_spindle_axis)]\opt
       F[$feed]
  }

  BLOCK_TEMPLATE cycle_drill
  {
       G_motion[$mom_sys_cycle_drill_code]
       X[$mom_cycle_feed_to_pos(0)]
       Z[$mom_cycle_feed_to_pos(2)]
       R[$mom_cycle_rapid_to_pos($mom_cycle_spindle_axis)]\opt
       F[$feed]
  }

  BLOCK_TEMPLATE cycle_drill_break_chip
  {
       G_motion[$mom_sys_cycle_drill_break_chip_code]
       X[$mom_cycle_feed_to_pos(0)]
       Z[$mom_cycle_feed_to_pos(2)]
       R[$mom_cycle_rapid_to_pos($mom_cycle_spindle_axis)]\opt
       F[$feed]
       cycle_step[$mom_cycle_step1]
  }

  BLOCK_TEMPLATE cycle_drill_deep
  {
       G_motion[$mom_sys_cycle_drill_deep_code]
       X[$mom_cycle_feed_to_pos(0)]
       Z[$mom_cycle_feed_to_pos(2)]
       R[$mom_cycle_rapid_to_pos($mom_cycle_spindle_axis)]\opt
       F[$feed]
       cycle_step[$mom_cycle_step1]
  }

  BLOCK_TEMPLATE cycle_drill_dwell
  {
       G_motion[$mom_sys_cycle_drill_dwell_code]
       X[$mom_cycle_feed_to_pos(0)]
       Z[$mom_cycle_feed_to_pos(2)]
       R[$mom_cycle_rapid_to_pos($mom_cycle_spindle_axis)]\opt
       F[$feed]
       cycle_dwell[$mom_cycle_delay]\opt
  }

  BLOCK_TEMPLATE cycle_off
  {
       G_motion[$mom_sys_cycle_off]
  }

  BLOCK_TEMPLATE cycle_tap
  {
       G_motion[$mom_sys_cycle_tap_code]
       X[$mom_cycle_feed_to_pos(0)]
       Z[$mom_cycle_feed_to_pos(2)]
       R[$mom_cycle_rapid_to_pos($mom_cycle_spindle_axis)]\opt
       F[$feed]
  }

  BLOCK_TEMPLATE delay
  {
       G_dwell[$mom_sys_delay_code($mom_delay_mode)]
       dwell[$delay_time]
  }

  BLOCK_TEMPLATE end_of_path
  {
       M_spindle[$mom_sys_spindle_direction_code(OFF)]
       M_coolant[$mom_sys_coolant_code(OFF)]
  }

  BLOCK_TEMPLATE end_of_program
  {
       M[$mom_sys_end_of_program_code]
  }

  BLOCK_TEMPLATE from
  {
       G_motion[$mom_sys_rapid_code]
       X[$mom_from_pos(0)]
       Z[$mom_from_pos(2)]
  }

  BLOCK_TEMPLATE inch_metric_mode
  {
       G[$mom_sys_unit_code($mom_output_unit)]
  }

  BLOCK_TEMPLATE incremental_mode
  {
       G_mode[$mom_sys_output_code(INCREMENTAL)]
  }

  BLOCK_TEMPLATE linear_move
  {
       G_motion[$mom_sys_linear_code]
       X[$mom_pos(0)]
       Z[$mom_pos(2)]
       F[$feed]
       M_coolant[$mom_sys_coolant_code($mom_coolant_status)]\opt
  }

  BLOCK_TEMPLATE manual_tool_change
  {
       M[$mom_sys_program_stop_code]
  }

  BLOCK_TEMPLATE manual_tool_change_1
  {
       T[$mom_tool_number]
       H[$mom_tool_adjust_register]\opt
  }

  BLOCK_TEMPLATE opstop
  {
       M[$mom_sys_optional_stop_code]\opt\nows
  }

  BLOCK_TEMPLATE output_unit
  {
       G[$mom_sys_unit_code($mom_output_unit)]
  }

  BLOCK_TEMPLATE prefun
  {
       G[$mom_prefun]
  }

  BLOCK_TEMPLATE rapid_move
  {
       G_motion[$mom_sys_rapid_code]
       X[$mom_pos(0)]
       Z[$mom_pos(2)]
  }

  BLOCK_TEMPLATE rewind_stop_code
  {
       Text[%]
  }

  BLOCK_TEMPLATE sequence_number
  {
       N[$mom_seqnum]
  }

  BLOCK_TEMPLATE spindle_css
  {
       G_spin[$mom_sys_spindle_mode_code(SFM)]
       S[$mom_spindle_speed]
       M_spindle[$mom_sys_spindle_direction_code($mom_spindle_direction)]\opt
  }

  BLOCK_TEMPLATE spindle_max_rpm
  {
       Text[G50]
       S[$mom_spindle_maximum_rpm]
  }

  BLOCK_TEMPLATE spindle_off
  {
       M_spindle[$mom_sys_spindle_direction_code(OFF)]
  }

  BLOCK_TEMPLATE spindle_range
  {
       M_range[$mom_sys_spindle_range_code($mom_spindle_range)]\opt
  }

  BLOCK_TEMPLATE spindle_rpm
  {
       G_spin[$mom_sys_spindle_mode_code(RPM)]
       S[$mom_spindle_speed]
       M_spindle[$mom_sys_spindle_direction_code($mom_spindle_direction)]\opt
  }

  BLOCK_TEMPLATE spindle_rpm_preset
  {
       G_spin[$mom_sys_spindle_mode_code(RPM)]
       S[$mom_spindle_rpm]
       M_spindle[$mom_sys_spindle_direction_code($mom_spindle_direction)]\opt
  }

  BLOCK_TEMPLATE start_of_program
  {
       G_feed[50]
       S[$mom_spindle_maximum_rpm]
  }

  BLOCK_TEMPLATE start_of_program_1
  {
       user_add[53.5]
  }

  BLOCK_TEMPLATE stop
  {
       M[$mom_sys_program_stop_code]
  }

  BLOCK_TEMPLATE thread_move
  {
       G_motion[$mom_sys_lathe_thread_advance_type($mom_lathe_thread_advance_type)]
       X[$mom_pos(0)]
       Z[$mom_pos(2)]
       F[$mom_lathe_thread_lead_k]
  }

  BLOCK_TEMPLATE tool_change_axis_preset
  {
       G[$mom_sys_reset_code]
       X[$mom_from_ref_pos(0)]
       Z[$mom_from_ref_pos(2)]
  }

  BLOCK_TEMPLATE tool_len_adj_off
  {
       H[$mom_sys_zero]
  }

  BLOCK_TEMPLATE tool_length_adjust
  {
       H[$mom_tool_adjust_register]
  }

  BLOCK_TEMPLATE tool_preselect
  {
       T[$mom_next_tool_number]
  }

  BLOCK_TEMPLATE post_cycle_set
  {
       G_motion[$mom_sys_cycle_reps_code]
       X[$mom_cycle_feed_to_pos(0)]
       Z[$mom_cycle_feed_to_pos(2)]
       R[$mom_cycle_rapid_to_pos($mom_cycle_spindle_axis)]\opt
       F[$feed]
  }

  BLOCK_TEMPLATE comment_data
  {
       LF_XABS[$mom_pos(0)]
       LF_ZABS[$mom_pos(2)]
       LF_FEED[$mom_feed_rate]
       LF_SPEED[$mom_spindle_speed]
  }

}
