1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
# This is a component of LinuxCNC
# Copyright 2011, 2013, 2014 Dewey Garrett <dgarrett@panix.com>,
# Michael Haberler <git@mah.priv.at>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
import sys
import traceback
from math import sin,cos
from interpreter import *
from emccanon import MESSAGE, SET_MOTION_OUTPUT_BIT, CLEAR_MOTION_OUTPUT_BIT,SET_AUX_OUTPUT_BIT,CLEAR_AUX_OUTPUT_BIT
from util import lineno, call_pydevd
throw_exceptions = 1 # raises InterpreterException if execute() or read() fail
def g886(self, **words):
for key in words:
MESSAGE("word '%s' = %f" % (key, words[key]))
if words.has_key('p'):
MESSAGE("the P word was present")
MESSAGE("comment on this line: '%s'" % (self.blocks[self.remap_level].comment))
return INTERP_OK
def involute(self, **words):
""" remap function with raw access to Interpreter internals """
if self.debugmask & 0x20000000: call_pydevd() # USER2 debug flag
if equal(self.feed_rate,0.0):
self.set_errormsg("feedrate > 0 required")
return INTERP_ERROR
if equal(self.speed[0], 0.0):
self.set_errormsg("spindle speed > 0 required")
return INTERP_ERROR
plunge = 0.1 # if Z word was given, plunge - with reduced feed
# inspect controlling block for relevant words
c = self.blocks[self.remap_level]
x0 = c.x_number if c.x_flag else 0
y0 = c.y_number if c.y_flag else 0
a = c.p_number if c.p_flag else 10
old_z = self.current_z
if self.debugmask & 0x10000000: # USER1 debug flag
print("x0=%f y0=%f a=%f old_z=%f" % (x0,y0,a,old_z))
try:
#self.execute("G3456") # would raise InterpreterException
self.execute("G21",lineno())
self.execute("G64 P0.001",lineno())
self.execute("G0 X%f Y%f" % (x0,y0),lineno())
if c.z_flag:
feed = self.feed_rate
self.execute("F%f G1 Z%f" % (feed * plunge, c.z_number),lineno())
self.execute("F%f" % (feed),lineno())
for i in range(100):
t = i/10.
x = x0 + a * (cos(t) + t * sin(t))
y = y0 + a * (sin(t) - t * cos(t))
self.execute("G1 X%f Y%f" % (x,y),lineno())
if c.z_flag: # retract to starting height
self.execute("G0 Z%f" % (old_z),lineno())
except InterpreterException as e:
msg = "%d: '%s' - %s" % (e.line_number,e.line_text, e.error_message)
self.set_errormsg(msg) # replace builtin error message
return INTERP_ERROR
return INTERP_OK
def m462(self, **words):
""" remap function which does the equivalent of M62, but via Python """
p = int(words['p'])
q = int(words['q'])
if q:
SET_MOTION_OUTPUT_BIT(p)
else:
CLEAR_MOTION_OUTPUT_BIT(p)
return INTERP_OK
def m465(self, **words):
""" remap function which does the equivalent of M65, but via Python """
p = int(words['p'])
q = int(words['q'])
if q:
SET_AUX_OUTPUT_BIT(p)
else:
CLEAR_AUX_OUTPUT_BIT(p)
return INTERP_OK
|