예제 #1
0
파일: remap.py 프로젝트: f1oat/files
def remap_m6(self, **words):
	MESSAGE("Tool change %d => %d" % (self.current_tool, self.selected_tool))
	print "Tool change %d => %d" % (self.current_tool, self.selected_tool)
	self.execute("G53 G0 Z20",lineno())
	self.execute("G53 G0 Z10",lineno())
	emccanon.CHANGE_TOOL(self.selected_pocket)
	self.current_pocket = self.selected_pocket
	self.selected_pocket = -1
	self.selected_tool = -1
	# cause a sync()
	self.set_tool_parameters()
	#self.toolchange_flag = True     # comment to avoid "/usr/bin/milltask (pid 6258) died on signal 11"
	yield INTERP_EXECUTE_FINISH
예제 #2
0
 def copyfile(self, remote, file_):
     try:
         with open(file_.replace('.xsl', ''), 'wb') as f:
             print(util.lineno(), 'Fetching', file_.replace('.xsl', ''))
             shutil.copyfileobj(remote, f)
     finally:
         remote.close()
예제 #3
0
 def classify_file(self, file_):
     '''Identify the language of the file'''
     mh = xslsetter.MetadataHandler(file_, create=True)
     url = mh.get_variable('filename')
     if ('regjeringen.no' in url and 'regjeringen.no' not in file_ and
             '.pdf' not in file_):
         try:
             remote = urllib2.urlopen(urllib2.Request(url.encode('utf8')))
             self.copyfile(remote, file_)
         except urllib2.HTTPError:
             print(util.lineno(), 'Could not fetch',
                   file_.replace('.xsl', ''), file=sys.stderr)
         except UnicodeEncodeError:
             print(util.lineno(), 'Unicode error in url', url,
                   file=sys.stderr)
         print(util.lineno(), 'sleeping …')
         time.sleep(2)
예제 #4
0
def StopSpindleNow(self):
    self.execute("M5", lineno())
    # Now lets stop the drill spindle if running
    self.execute("M65 P54")
    # Wait for signal spindleHasStopped to go high
    index = self.x.getSignalInfos("spindleHasStopped")
    delay = self.x.getDelay("spindlehasstopped")
    #self.execute("M66 P%d  L3 Q%f"" % (index, delay), lineno())
    self.execute("M66 P8 L3 Q15")
    print("Stop Spindle command sent")
예제 #5
0
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):
        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,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
예제 #6
0
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):
        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,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
예제 #7
0
def MoveZtoZero(self):
    self.execute("G53 G0 Z0.0", lineno())
    print("Moved to Z = 0.0")
예제 #8
0
def WaitAFewSeconds(self, sSec):
    self.execute("G4 P%f" % sSec, lineno())
예제 #9
0
def WaitOnSignalToBecome(self, sWhich, val, sSec):  # val = 0 (L2) val = 1 (L1)
    index = self.x.getSignalInfos(sWhich)
    self.execute("M66 P%d L%d Q%f" % (index, 4 if val == 0 else 3, sSec),
                 lineno())
예제 #10
0
def SendDOUT(self, sWhich, val):
    index = self.x.getSignalInfos(sWhich)
    # only call M6x if not already at desired value
    if CheckDOUT(self, sWhich, True) != val:
        self.execute("M6%d P%d" % (4 if val == 1 else 5, index), lineno())
예제 #11
0
def OpenCasket(self):
    #----------------------------------------------------------------
    self.execute("M64 P0", lineno())
    self.execute("G4 P0.5", lineno())
    self.execute("M65 P0", lineno())
    self.execute("M66 P2 L3 Q5", lineno())
예제 #12
0
def CloseCasket(self):
    #----------------------------------------------------------------
    self.execute("M64 P1", lineno())
    self.execute("G4 P0.5", lineno())
    self.execute("M65 P1", lineno())
예제 #13
0
 def append_parallel(self, file_, a):
     if os.path.exists(self.get_parallel_name(file_, a)):
         self.parallel_dict[file_].append(self.get_parallel_name(file_, a))
     else:
         print(util.lineno(), self.get_parallel_name(file_, a),
               'does not exist', a.get('title'),  file_, file=sys.stderr)