o sub ( Check if Current Tool and Next Tool Are the Same) o101 if [#<_current_tool> EQ #<_selected_tool>] ;(abort, Same tool request) o endsub [1]; o101 endif M5 M73 (auto-restore modal settings on return) G64 P0.5 (print, rack_change: loaded tool=#<_current_tool> current pocket: #<_current_pocket>) (print, rack_change: selected tool=#<_selected_tool> selected pocket: #<_selected_pocket>) M66 P22 L3 Q2 ; da li je Z osa referencirana o102 if [#5399 LT 0] (abort, Masina nije referencirana) o102 endif G53 G0 Z0 ; unload previous tool o300 if [#<_current_tool> GT 0 ] (print, idem da ostavim alat) o315 if [#<_current_tool> GE 4 ] # = #<_ini[tool_slot_delta]y_gap>] o315 else # = 0 o315 endif o301 if [EXISTS[#<_ini[change_position]x>]] G53 G0 Y [#<_ini[change_position]y> + # + [#<_current_tool> * #<_ini[tool_slot_delta]y>]] X [#<_ini[change_position]x>] G53 G0 Z #<_ini[change_position]z> o301 endif M64 P00 ; otpusti alat G4 P #<_ini[dwell]lock_time> M64 P01 G4 P #<_ini[dwell]lock_time> M66 P12 L3 Q3 ; ceka da spindle popusti alat o302 if [#5399 LT 0] (abort, Alat se nije otpustio) o302 endif G4 P #<_ini[dwell]mystery> ; o300 endif G53 G0 Z0 ; POKUPI ALAT ------------------------------------------------ (print, idem da uzmem alat) M64 P00 ; otpusti alat M64 P01 G4 P #<_ini[dwell]lock_time> G4 P #<_ini[dwell]lock_time> o310 if [#<_selected_tool> EQ 0] M65 P00 ; stegni alat M65 P01 (print, Trazen je alat 0) o310 endif o311 if [#<_selected_tool> GT 0] (print, trazen je alat veci od nula) M64 P00 ; otpusti alat M64 P01 G4 P #<_ini[dwell]lock_time> o316 if [#<_selected_tool> GE 4 ] # = #<_ini[tool_slot_delta]y_gap>] o316 else # = 0 o316 endif o312 if [EXISTS[#<_ini[change_position]x>]] G53 G0 Y [#<_ini[change_position]y> + # + [#<_selected_tool> * #<_ini[tool_slot_delta]y>]] X #<_ini[change_position]x> G53 G0 Z0 G53 G0 Z #<_ini[change_position]z> o312 endif M65 P00 ; stegni alat M65 P01 G4 P #<_ini[dwell]new_tool> G4 P #<_ini[dwell]post_unlock> M66 P10 L3 Q3 ; ceka da spindle uhvati alat o313 if [#5399 LT 0] (abort, Alat nije stegnut) o313 endif o311 endif G53 G0 Z0 (print, sad cu da primenim offset) G43 H#<_selected_tool> G53 G0 X-100 ; succeed by returning a positive value o endsub [1] m2